如何从 CoreAudio 获取首选通道布局

How to get preferred channel layout from CoreAudio

我想知道是否有人知道如何从 CoreAudio 获得首选频道布局。我尝试使用 kAudioDevicePropertyPreferredChannelLayout 来获取频道标签。但是,它始终显示 kAudioChannelLabel_Unknown 值。有什么驱动程序问题吗?或者在询问 kAudioDevicePropertyPreferredChannelLayout 之前需要设置一些属性。

我的代码在这里: https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/e61fedea3e08bcff64ef3db05931a1c757768d70

自己回答

而不是 kAudioDevicePropertyPreferredChannelLayout,使用 kAudioUnitProperty_AudioChannelLayout 让我获得正确的声道配置。

也许我们先使用kAudioDevicePropertyPreferredChannelLayout来获取布局会更好。如果它 returns 未知,那么我们使用 kAudioUnitProperty_AudioChannelLayout 来获取它。

代码:https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/96b5d39e3fa7d5d6e160c53917b213f9af3ba2c9#file-preferredchannellayout-cpp