From afb7b74873f5c1d69e6891652613762a171bb79b Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 29 Aug 2004 19:37:38 +0000 Subject: [PATCH] ext/alsa/: Add switches (simple boolean on/off). Original commit message from CVS: * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list): * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new): Add switches (simple boolean on/off). --- ChangeLog | 6 ++++++ ext/alsa/gstalsamixer.c | 18 ++++++++++++++---- ext/alsa/gstalsamixertrack.c | 10 ++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 154f687944..9927e731f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-08-29 Ronald S. Bultje > + + * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list): + * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new): + Add switches (simple boolean on/off). + 2004-08-27 David Schleef * sys/glsink/glimagesink.c: (gst_glimagesink_ximage_put), diff --git a/ext/alsa/gstalsamixer.c b/ext/alsa/gstalsamixer.c index d8867d61e3..fb664d5131 100644 --- a/ext/alsa/gstalsamixer.c +++ b/ext/alsa/gstalsamixer.c @@ -266,6 +266,7 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) for (i = 0; i < count; i++) { gint channels = 0; gint flags = GST_MIXER_TRACK_OUTPUT; + gboolean got_it = FALSE; if (snd_mixer_selem_has_capture_switch (element)) { if (dir != GST_PAD_SRC && dir != GST_PAD_UNKNOWN) @@ -279,13 +280,10 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) if (snd_mixer_selem_has_capture_volume (element)) { while (snd_mixer_selem_has_capture_channel (element, channels)) channels++; - if (first) { - first = FALSE; - flags |= GST_MIXER_TRACK_MASTER; - } track = gst_alsa_mixer_track_new (element, i, channels, flags, GST_ALSA_MIXER_TRACK_CAPTURE); mixer->tracklist = g_list_append (mixer->tracklist, track); + got_it = TRUE; } if (snd_mixer_selem_has_playback_volume (element)) { @@ -298,11 +296,23 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) track = gst_alsa_mixer_track_new (element, i, channels, flags, GST_ALSA_MIXER_TRACK_PLAYBACK); mixer->tracklist = g_list_append (mixer->tracklist, track); + got_it = TRUE; } if (snd_mixer_selem_is_enumerated (element)) { opts = gst_alsa_mixer_options_new (element, i); mixer->tracklist = g_list_append (mixer->tracklist, opts); + got_it = TRUE; + } + + if (!got_it) { + if (flags == GST_MIXER_TRACK_OUTPUT && + snd_mixer_selem_has_playback_switch (element)) { + /* simple mute switch */ + track = gst_alsa_mixer_track_new (element, i, 0, + flags, GST_ALSA_MIXER_TRACK_PLAYBACK); + mixer->tracklist = g_list_append (mixer->tracklist, track); + } } element = snd_mixer_elem_next (element); diff --git a/ext/alsa/gstalsamixertrack.c b/ext/alsa/gstalsamixertrack.c index c6a8f14117..7db05016d5 100644 --- a/ext/alsa/gstalsamixertrack.c +++ b/ext/alsa/gstalsamixertrack.c @@ -86,10 +86,12 @@ gst_alsa_mixer_track_new (snd_mixer_elem_t * element, alsa_track->track_num = track_num; /* set volume information */ - if (alsa_flags & GST_ALSA_MIXER_TRACK_PLAYBACK) { - snd_mixer_selem_get_playback_volume_range (element, &min, &max); - } else if (alsa_flags & GST_ALSA_MIXER_TRACK_CAPTURE) { - snd_mixer_selem_get_capture_volume_range (element, &min, &max); + if (channels) { + if (alsa_flags & GST_ALSA_MIXER_TRACK_PLAYBACK) { + snd_mixer_selem_get_playback_volume_range (element, &min, &max); + } else if (alsa_flags & GST_ALSA_MIXER_TRACK_CAPTURE) { + snd_mixer_selem_get_capture_volume_range (element, &min, &max); + } } track->min_volume = (gint) min; track->max_volume = (gint) max;