summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJosep Torra <n770galaxy@gmail.com>2012-10-01 11:14:24 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-18 14:03:09 +0200
commit69426572f8e9ef577a7cf0312e3868aa428039eb (patch)
treebf2d5dac9ed8aa789be81e5c080ec28266e0742d /sys
parentfc087f6419ef090427378e78331c50088503caab (diff)
opensles: implement the ringbuffer clear_all vmethod too
Diffstat (limited to 'sys')
-rw-r--r--sys/opensles/openslesringbuffer.c21
-rw-r--r--sys/opensles/openslesringbuffer.h1
2 files changed, 20 insertions, 2 deletions
diff --git a/sys/opensles/openslesringbuffer.c b/sys/opensles/openslesringbuffer.c
index 0eced5384..626e6f4d3 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)
{
@@ -899,6 +900,20 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
}
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)
{
G_OBJECT_CLASS (ring_parent_class)->dispose (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 9e8b16e81..8a192cbc2 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;