From 7aace622671fd6cd8ab7dc8aa6bc6ffa7e38d655 Mon Sep 17 00:00:00 2001 From: Alexander Slobodeniuk Date: Wed, 5 Feb 2025 21:02:16 +0100 Subject: [PATCH] aggregator: fix chaining up in GObject "constructed" virtual methods This doesn't always bring visible issue, but is formally incorrect: not chaining up means that the code doesn't trigger GstObject and GstElement "constructed" implementations. In particular both GstElement's and GstObject's classes in "constructed" may sign up this object for tracing and GstObject's class sets GST_OBJECT_FLAG_CONSTRUCTED flag. If we don't chain up none of this is going to be executed. For example, before the fix leaks tracer couldn't detect this leak: ```c int main (int argc, char **argv) { g_setenv ("GST_TRACERS", "leaks(name=all-leaks)", TRUE); g_setenv ("GST_DEBUG", "GST_TRACER:7", TRUE); g_setenv ("G_DEBUG", "fatal-warnings", TRUE); gst_init (&argc, &argv); // leak audiomixer: doesn't detect because it's based on the aggregator gst_element_factory_make ("audiomixer", "Jerry"); // leak videoconvert: this one is detected fine because it's not // based on the aggregator //gst_element_factory_make ("videoconvert", "Tom"); gst_deinit (); return 0; } // $ cc tst.c $(pkg-config --cflags --libs gstreamer-1.0) -o tst && ./tst ``` Part-of: --- subprojects/gstreamer/libs/gst/base/gstaggregator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/gstreamer/libs/gst/base/gstaggregator.c b/subprojects/gstreamer/libs/gst/base/gstaggregator.c index 3a152e49bf..b2d6fcbe6f 100644 --- a/subprojects/gstreamer/libs/gst/base/gstaggregator.c +++ b/subprojects/gstreamer/libs/gst/base/gstaggregator.c @@ -2849,6 +2849,8 @@ gst_aggregator_constructed (GObject * object) { GstAggregator *agg = GST_AGGREGATOR (object); + G_OBJECT_CLASS (aggregator_parent_class)->constructed (object); + if (agg->priv->force_live) { GST_OBJECT_FLAG_SET (agg, GST_ELEMENT_FLAG_SOURCE); } @@ -3510,6 +3512,8 @@ gst_aggregator_pad_constructed (GObject * object) { GstPad *pad = GST_PAD (object); + G_OBJECT_CLASS (gst_aggregator_pad_parent_class)->constructed (object); + if (GST_PAD_IS_SINK (pad)) { gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_aggregator_pad_chain));