summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gsttools/qgstreameraudioinputselector.cpp49
-rw-r--r--src/plugins/alsa/qalsaaudiodeviceinfo.cpp109
2 files changed, 75 insertions, 83 deletions
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
}
diff --git a/src/plugins/alsa/qalsaaudiodeviceinfo.cpp b/src/plugins/alsa/qalsaaudiodeviceinfo.cpp
index 349999c66..ce7fb701d 100644
--- a/src/plugins/alsa/qalsaaudiodeviceinfo.cpp
+++ b/src/plugins/alsa/qalsaaudiodeviceinfo.cpp
@@ -337,9 +337,14 @@ QList<QByteArray> QAlsaAudioDeviceInfo::availableDevices(QAudio::Mode mode)
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
// Create a list of all current audio devices that support mode
- void **hints;
+ void **hints, **n;
char *name, *descr, *io;
- int card = -1;
+
+ if(snd_device_name_hint(-1, "pcm", &hints) < 0) {
+ qWarning() << "no alsa devices available";
+ return devices;
+ }
+ n = hints;
if(mode == QAudio::AudioInput) {
filter = "Input";
@@ -347,35 +352,28 @@ QList<QByteArray> QAlsaAudioDeviceInfo::availableDevices(QAudio::Mode mode)
filter = "Output";
}
- while (snd_card_next(&card) == 0 && card >= 0) {
- if (snd_device_name_hint(card, "pcm", &hints) < 0)
- continue;
-
- void **n = hints;
- while (*n != NULL) {
- name = snd_device_name_get_hint(*n, "NAME");
- 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);
- if (deviceDescription.contains(QLatin1String("Default Audio Device")))
- devices.prepend(deviceName.toLocal8Bit().constData());
- else
- devices.append(deviceName.toLocal8Bit().constData());
- }
-
- free(descr);
- free(io);
+ while (*n != NULL) {
+ name = snd_device_name_get_hint(*n, "NAME");
+ 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);
+ if (deviceDescription.contains(QLatin1String("Default Audio Device")))
+ devices.prepend(deviceName.toLocal8Bit().constData());
+ else
+ devices.append(deviceName.toLocal8Bit().constData());
}
- free(name);
- ++n;
- }
- snd_device_name_free_hint(hints);
+ free(descr);
+ free(io);
+ }
+ free(name);
+ ++n;
}
+ snd_device_name_free_hint(hints);
#else
int idx = 0;
char* name;
@@ -416,41 +414,38 @@ void QAlsaAudioDeviceInfo::checkSurround()
surround51 = false;
surround71 = false;
- void **hints;
+ void **hints, **n;
char *name, *descr, *io;
- int card = -1;
- while (snd_card_next(&card) == 0 && card >= 0) {
- if (snd_device_name_hint(card, "pcm", &hints) < 0)
- continue;
+ if(snd_device_name_hint(-1, "pcm", &hints) < 0)
+ return;
- void **n = hints;
- 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)) {
- QString deviceName = QLatin1String(name);
- if (mode == QAudio::AudioOutput) {
- if(deviceName.contains(QLatin1String("surround40")))
- surround40 = true;
- if(deviceName.contains(QLatin1String("surround51")))
- surround51 = true;
- if(deviceName.contains(QLatin1String("surround71")))
- surround71 = true;
- }
+ n = hints;
+
+ 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)) {
+ QString deviceName = QLatin1String(name);
+ if (mode == QAudio::AudioOutput) {
+ if(deviceName.contains(QLatin1String("surround40")))
+ surround40 = true;
+ if(deviceName.contains(QLatin1String("surround51")))
+ surround51 = true;
+ if(deviceName.contains(QLatin1String("surround71")))
+ surround71 = true;
}
- if(name != NULL)
- free(name);
- if(descr != NULL)
- free(descr);
- if(io != NULL)
- free(io);
- ++n;
}
-
- 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);
}
QT_END_NAMESPACE