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>
This commit is contained in:
committed by
The Qt Project
parent
775914ffb2
commit
8c9b6f67a7
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user