summaryrefslogtreecommitdiff
path: root/gst/playback
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-04-21 02:05:36 +0900
committerSeungha Yang <seungha@centricular.com>2021-04-21 02:40:06 +0900
commite7855606876f558490e62d0af8cc79db1f12edb0 (patch)
tree9673013dd74d0d7cbd7a9f51c08f602d564d3e6e /gst/playback
parent3a1816bf3f04622b63e9cb1aba3a3a09c110d9be (diff)
downloadgstreamer-plugins-base-e7855606876f558490e62d0af8cc79db1f12edb0.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/1113>
Diffstat (limited to 'gst/playback')
-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 3837b25b9..dc6984d98 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;
@@ -1690,8 +1692,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);
@@ -1810,6 +1810,7 @@ static GstElement *
make_decoder (GstURIDecodeBin * decoder)
{
GstElement *decodebin;
+ gboolean unref_dbin = FALSE;
/* re-use pending decodebin */
if (decoder->pending_decodebins) {
@@ -1818,6 +1819,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");
@@ -1900,6 +1902,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;