diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-08-12 06:32:11 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-08-12 07:12:47 (GMT) |
commit | baf8eabd2c647d6ba2bf0a9dc5103f4726808c3d (patch) | |
tree | 040fa6443d3e6a1f4bf184657ff0a5c2c6e7e713 | |
parent | 224d8f7619447a4784da533ac26760ea1e7b9087 (diff) | |
download | Qt-baf8eabd2c647d6ba2bf0a9dc5103f4726808c3d.zip Qt-baf8eabd2c647d6ba2bf0a9dc5103f4726808c3d.tar.gz Qt-baf8eabd2c647d6ba2bf0a9dc5103f4726808c3d.tar.bz2 |
QAudioOutput(ALSA); Fix check for available devices.
ALSA can return a list of one empty item when no devices are available.
Task-number: QTBUG-12690
Reviewed-by: Andrew den Exter
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index f663dd2..633b309 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -431,21 +431,24 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) while (*n != NULL) { name = snd_device_name_get_hint(*n, "NAME"); - descr = snd_device_name_get_hint(*n, "DESC"); - io = snd_device_name_get_hint(*n, "IOID"); - if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) { - QString deviceName = QLatin1String(name); - QString deviceDescription = QLatin1String(descr); - allDevices.append(deviceName.toLocal8Bit().constData()); - if(deviceDescription.contains(QLatin1String("Default Audio Device"))) - devices.append(deviceName.toLocal8Bit().constData()); - } - if(name != NULL) + if (name != 0 && qstrcmp(name, "null") != 0) { + descr = snd_device_name_get_hint(*n, "DESC"); + io = snd_device_name_get_hint(*n, "IOID"); + + if ((descr != NULL) && ((io == NULL) || (io == filter))) { + QString deviceName = QLatin1String(name); + QString deviceDescription = QLatin1String(descr); + allDevices.append(deviceName.toLocal8Bit().constData()); + if (deviceDescription.contains(QLatin1String("Default Audio Device"))) + devices.append(deviceName.toLocal8Bit().constData()); + } + free(name); - if(descr != NULL) - free(descr); - if(io != NULL) - free(io); + if (descr != NULL) + free(descr); + if (io != NULL) + free(io); + } ++n; } snd_device_name_free_hint(hints); |