From: Ronald S. Bultje Date: Sun, 9 May 2004 00:30:06 +0000 (+0000) Subject: ext/alsa/: Fix alsa oddness in mixer after the combination of using mixer in source... X-Git-Tag: 1.19.3~511^2~14278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94d9342dc94a51fb8f84422f2d45b7fb38307b94;p=platform%2Fupstream%2Fgstreamer.git ext/alsa/: Fix alsa oddness in mixer after the combination of using mixer in source/sink elements and using hw:x,y in... Original commit message from CVS: * ext/alsa/gstalsa.c: (device_list), (gst_alsa_class_probe_devices): * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_open): Fix alsa oddness in mixer after the combination of using mixer in source/sink elements and using hw:x,y instead of just hw:x. --- diff --git a/ChangeLog b/ChangeLog index f320c79..821391b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-05-08 Ronald Bultje + + * ext/alsa/gstalsa.c: (device_list), + (gst_alsa_class_probe_devices): + * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_open): + Fix alsa oddness in mixer after the combination of using mixer + in source/sink elements and using hw:x,y instead of just hw:x. + 2004-05-09 Benjamin Otte * gst/wavparse/gstwavparse.c: (gst_wavparse_destroy_sourcepad), diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index 66db94a..108ad0c 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -319,6 +319,10 @@ device_list (snd_pcm_stream_t stream, GstAlsaClass * klass) int card, err, dev; snd_ctl_card_info_t *info; snd_pcm_info_t *pcminfo; + gboolean mixer = (stream == -1); + + if (stream == -1) + stream = 0; snd_ctl_card_info_alloca (&info); snd_pcm_info_alloca (&pcminfo); @@ -340,24 +344,27 @@ device_list (snd_pcm_stream_t stream, GstAlsaClass * klass) goto next_card; } - dev = -1; - while (1) { + if (mixer) { + klass->devices = g_list_append (klass->devices, g_strdup (name)); + } else { + dev = -1; + while (1) { + gchar *gst_device; - gchar *gst_device; + snd_ctl_pcm_next_device (handle, &dev); - snd_ctl_pcm_next_device (handle, &dev); + if (dev < 0) + break; + snd_pcm_info_set_device (pcminfo, dev); + snd_pcm_info_set_subdevice (pcminfo, 0); + snd_pcm_info_set_stream (pcminfo, stream); + if ((err = snd_ctl_pcm_info (handle, pcminfo)) < 0) { + continue; + } - if (dev < 0) - break; - snd_pcm_info_set_device (pcminfo, dev); - snd_pcm_info_set_subdevice (pcminfo, 0); - snd_pcm_info_set_stream (pcminfo, stream); - if ((err = snd_ctl_pcm_info (handle, pcminfo)) < 0) { - continue; + gst_device = g_strdup_printf ("hw:%d,%d", card, dev); + klass->devices = g_list_append (klass->devices, gst_device); } - - gst_device = g_strdup_printf ("hw:%d,%d", card, dev); - klass->devices = g_list_append (klass->devices, gst_device); } snd_ctl_close (handle); next_card: @@ -377,7 +384,7 @@ gst_alsa_class_probe_devices (GstAlsaClass * klass, gboolean check) * do function-wise look-ups. */ if (!init && !check) { - snd_pcm_stream_t mode = 0; + snd_pcm_stream_t mode = -1; const GList *templates; /* we assume one pad template at max [zero=mixer] */ diff --git a/ext/alsa/gstalsamixer.c b/ext/alsa/gstalsamixer.c index 1ababaf..b18a728 100644 --- a/ext/alsa/gstalsamixer.c +++ b/ext/alsa/gstalsamixer.c @@ -132,6 +132,7 @@ gst_alsa_mixer_open (GstAlsaMixer * mixer) { gint err, device; GstAlsa *alsa = GST_ALSA (mixer); + gchar *nocomma; mixer->mixer_handle = (snd_mixer_t *) - 1; @@ -143,9 +144,13 @@ gst_alsa_mixer_open (GstAlsaMixer * mixer) return FALSE; } - if ((err = snd_mixer_attach (mixer->mixer_handle, alsa->device)) < 0) { + nocomma = g_strdup (alsa->device); + if (strchr (nocomma, ',')) + strchr (nocomma, ',')[0] = '\0'; + + if ((err = snd_mixer_attach (mixer->mixer_handle, nocomma)) < 0) { GST_ERROR_OBJECT (GST_OBJECT (mixer), - "Cannot attach mixer to sound device `%s'.", alsa->device); + "Cannot attach mixer to sound device `%s'.", nocomma); goto error; } @@ -161,18 +166,21 @@ gst_alsa_mixer_open (GstAlsaMixer * mixer) /* I don't know how to get a device name from a mixer handle. So on * to the ugly hacks here, then... */ - if (sscanf (alsa->device, "hw:%d", &device) == 1) { + if (sscanf (nocomma, "hw:%d", &device) == 1) { gchar *name; if (!snd_card_get_name (device, &name)) alsa->cardname = name; } + g_free (nocomma); + return TRUE; error: snd_mixer_close (mixer->mixer_handle); mixer->mixer_handle = (snd_mixer_t *) - 1; + g_free (nocomma); return FALSE; }