Device Name Truncation with WaveOut.GetCapabilities

Feb 2, 2013 at 12:50 AM
I'm having a bit of a problem distinguishing device names due to the string truncation. I need to support XP users so I'm limited to WaveOut.GetCapabilities.

This might be a possible fix to the problem for the NAudio source.

It appears that the device name length is determined in the WaveOutCapabilities.cs file.
located in the source at ...\NAudio\Wave\MmeInterop\WaveOutCapabilities.cs
line 48 private const int MaxProductNameLength = 32;

I wonder if changing that value (say triple it = 96) will eliminate most of the device name truncation issues?

Then testing this simple code to see if the returned device names are longer.
for (int deviceId = 0; deviceId < deviceCount; deviceId++)
                var capabilities = WaveOut.GetCapabilities(deviceId);
                string name = capabilities.ProductName;
Sorry that I can't test this myself or I would. The NAudio solution source code won't build for me with VS2010-- lots of missing namespaces.
Feb 2, 2013 at 8:27 AM
unfortunately, this is a limitation of the WaveOut APIs themselves. 32 is the value of MAXPNAMELEN as used by WAVEOUTCAPS. Changing this value in NAudio will not get you a longer product name. There is only one workaround I know of and it involves using DirectSound. I'd imagine there might be a way of searching in the registry too.
Feb 2, 2013 at 10:42 AM
Ok, Thanks Mark.
The Ghost of Bill Gates strikes again. Who knew a device name would ever exceed a massive 32 bytes of memory? ;-)

I'll make do with a 32 character name. I'm trying to get away from DirectSound.