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:
{
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 ();
}
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");
* 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));
/*< public >*/ /* with STATE_LOCK */
/* element state */
- GMutex *state_lock;
+ GStaticRecMutex *state_lock;
GCond *state_cond;
guint8 current_state;
guint8 pending_state;