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:
Jan Schmidt 2009-11-11 17:12:19 +00:00
parent 039ef83523
commit f83ea8233b

View file

@ -4294,7 +4294,8 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
GstClock *clock;
gboolean res = FALSE;
GstFormat oformat, tformat;
GstClockTime now, base, latency;
GstClockTime now, latency;
GstClockTimeDiff base;
gint64 time, accum, duration;
gdouble rate;
gint64 last;
@ -4375,9 +4376,10 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
* rate and applied rate. */
base += accum;
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. */
if (rate < 0.0)
time += duration;