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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8416>
This commit is contained in:
Alexander Slobodeniuk 2025-02-05 21:02:16 +01:00 committed by GStreamer Marge Bot
parent 178f05aac7
commit 7aace62267

View file

@ -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));