summaryrefslogtreecommitdiff
path: root/sys/opensles
diff options
context:
space:
mode:
authorJosep Torra <n770galaxy@gmail.com>2012-09-27 18:33:09 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-18 14:03:09 +0200
commit97a1ccfab1cb360140ea3e9a1c80ea6d8757030f (patch)
tree1087b7a031f27d12c455a36bdb76605372f23b0d /sys/opensles
parente265cec514dfce6bf8ef5927a7b3aae45920e9cc (diff)
downloadgstreamer-plugins-bad-97a1ccfab1cb360140ea3e9a1c80ea6d8757030f.tar.gz
opensles: ensure that we register the callback only in STOPPED
Fixes the error registering the callback on the PLAYING -> PAUSE -> PLAYING state change sequence.
Diffstat (limited to 'sys/opensles')
-rw-r--r--sys/opensles/openslesringbuffer.c34
-rw-r--r--sys/opensles/openslesringbuffer.h1
2 files changed, 23 insertions, 12 deletions
diff --git a/sys/opensles/openslesringbuffer.c b/sys/opensles/openslesringbuffer.c
index 295658a6b..aa0486a04 100644
--- a/sys/opensles/openslesringbuffer.c
+++ b/sys/opensles/openslesringbuffer.c
@@ -215,12 +215,15 @@ _opensles_recorder_start (GstRingBuffer * rb)
gint i;
/* Register callback on the buffer queue */
- result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
- _opensles_recorder_cb, rb);
- if (result != SL_RESULT_SUCCESS) {
- GST_ERROR_OBJECT (thiz, "bufferQueue.RegisterCallback failed(0x%08x)",
- (guint32) result);
- return FALSE;
+ if (!thiz->is_queue_callback_registered) {
+ result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
+ _opensles_recorder_cb, rb);
+ if (result != SL_RESULT_SUCCESS) {
+ GST_ERROR_OBJECT (thiz, "bufferQueue.RegisterCallback failed(0x%08x)",
+ (guint32) result);
+ return FALSE;
+ }
+ thiz->is_queue_callback_registered = TRUE;
}
/* Fill the queue by enqueing buffers */
@@ -264,6 +267,7 @@ _opensles_recorder_stop (GstRingBuffer * rb)
(guint32) result);
return FALSE;
}
+ thiz->is_queue_callback_registered = FALSE;
/* Reset the queue */
result = (*thiz->bufferQueue)->Clear (thiz->bufferQueue);
@@ -494,12 +498,15 @@ _opensles_player_start (GstRingBuffer * rb)
gint i;
/* Register callback on the buffer queue */
- result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
- _opensles_player_cb, rb);
- if (result != SL_RESULT_SUCCESS) {
- GST_ERROR_OBJECT (thiz, "bufferQueue.RegisterCallback failed(0x%08x)",
- (guint32) result);
- return FALSE;
+ if (!thiz->is_queue_callback_registered) {
+ result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
+ _opensles_player_cb, rb);
+ if (result != SL_RESULT_SUCCESS) {
+ GST_ERROR_OBJECT (thiz, "bufferQueue.RegisterCallback failed(0x%08x)",
+ (guint32) result);
+ return FALSE;
+ }
+ thiz->is_queue_callback_registered = TRUE;
}
/* Fill the queue by enqueing buffers */
@@ -561,6 +568,7 @@ _opensles_player_stop (GstRingBuffer * rb)
(guint32) result);
return FALSE;
}
+ thiz->is_queue_callback_registered = FALSE;
/* Reset the queue */
result = (*thiz->bufferQueue)->Clear (thiz->bufferQueue);
@@ -571,6 +579,7 @@ _opensles_player_stop (GstRingBuffer * rb)
}
g_atomic_int_set (&thiz->segqueued, 0);
+ thiz->cursor = 0;
return TRUE;
}
@@ -900,4 +909,5 @@ gst_opensles_ringbuffer_init (GstOpenSLESRingBuffer * thiz,
thiz->outputMixObject = NULL;
thiz->playerObject = NULL;
thiz->recorderObject = NULL;
+ thiz->is_queue_callback_registered = FALSE;
}
diff --git a/sys/opensles/openslesringbuffer.h b/sys/opensles/openslesringbuffer.h
index b9111e846..2673685ae 100644
--- a/sys/opensles/openslesringbuffer.h
+++ b/sys/opensles/openslesringbuffer.h
@@ -88,6 +88,7 @@ struct _GstOpenSLESRingBuffer
guint8 * data;
guint cursor;
gint segqueued; /* ATOMIC */
+ gboolean is_queue_callback_registered;
/* vmethods */
AcquireFunc acquire;