From 69426572f8e9ef577a7cf0312e3868aa428039eb Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Mon, 1 Oct 2012 11:14:24 +0200 Subject: [PATCH] opensles: implement the ringbuffer clear_all vmethod too --- sys/opensles/openslesringbuffer.c | 21 +++++++++++++++++++-- sys/opensles/openslesringbuffer.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/opensles/openslesringbuffer.c b/sys/opensles/openslesringbuffer.c index 0eced53847..626e6f4d39 100644 --- a/sys/opensles/openslesringbuffer.c +++ b/sys/opensles/openslesringbuffer.c @@ -453,7 +453,9 @@ _opensles_player_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec) /* Allocate the queue associated ringbuffer memory */ thiz->data_segtotal = loc_bufq.numBuffers; - thiz->data = g_malloc (spec->segsize * thiz->data_segtotal); + thiz->data_size = spec->segsize * thiz->data_segtotal; + thiz->data = g_malloc0 (thiz->data_size); + g_atomic_int_set (&thiz->segqueued, 0); thiz->cursor = 0; return TRUE; @@ -611,7 +613,6 @@ _opensles_player_stop (GstRingBuffer * rb) * OpenSL ES ringbuffer wrapper */ - GstRingBuffer * gst_opensles_ringbuffer_new (RingBufferMode mode) { @@ -898,6 +899,20 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb) return res; } +static void +gst_opensles_ringbuffer_clear_all (GstRingBuffer * rb) +{ + GstOpenSLESRingBuffer *thiz; + + thiz = GST_OPENSLES_RING_BUFFER_CAST (rb); + + if (thiz->data) { + memset (thiz->data, 0, thiz->data_size); + g_atomic_int_set (&thiz->segqueued, 0); + thiz->cursor = 0; + } +} + static void gst_opensles_ringbuffer_dispose (GObject * object) { @@ -947,6 +962,8 @@ gst_opensles_ringbuffer_class_init (GstOpenSLESRingBufferClass * klass) gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_stop); gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_delay); + gstringbuffer_class->clear_all = + GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_clear_all); } static void diff --git a/sys/opensles/openslesringbuffer.h b/sys/opensles/openslesringbuffer.h index 9e8b16e81b..8a192cbc2f 100644 --- a/sys/opensles/openslesringbuffer.h +++ b/sys/opensles/openslesringbuffer.h @@ -88,6 +88,7 @@ struct _GstOpenSLESRingBuffer SLAndroidSimpleBufferQueueItf bufferQueue; guint data_segtotal; guint8 * data; + guint data_size; guint cursor; gint segqueued; /* ATOMIC */ gboolean is_queue_callback_registered;