summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-05-03 13:13:42 +0800
committerTim Blechmann <tim@klingt.org>2024-05-08 08:43:11 +0800
commit2937fe559305e0c1c81ba6942a586edfffe0bd76 (patch)
tree6f2ab783d007e2d051542acb58374a6c28f321b0
parent56df44c41bd233cd1d12c44b61650fb9b6419b87 (diff)
ALSA: use first device as default
When ALSA doesn't provide a "default" device, we can select the first in the list rather than creating a non-existent device. [ChangeLog] ALSA: use first device as default, if ALSA doesn't report a default device. Pick-to: 6.5 6.7 Change-Id: I1015d7107e8f253c0c940b6f68719ef868ac7d0f Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
-rw-r--r--src/multimedia/alsa/qalsamediadevices.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/multimedia/alsa/qalsamediadevices.cpp b/src/multimedia/alsa/qalsamediadevices.cpp
index b0f047036..10a7e464a 100644
--- a/src/multimedia/alsa/qalsamediadevices.cpp
+++ b/src/multimedia/alsa/qalsamediadevices.cpp
@@ -86,7 +86,6 @@ static QList<QAudioDevice> availableDevices(QAudioDevice::Mode mode)
}
}
}
- snd_device_name_free_hint(hints);
if (!hasDefault && sysdefault) {
// Make "sysdefault" the default device if there is no "default" device exists
@@ -94,11 +93,15 @@ static QList<QAudioDevice> availableDevices(QAudioDevice::Mode mode)
hasDefault = true;
}
if (!hasDefault && devices.size() > 0) {
- auto infop = new QAlsaAudioDeviceInfo("default", QString(), QAudioDevice::Output);
- infop->isDefault = true;
- devices.prepend(infop->create());
+ // forcefully declare the first device as "default"
+ QAlsaAudioDeviceInfo *infop = makeDeviceInfo(hints[0]);
+ if (infop) {
+ infop->isDefault = true;
+ devices.prepend(infop->create());
+ }
}
+ snd_device_name_free_hint(hints);
return devices;
}