encodebasebin: GstPad and GstStructure leak fixes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9167>
This commit is contained in:
Philippe Normand 2025-06-04 11:57:38 +02:00 committed by GStreamer Marge Bot
parent 1d20fd15b0
commit 3b896cd4ea

View File

@ -947,7 +947,7 @@ set_element_properties_from_encoding_profile (GstEncodingProfile * profile,
if (!factory) {
GST_INFO_OBJECT (profile, "No factory for underlying element, "
"not setting properties");
return;
goto done;
}
v = gst_structure_get_value (properties, "map");
@ -1522,7 +1522,7 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
const gchar * sinkpadname, GstCaps * sinkcaps, gboolean * encoder_not_found)
{
StreamGroup *sgroup = NULL;
GstPad *sinkpad, *srcpad = NULL, *muxerpad = NULL;
GstPad *sinkpad = NULL, *srcpad = NULL, *muxerpad = NULL;
/* Element we will link to the encoder */
GstElement *last = NULL;
GstElement *encoder = NULL;
@ -1751,7 +1751,8 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
gst_bin_add ((GstBin *) ebin, sgroup->smartencoder);
srcpad = gst_element_get_static_pad (sgroup->smartencoder, "src");
fast_pad_link (srcpad, sinkpad);
gst_object_unref (srcpad);
gst_clear_object (&srcpad);
gst_clear_object (&sinkpad);
tosync = g_list_append (tosync, sgroup->smartencoder);
sinkpad = gst_element_get_static_pad (sgroup->smartencoder, "sink");
}
@ -1766,9 +1767,8 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
/* Go straight to splitter */
if (G_UNLIKELY (fast_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK))
goto passthrough_link_failure;
gst_object_unref (sinkpad);
gst_object_unref (srcpad);
srcpad = NULL;
gst_clear_object (&sinkpad);
gst_clear_object (&srcpad);
/* Path 2 : Conversion / Encoding */
@ -1786,9 +1786,8 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
srcpad = gst_element_get_static_pad (sgroup->encoder, "src");
if (G_UNLIKELY (fast_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK))
goto encoder_link_failure;
gst_object_unref (sinkpad);
gst_object_unref (srcpad);
srcpad = NULL;
gst_clear_object (&sinkpad);
gst_clear_object (&srcpad);
}
@ -1940,6 +1939,8 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
}
/* Link to stream splitter */
gst_clear_object (&sinkpad);
gst_clear_object (&srcpad);
sinkpad = gst_element_get_static_pad (last, "sink");
srcpad =
local_element_request_pad (sgroup->splitter, NULL, "encodingsrc", NULL);
@ -1947,9 +1948,8 @@ _create_stream_group (GstEncodeBaseBin * ebin, GstEncodingProfile * sprof,
goto no_splitter_srcpad;
if (G_UNLIKELY (fast_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK))
goto splitter_encoding_failure;
gst_object_unref (sinkpad);
gst_object_unref (srcpad);
srcpad = NULL;
gst_clear_object (&sinkpad);
gst_clear_object (&srcpad);
/* End of Stream 2 setup */
@ -2054,8 +2054,8 @@ cleanup:
gst_caps_unref (format);
if (restriction)
gst_caps_unref (restriction);
if (srcpad)
gst_object_unref (srcpad);
gst_clear_object (&sinkpad);
gst_clear_object (&srcpad);
stream_group_free (ebin, sgroup);
g_list_free (tosync);
return NULL;