Make the base audiosink return an error when there is no audiobuffer negotiated.
authorWim Taymans <wim.taymans@gmail.com>
Fri, 6 May 2005 16:18:24 +0000 (16:18 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 6 May 2005 16:18:24 +0000 (16:18 +0000)
Original commit message from CVS:
Make the base audiosink return an error when there is no
audiobuffer negotiated.

ChangeLog
gst-libs/gst/audio/gstaudiosink.c
gst-libs/gst/audio/gstbaseaudiosink.c
gst-libs/gst/audio/gstbaseaudiosink.h
gst-libs/gst/audio/gstringbuffer.c
gst-libs/gst/audio/gstringbuffer.h

index 37bdf3c..47c5f09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2005-05-06  Wim Taymans  <wim@fluendo.com>
+
+       * gst-libs/gst/audio/gstaudiosink.c:
+       (gst_audioringbuffer_get_type), (gst_audioringbuffer_class_init),
+       (audioringbuffer_thread_func), (gst_audioringbuffer_init),
+       (gst_audioringbuffer_acquire), (gst_audioringbuffer_release),
+       (gst_audioringbuffer_play), (gst_audioringbuffer_stop),
+       (gst_audioringbuffer_delay), (gst_audiosink_class_init),
+       (gst_audiosink_create_ringbuffer):
+       * gst-libs/gst/audio/gstbaseaudiosink.c:
+       (gst_baseaudiosink_class_init), (gst_baseaudiosink_init),
+       (gst_baseaudiosink_get_clock), (gst_baseaudiosink_get_time),
+       (gst_baseaudiosink_set_property), (build_linear_format),
+       (debug_spec_caps), (debug_spec_buffer),
+       (gst_baseaudiosink_setcaps), (gst_baseaudiosink_get_times),
+       (gst_baseaudiosink_event), (gst_baseaudiosink_preroll),
+       (gst_baseaudiosink_render), (gst_baseaudiosink_create_ringbuffer),
+       (gst_baseaudiosink_callback), (gst_baseaudiosink_change_state):
+       * gst-libs/gst/audio/gstbaseaudiosink.h:
+       * gst-libs/gst/audio/gstringbuffer.c: (gst_ringbuffer_get_type),
+       (gst_ringbuffer_set_callback), (gst_ringbuffer_acquire),
+       (gst_ringbuffer_release), (gst_ringbuffer_is_acquired),
+       (gst_ringbuffer_play), (gst_ringbuffer_pause),
+       (gst_ringbuffer_stop), (gst_ringbuffer_delay),
+       (gst_ringbuffer_played_samples), (gst_ringbuffer_set_sample),
+       (wait_segment), (gst_ringbuffer_commit),
+       (gst_ringbuffer_prepare_read), (gst_ringbuffer_advance),
+       (gst_ringbuffer_clear):
+       * gst-libs/gst/audio/gstringbuffer.h:
+       Make the base audiosink return an error when there is no
+       audiobuffer negotiated.
+
 2005-05-06  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
 
        * ext/Makefile.am:
index a41486a..a3c2e23 100644 (file)
@@ -292,6 +292,9 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
 
   GST_LOCK (buf);
 
+  /* free the buffer */
+  gst_buffer_unref (buf->data);
+
   if (csink->close)
     result = csink->close (sink);
 
index 7b331ed..9af769a 100644 (file)
@@ -484,11 +484,19 @@ gst_baseaudiosink_render (GstBaseSink * bsink, GstBuffer * buf)
   offset = GST_BUFFER_OFFSET (buf);
 
   GST_DEBUG ("in offset %llu, time %lld", offset, GST_BUFFER_TIMESTAMP (buf));
+  if (!gst_ringbuffer_is_acquired (sink->ringbuffer))
+    goto wrong_state;
 
   gst_ringbuffer_commit (sink->ringbuffer, offset,
       GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
 
   return GST_FLOW_OK;
+
+wrong_state:
+  {
+    GST_DEBUG ("ringbuffer in wrong state");
+    return GST_FLOW_ERROR;
+  }
 }
 
 GstRingBuffer *
index eb37cde..aa3ccd7 100644 (file)
@@ -72,6 +72,7 @@ typedef struct _GstBaseAudioSinkClass GstBaseAudioSinkClass;
 struct _GstBaseAudioSink {
   GstBaseSink   element;
 
+  /*< protected >*/ /* with LOCK */
   /* our ringbuffer */
   GstRingBuffer *ringbuffer;
 
index 339b9e5..e391679 100644 (file)
@@ -239,6 +239,31 @@ done:
 }
 
 /**
+ * gst_ringbuffer_is_acquired:
+ * @buf: the #GstRingBuffer to check
+ *
+ * Check if the ringbuffer is acquired and ready to use.
+ *
+ * Returns: TRUE if the ringbuffer is acquired, FALSE on error.
+ *
+ * MT safe.
+ */
+gboolean
+gst_ringbuffer_is_acquired (GstRingBuffer * buf)
+{
+  gboolean res;
+
+  g_return_val_if_fail (buf != NULL, FALSE);
+
+  GST_LOCK (buf);
+  res = buf->acquired;
+  GST_UNLOCK (buf);
+
+  return res;
+}
+
+
+/**
  * gst_ringbuffer_play:
  * @buf: the #GstRingBuffer to play
  *
index 3ff630a..38079c5 100644 (file)
@@ -198,6 +198,8 @@ void        gst_ringbuffer_set_callback     (GstRingBuffer *buf, GstRingBufferCallb
 gboolean       gst_ringbuffer_acquire          (GstRingBuffer *buf, GstRingBufferSpec *spec);
 gboolean       gst_ringbuffer_release          (GstRingBuffer *buf);
 
+gboolean       gst_ringbuffer_is_acquired      (GstRingBuffer *buf);
+
 /* playback/pause */
 gboolean       gst_ringbuffer_play             (GstRingBuffer *buf);
 gboolean       gst_ringbuffer_pause            (GstRingBuffer *buf);