+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>
* gst/wavparse/gstwavparse.c: (gst_wavparse_destroy_sourcepad),
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);
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:
* 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] */
{
gint err, device;
GstAlsa *alsa = GST_ALSA (mixer);
+ gchar *nocomma;
mixer->mixer_handle = (snd_mixer_t *) - 1;
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;
}
/* 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;
}