From 41fe17addae99eb1494c07a8a92522213a72d956 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 16 Dec 2021 16:43:37 +0100 Subject: [PATCH] uridecodebin: use non-floating object as signal argument ... as was the case with source-setup signal until change of order in commit 52bca104e447309898ca8904b3914211ec7d4114 Part-of: --- subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c index e66f8f7..1f4250f 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin.c @@ -1321,6 +1321,8 @@ static const gchar *adaptive_media[] = { /* * Generate and configure a source element. + * + * Returns: (transfer full): a new #GstElement */ static GstElement * gen_source_element (GstURIDecodeBin * decoder) @@ -1397,6 +1399,15 @@ gen_source_element (GstURIDecodeBin * decoder) g_object_set (source, "subtitle-encoding", decoder->encoding, NULL); } + /* Sink reference before passing it to signal handler. + * Language binding might otherwise sink it and then unref. + * A floating ref is also tricky for a native signal handler in case + * of a "transfer floating" call followed by unref + * (e.g. some container_add and then container_remove). + * Bottom line; best not have a floating ref boldly going into unknown code. + */ + g_object_ref_sink (source); + g_signal_emit (decoder, gst_uri_decode_bin_signals[SIGNAL_SOURCE_SETUP], 0, source); @@ -2262,6 +2273,8 @@ setup_source (GstURIDecodeBin * decoder) /* state will be merged later - if file is not found, error will be * handled by the application right after. */ gst_bin_add (GST_BIN_CAST (decoder), decoder->source); + /* bin now has a ref, but the local reference is not counted */ + g_object_unref (decoder->source); /* notify of the new source used */ g_object_notify (G_OBJECT (decoder), "source"); -- 2.7.4