From: Sebastian Dröge Date: Fri, 6 Feb 2015 09:33:59 +0000 (+0100) Subject: aggregator: Fix min>max latency error check X-Git-Tag: 1.16.2~574^2~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e57b62be72dc59e8799818427f6a6eb562064f81;p=platform%2Fupstream%2Fgstreamer.git aggregator: Fix min>max latency error check We have to include the upstream latency, our own latency and the subclass latency in the calculations. FIXME: This is still not entirely correct --- diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c index 44cf295..9f29bec 100644 --- a/libs/gst/base/gstaggregator.c +++ b/libs/gst/base/gstaggregator.c @@ -1193,16 +1193,6 @@ gst_aggregator_query_latency (GstAggregator * self, GstQuery * query) GST_OBJECT_LOCK (self); our_latency = self->priv->latency; - if (data.live && GST_CLOCK_TIME_IS_VALID (our_latency) && - our_latency > data.max) { - GST_ELEMENT_WARNING (self, CORE, NEGOTIATION, - ("%s", "Latency too big"), - ("The requested latency value is too big for the current pipeline. " - "Limiting to %" G_GINT64_FORMAT, data.max)); - self->priv->latency = data.max; - /* FIXME: shouldn't we g_object_notify() the change here? */ - } - if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (data.min))) { GST_WARNING_OBJECT (self, "Invalid minimum latency, using 0"); data.min = 0; @@ -1232,6 +1222,18 @@ gst_aggregator_query_latency (GstAggregator * self, GstQuery * query) && GST_CLOCK_TIME_IS_VALID (data.max)) data.max += self->priv->sub_latency_max; + if (data.live && GST_CLOCK_TIME_IS_VALID (our_latency) && data.min > data.max) { + GST_ELEMENT_WARNING (self, CORE, NEGOTIATION, + ("%s", "Latency too big"), + ("The requested latency value is too big for the current pipeline. " + "Limiting to %" G_GINT64_FORMAT, data.max)); + data.min = data.max; + /* FIXME: This could in theory become negative, but in + * that case all is lost anyway */ + self->priv->latency -= data.min - data.max; + /* FIXME: shouldn't we g_object_notify() the change here? */ + } + GST_OBJECT_UNLOCK (self); GST_DEBUG_OBJECT (self, "configured latency live:%s min:%" G_GINT64_FORMAT @@ -1577,19 +1579,33 @@ static void gst_aggregator_set_latency_property (GstAggregator * self, gint64 latency) { gboolean changed; + GstClockTime min, max; g_return_if_fail (GST_IS_AGGREGATOR (self)); GST_OBJECT_LOCK (self); - - if (self->priv->latency_live && self->priv->latency_max != 0 && - GST_CLOCK_TIME_IS_VALID (latency) && latency > self->priv->latency_max) { - GST_ELEMENT_WARNING (self, CORE, NEGOTIATION, - ("%s", "Latency too big"), - ("The requested latency value is too big for the latency in the " - "current pipeline. Limiting to %" G_GINT64_FORMAT, - self->priv->latency_max)); - latency = self->priv->latency_max; + if (self->priv->latency_live) { + min = self->priv->latency_min; + max = self->priv->latency_max; + /* add our own */ + min += latency; + min += self->priv->sub_latency_min; + if (GST_CLOCK_TIME_IS_VALID (self->priv->sub_latency_max) + && GST_CLOCK_TIME_IS_VALID (max)) + max += self->priv->sub_latency_max; + else if (GST_CLOCK_TIME_IS_VALID (self->priv->sub_latency_max)) + max = self->priv->sub_latency_max; + + if (GST_CLOCK_TIME_IS_VALID (max) && min > max) { + GST_ELEMENT_WARNING (self, CORE, NEGOTIATION, + ("%s", "Latency too big"), + ("The requested latency value is too big for the latency in the " + "current pipeline. Limiting to %" G_GINT64_FORMAT, max)); + /* FIXME: This could in theory become negative, but in + * that case all is lost anyway */ + latency -= min - max; + /* FIXME: shouldn't we g_object_notify() the change here? */ + } } changed = (self->priv->latency != latency);