openslessink: Return 0 delay if the player object is in PAUSED state
authorJosep Torra <n770galaxy@gmail.com>
Fri, 12 Oct 2012 08:08:59 +0000 (10:08 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 18 Oct 2012 12:03:10 +0000 (14:03 +0200)
sys/opensles/openslesringbuffer.c

index ea17f7c..8038821 100644 (file)
@@ -887,13 +887,16 @@ gst_opensles_ringbuffer_delay (GstRingBuffer * rb)
   thiz = GST_OPENSLES_RING_BUFFER_CAST (rb);
 
   if (thiz->playerPlay) {
+    SLuint32 state;
     SLmillisecond position;
-    guint64 playedpos, queuedpos;
-
-    (*thiz->playerPlay)->GetPosition (thiz->playerPlay, &position);
-    playedpos = gst_util_uint64_scale_round (position, rb->spec.rate, 1000);
-    queuedpos = g_atomic_int_get (&thiz->segqueued) * rb->samples_per_seg;
-    res = queuedpos - playedpos;
+    guint64 playedpos = 0, queuedpos = 0;
+    (*thiz->playerPlay)->GetPlayState (thiz->playerPlay, &state);
+    if (state == SL_PLAYSTATE_PLAYING) {
+      (*thiz->playerPlay)->GetPosition (thiz->playerPlay, &position);
+      playedpos = gst_util_uint64_scale_round (position, rb->spec.rate, 1000);
+      queuedpos = g_atomic_int_get (&thiz->segqueued) * rb->samples_per_seg;
+      res = queuedpos - playedpos;
+    }
 
     GST_LOG_OBJECT (thiz, "queued samples %" G_GUINT64_FORMAT " position %u ms "
         "(%" G_GUINT64_FORMAT " samples) delay %u samples",