Make the base audiosink return an error when there is no audiobuffer negotiated.

Original commit message from CVS:
Make the base audiosink return an error when there is no
audiobuffer negotiated.
This commit is contained in:
Wim Taymans 2005-05-06 16:18:24 +00:00
parent 393df2e486
commit fa8c2eb659
6 changed files with 71 additions and 0 deletions

View file

@ -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> 2005-05-06 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/Makefile.am: * ext/Makefile.am:

View file

@ -292,6 +292,9 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
GST_LOCK (buf); GST_LOCK (buf);
/* free the buffer */
gst_buffer_unref (buf->data);
if (csink->close) if (csink->close)
result = csink->close (sink); result = csink->close (sink);

View file

@ -484,11 +484,19 @@ gst_baseaudiosink_render (GstBaseSink * bsink, GstBuffer * buf)
offset = GST_BUFFER_OFFSET (buf); offset = GST_BUFFER_OFFSET (buf);
GST_DEBUG ("in offset %llu, time %lld", offset, GST_BUFFER_TIMESTAMP (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_ringbuffer_commit (sink->ringbuffer, offset,
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
return GST_FLOW_OK; return GST_FLOW_OK;
wrong_state:
{
GST_DEBUG ("ringbuffer in wrong state");
return GST_FLOW_ERROR;
}
} }
GstRingBuffer * GstRingBuffer *

View file

@ -72,6 +72,7 @@ typedef struct _GstBaseAudioSinkClass GstBaseAudioSinkClass;
struct _GstBaseAudioSink { struct _GstBaseAudioSink {
GstBaseSink element; GstBaseSink element;
/*< protected >*/ /* with LOCK */
/* our ringbuffer */ /* our ringbuffer */
GstRingBuffer *ringbuffer; GstRingBuffer *ringbuffer;

View file

@ -238,6 +238,31 @@ done:
return res; return res;
} }
/**
* 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: * gst_ringbuffer_play:
* @buf: the #GstRingBuffer to play * @buf: the #GstRingBuffer to play

View file

@ -198,6 +198,8 @@ void gst_ringbuffer_set_callback (GstRingBuffer *buf, GstRingBufferCallb
gboolean gst_ringbuffer_acquire (GstRingBuffer *buf, GstRingBufferSpec *spec); gboolean gst_ringbuffer_acquire (GstRingBuffer *buf, GstRingBufferSpec *spec);
gboolean gst_ringbuffer_release (GstRingBuffer *buf); gboolean gst_ringbuffer_release (GstRingBuffer *buf);
gboolean gst_ringbuffer_is_acquired (GstRingBuffer *buf);
/* playback/pause */ /* playback/pause */
gboolean gst_ringbuffer_play (GstRingBuffer *buf); gboolean gst_ringbuffer_play (GstRingBuffer *buf);
gboolean gst_ringbuffer_pause (GstRingBuffer *buf); gboolean gst_ringbuffer_pause (GstRingBuffer *buf);