From cfd14e0fd38c332c85437b2eb2b4abea69e451da Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 10 Oct 2005 14:33:13 +0000 Subject: [PATCH] gst/gstelement.c (gst_element_init, gst_element_finalize): Allocate and free the mutex properly. Original commit message from CVS: 2005-10-10 Andy Wingo * gst/gstelement.c (gst_element_init, gst_element_finalize): Allocate and free the mutex properly. * gst/gstelement.h (GST_STATE_UNLOCK_FULL, GST_STATE_LOCK_FULL): New macros. (GstElement): The state_lock is now recursive. Rebuild your plugins, suckers. Old macros adapted. --- ChangeLog | 8 ++++++++ gst/gstelement.c | 5 +++-- gst/gstelement.h | 17 ++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f02e26..b31b984 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2005-10-10 Andy Wingo + * gst/gstelement.c (gst_element_init, gst_element_finalize): + Allocate and free the mutex properly. + + * gst/gstelement.h (GST_STATE_UNLOCK_FULL, GST_STATE_LOCK_FULL): + New macros. + (GstElement): The state_lock is now recursive. Rebuild your + plugins, suckers. Old macros adapted. + * docs/gst/gstreamer-sections.txt: Doc updates. * gst/gstutils.h: diff --git a/gst/gstelement.c b/gst/gstelement.c index 5829b3e..11257c5 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -241,7 +241,8 @@ gst_element_init (GstElement * element) { element->current_state = GST_STATE_NULL; element->pending_state = GST_STATE_VOID_PENDING; - element->state_lock = g_mutex_new (); + element->state_lock = g_new0 (GStaticRecMutex, 1); + g_static_rec_mutex_init (element->state_lock); element->state_cond = g_cond_new (); } @@ -2213,7 +2214,7 @@ gst_element_finalize (GObject * object) g_cond_free (element->state_cond); element->state_cond = NULL; GST_STATE_UNLOCK (element); - g_mutex_free (element->state_lock); + g_static_rec_mutex_free (element->state_lock); GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize parent"); diff --git a/gst/gstelement.h b/gst/gstelement.h index 0669557..d834d39 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -274,13 +274,16 @@ G_STMT_START { \ * This function is used by the core. It is taken while getting or setting * the state, during state changes, and while finalizing. */ -#define GST_STATE_LOCK(elem) g_mutex_lock(GST_STATE_GET_LOCK(elem)) -#define GST_STATE_TRYLOCK(elem) g_mutex_trylock(GST_STATE_GET_LOCK(elem)) -#define GST_STATE_UNLOCK(elem) g_mutex_unlock(GST_STATE_GET_LOCK(elem)) +#define GST_STATE_LOCK(elem) g_static_rec_mutex_lock(GST_STATE_GET_LOCK(elem)) +#define GST_STATE_TRYLOCK(elem) g_static_rec_mutex_trylock(GST_STATE_GET_LOCK(elem)) +#define GST_STATE_UNLOCK(elem) g_static_rec_mutex_unlock(GST_STATE_GET_LOCK(elem)) +#define GST_STATE_UNLOCK_FULL(elem) g_static_rec_mutex_unlock_full(GST_STATE_GET_LOCK(elem)) +#define GST_STATE_LOCK_FULL(elem,t) g_static_rec_mutex_lock_full(GST_STATE_GET_LOCK(elem), t) #define GST_STATE_GET_COND(elem) (GST_ELEMENT_CAST(elem)->state_cond) -#define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem)) -#define GST_STATE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem),\ - timeval) +#define GST_STATE_WAIT(elem) g_static_rec_cond_wait (GST_STATE_GET_COND (elem), \ + GST_STATE_GET_LOCK (elem)) +#define GST_STATE_TIMED_WAIT(elem, timeval) g_static_rec_cond_timed_wait (GST_STATE_GET_COND (elem), \ + GST_STATE_GET_LOCK (elem), timeval) #define GST_STATE_SIGNAL(elem) g_cond_signal (GST_STATE_GET_COND (elem)); #define GST_STATE_BROADCAST(elem) g_cond_broadcast (GST_STATE_GET_COND (elem)); @@ -290,7 +293,7 @@ struct _GstElement /*< public >*/ /* with STATE_LOCK */ /* element state */ - GMutex *state_lock; + GStaticRecMutex *state_lock; GCond *state_cond; guint8 current_state; guint8 pending_state; -- 2.7.4