From 6e89c000bbdfa066424e3d21242bacbf5a207c3e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 6 Sep 2004 15:14:01 +0000 Subject: [PATCH] gst/gstelement.c: Added extra refcounting around various places. Original commit message from CVS: * gst/gstelement.c: (gst_element_threadsafe_properties_pre_run), (gst_element_threadsafe_properties_post_run), (gst_element_set_state), (gst_element_change_state): Added extra refcounting around various places. --- ChangeLog | 7 +++++++ gst/gstelement.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78aafcfba7..ac6672dcae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-09-06 Wim Taymans + + * gst/gstelement.c: (gst_element_threadsafe_properties_pre_run), + (gst_element_threadsafe_properties_post_run), + (gst_element_set_state), (gst_element_change_state): + Added extra refcounting around various places. + 2004-09-06 Wim Taymans * gst/gstpad.c: (gst_pad_link_call_link_functions): diff --git a/gst/gstelement.c b/gst/gstelement.c index 8defdd7c9c..f44b7d803a 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -296,6 +296,9 @@ element_get_property (GstElement * element, const GParamSpec * pspec, static void gst_element_threadsafe_properties_pre_run (GstElement * element) { + /* need to ref the object because we don't want to lose the object + * before the post run function is called */ + gst_object_ref (GST_OBJECT (element)); GST_DEBUG ("locking element %s", GST_OBJECT_NAME (element)); g_mutex_lock (element->property_mutex); gst_element_set_pending_properties (element); @@ -306,6 +309,7 @@ gst_element_threadsafe_properties_post_run (GstElement * element) { GST_DEBUG ("unlocking element %s", GST_OBJECT_NAME (element)); g_mutex_unlock (element->property_mutex); + gst_object_unref (GST_OBJECT (element)); } /** @@ -2722,14 +2726,20 @@ GstElementStateReturn gst_element_set_state (GstElement * element, GstElementState state) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); + GstElementStateReturn ret; g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); GST_DEBUG_OBJECT (element, "setting state to %s", gst_element_state_get_name (state)); klass = GST_ELEMENT_GET_CLASS (element); - /* a set_state function is mandatory */ g_return_val_if_fail (klass->set_state, GST_STATE_FAILURE); - return klass->set_state (element, state); + + /* a set_state function is mandatory */ + gst_object_ref (GST_OBJECT (element)); + ret = klass->set_state (element, state); + gst_object_unref (GST_OBJECT (element)); + + return ret; } static GstElementStateReturn @@ -3004,7 +3014,6 @@ gst_element_change_state (GstElement * element) * - a new state was added * - somehow the element was asked to jump across an intermediate state */ - g_assert_not_reached (); break; } @@ -3036,9 +3045,7 @@ gst_element_change_state (GstElement * element) 0, old_state, GST_STATE (element)); /* signal the state change in case somebody is waiting for us */ - g_mutex_lock (element->state_mutex); g_cond_signal (element->state_cond); - g_mutex_unlock (element->state_mutex); gst_object_unref (GST_OBJECT (element)); return GST_STATE_SUCCESS;