summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-04-21 02:05:36 +0900
committerTim-Philipp Müller <tim@centricular.com>2021-04-21 23:32:02 +0100
commit5c504d023b9722fe4e53341121f338e9caf5400f (patch)
tree9274bac3b6d3d64bb344b9d74f1e132049136641
parentd8f473ea3ea4609ece8a820105851960a5ce12d7 (diff)
downloadgstreamer-plugins-base-5c504d023b9722fe4e53341121f338e9caf5400f.tar.gz
uridecodebin: Don't force floating reference for future reusable decodebin
uridecodebin assumes that refcount of decodebins stored in pending_decodebins are floating but it might not be true in case that refcount of the decodebin was touched in other places. To avoid the floating refcount issue, hold strong reference. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1119>
-rw-r--r--gst/playback/gsturidecodebin.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c
index 5fb30fd02..f4d9f59c0 100644
--- a/gst/playback/gsturidecodebin.c
+++ b/gst/playback/gsturidecodebin.c
@@ -101,7 +101,9 @@ struct _GstURIDecodeBin
GstElement *queue;
GstElement *typefind;
guint have_type_id; /* have-type signal id from typefind */
+ /* without holding ref */
GSList *decodebins;
+ /* Holding strong reference to decodebin */
GSList *pending_decodebins;
GHashTable *streams;
guint numpads;
@@ -1689,8 +1691,6 @@ remove_decoders (GstURIDecodeBin * bin, gboolean force)
caps = DEFAULT_CAPS;
g_object_set (decoder, "caps", caps, NULL);
gst_caps_unref (caps);
- /* make it freshly floating again */
- g_object_force_floating (G_OBJECT (decoder));
bin->pending_decodebins =
g_slist_prepend (bin->pending_decodebins, decoder);
@@ -1809,6 +1809,7 @@ static GstElement *
make_decoder (GstURIDecodeBin * decoder)
{
GstElement *decodebin;
+ gboolean unref_dbin = FALSE;
/* re-use pending decodebin */
if (decoder->pending_decodebins) {
@@ -1817,6 +1818,7 @@ make_decoder (GstURIDecodeBin * decoder)
decodebin = (GstElement *) first->data;
decoder->pending_decodebins =
g_slist_delete_link (decoder->pending_decodebins, first);
+ unref_dbin = TRUE;
} else {
GST_LOG_OBJECT (decoder, "making new decodebin");
@@ -1899,6 +1901,11 @@ make_decoder (GstURIDecodeBin * decoder)
gst_bin_add (GST_BIN_CAST (decoder), decodebin);
decoder->decodebins = g_slist_prepend (decoder->decodebins, decodebin);
+ /* Unref if this decodebin came from our pending_decodebins,
+ * since we were holding strong reference to decodebin and gst_bin_add()
+ * will increase refcount */
+ if (unref_dbin)
+ gst_object_unref (decodebin);
return decodebin;