diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-09-02 11:01:29 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-09-07 05:15:09 +0000 |
commit | af985a697a47cc887625e06c05f5cb785ee66d35 (patch) | |
tree | 0fab320f17677f6bd8be88156300e13133ea0ea1 /src/plugins/wasapi/qwasapiutils.cpp | |
parent | 9fb4597d5c0d3fa3340ae74ed2eb6bb8e3ee2d17 (diff) | |
download | qtmultimedia-af985a697a47cc887625e06c05f5cb785ee66d35.tar.gz |
winrt: Fix QAudioDeviceInfo::default*Device to return name instead id
3c5bbb0dac7bed3199ddddc88c0175d5a2ac1036 added the default* functions to
query a default device. However, IMediaDeviceStatics can only return ids
and not the device names. Hence we need to invoke availableDevices to
create the internal mapping and return the device name to properly
initialize audio devices afterwards.
Task-number: QTBUG-55631
Change-Id: I38b9205a933de5e41296a2e5880d0379db41ad97
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/wasapi/qwasapiutils.cpp')
-rw-r--r-- | src/plugins/wasapi/qwasapiutils.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/wasapi/qwasapiutils.cpp b/src/plugins/wasapi/qwasapiutils.cpp index 6340a3b01..727c94c23 100644 --- a/src/plugins/wasapi/qwasapiutils.cpp +++ b/src/plugins/wasapi/qwasapiutils.cpp @@ -182,6 +182,13 @@ QByteArray QWasapiUtils::defaultDevice(QAudio::Mode mode) { qCDebug(lcMmUtils) << __FUNCTION__ << mode; + QList<QByteArray> &deviceNames = mode == QAudio::AudioInput ? gMapping->inputDeviceNames : gMapping->outputDeviceNames; + QList<QString> &deviceIds = mode == QAudio::AudioInput ? gMapping->inputDeviceIds : gMapping->outputDeviceIds; + if (deviceNames.isEmpty() || deviceIds.isEmpty()) // Initialize + availableDevices(mode); + if (deviceNames.isEmpty() || deviceIds.isEmpty()) // No audio devices at all + return QByteArray(); + ComPtr<IMediaDeviceStatics> mediaDeviceStatics; HRESULT hr; @@ -198,7 +205,9 @@ QByteArray QWasapiUtils::defaultDevice(QAudio::Mode mode) const wchar_t *dadWStr = defaultAudioDevice.GetRawBuffer(&dADSize); const QString defaultAudioDeviceId = QString::fromWCharArray(dadWStr, dADSize); - return defaultAudioDeviceId.toLocal8Bit(); + Q_ASSERT(deviceIds.indexOf(defaultAudioDeviceId) != -1); + + return deviceNames.at(deviceIds.indexOf(defaultAudioDeviceId)); } QList<QByteArray> QWasapiUtils::availableDevices(QAudio::Mode mode) |