summaryrefslogtreecommitdiffstats
path: root/sys/oss
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2006-04-10 19:55:31 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2006-04-10 19:55:31 +0000
commit4ebda6356b3d0d5391410ac5d593dca7d8a4885b (patch)
tree7fc2e2b4ee5ae58d015237a8bbe181ce89ad3afc /sys/oss
parent4d598ca20146707158392755903950ce07ca411f (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')
-rw-r--r--sys/oss/Makefile.am3
-rw-r--r--sys/oss/common.h43
-rw-r--r--sys/oss/gstosssink.c71
-rw-r--r--sys/oss/gstosssrc.c52
4 files changed, 88 insertions, 81 deletions
diff --git a/sys/oss/Makefile.am b/sys/oss/Makefile.am
index f7dc0aa5..079444be 100644
--- a/sys/oss/Makefile.am
+++ b/sys/oss/Makefile.am
@@ -18,7 +18,8 @@ libgstossaudio_la_LIBADD = \
$(GST_LIBS)
libgstossaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-noinst_HEADERS = gstosssink.h \
+noinst_HEADERS = common.h \
+ gstosssink.h \
gstosssrc.h \
gstosshelper.h \
gstossdmabuffer.h \
diff --git a/sys/oss/common.h b/sys/oss/common.h
new file mode 100644
index 00000000..2445c3d8
--- /dev/null
+++ b/sys/oss/common.h
@@ -0,0 +1,43 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2000,2005 Wim Taymans <wim@fluendo.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#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, SETTINGS,\
+ (NULL), \
+ ("Unable to set param " _detail ": %s", \
+ g_strerror (errno))); \
+ return FALSE; \
+ } \
+ GST_DEBUG_OBJECT(_oss, _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, SETTINGS, \
+ (NULL), \
+ ("Unable to get param " _detail ": %s", \
+ g_strerror (errno))); \
+ return FALSE; \
+ } \
+} G_STMT_END
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;
}
}
diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c
index 4ad6a63e..7ff4c935 100644
--- a/sys/oss/gstosssrc.c
+++ b/sys/oss/gstosssrc.c
@@ -45,6 +45,7 @@
#endif /* HAVE_OSS_INCLUDE_IN_SYS */
#include "gstosssrc.h"
+#include "common.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
#define GST_CAT_DEFAULT oss_debug
@@ -248,31 +249,6 @@ ilog2 (gint x)
return (x & 0x0000003f) - 1;
}
-#define SET_PARAM(_oss, _name, _val) \
-G_STMT_START { \
- int _tmp = _val; \
- if (ioctl(_oss->fd, _name, &_tmp) == -1) { \
- GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ, \
- ("Unable to set param "G_STRINGIFY (_name)": %s", \
- g_strerror (errno)), \
- (NULL)); \
- return FALSE; \
- } \
- GST_DEBUG_OBJECT (_oss, G_STRINGIFY (_name)" %d", _tmp); \
-} G_STMT_END
-
-#define GET_PARAM(_oss, _name, _val) \
-G_STMT_START { \
- if (ioctl(oss->fd, _name, _val) == -1) { \
- GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ, \
- ("Unable to get param "G_STRINGIFY (_name)": %s", \
- g_strerror (errno)), \
- (NULL)); \
- return FALSE; \
- } \
- GST_DEBUG_OBJECT (_oss, G_STRINGIFY (_name)" %d", _val); \
-} G_STMT_END
-
static gint
gst_oss_src_get_format (GstBufferFormat fmt)
{
@@ -388,20 +364,20 @@ gst_oss_src_prepare (GstAudioSrc * asrc, 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);
+ SET_PARAM (oss, SNDCTL_DSP_SETFRAGMENT, tmp, "SETFRAGMENT");
- SET_PARAM (oss, SNDCTL_DSP_RESET, 0);
+ SET_PARAM (oss, SNDCTL_DSP_RESET, 0, "RESET");
- SET_PARAM (oss, SNDCTL_DSP_SETFMT, fmt);
+ SET_PARAM (oss, SNDCTL_DSP_SETFMT, fmt, "SETFMT");
if (spec->channels == 2)
- SET_PARAM (oss, SNDCTL_DSP_STEREO, 1);
- SET_PARAM (oss, SNDCTL_DSP_CHANNELS, spec->channels);
- SET_PARAM (oss, SNDCTL_DSP_SPEED, spec->rate);
+ SET_PARAM (oss, SNDCTL_DSP_STEREO, 1, "STEREO");
+ SET_PARAM (oss, SNDCTL_DSP_CHANNELS, spec->channels, "CHANNELS");
+ SET_PARAM (oss, SNDCTL_DSP_SPEED, spec->rate, "SPEED");
- GET_PARAM (oss, SNDCTL_DSP_GETISPACE, &info);
+ GET_PARAM (oss, SNDCTL_DSP_GETISPACE, &info, "GETISPACE");
spec->segsize = info.fragsize;
spec->segtotal = info.fragstotal;
@@ -413,8 +389,8 @@ gst_oss_src_prepare (GstAudioSrc * asrc, 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;
@@ -454,12 +430,12 @@ gst_oss_src_unprepare (GstAudioSrc * asrc)
couldnt_close:
{
- GST_DEBUG ("Could not close the audio device");
+ GST_DEBUG_OBJECT (asrc, "Could not close the audio device");
return FALSE;
}
couldnt_reopen:
{
- GST_DEBUG ("Could not reopen the audio device");
+ GST_DEBUG_OBJECT (asrc, "Could not reopen the audio device");
return FALSE;
}
}