opensles: implement the ringbuffer clear_all vmethod too

This commit is contained in:
Josep Torra 2012-10-01 11:14:24 +02:00 committed by Sebastian Dröge
parent fc087f6419
commit 69426572f8
2 changed files with 20 additions and 2 deletions

View file

@ -453,7 +453,9 @@ _opensles_player_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
/* Allocate the queue associated ringbuffer memory */ /* Allocate the queue associated ringbuffer memory */
thiz->data_segtotal = loc_bufq.numBuffers; 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; thiz->cursor = 0;
return TRUE; return TRUE;
@ -611,7 +613,6 @@ _opensles_player_stop (GstRingBuffer * rb)
* OpenSL ES ringbuffer wrapper * OpenSL ES ringbuffer wrapper
*/ */
GstRingBuffer * GstRingBuffer *
gst_opensles_ringbuffer_new (RingBufferMode mode) gst_opensles_ringbuffer_new (RingBufferMode mode)
{ {
@ -898,6 +899,20 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
return res; 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 static void
gst_opensles_ringbuffer_dispose (GObject * object) 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->stop = GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_stop);
gstringbuffer_class->delay = gstringbuffer_class->delay =
GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_delay); GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_delay);
gstringbuffer_class->clear_all =
GST_DEBUG_FUNCPTR (gst_opensles_ringbuffer_clear_all);
} }
static void static void

View file

@ -88,6 +88,7 @@ struct _GstOpenSLESRingBuffer
SLAndroidSimpleBufferQueueItf bufferQueue; SLAndroidSimpleBufferQueueItf bufferQueue;
guint data_segtotal; guint data_segtotal;
guint8 * data; guint8 * data;
guint data_size;
guint cursor; guint cursor;
gint segqueued; /* ATOMIC */ gint segqueued; /* ATOMIC */
gboolean is_queue_callback_registered; gboolean is_queue_callback_registered;