From d19f40c7169db209fd71b06d3d2f9c209aacfe5e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 10 Feb 2011 14:50:04 +0100 Subject: basesink: keep track of earliest QoS timestamp Keep track of the earliest allowed timestamp according to the latest QoS report and drop buffers before that time. Activate this filter when throttling is enabled. We could later also activate this in the other QoS cases. See #638891 --- libs/gst/base/gstbasesink.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 498b0e9600..046fd11e68 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -260,7 +260,8 @@ struct _GstBaseSinkPrivate /* Cached GstClockID */ GstClockID cached_clock_id; - /* for throttling */ + /* for throttling and QoS */ + GstClockTime earliest_in_time; GstClockTime throttle_time; }; @@ -2490,6 +2491,10 @@ do_step: /* save sync time for eos when the previous object needed sync */ priv->eos_rtime = (do_sync ? priv->current_rstop : GST_CLOCK_TIME_NONE); + if (G_UNLIKELY (priv->earliest_in_time != -1 + && rstart < priv->earliest_in_time)) + goto qos_dropped; + again: /* first do preroll, this makes sure we commit our state * to PAUSED and can continue to PLAYING. We cannot perform @@ -2576,6 +2581,12 @@ not_syncable: GST_DEBUG_OBJECT (basesink, "non syncable object %p", obj); return GST_FLOW_OK; } +qos_dropped: + { + GST_DEBUG_OBJECT (basesink, "dropped because of QoS %p", obj); + *late = TRUE; + return GST_FLOW_OK; + } flushing: { GST_DEBUG_OBJECT (basesink, "we are flushing"); @@ -2754,6 +2765,7 @@ gst_base_sink_reset_qos (GstBaseSink * sink) priv = sink->priv; priv->last_in_time = GST_CLOCK_TIME_NONE; + priv->earliest_in_time = GST_CLOCK_TIME_NONE; priv->last_left = GST_CLOCK_TIME_NONE; priv->avg_duration = GST_CLOCK_TIME_NONE; priv->avg_pt = GST_CLOCK_TIME_NONE; @@ -2833,6 +2845,9 @@ gst_base_sink_is_too_late (GstBaseSink * basesink, GstMiniObject * obj, done: if (!late || !GST_CLOCK_TIME_IS_VALID (priv->last_in_time)) { priv->last_in_time = start; + /* the next allowed input timestamp */ + if (priv->throttle_time > 0) + priv->earliest_in_time = start + priv->throttle_time; } return late; -- cgit v1.2.3