mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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.
This commit is contained in:
parent
5d568b25ce
commit
94d9342dc9
3 changed files with 41 additions and 18 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-05-08 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
|
* 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 <otte@gnome.org>
|
2004-05-09 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
* gst/wavparse/gstwavparse.c: (gst_wavparse_destroy_sourcepad),
|
* gst/wavparse/gstwavparse.c: (gst_wavparse_destroy_sourcepad),
|
||||||
|
|
|
@ -319,6 +319,10 @@ device_list (snd_pcm_stream_t stream, GstAlsaClass * klass)
|
||||||
int card, err, dev;
|
int card, err, dev;
|
||||||
snd_ctl_card_info_t *info;
|
snd_ctl_card_info_t *info;
|
||||||
snd_pcm_info_t *pcminfo;
|
snd_pcm_info_t *pcminfo;
|
||||||
|
gboolean mixer = (stream == -1);
|
||||||
|
|
||||||
|
if (stream == -1)
|
||||||
|
stream = 0;
|
||||||
|
|
||||||
snd_ctl_card_info_alloca (&info);
|
snd_ctl_card_info_alloca (&info);
|
||||||
snd_pcm_info_alloca (&pcminfo);
|
snd_pcm_info_alloca (&pcminfo);
|
||||||
|
@ -340,24 +344,27 @@ device_list (snd_pcm_stream_t stream, GstAlsaClass * klass)
|
||||||
goto next_card;
|
goto next_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = -1;
|
if (mixer) {
|
||||||
while (1) {
|
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)
|
gst_device = g_strdup_printf ("hw:%d,%d", card, dev);
|
||||||
break;
|
klass->devices = g_list_append (klass->devices, gst_device);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
snd_ctl_close (handle);
|
snd_ctl_close (handle);
|
||||||
next_card:
|
next_card:
|
||||||
|
@ -377,7 +384,7 @@ gst_alsa_class_probe_devices (GstAlsaClass * klass, gboolean check)
|
||||||
* do function-wise look-ups. */
|
* do function-wise look-ups. */
|
||||||
|
|
||||||
if (!init && !check) {
|
if (!init && !check) {
|
||||||
snd_pcm_stream_t mode = 0;
|
snd_pcm_stream_t mode = -1;
|
||||||
const GList *templates;
|
const GList *templates;
|
||||||
|
|
||||||
/* we assume one pad template at max [zero=mixer] */
|
/* we assume one pad template at max [zero=mixer] */
|
||||||
|
|
|
@ -132,6 +132,7 @@ gst_alsa_mixer_open (GstAlsaMixer * mixer)
|
||||||
{
|
{
|
||||||
gint err, device;
|
gint err, device;
|
||||||
GstAlsa *alsa = GST_ALSA (mixer);
|
GstAlsa *alsa = GST_ALSA (mixer);
|
||||||
|
gchar *nocomma;
|
||||||
|
|
||||||
mixer->mixer_handle = (snd_mixer_t *) - 1;
|
mixer->mixer_handle = (snd_mixer_t *) - 1;
|
||||||
|
|
||||||
|
@ -143,9 +144,13 @@ gst_alsa_mixer_open (GstAlsaMixer * mixer)
|
||||||
return FALSE;
|
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),
|
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;
|
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
|
/* I don't know how to get a device name from a mixer handle. So on
|
||||||
* to the ugly hacks here, then... */
|
* to the ugly hacks here, then... */
|
||||||
if (sscanf (alsa->device, "hw:%d", &device) == 1) {
|
if (sscanf (nocomma, "hw:%d", &device) == 1) {
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
if (!snd_card_get_name (device, &name))
|
if (!snd_card_get_name (device, &name))
|
||||||
alsa->cardname = name;
|
alsa->cardname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (nocomma);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
snd_mixer_close (mixer->mixer_handle);
|
snd_mixer_close (mixer->mixer_handle);
|
||||||
mixer->mixer_handle = (snd_mixer_t *) - 1;
|
mixer->mixer_handle = (snd_mixer_t *) - 1;
|
||||||
|
g_free (nocomma);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue