improve _open error messages

Original commit message from CVS:
improve _open error messages
This commit is contained in:
Thomas Vander Stichele 2004-06-01 15:14:09 +00:00
parent 7fc0c37a08
commit 4c039c6dc7
2 changed files with 35 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2004-06-01 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* ext/alsa/gstalsa.c: (gst_alsa_open_audio):
improve error messages on open
2004-06-01 Thomas Vander Stichele <thomas at apestaart dot org> 2004-06-01 Thomas Vander Stichele <thomas at apestaart dot org>
* sys/v4l/v4l-overlay_calls.c: (gst_v4l_set_overlay): * sys/v4l/v4l-overlay_calls.c: (gst_v4l_set_overlay):

View file

@ -1174,6 +1174,7 @@ static gboolean
gst_alsa_open_audio (GstAlsa * this) gst_alsa_open_audio (GstAlsa * this)
{ {
snd_pcm_info_t *info; snd_pcm_info_t *info;
int ret;
g_assert (this != NULL); g_assert (this != NULL);
g_assert (this->handle == NULL); g_assert (this->handle == NULL);
@ -1191,11 +1192,34 @@ gst_alsa_open_audio (GstAlsa * this)
"error opening log output: %s"); "error opening log output: %s");
#endif #endif
if (snd_pcm_open (&this->handle, this->device, if ((ret = snd_pcm_open (&this->handle, this->device,
GST_ALSA_GET_CLASS (this)->stream, SND_PCM_NONBLOCK) < 0) { GST_ALSA_GET_CLASS (this)->stream, SND_PCM_NONBLOCK)) < 0) {
/* ALSA inverts standard errno.h error codes */
switch (-ret) {
case EBUSY:
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY, GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY,
(_("Alsa device \"%s\" is already in use by another program."), (_("ALSA device \"%s\" is already in use by another program."),
this->device), (NULL)); this->device), (NULL));
break;
case EACCES:
case ETXTBSY:
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, OPEN_READ_WRITE,
(_("Could not access ALSA device \"%s\", check its permissions."),
this->device), GST_ERROR_SYSTEM);
break;
case ENXIO:
case ENODEV:
case ENOENT:
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY,
(_("ALSA device \"%s\" does not exist."), this->device), (NULL));
break;
default:
GST_ELEMENT_ERROR (GST_ELEMENT (this), RESOURCE, BUSY,
(_("ALSA device \"%s\" had an error."),
this->device), ("ALSA error %d: %s", ret, snd_strerror (ret)));
break;
}
return FALSE; return FALSE;
} }