diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2006-04-10 19:55:31 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2006-04-10 19:55:31 +0000 |
commit | 4ebda6356b3d0d5391410ac5d593dca7d8a4885b (patch) | |
tree | 7fc2e2b4ee5ae58d015237a8bbe181ce89ad3afc /sys/oss/gstosssink.c | |
parent | 4d598ca20146707158392755903950ce07ca411f (diff) |
sys/oss/: - the user-visible error strings were in the wrong category
Original commit message from CVS:
* sys/oss/Makefile.am:
* sys/oss/common.h:
* sys/oss/gstosssink.c: (gst_oss_sink_init), (gst_oss_sink_open),
(gst_oss_sink_prepare), (gst_oss_sink_unprepare):
* sys/oss/gstosssrc.c: (gst_oss_src_prepare),
(gst_oss_src_unprepare):
- the user-visible error strings were in the wrong category
- and the messages were not marked for translation
- which is actually a good thing, because they were exactly
the kind of message you would never want anyone to see
- the macros were using variables that didn't exist in the macro
arguments
- and they were obviously copied from each other and then modified
- so a common header makes sense
Diffstat (limited to 'sys/oss/gstosssink.c')
-rw-r--r-- | sys/oss/gstosssink.c | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c index c1bc5480..47994119 100644 --- a/sys/oss/gstosssink.c +++ b/sys/oss/gstosssink.c @@ -43,6 +43,7 @@ # endif /* HAVE_OSS_INCLUDE_IN_ROOT */ #endif /* HAVE_OSS_INCLUDE_IN_SYS */ +#include "common.h" #include "gstosssink.h" GST_DEBUG_CATEGORY_EXTERN (oss_debug); @@ -203,7 +204,7 @@ gst_oss_sink_class_init (GstOssSinkClass * klass) static void gst_oss_sink_init (GstOssSink * osssink) { - GST_DEBUG ("initializing osssink"); + GST_DEBUG_OBJECT (osssink, "initializing osssink"); osssink->device = g_strdup (DEFAULT_DEVICE); osssink->fd = -1; @@ -298,30 +299,6 @@ ilog2 (gint x) return (x & 0x0000003f) - 1; } -#define SET_PARAM(_oss, _name, _val, _detail) \ -G_STMT_START { \ - int _tmp = _val; \ - if (ioctl(_oss->fd, _name, &_tmp) == -1) { \ - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_WRITE, \ - ("Unable to set param " _detail ": %s", \ - g_strerror (errno)), \ - (NULL)); \ - return FALSE; \ - } \ - GST_DEBUG(_detail " %d", _tmp); \ -} G_STMT_END - -#define GET_PARAM(_oss, _name, _val, _detail) \ -G_STMT_START { \ - if (ioctl(oss->fd, _name, _val) == -1) { \ - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_WRITE, \ - ("Unable to get param " _detail ": %s", \ - g_strerror (errno)), \ - (NULL)); \ - return FALSE; \ - } \ -} G_STMT_END - static gint gst_oss_sink_get_format (GstBufferFormat fmt) { @@ -377,16 +354,26 @@ gst_oss_sink_open (GstAudioSink * asink) mode |= O_NONBLOCK; oss->fd = open (oss->device, mode, 0); - if (oss->fd == -1) - goto open_failed; + if (oss->fd == -1) { + switch (errno) { + case EBUSY: + goto busy; + default: + goto open_failed; + } + } return TRUE; +busy: + { + GST_ELEMENT_ERROR (oss, RESOURCE, BUSY, (NULL), (NULL)); + return FALSE; + } + open_failed: { - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_WRITE, - ("Unable to open device %s for writing: %s", - oss->device, g_strerror (errno)), (NULL)); + GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_WRITE, (NULL), GST_ERROR_SYSTEM); return FALSE; } } @@ -429,8 +416,8 @@ gst_oss_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec) tmp = ilog2 (spec->segsize); tmp = ((spec->segtotal & 0x7fff) << 16) | tmp; - GST_DEBUG ("set segsize: %d, segtotal: %d, value: %08x", spec->segsize, - spec->segtotal, tmp); + GST_DEBUG_OBJECT (oss, "set segsize: %d, segtotal: %d, value: %08x", + spec->segsize, spec->segtotal, tmp); SET_PARAM (oss, SNDCTL_DSP_SETFRAGMENT, tmp, "SETFRAGMENT"); GET_PARAM (oss, SNDCTL_DSP_GETOSPACE, &info, "GETOSPACE"); @@ -442,28 +429,28 @@ gst_oss_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec) oss->bytes_per_sample = (spec->width / 8) * spec->channels; memset (spec->silence_sample, 0, spec->bytes_per_sample); - GST_DEBUG ("got segsize: %d, segtotal: %d, value: %08x", spec->segsize, - spec->segtotal, tmp); + GST_DEBUG_OBJECT (oss, "got segsize: %d, segtotal: %d, value: %08x", + spec->segsize, spec->segtotal, tmp); return TRUE; non_block: { - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ, + GST_ELEMENT_ERROR (oss, RESOURCE, SETTINGS, (NULL), ("Unable to set device %s in non blocking mode: %s", - oss->device, g_strerror (errno)), (NULL)); + oss->device, g_strerror (errno))); return FALSE; } wrong_format: { - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ, - ("Unable to get format %d", spec->format), (NULL)); + GST_ELEMENT_ERROR (oss, RESOURCE, SETTINGS, (NULL), + ("Unable to get format %d", spec->format)); return FALSE; } dodgy_width: { - GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ, - ("unexpected width %d", spec->width), (NULL)); + GST_ELEMENT_ERROR (oss, RESOURCE, SETTINGS, (NULL), + ("unexpected width %d", spec->width)); return FALSE; } } @@ -483,12 +470,12 @@ gst_oss_sink_unprepare (GstAudioSink * asink) couldnt_close: { - GST_DEBUG ("Could not close the audio device"); + GST_DEBUG_OBJECT (asink, "Could not close the audio device"); return FALSE; } couldnt_reopen: { - GST_DEBUG ("Could not reopen the audio device"); + GST_DEBUG_OBJECT (asink, "Could not reopen the audio device"); return FALSE; } } |