summaryrefslogtreecommitdiffstats
path: root/src/plugins/coreaudio/coreaudiodeviceinfo.mm
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-03-31 14:22:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-01 13:43:13 +0200
commitd2b54b360ec0cedf2dfd64c72cc8f476fb93bc7c (patch)
tree60d55122abb4b7953e6d2d4512b73b394ea67521 /src/plugins/coreaudio/coreaudiodeviceinfo.mm
parentb6970e2e79aac9a63bc4db5f879a3f050889f991 (diff)
CoreAudio: fix supported channel count.
We were using the number of channels actually used by audio devices as the maximum channel count. This is wrong as CoreAudio can automatically split or merge channels in order to accommodate the device. We now assume all channel configurations are valid. Task-number: QTBUG-37956 Change-Id: Ia8e8bbea8543caa7fecda305be74a2953b92fd25 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/plugins/coreaudio/coreaudiodeviceinfo.mm')
-rw-r--r--src/plugins/coreaudio/coreaudiodeviceinfo.mm36
1 files changed, 6 insertions, 30 deletions
diff --git a/src/plugins/coreaudio/coreaudiodeviceinfo.mm b/src/plugins/coreaudio/coreaudiodeviceinfo.mm
index 56765cafd..ac41a310c 100644
--- a/src/plugins/coreaudio/coreaudiodeviceinfo.mm
+++ b/src/plugins/coreaudio/coreaudiodeviceinfo.mm
@@ -196,38 +196,14 @@ QList<int> CoreAudioDeviceInfo::supportedSampleRates()
QList<int> CoreAudioDeviceInfo::supportedChannelCounts()
{
- QList<int> supportedChannels;
- int maxChannels = 0;
+ static QList<int> supportedChannels;
-#if defined(Q_OS_OSX)
- UInt32 propSize = 0;
- AudioObjectPropertyScope scope = m_mode == QAudio::AudioInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
- AudioObjectPropertyAddress streamConfigurationPropertyAddress = { kAudioDevicePropertyStreamConfiguration,
- scope,
- kAudioObjectPropertyElementMaster };
-
- if (AudioObjectGetPropertyDataSize(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize) == noErr) {
- AudioBufferList* audioBufferList = static_cast<AudioBufferList*>(malloc(propSize));
-
- if (audioBufferList != 0) {
- if (AudioObjectGetPropertyData(m_deviceId, &streamConfigurationPropertyAddress, 0, NULL, &propSize, audioBufferList) == noErr) {
- for (int i = 0; i < int(audioBufferList->mNumberBuffers); ++i)
- maxChannels += audioBufferList->mBuffers[i].mNumberChannels;
- }
-
- free(audioBufferList);
- }
+ if (supportedChannels.isEmpty()) {
+ // If the number of channels is not supported by an audio device, Core Audio will
+ // automatically convert the audio data.
+ for (int i = 1; i <= 16; ++i)
+ supportedChannels.append(i);
}
-#else //iOS
- if (m_mode == QAudio::AudioInput)
- maxChannels = CoreAudioSessionManager::instance().inputChannelCount();
- else if (m_mode == QAudio::AudioOutput)
- maxChannels = CoreAudioSessionManager::instance().outputChannelCount();
-#endif
-
- // 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;
}