Search code examples
windowsvisual-c++audiodevicewasapi

How do I get information out of IMMDevice?


I'm a complete beginner with regards to IMMDevice, and I need to ask what a good, easy way to get some device out of information out of it is. In my program, I've already successfully set a pointer to one of those with GetDefaultAudioEndpoint(). Now I just need to be able to get some basic information out of it, like some speaker info or the ID of the speaker or anything like that. What's a good way to do this that a total beginner would be able to pick up on? Thanks!


Solution

  • Devices have various properties attached, and you can read them from a device property store. MSDN gives you a code snippet here:

    Audio Endpoint Devices > Device Properties

    You can also use pre-built utilities to quickly check your devices and see what you can obtain from a IMMDevice pointer:

    The latter presents you the properties like this:

    enter image description here

    And you can check source code here http://www.alax.info/trac/public/browser/trunk/Utilities/EnumerateAudioDevices/MainDialog.h#L72 that it starts from as much as having a IMMDevice pointer on hands in line 72.