Matthew van Eerde's web log
I am a Software Development Engineer in Test working for the Windows Sound team. You can contact me via email: mateer at microsoft dot com
vbBretty on the audio forums asked how to tell if a given audio output and a given audio input were on the same physical audio card.
I found the exercise interesting enough to share here:
This is a perfect example of how something should be much simpler than it is. That's a ridiculous amount of code!
Yes... I agree that the DeviceTopology "connector dance" is a little cumbersome, and the PKEY_Device_InstanceId trick starts to smack of voodoo.
I considered writing a helper function
HRESULT InstanceId_From_IMMDevice(IMMDevice *pEndpoint, LPWSTR *ppwszInstanceId);
which would cut the length of the program by about a third, but I think the sample is more readable (though longer) the way I did it.
On the other hand, the code posted is fully functional, under 200 lines, and that's with full logging, error checking, comments, and denormalization.
What are the scenarios when you need to know what hardware is behind the audio endpoint?
can you please tell me .......from where to get this DeviceTopology.h header file cz it seems not to be present.....
Download the Windows SDK.
On my machine devicetopology.h is in the following folder:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
> What are the scenarios when you need
> to know what hardware is behind the audio endpoint?
I'm just rambling here, but hey:
Any app that provides voice communication, esp. games might be interested in knowing that. Users do care about their default output device, but a lot of errors in voice com stem from improperly set input configuration. If the user is already using e.g. a USB headset for output, the game can make a safe bet by using the headset's microphone. Or at least point the user to mismatching configs.