mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 07:08:23 +00:00
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.
This commit is contained in:
parent
5efcf702e4
commit
cfd14e0fd3
3 changed files with 21 additions and 9 deletions
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue