openslesringbuffer: Only pre-roll a single buffer
authorSebastian Dröge <sebastian@centricular.com>
Thu, 5 Feb 2015 11:24:04 +0000 (12:24 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 5 Feb 2015 11:28:22 +0000 (12:28 +0100)
There is no reason to pre-roll more buffers here as we have our own ringbuffer
with more segments around it, and we can immediately provide more buffers to
OpenSL ES when it requests that from the callback.

Pre-rolling a single buffer before starting is necessary though, as otherwise
we will only output silence.

Lowers latency a bit, depending on latency-time and buffer-time settings.

sys/opensles/openslesringbuffer.c

index a853a1d..74af266 100644 (file)
@@ -520,7 +520,6 @@ _opensles_player_start (GstAudioRingBuffer * rb)
 {
   GstOpenSLESRingBuffer *thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
   SLresult result;
-  gint i;
 
   /* Register callback on the buffer queue */
   if (!thiz->is_queue_callback_registered) {
@@ -534,11 +533,9 @@ _opensles_player_start (GstAudioRingBuffer * rb)
     thiz->is_queue_callback_registered = TRUE;
   }
 
-  /* Fill the queue by enqueing buffers */
+  /* Fill the queue by enqueing a buffer */
   if (!g_atomic_int_get (&thiz->is_prerolled)) {
-    for (i = 0; i < thiz->data_segtotal; i++) {
-      _opensles_player_cb (NULL, rb);
-    }
+    _opensles_player_cb (NULL, rb);
     g_atomic_int_set (&thiz->is_prerolled, 1);
   }