From 8c9b6f67a73824aab8c74df7a1254425985fd8a5 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Sun, 2 Mar 2014 20:39:44 +0100 Subject: 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 --- src/plugins/coreaudio/coreaudiodeviceinfo.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/plugins/coreaudio') 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 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; + } } } -- cgit v1.2.3