Commit cfd14e0f authored by Andy Wingo Wingo's avatar Andy Wingo Wingo

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  <wingo@pobox.com>

* 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.
parent 5efcf702
2005-10-10 Andy Wingo <wingo@pobox.com>
* 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:
......
......@@ -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");
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment