diff --git a/ChangeLog b/ChangeLog index ce50411bd9..ab7a05c6b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-05-07 Ronald Bultje + + * 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 * ext/lame/gstlame.c: (gst_lame_chain): diff --git a/ext/alsa/gstalsamixer.c b/ext/alsa/gstalsamixer.c index e2912f25bc..1ababaf39c 100644 --- a/ext/alsa/gstalsamixer.c +++ b/ext/alsa/gstalsamixer.c @@ -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++; diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 7ff037b1c9..172f852ff0 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -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; } diff --git a/ext/alsa/gstalsasink.h b/ext/alsa/gstalsasink.h index 06e67260f4..c6e2bf3f53 100644 --- a/ext/alsa/gstalsasink.h +++ b/ext/alsa/gstalsasink.h @@ -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); diff --git a/ext/alsa/gstalsasrc.c b/ext/alsa/gstalsasrc.c index 1913715468..aef4dbd0fa 100644 --- a/ext/alsa/gstalsasrc.c +++ b/ext/alsa/gstalsasrc.c @@ -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; diff --git a/ext/alsa/gstalsasrc.h b/ext/alsa/gstalsasrc.h index 01cacba6fe..5b4c2b77f5 100644 --- a/ext/alsa/gstalsasrc.h +++ b/ext/alsa/gstalsasrc.h @@ -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);