sys/oss/gstosssink.c: Some drivers do not support unsetting the non-blocking flag...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 17 Oct 2006 14:37:49 +0000 (14:37 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 17 Oct 2006 14:37:49 +0000 (14:37 +0000)
Original commit message from CVS:
* sys/oss/gstosssink.c: (gst_oss_sink_prepare):
Some drivers do not support unsetting the non-blocking flag once the
device is opened. In those cases, close/open the device in
non-blocking mode. Fixes #362673.

ChangeLog
sys/oss/gstosssink.c

index f204f09..2afcc8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-17  Wim Taymans  <wim@fluendo.com>
+
+       * sys/oss/gstosssink.c: (gst_oss_sink_prepare):
+       Some drivers do not support unsetting the non-blocking flag once the
+       device is opened. In those cases, close/open the device in
+       non-blocking mode. Fixes #362673.
+
 2006-10-17  Stefan Kost  <ensonic@users.sf.net>
 
        * sys/v4l2/v4l2_calls.c: (gst_v4l2_fill_lists):
index 7e1e32b..1351d1b 100644 (file)
@@ -427,10 +427,17 @@ gst_oss_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
 
   oss = GST_OSSSINK (asink);
 
+  /* we opened non-blocking so that we can detect if the device is available
+   * without hanging forever. We now want to remove the non-blocking flag. */
   mode = fcntl (oss->fd, F_GETFL);
   mode &= ~O_NONBLOCK;
-  if (fcntl (oss->fd, F_SETFL, mode) == -1)
-    goto non_block;
+  if (fcntl (oss->fd, F_SETFL, mode) == -1) {
+    /* some drivers do no support unsetting the non-blocking flag, try to
+     * close/open the device then. This is racy but we error out properly. */
+    gst_oss_sink_close (asink);
+    if ((oss->fd = open (oss->device, O_WRONLY, 0)) == -1)
+      goto non_block;
+  }
 
   tmp = gst_oss_sink_get_format (spec->format);
   if (tmp == 0)
@@ -458,7 +465,6 @@ gst_oss_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
 
   spec->bytes_per_sample = (spec->width / 8) * spec->channels;
   oss->bytes_per_sample = (spec->width / 8) * spec->channels;
-  memset (spec->silence_sample, 0, spec->bytes_per_sample);
 
   GST_DEBUG_OBJECT (oss, "got segsize: %d, segtotal: %d, value: %08x",
       spec->segsize, spec->segtotal, tmp);