glvideomixer: Keep a reference to the underlying pad

There was cases where we were accessing the pad while it was already
destroyed. Ensure it can't happen by owning a ref on it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3916>
This commit is contained in:
Thibault Saunier 2023-02-10 08:20:38 -03:00 committed by GStreamer Marge Bot
parent 04615ca55a
commit dc1c9c8985

View file

@ -234,6 +234,7 @@ static void gst_gl_video_mixer_input_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static gboolean gst_gl_video_mixer_src_event (GstAggregator * agg,
GstEvent * event);
static void gst_gl_video_mixer_input_dispose (GObject * object);
typedef struct _GstGLVideoMixerInput GstGLVideoMixerInput;
typedef GstGhostPadClass GstGLVideoMixerInputClass;
@ -263,6 +264,7 @@ gst_gl_video_mixer_input_class_init (GstGLVideoMixerInputClass * klass)
gobject_class->set_property = gst_gl_video_mixer_input_set_property;
gobject_class->get_property = gst_gl_video_mixer_input_get_property;
gobject_class->dispose = gst_gl_video_mixer_input_dispose;
g_object_class_install_property (gobject_class, PROP_INPUT_ZORDER,
g_param_spec_uint ("zorder", "Z-Order", "Z Order of the picture",
@ -492,6 +494,14 @@ gst_gl_video_mixer_input_set_property (GObject * object, guint prop_id,
g_object_set_property (G_OBJECT (self->mixer_pad), pspec->name, value);
}
static void
gst_gl_video_mixer_input_dispose (GObject * object)
{
GstGLVideoMixerInput *self = (GstGLVideoMixerInput *) object;
gst_clear_object (&self->mixer_pad);
}
static GstGhostPad *
_create_video_mixer_input (GstGLMixerBin * self, GstPad * mixer_pad)
{
@ -525,7 +535,7 @@ _create_video_mixer_input (GstGLMixerBin * self, GstPad * mixer_pad)
ADD_BINDING (mixer_pad, input, "yalign");
#undef ADD_BINDING
input->mixer_pad = mixer_pad;
input->mixer_pad = gst_object_ref (mixer_pad);
return GST_GHOST_PAD (input);
}