Brad
Brad

Reputation: 163240

Registry location of DirectShow audio capture devices

I am executing VLC from my application to capture and encode from a DirectShow audio capture device. VLC sends the encoded data to my application via STDOUT. I need a way to enumerate DirectShow audio capture devices. Unfortunately, VLC doesn't seem to provide any non-GUI way for this.

While looking for a simple way to get a list of device names, I stumbled on these registry keys where child keys are named after audio capture devices:

Is this registry location guaranteed to be in the same place for other machines and recent versions of DirectX? Short of implementing a ton of DirectX code, is there some other way to get a list of the DirectShow audio device names? (Possibly through some output of a diagnostic tool.)

Upvotes: 0

Views: 3451

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69662

The list of DirectShow (a Windows core API, not a part of DirectX anymore) devices is provided by enumerators listing specific category (audio input devices in this case, CLSID_AudioInputDeviceCategory) on request. This is the GUID in question and registry does not necessarily contains entries for all devices there. Instead, enumerator provides the list of devices programmatically via API, combining the available devices of different types.

There is no way to affect enumeration order in well defined/documented way.

The easiest way to enumerate the devices is Windows SDK GraphEdt.exe tool, or its nicer alternate options GraphStudio/GraphStudioNext. Ctrl+F and then select the category:

enter image description here

You can also enumerate devices and their capabilities with EnumerateAudioCaptureFilterCapabilities command line tool (source code), where "Friendly Name" lines list devices in enumeration order:

Moniker Display Name: @device:cm:{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Stereo Mix (Realtek High Defini
Friendly Name: Stereo Mix (Realtek High Defini
  Pin: Capture
    Capability Count: 23
    Capability 0:
    AM_MEDIA_TYPE:
      .bFixedSizeSamples: 1
      .bTemporalCompression: 0
      .lSampleSize: 4
      .cbFormat: 18
    WAVEFORMATEX:
      .wFormatTag: 1
      .nChannels: 2
      .nSamplesPerSec: 44100
      .nAvgBytesPerSec: 176400
      .nBlockAlign: 4
      .wBitsPerSample: 16
      .cbSize: 0

To affect the order, such as to place a device on interest on top of the list, I can only think of API hooking, which is a possible thing but not recommended for wide use due to alteration of standard system behavior.

Upvotes: 1

Related Questions