diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2014-01-30 16:32:53 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-30 18:12:44 +0100 |
commit | 0ab81ef59f35d103ec8174834c4fc2a4dcced453 (patch) | |
tree | 20d4346b56a14b97d2c78409ccb7d1873564658b /src/gsttools | |
parent | 67b86a9fbd87fb50e896bf66313c2f949501df5b (diff) |
Alsa: fix crash when detecting devices.
Some old versions of Alsa crash when snd_device_name_hint(-1, ...) is
called. This patch works around the problem by iterating manually over all
the available sound cards.
Change-Id: Ic380a371acc15013d137553ff30d68bed5af664e
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/gsttools')
-rw-r--r-- | src/gsttools/qgstreameraudioinputselector.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/gsttools/qgstreameraudioinputselector.cpp b/src/gsttools/qgstreameraudioinputselector.cpp index dcab762a2..02d3e5681 100644 --- a/src/gsttools/qgstreameraudioinputselector.cpp +++ b/src/gsttools/qgstreameraudioinputselector.cpp @@ -119,33 +119,36 @@ void QGstreamerAudioInputSelector::updateAlsaDevices() { #ifdef HAVE_ALSA void **hints, **n; - if (snd_device_name_hint(-1, "pcm", &hints) < 0) { - qWarning()<<"no alsa devices available"; - return; - } - n = hints; - - while (*n != NULL) { - char *name = snd_device_name_get_hint(*n, "NAME"); - char *descr = snd_device_name_get_hint(*n, "DESC"); - char *io = snd_device_name_get_hint(*n, "IOID"); - - if ((name != NULL) && (descr != NULL)) { - if ( io == NULL || qstrcmp(io,"Input") == 0 ) { - m_names.append(QLatin1String("alsa:")+QString::fromUtf8(name)); - m_descriptions.append(QString::fromUtf8(descr)); + int card = -1; + + while (snd_card_next(&card) == 0 && card >= 0) { + if (snd_device_name_hint(card, "pcm", &hints) < 0) + continue; + + n = hints; + while (*n != NULL) { + char *name = snd_device_name_get_hint(*n, "NAME"); + char *descr = snd_device_name_get_hint(*n, "DESC"); + char *io = snd_device_name_get_hint(*n, "IOID"); + + if ((name != NULL) && (descr != NULL)) { + if ( io == NULL || qstrcmp(io,"Input") == 0 ) { + m_names.append(QLatin1String("alsa:")+QString::fromUtf8(name)); + m_descriptions.append(QString::fromUtf8(descr)); + } } + + if (name != NULL) + free(name); + if (descr != NULL) + free(descr); + if (io != NULL) + free(io); + ++n; } - if (name != NULL) - free(name); - if (descr != NULL) - free(descr); - if (io != NULL) - free(io); - n++; + snd_device_name_free_hint(hints); } - snd_device_name_free_hint(hints); #endif } |