opensles: ensure that we register the callback only in STOPPED

Fixes the error registering the callback on the PLAYING -> PAUSE ->
PLAYING state change sequence.
This commit is contained in:
Josep Torra 2012-09-27 18:33:09 +02:00 committed by Sebastian Dröge
parent e265cec514
commit 97a1ccfab1
2 changed files with 23 additions and 12 deletions

View file

@ -215,6 +215,7 @@ _opensles_recorder_start (GstRingBuffer * rb)
gint i;
/* Register callback on the buffer queue */
if (!thiz->is_queue_callback_registered) {
result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
_opensles_recorder_cb, rb);
if (result != SL_RESULT_SUCCESS) {
@ -222,6 +223,8 @@ _opensles_recorder_start (GstRingBuffer * rb)
(guint32) result);
return FALSE;
}
thiz->is_queue_callback_registered = TRUE;
}
/* Fill the queue by enqueing buffers */
for (i = 0; i < RECORDER_QUEUE_SIZE; i++) {
@ -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,6 +498,7 @@ _opensles_player_start (GstRingBuffer * rb)
gint i;
/* Register callback on the buffer queue */
if (!thiz->is_queue_callback_registered) {
result = (*thiz->bufferQueue)->RegisterCallback (thiz->bufferQueue,
_opensles_player_cb, rb);
if (result != SL_RESULT_SUCCESS) {
@ -501,6 +506,8 @@ _opensles_player_start (GstRingBuffer * rb)
(guint32) result);
return FALSE;
}
thiz->is_queue_callback_registered = TRUE;
}
/* Fill the queue by enqueing buffers */
for (i = 0; i < thiz->data_segtotal; i++) {
@ -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;
}

View file

@ -88,6 +88,7 @@ struct _GstOpenSLESRingBuffer
guint8 * data;
guint cursor;
gint segqueued; /* ATOMIC */
gboolean is_queue_callback_registered;
/* vmethods */
AcquireFunc acquire;