I was wondering if anyone know how to get preferred channel layout from CoreAudio. I try to use kAudioDevicePropertyPreferredChannelLayout to get the channel label. However, it always shows kAudioChannelLabel_Unknown value. Is there something driver issue? or it's necessary to set some properties before asking kAudioDevicePropertyPreferredChannelLayout.
my code is here: https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/e61fedea3e08bcff64ef3db05931a1c757768d70
Answer by myself.
Instead of kAudioDevicePropertyPreferredChannelLayout, Using kAudioUnitProperty_AudioChannelLayout allow me to get the correct channel configuration.
Maybe it would be better if we use kAudioDevicePropertyPreferredChannelLayout to get the layout first. If it returns Unknown, then we use kAudioUnitProperty_AudioChannelLayout to get it.
Code: https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/96b5d39e3fa7d5d6e160c53917b213f9af3ba2c9#file-preferredchannellayout-cpp