gst/gstelement.c (gst_element_init, gst_element_finalize): Allocate and free the...
authorAndy Wingo <wingo@pobox.com>
Mon, 10 Oct 2005 14:33:13 +0000 (14:33 +0000)
committerAndy Wingo <wingo@pobox.com>
Mon, 10 Oct 2005 14:33:13 +0000 (14:33 +0000)
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.

ChangeLog
gst/gstelement.c
gst/gstelement.h

index 8f02e2689ab9555e220bdfda5d4e3fba56747e60..b31b984f526f64a24d54db845e1c9a1a729b5d9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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:
index 5829b3e2858343a6b62ec17cf1b1b3744f3c7b60..11257c53d388ddc0064a86a6f5e35547d3bdff56 100644 (file)
@@ -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");
 
index 066955705518b40b26bd6bb0574d9d30cecd98fd..d834d3912dfd49c0ef426be44716e3c8eef00bd1 100644 (file)
@@ -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;