baseaudiosink: subtract the render_delay from our latency
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 24 Sep 2010 10:54:47 +0000 (12:54 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 24 Sep 2010 10:54:47 +0000 (12:54 +0200)
The latency reported by the base class includes the render_delay, which we don't
want to include when we start slaving our clocks.

See #630441

gst-libs/gst/audio/gstbaseaudiosink.c

index 218984a..4ae1e44 100644 (file)
@@ -1145,7 +1145,7 @@ gst_base_audio_sink_sync_latency (GstBaseSink * bsink, GstMiniObject * obj)
 {
   GstClock *clock;
   GstClockReturn status;
-  GstClockTime time;
+  GstClockTime time, render_delay;
   GstFlowReturn ret;
   GstBaseAudioSink *sink;
   GstClockTime itime, etime;
@@ -1175,6 +1175,15 @@ gst_base_audio_sink_sync_latency (GstBaseSink * bsink, GstMiniObject * obj)
     time = sink->priv->us_latency;
     GST_OBJECT_UNLOCK (sink);
 
+    /* Renderdelay is added onto our own latency, and needs
+     * to be subtracted as well */
+    render_delay = gst_base_sink_get_render_delay (bsink);
+
+    if (G_LIKELY (time > render_delay))
+      time -= render_delay;
+    else
+      time = 0;
+
     /* preroll done, we can sync since we are in PLAYING now. */
     GST_DEBUG_OBJECT (sink, "possibly waiting for clock to reach %"
         GST_TIME_FORMAT, GST_TIME_ARGS (time));