diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-08-12 06:32:11 (GMT) |
---|---|---|
committer | Jesper Thomschutz <jesper.thomschutz@nokia.com> | 2010-08-13 08:58:42 (GMT) |
commit | b004dad34039300abfc1058439f6c57063ea8080 (patch) | |
tree | cd648ff494d44276f9c9e8e97344593d08f1db45 | |
parent | baf23e4547d3fd471d7d60b63aab1a3c98daa35d (diff) | |
download | Qt-b004dad34039300abfc1058439f6c57063ea8080.zip Qt-b004dad34039300abfc1058439f6c57063ea8080.tar.gz Qt-b004dad34039300abfc1058439f6c57063ea8080.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
(cherry picked from commit baf8eabd2c647d6ba2bf0a9dc5103f4726808c3d)
-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 36270a7..cea8410 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -426,21 +426,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); |