summaryrefslogtreecommitdiffstats
path: root/sys/oss
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2005-08-08 16:43:47 +0000
committerAndy Wingo <wingo@pobox.com>2005-08-08 16:43:47 +0000
commit568194ce35e3afe61e2e8aa51a9477b2891e5765 (patch)
tree4b925cffef7a71d9e04af9f6dab3e82ff4ff3fe9 /sys/oss
parentea90cab3ed09035c9491c4dd4172eb18a5be9d03 (diff)
sys/oss/gstosssink.c (gst_oss_sink_open, gst_oss_sink_close)
Original commit message from CVS: 2005-08-08 Andy Wingo <wingo@pobox.com> * sys/oss/gstosssink.c (gst_oss_sink_open, gst_oss_sink_close) (gst_oss_sink_prepare, gst_oss_sink_unprepare): Update for newer audiosink api. * ext/raw1394/gstdv1394src.c (gst_dv1394src_get_property) (gst_dv1394src_set_property): Style. All about the style. * ext/esd/esdsink.c (gst_esdsink_getcaps): Return specific caps only if in READY or higher (i.e., if _open() has been called.) (gst_esdsink_open, gst_esdsink_close, gst_esdsink_prepare) (gst_esdsink_unprepare): Update for audiosink changes. (gst_esdsink_change_state): Die!
Diffstat (limited to 'sys/oss')
-rw-r--r--sys/oss/gstosssink.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/sys/oss/gstosssink.c b/sys/oss/gstosssink.c
index 2ad6d619..e26a8e79 100644
--- a/sys/oss/gstosssink.c
+++ b/sys/oss/gstosssink.c
@@ -48,9 +48,11 @@ static void gst_oss_sink_dispose (GObject * object);
static GstCaps *gst_oss_sink_getcaps (GstBaseSink * bsink);
-static gboolean gst_oss_sink_open (GstAudioSink * asink,
- GstRingBufferSpec * spec);
+static gboolean gst_oss_sink_open (GstAudioSink * asink);
static gboolean gst_oss_sink_close (GstAudioSink * asink);
+static gboolean gst_oss_sink_prepare (GstAudioSink * asink,
+ GstRingBufferSpec * spec);
+static gboolean gst_oss_sink_unprepare (GstAudioSink * asink);
static guint gst_oss_sink_write (GstAudioSink * asink, gpointer data,
guint length);
static guint gst_oss_sink_delay (GstAudioSink * asink);
@@ -150,6 +152,8 @@ gst_oss_sink_class_init (GstOssSinkClass * klass)
gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_oss_sink_open);
gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_oss_sink_close);
+ gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_oss_sink_prepare);
+ gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR (gst_oss_sink_unprepare);
gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_oss_sink_write);
gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_oss_sink_delay);
gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_oss_sink_reset);
@@ -265,12 +269,10 @@ gst_oss_sink_get_format (GstBufferFormat fmt)
}
static gboolean
-gst_oss_sink_open (GstAudioSink * asink, GstRingBufferSpec * spec)
+gst_oss_sink_open (GstAudioSink * asink)
{
- struct audio_buf_info info;
- int mode;
GstOssSink *oss;
- int tmp;
+ int mode;
oss = GST_OSSSINK (asink);
@@ -282,9 +284,33 @@ gst_oss_sink_open (GstAudioSink * asink, GstRingBufferSpec * spec)
perror ("/dev/dsp");
return FALSE;
}
+
+ return TRUE;
+}
+
+static gboolean
+gst_oss_sink_close (GstAudioSink * asink)
+{
+ close (GST_OSSSINK (asink)->fd);
+ return TRUE;
+}
+
+static gboolean
+gst_oss_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
+{
+ GstOssSink *oss;
+ struct audio_buf_info info;
+ int mode;
+ int tmp;
+
+ oss = GST_OSSSINK (asink);
+
mode = fcntl (oss->fd, F_GETFL);
mode &= ~O_NONBLOCK;
- fcntl (oss->fd, F_SETFL, mode);
+ if (fcntl (oss->fd, F_SETFL, mode) == -1) {
+ perror ("/dev/dsp");
+ return FALSE;
+ }
tmp = gst_oss_sink_get_format (spec->format);
if (tmp == 0)
@@ -323,10 +349,28 @@ wrong_format:
}
static gboolean
-gst_oss_sink_close (GstAudioSink * asink)
+gst_oss_sink_unprepare (GstAudioSink * asink)
{
- close (GST_OSSSINK (asink)->fd);
+ /* could do a SNDCTL_DSP_RESET, but the OSS manual recommends a close/open */
+
+ if (!gst_oss_sink_close (asink))
+ goto couldnt_close;
+
+ if (!gst_oss_sink_open (asink))
+ goto couldnt_reopen;
+
return TRUE;
+
+couldnt_close:
+ {
+ GST_DEBUG ("Could not close the audio device");
+ return FALSE;
+ }
+couldnt_reopen:
+ {
+ GST_DEBUG ("Could not reopen the audio device");
+ return FALSE;
+ }
}
static guint