简体   繁体   中英

Windows Core Audio Api get all supported formats on capture device

I would like to enumerate all supported formats on Capture device in device Properties -> Advanced -> DefaultFormat section.

I would like to use Windows Core Audio Api to do so, however I can't really find suitable interface that I could use to read those formats.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370858(v=vs.85).aspx#

Any idea which interface would provide me with such functionality?

There is the IMMDeviceEnumerator interface which can help you to obtain pointer to the IMMDevice you need ( IMMDevice interface represents an audio endpoint device: render or capture):

Anyway, when you have the pointer to the IMMDevice you need to look up supported formats for, you can get the pointer to the IAudioClient interface using IMMDevice::Activate method. IAudioClient interface allows you to check if the device supports an audio format or not (method IAudioClient::IsFormatSupported , audio format is described by WAVEFORMATEX structure). Unfortunately, right now there is no method in Core Audio API which returns a list of supported formats by the device, so you will need to enumerate possible values of WAVEFORMATEX members structure and check if every format supported by device by yourself.

But you can get the format that user did select in the DefaultFormat section by using IMMDevice property store ( IMMDevice::OpenPropertyStore ) and then checking for the PKEY_AudioEngine_DeviceFormat key (here is the description: MSDN: PKEY_AudioEngine_DeviceFormat ).

It would be useful to read:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM