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 <christian.stromme@digia.com>
Reviewed-by: Ivan Romanov <drizt@land.ru>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
Yoann Lopes
2013-11-26 16:34:29 +01:00
committed by The Qt Project
parent 9b7fd8c769
commit dd11f6d052

View File

@@ -188,11 +188,11 @@ QList<int> CoreAudioDeviceInfo::supportedSampleRates()
QList<int> CoreAudioDeviceInfo::supportedChannelCounts() QList<int> CoreAudioDeviceInfo::supportedChannelCounts()
{ {
QSet<int> supportedChannels; QList<int> supportedChannels;
int maxChannels = 0;
#if defined(Q_OS_OSX) #if defined(Q_OS_OSX)
UInt32 propSize = 0; UInt32 propSize = 0;
int channels = 0;
AudioObjectPropertyScope scope = m_mode == QAudio::AudioInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyScope scope = m_mode == QAudio::AudioInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress streamConfigurationPropertyAddress = { kAudioDevicePropertyStreamConfiguration, AudioObjectPropertyAddress streamConfigurationPropertyAddress = { kAudioDevicePropertyStreamConfiguration,
scope, scope,
@@ -203,24 +203,25 @@ QList<int> CoreAudioDeviceInfo::supportedChannelCounts()
if (audioBufferList != 0) { if (audioBufferList != 0) {
if (AudioObjectGetPropertyData(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize, audioBufferList) == noErr) { if (AudioObjectGetPropertyData(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize, audioBufferList) == noErr) {
for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i) { for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i)
channels += audioBufferList->mBuffers[i].mNumberChannels; maxChannels += audioBufferList->mBuffers[i].mNumberChannels;
supportedChannels << channels;
}
} }
free(audioBufferList); free(audioBufferList);
} }
} }
#else //iOS #else //iOS
if (m_mode == QAudio::AudioInput) { if (m_mode == QAudio::AudioInput)
supportedChannels << CoreAudioSessionManager::instance().inputChannelCount(); maxChannels = CoreAudioSessionManager::instance().inputChannelCount();
} else if (m_mode == QAudio::AudioOutput) { else if (m_mode == QAudio::AudioOutput)
supportedChannels << CoreAudioSessionManager::instance().outputChannelCount(); maxChannels = CoreAudioSessionManager::instance().outputChannelCount();
}
#endif #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;
} }