diff options
author | Andy Nichols <andy.nichols@digia.com> | 2014-03-02 20:39:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-03 16:45:38 +0100 |
commit | 8c9b6f67a73824aab8c74df7a1254425985fd8a5 (patch) | |
tree | 26f7b01f02dd23c776332bbe16768419a583026e /src/plugins/coreaudio | |
parent | 775914ffb21bcdc6059e5867993b927a824d0cac (diff) |
CoreAudio: Use the real default audio device for QSoundEffect
There is an assumption in QtMultimedia that the first audio device
returned by QAudioDeviceInfo::availableDevices is the default device, so
we must make an effor to make sure this is true. This commit should fix
the issue on OS X.
Task-number: QTBUG-36638
Change-Id: Id388d7218b465cb29d826f46ee825e982c5f7ffc
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src/plugins/coreaudio')
-rw-r--r-- | src/plugins/coreaudio/coreaudiodeviceinfo.mm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/coreaudio/coreaudiodeviceinfo.mm b/src/plugins/coreaudio/coreaudiodeviceinfo.mm index 5d07ca48a..bb1f046a6 100644 --- a/src/plugins/coreaudio/coreaudiodeviceinfo.mm +++ b/src/plugins/coreaudio/coreaudiodeviceinfo.mm @@ -327,7 +327,7 @@ QByteArray CoreAudioDeviceInfo::defaultOutputDevice() #if defined(Q_OS_OSX) AudioDeviceID audioDevice; UInt32 size = sizeof(audioDevice); - AudioObjectPropertyAddress defaultOutputDevicePropertyAddress = { kAudioHardwarePropertyDefaultInputDevice, + AudioObjectPropertyAddress defaultOutputDevicePropertyAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; @@ -363,10 +363,15 @@ QList<QByteArray> CoreAudioDeviceInfo::availableDevices(QAudio::Mode mode) AudioDeviceID* audioDevices = new AudioDeviceID[dc]; if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &audioDevicesPropertyAddress, 0, NULL, &propSize, audioDevices) == noErr) { + QByteArray defaultDevice = (mode == QAudio::AudioOutput) ? defaultOutputDevice() : defaultInputDevice(); for (int i = 0; i < dc; ++i) { QByteArray info = get_device_info(audioDevices[i], mode); - if (!info.isNull()) - devices << info; + if (!info.isNull()) { + if (info == defaultDevice) + devices.prepend(info); + else + devices << info; + } } } |