summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosep Torra <n770galaxy@gmail.com>2012-09-20 10:41:50 +0200
committerJosep Torra <n770galaxy@gmail.com>2012-09-20 10:41:50 +0200
commitbd7d39cdb859591df3ddc3a4cefb9b09c75924dc (patch)
treebcc914af4d208da02ade789a550f6d564e1595c5
parent853117f389532a412283e864ea8b81f2e961ad87 (diff)
opensles: produces expected output until ringbuffer wraps
Add some log messages. Fixed a bit the _player_cb function and properly advance reding in the ringbuffer. Still produces noise when the ringbuffer wraps.
-rw-r--r--sys/opensles/openslesringbuffer.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/opensles/openslesringbuffer.c b/sys/opensles/openslesringbuffer.c
index 849f00093..dd41ad93e 100644
--- a/sys/opensles/openslesringbuffer.c
+++ b/sys/opensles/openslesringbuffer.c
@@ -297,7 +297,8 @@ _opensles_player_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
}
/* Enqueue a buffer */
- GST_LOG_OBJECT (thiz, "enqueue: %p size %d", readptr, len);
+ GST_LOG_OBJECT (thiz, "enqueue: %p size %d segment: %d",
+ readptr, len, readseg);
result = (*thiz->bufferQueue)->Enqueue (thiz->bufferQueue, readptr, len);
if (result != SL_RESULT_SUCCESS) {
@@ -306,15 +307,14 @@ _opensles_player_cb (SLAndroidSimpleBufferQueueItf bufferQueue, void *context)
return;
}
- if (thiz->last_readseg != readseg) {
- if (thiz->last_readseg >= 0) {
- /* Clear written samples */
- gst_ring_buffer_clear (rb, readseg);
- /* We wrote one segment */
- gst_ring_buffer_advance (rb, 1);
- }
- thiz->last_readseg = readseg;
+ if (thiz->last_readseg >= 0) {
+ GST_LOG_OBJECT (thiz, "clear segment %d", thiz->last_readseg);
+ /* Clear written samples */
+ gst_ring_buffer_clear (rb, thiz->last_readseg);
+ /* We wrote one segment */
}
+ gst_ring_buffer_advance (rb, 1);
+ thiz->last_readseg = readseg;
}
static gboolean
@@ -326,7 +326,7 @@ _opensles_player_acquire (GstRingBuffer * rb, guint nbuffers,
/* Configure audio source */
SLDataLocator_AndroidSimpleBufferQueue loc_bufq =
- { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, nbuffers };
+ { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2 };
SLDataSource audioSrc = { &loc_bufq, format };
/* Configure audio sink */
@@ -578,7 +578,7 @@ gst_opensles_ringbuffer_acquire (GstRingBuffer * rb, GstRingBufferSpec * spec)
spec->segsize =
(spec->latency_time * spec->rate / G_USEC_PER_SEC) *
spec->bytes_per_sample;
- spec->segtotal = MAX (2, spec->buffer_time / spec->latency_time);
+ spec->segtotal = (spec->buffer_time / spec->latency_time) << 4;
thiz->last_readseg = -1;
/* Define the format in OpenSL ES terms */