From ba11343826229e983cb1d38811c8363d355e2e01 Mon Sep 17 00:00:00 2001 From: Martin Banky Date: Tue, 6 Oct 2009 08:26:00 +1000 Subject: Fixed QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) filtering If an audio device only supported Input or Output, it would not be added to the list of devices. Only devices that returned IOID == NULL would be added. Also, _m was not being used, and io was unneccessarily being cast to a QString. Merge-request: 1664 Reviewed-by: Kurt Korbatits --- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index dc24875..55020a6 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -360,33 +360,30 @@ void QAudioDeviceInfoInternal::updateLists() QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) { - QAudio::Mode _m; QList devices; QByteArray filter; - QString dir; // Create a list of all current audio devices that support mode void **hints, **n; char *name, *descr, *io; if(snd_device_name_hint(-1, "pcm", &hints) < 0) { - qWarning()<<"no alsa devices available"; + qWarning() << "no alsa devices available"; return devices; } n = hints; + if(mode == QAudio::AudioInput) { + filter = "Input"; + } else { + filter = "Output"; + } + while (*n != NULL) { - _m = QAudio::AudioOutput; name = snd_device_name_get_hint(*n, "NAME"); descr = snd_device_name_get_hint(*n, "DESC"); io = snd_device_name_get_hint(*n, "IOID"); - dir = QString::fromUtf8(io); - if((name != NULL) && (descr != NULL) && ((io == NULL) || (dir.length() ==filter.length()))) { - if(dir.length() == 5) - _m = QAudio::AudioInput; - if(io == NULL) - _m = mode; - + if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) { QString str = QLatin1String(name); if(str.contains(QLatin1String("default"))) { @@ -400,17 +397,12 @@ QList QAudioDeviceInfoInternal::deviceList(QAudio::Mode mode) free(descr); if(io != NULL) free(io); - n++; + ++n; } snd_device_name_free_hint(hints); if(devices.size() > 0) { devices.append("default"); - if(mode == QAudio::AudioInput) { - filter.append("Input"); - } else { - filter.append("Output"); - } } return devices; -- cgit v0.12