Windows Core Audio Api在捕获设备上获取所有受支持的格式 [英] Windows Core Audio Api get all supported formats on capture device

查看:159
本文介绍了Windows Core Audio Api在捕获设备上获取所有受支持的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在设备属性->高级-> DefaultFormat部分中枚举Capture设备上所有受支持的格式.

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

我想使用Windows Core Audio Api来做到这一点,但是我真的找不到适合的界面来读取这些格式.

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/zh-CN/library/windows/desktop/dd370858(v=vs.85).aspx#

您知道哪个界面可以为我提供这种功能吗?

Any idea which interface would provide me with such functionality?

推荐答案

IMMDevice (IMMDevice接口代表音频终结点设备:呈现或捕获):

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):

  • you can use IMMDeviceEnumerator::EnumAudioEndpoints method to get all active capture devices in the system, or
  • you can call IMMDeviceEnumerator::GetDefaultAudioEndpoint to obtain pointer to the default capture device.

无论如何,当您拥有要查找支持的格式的IMMDevice的指针时,可以获取 IMMDevice :: Activate 方法. IAudioClient界面允许您检查设备是否支持音频格式(方法 WAVEFORMATEX 结构).不幸的是,目前Core Audio API中没有方法可以返回设备支持的格式列表,因此您将需要枚举WAVEFORMATEX成员结构的可能值,并检查设备是否支持自己的每种格式.

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.

但是您可以使用IMMDevice属性存储来获取用户在DefaultFormat部分中选择的格式( MSDN:PKEY_AudioEngine_DeviceFormat ).

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:

  • MSDN: Device Formats
  • MSDN: Device Properties
  • MSDN: Audio Endpoint Properties

这篇关于Windows Core Audio Api在捕获设备上获取所有受支持的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