ext/alsa/: Make alsasink/src a subclass of alsamixer so that mixer stuff shows up...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Fri, 7 May 2004 04:56:56 +0000 (04:56 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Fri, 7 May 2004 04:56:56 +0000 (04:56 +0000)
Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list):
* ext/alsa/gstalsasink.c: (gst_alsa_sink_get_type),
(gst_alsa_sink_class_init):
* ext/alsa/gstalsasink.h:
* ext/alsa/gstalsasrc.c: (gst_alsa_src_get_type),
(gst_alsa_src_class_init):
* ext/alsa/gstalsasrc.h:
Make alsasink/src a subclass of alsamixer so that mixer stuff
shows up in gst-rec. Needs some finetuning.

ChangeLog
ext/alsa/gstalsamixer.c
ext/alsa/gstalsasink.c
ext/alsa/gstalsasink.h
ext/alsa/gstalsasrc.c
ext/alsa/gstalsasrc.h

index ce50411bd9378147845c04ee24a74e1e55324f42..ab7a05c6b1d868c2489dbda90f6b5af8b6a896f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-05-07  Ronald Bultje  <rbultje@ronald.bitfreak.net>
+
+       * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list):
+       * ext/alsa/gstalsasink.c: (gst_alsa_sink_get_type),
+       (gst_alsa_sink_class_init):
+       * ext/alsa/gstalsasink.h:
+       * ext/alsa/gstalsasrc.c: (gst_alsa_src_get_type),
+       (gst_alsa_src_class_init):
+       * ext/alsa/gstalsasrc.h:
+         Make alsasink/src a subclass of alsamixer so that mixer stuff
+         shows up in gst-rec. Needs some finetuning.
+
 2004-05-05  Benjamin Otte  <in7y118@public.uni-hamburg.de>
 
        * ext/lame/gstlame.c: (gst_lame_chain):
index e2912f25bc954a740aa8b3a979fe00164df8b5dc..1ababaf39ce17f7246d543425e239e14f22801a2 100644 (file)
@@ -225,9 +225,17 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
   gint i, count;
   snd_mixer_elem_t *element;
   GstMixerTrack *track;
+  const GList *templates;
+  GstPadDirection dir = GST_PAD_UNKNOWN;
 
   g_return_if_fail (((gint) mixer->mixer_handle) != -1);
 
+  /* find direction */
+  templates =
+      gst_element_class_get_pad_template_list (GST_ELEMENT_GET_CLASS (mixer));
+  if (templates)
+    dir = GST_PAD_TEMPLATE (templates->data)->direction;
+
   count = snd_mixer_get_count (mixer->mixer_handle);
   element = snd_mixer_first_elem (mixer->mixer_handle);
 
@@ -240,10 +248,10 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
       continue;
 
     /* find out if this element can be an input */
-
-    if (snd_mixer_selem_has_capture_channel (element, 0) ||
-        snd_mixer_selem_has_capture_switch (element) ||
-        snd_mixer_selem_is_capture_mono (element)) {
+    if ((dir == GST_PAD_SRC || dir == GST_PAD_UNKNOWN) &&
+        (snd_mixer_selem_has_capture_channel (element, 0) ||
+            snd_mixer_selem_has_capture_switch (element) ||
+            snd_mixer_selem_is_capture_mono (element))) {
       while (snd_mixer_selem_has_capture_channel (element, channels))
         channels++;
 
@@ -256,9 +264,10 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
 
     channels = 0;
 
-    if (snd_mixer_selem_has_playback_channel (element, 0) ||
-        snd_mixer_selem_has_playback_switch (element) ||
-        snd_mixer_selem_is_playback_mono (element)) {
+    if ((dir == GST_PAD_SINK || dir == GST_PAD_UNKNOWN) &&
+        (snd_mixer_selem_has_playback_channel (element, 0) ||
+            snd_mixer_selem_has_playback_switch (element) ||
+            snd_mixer_selem_is_playback_mono (element))) {
       while (snd_mixer_selem_has_playback_channel (element, channels))
         channels++;
 
index 7ff037b1c937ac99e51eb35d9fd6ca1e98201d36..172f852ff08abdaef35929ef0fdccbd45d3c3770 100644 (file)
@@ -95,8 +95,8 @@ gst_alsa_sink_get_type (void)
     };
 
     alsa_sink_type =
-        g_type_register_static (GST_TYPE_ALSA, "GstAlsaSink", &alsa_sink_info,
-        0);
+        g_type_register_static (GST_TYPE_ALSA_MIXER, "GstAlsaSink",
+        &alsa_sink_info, 0);
   }
   return alsa_sink_type;
 }
@@ -128,7 +128,7 @@ gst_alsa_sink_class_init (gpointer g_class, gpointer class_data)
   alsa_class = (GstAlsaClass *) klass;
 
   if (sink_parent_class == NULL)
-    sink_parent_class = g_type_class_ref (GST_TYPE_ALSA);
+    sink_parent_class = g_type_class_ref (GST_TYPE_ALSA_MIXER);
 
   alsa_class->stream = SND_PCM_STREAM_PLAYBACK;
   alsa_class->transmit_mmap = gst_alsa_sink_mmap;
@@ -294,7 +294,7 @@ gst_alsa_sink_mmap (GstAlsa * this, snd_pcm_sframes_t * avail)
     goto out;
   }
 
