summaryrefslogtreecommitdiff
path: root/gst/rtpmanager/gstrtpbin.c
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2018-01-15 18:13:37 +0100
committerMathieu Duponchelle <mathieu@centricular.com>2018-01-18 15:26:43 +0100
commit03dc22951bacb6fdc3868c8f801e6a52c33a745f (patch)
tree873f2e4ac6666a1d9de5ca8a1a7bcd16fdf2aff4 /gst/rtpmanager/gstrtpbin.c
parentf7e280bf0d90b0ee2732ee5918115762889a3e88 (diff)
rtpbin: fix leak of elements requested by signals
When the signal returns a floating reference, as its return type is transfer full, we need to sink it ourselves before passing it to gst_bin_add (which is transfer floating). This allows us to unref it in bin_remove_element later on, and thus to also release the reference we now own if the signal returns a non-floating reference as well. As we now still hold a reference to the element when removing it, we also need to lock its state and setting it to NULL before unreffing it Also update the request_aux_sender test. https://bugzilla.gnome.org/show_bug.cgi?id=792543
Diffstat (limited to 'gst/rtpmanager/gstrtpbin.c')
-rw-r--r--gst/rtpmanager/gstrtpbin.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index 9b2c0396d..d848711a3 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -865,6 +865,10 @@ bin_manage_element (GstRtpBin * bin, GstElement * element)
GST_DEBUG_OBJECT (bin, "requested element %p already in bin", element);
} else {
GST_DEBUG_OBJECT (bin, "adding requested element %p", element);
+
+ if (g_object_is_floating (element))
+ element = gst_object_ref_sink (element);
+
if (!gst_bin_add (GST_BIN_CAST (bin), element))
goto add_failed;
if (!gst_element_sync_state_with_parent (element))
@@ -880,6 +884,7 @@ bin_manage_element (GstRtpBin * bin, GstElement * element)
add_failed:
{
GST_WARNING_OBJECT (bin, "unable to add element");
+ gst_object_unref (element);
return FALSE;
}
}
@@ -894,10 +899,13 @@ remove_bin_element (GstElement * element, GstRtpBin * bin)
if (find) {
priv->elements = g_list_delete_link (priv->elements, find);
- if (!g_list_find (priv->elements, element))
+ if (!g_list_find (priv->elements, element)) {
+ gst_element_set_locked_state (element, TRUE);
gst_bin_remove (GST_BIN_CAST (bin), element);
- else
- gst_object_unref (element);
+ gst_element_set_state (element, GST_STATE_NULL);
+ }
+
+ gst_object_unref (element);
}
}