简体   繁体   English

Windows Core Audio Api可在捕获设备上获得所有支持的格式

[英]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. 我想在设备属性 - >高级 - > DefaultFormat部分中枚举Capture设备上所有支持的格式。

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. 我想使用Windows Core Audio Api这样做,但我找不到合适的界面,我可以用来读取这些格式。

https://msdn.microsoft.com/en-us/library/windows/desktop/dd370858(v=vs.85).aspx# 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): IMMDeviceEnumerator接口可以帮助您获取指向所需IMMDevice的指针( IMMDevice接口代表音频端点设备:渲染或捕获):

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. 无论如何,当你有指向IMMDevice的指针时,你需要查找支持的格式,你可以使用IMMDevice :: Activate方法获得指向IAudioClient接口的指针。 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). IAudioClient接口允许您检查设备是否支持音频格式(方法IAudioClient :: IsFormatSupported ,音频格式由WAVEFORMATEX结构描述)。 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. 不幸的是,现在Core Audio API中没有方法返回设备支持的格式列表,因此您需要枚举WAVEFORMATEX成员结构的可能值,并检查设备是否支持每种格式。

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 ). 但是您可以通过使用IMMDevice属性存储( IMMDevice :: OpenPropertyStore )获取用户在DefaultFormat部分中选择的格式,然后检查PKEY_AudioEngine_DeviceFormat键(这里是描述: MSDN:PKEY_AudioEngine_DeviceFormat )。

It would be useful to read: 阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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