ext/alsa/: Fix names, fix loop.

Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new):
* ext/alsa/gstalsamixertrack.h:
Fix names, fix loop.
This commit is contained in:
Ronald S. Bultje 2004-10-25 13:51:41 +00:00
parent 071d574ca3
commit a5ba798652
4 changed files with 40 additions and 10 deletions

View file

@ -1,3 +1,10 @@
2004-10-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new):
* ext/alsa/gstalsamixertrack.h:
Fix names, fix loop.
2004-10-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net> 2004-10-25 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/speex/gstspeexdec.c: (gst_speex_dec_init), * ext/speex/gstspeexdec.c: (gst_speex_dec_init),

View file

@ -264,26 +264,45 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
/* build track list */ /* build track list */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
gint channels = 0; GList *item;
gchar *name;
gint channels = 0, samename = 0;
gint flags = GST_MIXER_TRACK_OUTPUT; gint flags = GST_MIXER_TRACK_OUTPUT;
gboolean got_it = FALSE; gboolean got_it = FALSE;
if (snd_mixer_selem_has_capture_switch (element)) { if (snd_mixer_selem_has_capture_switch (element)) {
if (dir != GST_PAD_SRC && dir != GST_PAD_UNKNOWN) if (dir != GST_PAD_SRC && dir != GST_PAD_UNKNOWN)
continue; goto next;
flags = GST_MIXER_TRACK_INPUT; flags = GST_MIXER_TRACK_INPUT;
} else { } else {
if (dir != GST_PAD_SINK && dir != GST_PAD_UNKNOWN) if (dir != GST_PAD_SINK && dir != GST_PAD_UNKNOWN)
continue; goto next;
} }
/* prevent dup names */
for (item = mixer->tracklist; item != NULL; item = item->next) {
if (!strcmp (snd_mixer_selem_get_name (element),
snd_mixer_selem_get_name (GST_ALSA_MIXER_TRACK (item->data)->
element)))
samename++;
}
if (samename == 0)
name = g_strdup (snd_mixer_selem_get_name (element));
else
name = g_strdup_printf ("%s %d", snd_mixer_selem_get_name (element),
samename + 1);
if (snd_mixer_selem_has_capture_volume (element)) { if (snd_mixer_selem_has_capture_volume (element)) {
while (snd_mixer_selem_has_capture_channel (element, channels)) while (snd_mixer_selem_has_capture_channel (element, channels))
channels++; channels++;
track = gst_alsa_mixer_track_new (element, i, channels, track = gst_alsa_mixer_track_new (element, name,
flags, GST_ALSA_MIXER_TRACK_CAPTURE); i, channels, flags, GST_ALSA_MIXER_TRACK_CAPTURE);
mixer->tracklist = g_list_append (mixer->tracklist, track); mixer->tracklist = g_list_append (mixer->tracklist, track);
got_it = TRUE; got_it = TRUE;
/* there might be another volume slider; make that playback */
flags &= ~GST_MIXER_TRACK_INPUT;
flags |= GST_MIXER_TRACK_OUTPUT;
} }
if (snd_mixer_selem_has_playback_volume (element)) { if (snd_mixer_selem_has_playback_volume (element)) {
@ -293,8 +312,8 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
first = FALSE; first = FALSE;
flags |= GST_MIXER_TRACK_MASTER; flags |= GST_MIXER_TRACK_MASTER;
} }
track = gst_alsa_mixer_track_new (element, i, channels, track = gst_alsa_mixer_track_new (element, name,
flags, GST_ALSA_MIXER_TRACK_PLAYBACK); i, channels, flags, GST_ALSA_MIXER_TRACK_PLAYBACK);
mixer->tracklist = g_list_append (mixer->tracklist, track); mixer->tracklist = g_list_append (mixer->tracklist, track);
got_it = TRUE; got_it = TRUE;
} }
@ -309,12 +328,14 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer)
if (flags == GST_MIXER_TRACK_OUTPUT && if (flags == GST_MIXER_TRACK_OUTPUT &&
snd_mixer_selem_has_playback_switch (element)) { snd_mixer_selem_has_playback_switch (element)) {
/* simple mute switch */ /* simple mute switch */
track = gst_alsa_mixer_track_new (element, i, 0, track = gst_alsa_mixer_track_new (element, name,
flags, GST_ALSA_MIXER_TRACK_PLAYBACK); i, 0, flags, GST_ALSA_MIXER_TRACK_PLAYBACK);
mixer->tracklist = g_list_append (mixer->tracklist, track); mixer->tracklist = g_list_append (mixer->tracklist, track);
} }
} }
g_free (name);
next:
element = snd_mixer_elem_next (element); element = snd_mixer_elem_next (element);
} }
} }

View file

@ -69,6 +69,7 @@ gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track)
GstMixerTrack * GstMixerTrack *
gst_alsa_mixer_track_new (snd_mixer_elem_t * element, gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
const gchar * label,
gint track_num, gint channels, gint flags, gint alsa_flags) gint track_num, gint channels, gint flags, gint alsa_flags)
{ {
gint i; gint i;
@ -78,7 +79,7 @@ gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
GstAlsaMixerTrack *alsa_track = (GstAlsaMixerTrack *) track; GstAlsaMixerTrack *alsa_track = (GstAlsaMixerTrack *) track;
/* set basic information */ /* set basic information */
track->label = g_strdup_printf ("%s", snd_mixer_selem_get_name (element)); track->label = g_strdup (label);
track->num_channels = channels; track->num_channels = channels;
track->flags = flags; track->flags = flags;
alsa_track->element = element; alsa_track->element = element;

View file

@ -51,6 +51,7 @@ struct _GstAlsaMixerTrackClass {
GType gst_alsa_mixer_track_get_type (void); GType gst_alsa_mixer_track_get_type (void);
GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element, GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
const gchar * name,
gint track_num, gint track_num,
gint channels, gint channels,
gint flags, gint flags,