Audio Device Enumeration to uniquely identify a USB audio device
-
Recently I've looked at several examples to find a way to uniquely identify a USB audio device, such as a Logitech Headset or Microphone. I looked at a DirectShow and DirectX.DirectSound example in C# called DirectXCapture_demo and I also looked at an example in C++ called DirectSoundEnumerator. The project that I am working on is in C#. In the DirectSoundEnumerator example I noticed under the interface column that the string or interface displayed starts out with USB as opposed to HD Audio. I am trying to find a generic way to make this determination, because we may have different USB devices, even though we are using Logitech devices right now. I also looked at a third example called DirectSoundDemo. In the DirectSoundDemo I can access just about all the same fields that I can in the DirectSoundEnumerator example except the data displayed in the Interface column. Does anyone know a way in C# to access the data in the Interface column of the DirectSoundEnumerator example? Also, is that the best way to uniquely identify a USB Audio Device as opposed to a HD Audio Device on your integrated sound card? Any help would be greatly appreciated and thanks in advance.
GrizMan
-
Recently I've looked at several examples to find a way to uniquely identify a USB audio device, such as a Logitech Headset or Microphone. I looked at a DirectShow and DirectX.DirectSound example in C# called DirectXCapture_demo and I also looked at an example in C++ called DirectSoundEnumerator. The project that I am working on is in C#. In the DirectSoundEnumerator example I noticed under the interface column that the string or interface displayed starts out with USB as opposed to HD Audio. I am trying to find a generic way to make this determination, because we may have different USB devices, even though we are using Logitech devices right now. I also looked at a third example called DirectSoundDemo. In the DirectSoundDemo I can access just about all the same fields that I can in the DirectSoundEnumerator example except the data displayed in the Interface column. Does anyone know a way in C# to access the data in the Interface column of the DirectSoundEnumerator example? Also, is that the best way to uniquely identify a USB Audio Device as opposed to a HD Audio Device on your integrated sound card? Any help would be greatly appreciated and thanks in advance.
GrizMan
GD: Total can of worms but it's possible, using the Setup API. This will get the raw strings used in the registry and allow you to parse them to see if they are USB devices. See SetupDiGetDeviceRegistryProperty() and friends. Note the SPDRP_DEVTYPE, PDRP_LOCATION_INFORMATION,SPDRP_DEVICEDESC and associated flags. I have only ever done this in C++ - no idea if the API is exposed to managed code. I did this stuff some time back when working with kernel-streaming audio on XP and it was no fun. I believe the situation is even more complex with Vista as it has a rather different device name mapping scheme, even though the SetupAPI stuff still should (!) work. Here's an example I've copied directly from RegEdit - CP need to allow screenshots in their replies to questions! The device in question is a Roland/Edirol USB I/O device. Note that you get a friendly name (sometimes) and a key that actually has USB in it. HTH. :) Root is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\Vid_0582&Pid_0018\5&be1018e&0&2 Value 0 Name: DeviceDesc Type: REG_SZ Data: USB Composite Device Value 1 Name: LocationInformation Type: REG_SZ Data: EDIROL UA-1A Value 2 Name: Capabilities Type: REG_DWORD Data: 0x84 Value 3 Name: UINumber Type: REG_DWORD Data: 0x0 Value 4 Name: HardwareID Type: REG_MULTI_SZ Data: USB\Vid_0582&Pid_0018&Rev_0101 USB\Vid_0582&Pid_0018
-
GD: Total can of worms but it's possible, using the Setup API. This will get the raw strings used in the registry and allow you to parse them to see if they are USB devices. See SetupDiGetDeviceRegistryProperty() and friends. Note the SPDRP_DEVTYPE, PDRP_LOCATION_INFORMATION,SPDRP_DEVICEDESC and associated flags. I have only ever done this in C++ - no idea if the API is exposed to managed code. I did this stuff some time back when working with kernel-streaming audio on XP and it was no fun. I believe the situation is even more complex with Vista as it has a rather different device name mapping scheme, even though the SetupAPI stuff still should (!) work. Here's an example I've copied directly from RegEdit - CP need to allow screenshots in their replies to questions! The device in question is a Roland/Edirol USB I/O device. Note that you get a friendly name (sometimes) and a key that actually has USB in it. HTH. :) Root is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\Vid_0582&Pid_0018\5&be1018e&0&2 Value 0 Name: DeviceDesc Type: REG_SZ Data: USB Composite Device Value 1 Name: LocationInformation Type: REG_SZ Data: EDIROL UA-1A Value 2 Name: Capabilities Type: REG_DWORD Data: 0x84 Value 3 Name: UINumber Type: REG_DWORD Data: 0x0 Value 4 Name: HardwareID Type: REG_MULTI_SZ Data: USB\Vid_0582&Pid_0018&Rev_0101 USB\Vid_0582&Pid_0018
I found another way to approach it. It's a bit of a hack, but for now to get the Interface ID using C# from my application, I can modify the DirectSoundEnumerator C++ application to remove the GUI and get rid of the dialog. Once that is done, I can run the C++ application as a process in C# and have it write the Description and Interface ID data to a file. I can then read the data from the file to get the Interface ID associated with the device and map that to the unique devices I access in my application. Like I said, it's kind of a hack, but until I find a better way to do it with C#, it will get the job done. I'm going to call this a general message type and not the answer yet because it is a hack and maybe there is a better way to do this.
GrizMan