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:20:33 (GMT) |
commit | da0303d1ba6acc58f60c7448fefeffc88e8e331b (patch) | |
tree | 922ff01fb97543a54c028a66e00379e45f3b080e /src/multimedia | |
parent | 8dca92fd7987a9aa727dea6c367c079a39668f09 (diff) | |
download | Qt-da0303d1ba6acc58f60c7448fefeffc88e8e331b.zip Qt-da0303d1ba6acc58f60c7448fefeffc88e8e331b.tar.gz Qt-da0303d1ba6acc58f60c7448fefeffc88e8e331b.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
Diffstat (limited to 'src/multimedia')
-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); |