From 5ac2327f0555a7611c571b31bfd4050555e78e7b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 24 Aug 2005 11:29:10 +0000 Subject: [PATCH] gst-libs/gst/audio/gstringbuffer.*: Added function to clear the ringbuffer. Original commit message from CVS: * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_set_sample), (gst_ring_buffer_clear_all): * gst-libs/gst/audio/gstringbuffer.h: Added function to clear the ringbuffer. --- ChangeLog | 7 +++++++ gst-libs/gst/audio/gstringbuffer.c | 28 +++++++++++++++++++++++----- gst-libs/gst/audio/gstringbuffer.h | 3 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a597f6bffc..b83fe6be53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-24 Wim Taymans + + * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_set_sample), + (gst_ring_buffer_clear_all): + * gst-libs/gst/audio/gstringbuffer.h: + Added function to clear the ringbuffer. + 2005-08-24 Andy Wingo * sys/v4l/gstv4lelement.c (gst_v4lelement_start) diff --git a/gst-libs/gst/audio/gstringbuffer.c b/gst-libs/gst/audio/gstringbuffer.c index 765d07ba19..d569475b9b 100644 --- a/gst-libs/gst/audio/gstringbuffer.c +++ b/gst-libs/gst/audio/gstringbuffer.c @@ -822,8 +822,6 @@ gst_ring_buffer_samples_done (GstRingBuffer * buf) void gst_ring_buffer_set_sample (GstRingBuffer * buf, guint64 sample) { - gint i; - g_return_if_fail (buf != NULL); if (sample == -1) @@ -838,13 +836,33 @@ gst_ring_buffer_set_sample (GstRingBuffer * buf, guint64 sample) buf->segbase = buf->segdone - sample / buf->samples_per_seg; buf->next_sample = sample; - for (i = 0; i < buf->spec.segtotal; i++) { - gst_ring_buffer_clear (buf, i); - } + gst_ring_buffer_clear_all (buf); GST_DEBUG ("set sample to %llu, segbase %d", sample, buf->segbase); } +/** + * gst_ring_buffer_clear_all: + * @buf: the #GstRingBuffer to clear + * + * Fill the ringbuffer with silence. + * + * MT safe. + */ +void +gst_ring_buffer_clear_all (GstRingBuffer * buf) +{ + gint i; + + g_return_if_fail (buf != NULL); + g_return_if_fail (buf->spec.segtotal > 0); + + for (i = 0; i < buf->spec.segtotal; i++) { + gst_ring_buffer_clear (buf, i); + } +} + + static gboolean wait_segment (GstRingBuffer * buf) { diff --git a/gst-libs/gst/audio/gstringbuffer.h b/gst-libs/gst/audio/gstringbuffer.h index bd57c8f971..13058d4ac3 100644 --- a/gst-libs/gst/audio/gstringbuffer.h +++ b/gst-libs/gst/audio/gstringbuffer.h @@ -236,6 +236,9 @@ guint64 gst_ring_buffer_samples_done (GstRingBuffer *buf); void gst_ring_buffer_set_sample (GstRingBuffer *buf, guint64 sample); +/* clear all segments */ +void gst_ring_buffer_clear_all (GstRingBuffer *buf); + /* commit samples */ guint gst_ring_buffer_commit (GstRingBuffer *buf, guint64 sample, guchar *data, guint len);