ext/alsa/gstalsa.c: Don't probe for playback device if we're a source element. Fixes...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Thu, 29 Apr 2004 00:40:14 +0000 (00:40 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Thu, 29 Apr 2004 00:40:14 +0000 (00:40 +0000)
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_probe_devices):
Don't probe for playback device if we're a source element. Fixes
#139658.

ChangeLog
ext/alsa/gstalsa.c

index 7fc40e8..419346b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-04-28  Ronald Bultje  <rbultje@ronald.bitfreak.net>
+
+       * ext/alsa/gstalsa.c: (gst_alsa_class_probe_devices):
+         Don't probe for playback device if we're a source element. Fixes
+         #139658.
+
 2004-04-29  Benjamin Otte  <otte@gnome.org>
 
        * ext/mad/gstid3tag.c: (gst_id3_tag_handle_event),
index dbdd363..9358857 100644 (file)
@@ -326,11 +326,23 @@ gst_alsa_class_probe_devices (GstAlsaClass * klass, gboolean check)
     gint num, res;
     gchar *dev;
     snd_pcm_t *pcm;
+    snd_pcm_stream_t mode = 0;
+    const GList *templates;
+
+    /* we assume one pad template at max [zero=mixer] */
+    templates =
+        gst_element_class_get_pad_template_list (GST_ELEMENT_CLASS (klass));
+    if (templates) {
+      if (GST_PAD_TEMPLATE_DIRECTION (templates->data) == GST_PAD_SRC)
+        mode = SND_PCM_STREAM_CAPTURE;
+      else
+        mode = SND_PCM_STREAM_PLAYBACK;
+    }
 
     for (num = 0; num < MAX_DEVICES; num++) {
       dev = g_strdup_printf ("hw:%d", num);
 
-      if (!(res = snd_pcm_open (&pcm, dev, 0, SND_PCM_NONBLOCK)) ||
+      if (!(res = snd_pcm_open (&pcm, dev, mode, SND_PCM_NONBLOCK)) ||
           res == -EBUSY) {
         klass->devices = g_list_append (klass->devices, dev);