basesink: improve adjust_time()

Add some more comments.
Make sure we don't end up with negative timestamps.
This commit is contained in:
Wim Taymans 2010-09-24 12:22:33 +02:00
parent 54a5871434
commit 29e23e9142

View file

@ -2005,7 +2005,8 @@ out_of_segment:
}
/* with STREAM_LOCK, PREROLL_LOCK, LOCK
* adjust a timestamp with the latency and timestamp offset */
* adjust a timestamp with the latency and timestamp offset. This function does
* not adjust for the render delay. */
static GstClockTime
gst_base_sink_adjust_time (GstBaseSink * basesink, GstClockTime time)
{
@ -2015,7 +2016,7 @@ gst_base_sink_adjust_time (GstBaseSink * basesink, GstClockTime time)
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time)))
return time;
time += basesink->priv->latency - basesink->priv->render_delay;
time += basesink->priv->latency;
/* apply offset, be carefull for underflows */
ts_offset = basesink->priv->ts_offset;
@ -2028,6 +2029,12 @@ gst_base_sink_adjust_time (GstBaseSink * basesink, GstClockTime time)
} else
time += ts_offset;
/* subtract the render delay again, which was included in the latency */
if (time > basesink->priv->render_delay)
time -= basesink->priv->render_delay;
else
time = 0;
return time;
}