ext/alsa/: Avoid setting and using a NULL device name.

Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsasink_set_property),
(gst_alsasink_open):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_set_property),
(gst_alsasrc_open):
Avoid setting and using a NULL device name.
Print more info when we fail to open a device.
This commit is contained in:
Wim Taymans 2006-08-16 11:38:52 +00:00
parent 6aeb8149dd
commit e71487073c
3 changed files with 27 additions and 8 deletions

View file

@ -1,3 +1,12 @@
2006-08-16 Wim Taymans <wim@fluendo.com>
* ext/alsa/gstalsasink.c: (gst_alsasink_set_property),
(gst_alsasink_open):
* ext/alsa/gstalsasrc.c: (gst_alsasrc_set_property),
(gst_alsasrc_open):
Avoid setting and using a NULL device name.
Print more info when we fail to open a device.
2006-08-16 Tim-Philipp Müller <tim at centricular dot net> 2006-08-16 Tim-Philipp Müller <tim at centricular dot net>
* docs/libs/gst-plugins-base-libs-sections.txt: * docs/libs/gst-plugins-base-libs-sections.txt:

View file

@ -227,9 +227,12 @@ gst_alsasink_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_DEVICE: case PROP_DEVICE:
if (sink->device) g_free (sink->device);
g_free (sink->device); sink->device = g_value_dup_string (value);
sink->device = g_strdup (g_value_get_string (value)); /* setting NULL restores the default device */
if (sink->device == NULL) {
sink->device = g_strdup (DEFAULT_DEVICE);
}
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -629,10 +632,12 @@ gst_alsasink_open (GstAudioSink * asink)
open_error: open_error:
{ {
if (err == -EBUSY) { if (err == -EBUSY) {
GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, (NULL), ("Device is busy")); GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, (NULL), ("Device '%s' is busy",
alsa->device));
} else { } else {
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE, GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE,
(NULL), ("Playback open error: %s", snd_strerror (err))); (NULL), ("Playback open error on device '%s': %s", alsa->device,
snd_strerror (err)));
} }
return FALSE; return FALSE;
} }

View file

@ -242,6 +242,9 @@ gst_alsasrc_set_property (GObject * object, guint prop_id,
case PROP_DEVICE: case PROP_DEVICE:
g_free (src->device); g_free (src->device);
src->device = g_value_dup_string (value); src->device = g_value_dup_string (value);
if (src->device == NULL) {
src->device = g_strdup (DEFAULT_PROP_DEVICE);
}
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -601,10 +604,12 @@ gst_alsasrc_open (GstAudioSrc * asrc)
open_error: open_error:
{ {
if (err == -EBUSY) { if (err == -EBUSY) {
GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, (NULL), (NULL)); GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, (NULL), ("Device '%s' is busy",
alsa->device));
} else { } else {
GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE,
(NULL), ("Recording open error: %s", snd_strerror (err))); (NULL), ("Recording open error on device '%s': %s", alsa->device,
snd_strerror (err)));
} }
return FALSE; return FALSE;
} }