- out:
+out:
   g_free (src);
   return err;
 }
index 06e67260f4e54fcc5b21da4060b26d498d86f76c..c6e2bf3f53ae27d6fabfa08cff2b1033fa78fd67 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef __GST_ALSA_SINK_H__
 #define __GST_ALSA_SINK_H__
 
-#include "gstalsa.h"
+#include "gstalsamixer.h"
 
 G_BEGIN_DECLS
 
@@ -36,7 +36,7 @@ typedef struct _GstAlsaSink GstAlsaSink;
 typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
 
 struct _GstAlsaSink {
-  GstAlsa    parent;
+  GstAlsaMixer parent;
 
   /* array of the data on the channels */
   guint8    *data[GST_ALSA_MAX_TRACKS];      /* pointer into buffer */
@@ -47,7 +47,7 @@ struct _GstAlsaSink {
 };
 
 struct _GstAlsaSinkClass {
-  GstAlsaClass parent_class;
+  GstAlsaMixerClass parent_class;
 };
 
 GType gst_alsa_sink_get_type (void);
index 1913715468bafcf42e38d6122b95e80487f5f6a8..aef4dbd0fa7f4b18632f70350e940567ee812918 100644 (file)
@@ -79,7 +79,8 @@ gst_alsa_src_get_type (void)
     };
 
     alsa_src_type =
-        g_type_register_static (GST_TYPE_ALSA, "GstAlsaSrc", &alsa_src_info, 0);
+        g_type_register_static (GST_TYPE_ALSA_MIXER, "GstAlsaSrc",
+        &alsa_src_info, 0);
   }
   return alsa_src_type;
 }
@@ -109,7 +110,7 @@ gst_alsa_src_class_init (gpointer g_class, gpointer class_data)
   alsa_class = (GstAlsaClass *) klass;
 
   if (src_parent_class == NULL)
-    src_parent_class = g_type_class_ref (GST_TYPE_ALSA);
+    src_parent_class = g_type_class_ref (GST_TYPE_ALSA_MIXER);
 
   alsa_class->stream = SND_PCM_STREAM_CAPTURE;
   alsa_class->transmit_mmap = gst_alsa_src_mmap;
index 01cacba6fef4627f0ebaf825d3751bc5ebe4697c..5b4c2b77f5ff5cfcd8246f1a4a73ee62edd66f5c 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef __GST_ALSA_SRC_H__
 #define __GST_ALSA_SRC_H__
 
-#include "gstalsa.h"
+#include "gstalsamixer.h"
 
 G_BEGIN_DECLS
 
@@ -36,12 +36,12 @@ typedef struct _GstAlsaSrc GstAlsaSrc;
 typedef struct _GstAlsaSrcClass GstAlsaSrcClass;
 
 struct _GstAlsaSrc {
-  GstAlsa        parent;
+  GstAlsaMixer   parent;
   GstBuffer     *buf[GST_ALSA_MAX_TRACKS];
 };
 
 struct _GstAlsaSrcClass {
-  GstAlsaClass parent_class;
+  GstAlsaMixerClass parent_class;
 };
 
 GType gst_alsa_src_get_type (void);