From 90584e29d7397cfa6ffea7207ded677c77eed986 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 5 May 2022 15:05:43 +0300 Subject: [PATCH] aggregator: Only send events up to CAPS event from gst_aggregator_set_src_caps() Otherwise setting the srcpad caps based on the sinkpad caps event will already push a segment event downstream before the upstream segment is known. If the upstream segments are just forwarded when the upstream segment event arrives this would result in two segment events being sent downstream, of which the first one will usually be simply wrong. Part-of: --- subprojects/gstreamer/libs/gst/base/gstaggregator.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/subprojects/gstreamer/libs/gst/base/gstaggregator.c b/subprojects/gstreamer/libs/gst/base/gstaggregator.c index 5990753..a0fbfb3 100644 --- a/subprojects/gstreamer/libs/gst/base/gstaggregator.c +++ b/subprojects/gstreamer/libs/gst/base/gstaggregator.c @@ -600,7 +600,7 @@ gst_aggregator_reset_flow_values (GstAggregator * self) } static inline void -gst_aggregator_push_mandatory_events (GstAggregator * self) +gst_aggregator_push_mandatory_events (GstAggregator * self, gboolean up_to_caps) { GstAggregatorPrivate *priv = self->priv; GstEvent *segment = NULL; @@ -620,7 +620,6 @@ gst_aggregator_push_mandatory_events (GstAggregator * self) } if (self->priv->srccaps) { - GST_INFO_OBJECT (self, "pushing caps: %" GST_PTR_FORMAT, self->priv->srccaps); if (!gst_pad_push_event (GST_PAD (self->srcpad), @@ -631,6 +630,9 @@ gst_aggregator_push_mandatory_events (GstAggregator * self) self->priv->srccaps = NULL; } + if (up_to_caps) + return; + GST_OBJECT_LOCK (self); if (self->priv->send_segment && !self->priv->flushing) { segment = @@ -657,7 +659,6 @@ gst_aggregator_push_mandatory_events (GstAggregator * self) gst_pad_push_event (self->srcpad, segment); if (tags) gst_pad_push_event (self->srcpad, tags); - } /** @@ -672,14 +673,14 @@ gst_aggregator_set_src_caps (GstAggregator * self, GstCaps * caps) { GST_PAD_STREAM_LOCK (self->srcpad); gst_caps_replace (&self->priv->srccaps, caps); - gst_aggregator_push_mandatory_events (self); + gst_aggregator_push_mandatory_events (self, TRUE); GST_PAD_STREAM_UNLOCK (self->srcpad); } static GstFlowReturn gst_aggregator_default_finish_buffer (GstAggregator * self, GstBuffer * buffer) { - gst_aggregator_push_mandatory_events (self); + gst_aggregator_push_mandatory_events (self, FALSE); GST_OBJECT_LOCK (self); if (!self->priv->flushing && gst_pad_is_active (self->srcpad)) { @@ -718,7 +719,7 @@ static GstFlowReturn gst_aggregator_default_finish_buffer_list (GstAggregator * self, GstBufferList * bufferlist) { - gst_aggregator_push_mandatory_events (self); + gst_aggregator_push_mandatory_events (self, FALSE); GST_OBJECT_LOCK (self); if (!self->priv->flushing && gst_pad_is_active (self->srcpad)) { @@ -760,7 +761,7 @@ static void gst_aggregator_push_eos (GstAggregator * self) { GstEvent *event; - gst_aggregator_push_mandatory_events (self); + gst_aggregator_push_mandatory_events (self, FALSE); event = gst_event_new_eos (); -- 2.7.4