From 71f92e2b3ecf105437641478492b6815b961bb0d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 8 Oct 2007 10:21:15 +0000 Subject: [PATCH] libs/gst/base/gstbasesink.c: Don't try to preroll non-async elements after a flush. Original commit message from CVS: * libs/gst/base/gstbasesink.c: (gst_base_sink_event), (gst_base_sink_get_position): Don't try to preroll non-async elements after a flush. Subtract latency form clock times when reporting position. --- ChangeLog | 7 +++++++ libs/gst/base/gstbasesink.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 72f4f387f2..c12ba791dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-08 Wim Taymans + + * libs/gst/base/gstbasesink.c: (gst_base_sink_event), + (gst_base_sink_get_position): + Don't try to preroll non-async elements after a flush. + Subtract latency form clock times when reporting position. + 2007-10-05 Wim Taymans * gst/gstpad.c: (gst_pad_pause_task): diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 7959051e10..c93ddb1190 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -2216,6 +2216,7 @@ gst_base_sink_event (GstPad * pad, GstEvent * event) gst_element_lost_state (GST_ELEMENT_CAST (basesink)); } else { basesink->priv->have_latency = TRUE; + basesink->need_preroll = FALSE; } GST_PAD_STREAM_UNLOCK (pad); @@ -2809,7 +2810,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, /* we can answer time format */ case GST_FORMAT_TIME: { - GstClockTime now, base; + GstClockTime now, base, latency; gint64 time, accum, duration; gdouble rate; gint64 last; @@ -2854,6 +2855,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, accum = basesink->segment.accum; rate = basesink->segment.rate * basesink->segment.applied_rate; gst_base_sink_get_position_last (basesink, &last); + latency = basesink->priv->latency; gst_object_ref (clock); /* need to release the object lock before we can get the time, @@ -2862,11 +2864,13 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, GST_OBJECT_UNLOCK (basesink); now = gst_clock_get_time (clock); + /* subtract base time and accumulated time from the clock time. * Make sure we don't go negative. This is the current time in * the segment which we need to scale with the combined * rate and applied rate. */ base += accum; + base += latency; base = MIN (now, base); /* for negative rates we need to count back from from the segment