Use correct default audio output and input devices on Windows.
authorYoann Lopes <yoann.lopes@digia.com>
Tue, 25 Jun 2013 11:20:55 +0000 (13:20 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 25 Jun 2013 12:05:15 +0000 (14:05 +0200)
It was returning the first available device as the default, which might
not be the actual default device. Use the WAVE_MAPPER device ID instead
that tells Windows to use the most appropriate device.

Change-Id: Id1e9324e889bbaaab54bc0e0da810a7ce5fcb592
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp

index f3af7e0..e9503d4 100644 (file)
@@ -469,20 +469,22 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
 
 QByteArray QAudioDeviceInfoInternal::defaultOutputDevice()
 {
-    QList<QByteArray> list = availableDevices(QAudio::AudioOutput);
-    if (list.size() > 0)
-        return list.at(0);
-    else
-        return QByteArray();
+    QByteArray defaultDevice;
+    QDataStream ds(&defaultDevice, QIODevice::WriteOnly);
+    ds << quint32(WAVE_MAPPER) // device ID for default device
+       << QStringLiteral("Default Output Device");
+
+    return defaultDevice;
 }
 
 QByteArray QAudioDeviceInfoInternal::defaultInputDevice()
 {
-    QList<QByteArray> list = availableDevices(QAudio::AudioInput);
-    if (list.size() > 0)
-        return list.at(0);
-    else
-        return QByteArray();
+    QByteArray defaultDevice;
+    QDataStream ds(&defaultDevice, QIODevice::WriteOnly);
+    ds << quint32(WAVE_MAPPER) // device ID for default device
+       << QStringLiteral("Default Input Device");
+
+    return defaultDevice;
 }
 
 QT_END_NAMESPACE