glmixer: unref the GstGLUpload in the pad if freed while running
authorMatthew Waters <ystreet00@gmail.com>
Tue, 19 Aug 2014 07:01:36 +0000 (17:01 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:45 +0000 (19:31 +0000)
Dynamic pipelines that get and release the sink pads will finalize
the pad without going through gst_gl_mixer_stop() which is where the
upload object is usually freed.  Don't leak objects in such case.

ext/gl/gstglmixer.c

index 1420b83..62bb4d4 100644 (file)
@@ -49,6 +49,7 @@ static void gst_gl_mixer_pad_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 static void gst_gl_mixer_pad_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
+static void gst_gl_mixer_pad_finalize (GObject * object);
 
 static void gst_gl_mixer_set_context (GstElement * element,
     GstContext * context);
@@ -85,6 +86,19 @@ gst_gl_mixer_pad_class_init (GstGLMixerPadClass * klass)
 
   gobject_class->set_property = gst_gl_mixer_pad_set_property;
   gobject_class->get_property = gst_gl_mixer_pad_get_property;
+
+  gobject_class->finalize = gst_gl_mixer_pad_finalize;
+}
+
+static void
+gst_gl_mixer_pad_finalize (GObject * object)
+{
+  GstGLMixerPad *pad = GST_GL_MIXER_PAD (object);
+
+  if (pad->upload) {
+    gst_object_unref (pad->upload);
+    pad->upload = NULL;
+  }
 }
 
 static void