mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
basesink: improve adjust_time()
Add some more comments. Make sure we don't end up with negative timestamps.
This commit is contained in:
parent
54a5871434
commit
29e23e9142
1 changed files with 9 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue