From e1d76e2df53b766f418e15282a2b908e91108b66 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 11 Mar 2015 14:32:17 +0100 Subject: Revert "Alsa: fix crash when detecting devices." This reverts commit 0ab81ef59f35d103ec8174834c4fc2a4dcced453. The workaround causes software devices not to appear in the list of available devices. Besides, since the crash is caused by a bug in older versions of Alsa, the workaround was probably a bad idea in the first place. People should update Alsa instead. Task-number: QTBUG-42326 Change-Id: I37923a87180d1c5abc18d52d84f633e14ba46860 Reviewed-by: Christian Stromme --- src/gsttools/qgstreameraudioinputselector.cpp | 49 +++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'src/gsttools/qgstreameraudioinputselector.cpp') diff --git a/src/gsttools/qgstreameraudioinputselector.cpp b/src/gsttools/qgstreameraudioinputselector.cpp index 31634f024..a0ced3367 100644 --- a/src/gsttools/qgstreameraudioinputselector.cpp +++ b/src/gsttools/qgstreameraudioinputselector.cpp @@ -111,36 +111,33 @@ void QGstreamerAudioInputSelector::updateAlsaDevices() { #ifdef HAVE_ALSA void **hints, **n; - 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 (snd_device_name_hint(-1, "pcm", &hints) < 0) { + qWarning()<<"no alsa devices available"; + return; + } + n = hints; - if (name != NULL) - free(name); - if (descr != NULL) - free(descr); - if (io != NULL) - free(io); - ++n; + 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)); + } } - snd_device_name_free_hint(hints); + if (name != NULL) + free(name); + if (descr != NULL) + free(descr); + if (io != NULL) + free(io); + n++; } + snd_device_name_free_hint(hints); #endif } -- cgit v1.2.3