From 7bd29abb9d8e6cabdcf7c7a27bdfdeab28457f95 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 16 Oct 2008 15:38:50 +0000 Subject: [PATCH] gst-libs/gst/audio/gstringbuffer.c: In pull mode we want the callback to prepull a buffer we can preroll on even when... Original commit message from CVS: * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_prepare_read): In pull mode we want the callback to prepull a buffer we can preroll on even when we are not yet playing. --- ChangeLog | 7 +++++++ gst-libs/gst/audio/gstringbuffer.c | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b87b530f3..3e378c7cf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-10-16 Wim Taymans + + * gst-libs/gst/audio/gstringbuffer.c: + (gst_ring_buffer_prepare_read): + In pull mode we want the callback to prepull a buffer we can preroll on + even when we are not yet playing. + 2008-10-16 Stefan Kost * ext/alsa/Makefile.am: diff --git a/gst-libs/gst/audio/gstringbuffer.c b/gst-libs/gst/audio/gstringbuffer.c index ccb4eeeff5..7312436566 100644 --- a/gst-libs/gst/audio/gstringbuffer.c +++ b/gst-libs/gst/audio/gstringbuffer.c @@ -1662,10 +1662,6 @@ gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment, g_return_val_if_fail (GST_IS_RING_BUFFER (buf), FALSE); - /* buffer must be started */ - if (g_atomic_int_get (&buf->state) != GST_RING_BUFFER_STATE_STARTED) - return FALSE; - g_return_val_if_fail (buf->data != NULL, FALSE); g_return_val_if_fail (segment != NULL, FALSE); g_return_val_if_fail (readptr != NULL, FALSE); @@ -1673,6 +1669,12 @@ gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment, data = GST_BUFFER_DATA (buf->data); + if (buf->callback == NULL) { + /* push mode, fail when nothing is started */ + if (g_atomic_int_get (&buf->state) != GST_RING_BUFFER_STATE_STARTED) + return FALSE; + } + /* get the position of the pointer */ segdone = g_atomic_int_get (&buf->segdone); @@ -1680,14 +1682,14 @@ gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment, *len = buf->spec.segsize; *readptr = data + *segment * *len; + GST_LOG ("prepare read from segment %d (real %d) @%p", + *segment, segdone, *readptr); + /* callback to fill the memory with data, for pull based * scheduling. */ if (buf->callback) buf->callback (buf, *readptr, *len, buf->cb_data); - GST_LOG ("prepare read from segment %d (real %d) @%p", - *segment, segdone, *readptr); - return TRUE; }