mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
basesink: Fix treating base_time as unsigned in position calculation
Element base_time is a signed quantity, which leads to basesink returning a position of 0 when dealing with a negative base time - which are quite legal when clocks (such as the audio clock) are close to 0. This doesn't manifest in normal pipelines, of course - but can happen (at least) when manually setting the base time on a pipeline.
This commit is contained in:
parent
039ef83523
commit
f83ea8233b
1 changed files with 5 additions and 3 deletions
|
@ -4294,7 +4294,8 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
GstFormat oformat, tformat;
|
GstFormat oformat, tformat;
|
||||||
GstClockTime now, base, latency;
|
GstClockTime now, latency;
|
||||||
|
GstClockTimeDiff base;
|
||||||
gint64 time, accum, duration;
|
gint64 time, accum, duration;
|
||||||
gdouble rate;
|
gdouble rate;
|
||||||
gint64 last;
|
gint64 last;
|
||||||
|
@ -4375,9 +4376,10 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
|
||||||
* rate and applied rate. */
|
* rate and applied rate. */
|
||||||
base += accum;
|
base += accum;
|
||||||
base += latency;
|
base += latency;
|
||||||
base = MIN (now, base);
|
if (GST_CLOCK_DIFF (base, now) < 0)
|
||||||
|
base = -now;
|
||||||
|
|
||||||
/* for negative rates we need to count back from from the segment
|
/* for negative rates we need to count back from the segment
|
||||||
* duration. */
|
* duration. */
|
||||||
if (rate < 0.0)
|
if (rate < 0.0)
|
||||||
time += duration;
|
time += duration;
|
||||||
|
|
Loading…
Reference in a new issue