aggregator: fix live query when force-live is TRUE

When force-live is TRUE, aggregator will correctly change its state with
NO_PREROLL, but unless something upstream is live did not previously set
live to TRUE on the latency query.

Fix this by or'ing force_live into the result.

Also improve debug

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7718>
This commit is contained in:
Mathieu Duponchelle 2024-10-23 16:14:45 +02:00 committed by GStreamer Marge Bot
parent ff6ad49557
commit 5e8359d407

View file

@ -2279,9 +2279,11 @@ gst_aggregator_request_new_pad (GstElement * element,
static gboolean static gboolean
gst_aggregator_query_latency_unlocked (GstAggregator * self, GstQuery * query) gst_aggregator_query_latency_unlocked (GstAggregator * self, GstQuery * query)
{ {
gboolean query_ret, live; gboolean query_ret, upstream_live;
GstClockTime our_latency, min, max; GstClockTime our_latency, min, max;
GST_TRACE_OBJECT (self, "querying latency");
/* Temporarily release the lock to do the query. */ /* Temporarily release the lock to do the query. */
SRC_UNLOCK (self); SRC_UNLOCK (self);
query_ret = gst_pad_query_default (self->srcpad, GST_OBJECT (self), query); query_ret = gst_pad_query_default (self->srcpad, GST_OBJECT (self), query);
@ -2292,7 +2294,12 @@ gst_aggregator_query_latency_unlocked (GstAggregator * self, GstQuery * query)
return FALSE; return FALSE;
} }
gst_query_parse_latency (query, &live, &min, &max); gst_query_parse_latency (query, &upstream_live, &min, &max);
GST_LOG_OBJECT (self,
"queried upstream latency, live: %s min: %" GST_TIME_FORMAT " max: %"
GST_TIME_FORMAT, upstream_live ? "true" : "false", GST_TIME_ARGS (min),
GST_TIME_ARGS (max));
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (min))) { if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (min))) {
GST_ERROR_OBJECT (self, "Invalid minimum latency %" GST_TIME_FORMAT GST_ERROR_OBJECT (self, "Invalid minimum latency %" GST_TIME_FORMAT
@ -2322,7 +2329,7 @@ gst_aggregator_query_latency_unlocked (GstAggregator * self, GstQuery * query)
our_latency = self->priv->latency; our_latency = self->priv->latency;
self->priv->peer_latency_live = live; self->priv->peer_latency_live = upstream_live;
self->priv->peer_latency_min = min; self->priv->peer_latency_min = min;
self->priv->peer_latency_max = max; self->priv->peer_latency_max = max;
self->priv->has_peer_latency = TRUE; self->priv->has_peer_latency = TRUE;
@ -2339,9 +2346,10 @@ gst_aggregator_query_latency_unlocked (GstAggregator * self, GstQuery * query)
SRC_BROADCAST (self); SRC_BROADCAST (self);
GST_DEBUG_OBJECT (self, "configured latency live:%s min:%" G_GINT64_FORMAT GST_DEBUG_OBJECT (self, "configured latency live:%s min:%" G_GINT64_FORMAT
" max:%" G_GINT64_FORMAT, live ? "true" : "false", min, max); " max:%" G_GINT64_FORMAT,
is_live_unlocked (self) ? "true" : "false", min, max);
gst_query_set_latency (query, live, min, max); gst_query_set_latency (query, is_live_unlocked (self), min, max);
return query_ret; return query_ret;
} }