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:
committed by
The Qt Project
parent
9b7fd8c769
commit
dd11f6d052
@@ -188,11 +188,11 @@ QList<int> CoreAudioDeviceInfo::supportedSampleRates()
|
||||
|
||||
QList<int> CoreAudioDeviceInfo::supportedChannelCounts()
|
||||
{
|
||||
QSet<int> supportedChannels;
|
||||
QList<int> 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<int> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user