From dd11f6d0527bfac17d855909397f66fe816a0d1f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 26 Nov 2013 16:34:29 +0100 Subject: [PATCH] CoreAudio: fix supported input and output channel count. Only the maximum number of channels was reported as being supported. We now report all possible configurations up to the maximum number of channels to be supported. Task-number: QTBUG-34639 Change-Id: Ib4c599ea8b772ebeaaca95137d24bac49dbd80d3 Reviewed-by: Christian Stromme Reviewed-by: Ivan Romanov Reviewed-by: Andy Nichols --- src/plugins/coreaudio/coreaudiodeviceinfo.mm | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/plugins/coreaudio/coreaudiodeviceinfo.mm b/src/plugins/coreaudio/coreaudiodeviceinfo.mm index 77a9b835..92ce9886 100644 --- a/src/plugins/coreaudio/coreaudiodeviceinfo.mm +++ b/src/plugins/coreaudio/coreaudiodeviceinfo.mm @@ -188,11 +188,11 @@ QList CoreAudioDeviceInfo::supportedSampleRates() QList CoreAudioDeviceInfo::supportedChannelCounts() { - QSet supportedChannels; + QList supportedChannels; + int maxChannels = 0; #if defined(Q_OS_OSX) UInt32 propSize = 0; - int channels = 0; AudioObjectPropertyScope scope = m_mode == QAudio::AudioInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyAddress streamConfigurationPropertyAddress = { kAudioDevicePropertyStreamConfiguration, scope, @@ -203,24 +203,25 @@ QList CoreAudioDeviceInfo::supportedChannelCounts() if (audioBufferList != 0) { if (AudioObjectGetPropertyData(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize, audioBufferList) == noErr) { - for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { - channels += audioBufferList->mBuffers[i].mNumberChannels; - supportedChannels << channels; - } + for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) + maxChannels += audioBufferList->mBuffers[i].mNumberChannels; } free(audioBufferList); } } #else //iOS - if (m_mode == QAudio::AudioInput) { - supportedChannels << CoreAudioSessionManager::instance().inputChannelCount(); - } else if (m_mode == QAudio::AudioOutput) { - supportedChannels << CoreAudioSessionManager::instance().outputChannelCount(); - } + if (m_mode == QAudio::AudioInput) + maxChannels = CoreAudioSessionManager::instance().inputChannelCount(); + else if (m_mode == QAudio::AudioOutput) + maxChannels = CoreAudioSessionManager::instance().outputChannelCount(); #endif - return supportedChannels.toList(); + // Assume all channel configurations are supported up to the maximum number of channels + for (int i = 1; i <= maxChannels; ++i) + supportedChannels.append(i); + + return supportedChannels; }