+2006-04-10 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * 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
+
2006-04-10 Tim-Philipp Müller <tim at centricular dot net>
* gst/matroska/ebml-read.c: (gst_ebml_read_sint):
$(GST_LIBS)
libgstossaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-noinst_HEADERS = gstosssink.h \
+noinst_HEADERS = common.h \
+ gstosssink.h \
gstosssrc.h \
gstosshelper.h \
gstossdmabuffer.h \
--- /dev/null
+/* 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
# endif /* HAVE_OSS_INCLUDE_IN_ROOT */
#endif /* HAVE_OSS_INCLUDE_IN_SYS */
+#include "common.h"
#include "gstosssink.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
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;
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)
{
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;
}
}
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");
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;
}
}
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;
}
}
#endif /* HAVE_OSS_INCLUDE_IN_SYS */
#include "gstosssrc.h"
+#include "common.h"
GST_DEBUG_CATEGORY_EXTERN (oss_debug);
#define GST_CAT_DEFAULT oss_debug
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)
{
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;
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;
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;
}
}