Commit 252327f8 authored by Wim Taymans's avatar Wim Taymans

Update for new gthread API

parent 8af013f3
......@@ -63,71 +63,6 @@ typedef struct stat GStatBuf;
/* copies */
#if GLIB_CHECK_VERSION (2, 31, 0)
#define g_mutex_new gst_g_mutex_new
static inline GMutex *
gst_g_mutex_new (void)
{
GMutex *mutex = g_slice_new (GMutex);
g_mutex_init (mutex);
return mutex;
}
#define g_mutex_free gst_g_mutex_free
static inline void
gst_g_mutex_free (GMutex *mutex)
{
g_mutex_clear (mutex);
g_slice_free (GMutex, mutex);
}
#define g_static_rec_mutex_init gst_g_static_rec_mutex_init
static inline void
gst_g_static_rec_mutex_init (GStaticRecMutex *mutex)
{
static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
*mutex = init_mutex;
}
#define g_cond_new gst_g_cond_new
static inline GCond *
gst_g_cond_new (void)
{
GCond *cond = g_slice_new (GCond);
g_cond_init (cond);
return cond;
}
#define g_cond_free gst_g_cond_free
static inline void
gst_g_cond_free (GCond *cond)
{
g_cond_clear (cond);
g_slice_free (GCond, cond);
}
#define g_cond_timed_wait gst_g_cond_timed_wait
static inline gboolean
gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
{
gint64 end_time;
if (abs_time == NULL) {
g_cond_wait (cond, mutex);
return TRUE;
}
end_time = abs_time->tv_sec;
end_time *= 1000000;
end_time += abs_time->tv_usec;
/* would be nice if we had clock_rtoffset, but that didn't seem to
* make it into the kernel yet...
*/
/* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and
* g_get_real_time() are returning the same clock and we'd add ~0
*/
end_time += g_get_monotonic_time () - g_get_real_time ();
return g_cond_wait_until (cond, mutex, end_time);
}
#endif /* GLIB_CHECK_VERSION (2, 31, 0) */
/* adaptations */
G_END_DECLS
......
......@@ -157,9 +157,6 @@
* Last reviewed on 2006-04-28 (0.10.6)
*/
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gst_private.h"
#include "gstevent.h"
......
......@@ -26,9 +26,6 @@
*
*/
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gst_private.h"
#include "glib-compat-private.h"
......@@ -49,12 +46,12 @@ GST_DEBUG_CATEGORY_STATIC (gst_buffer_pool_debug);
#define GST_BUFFER_POOL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolPrivate))
#define GST_BUFFER_POOL_LOCK(pool) (g_static_rec_mutex_lock(&pool->priv->rec_lock))
#define GST_BUFFER_POOL_UNLOCK(pool) (g_static_rec_mutex_unlock(&pool->priv->rec_lock))
#define GST_BUFFER_POOL_LOCK(pool) (g_rec_mutex_lock(&pool->priv->rec_lock))
#define GST_BUFFER_POOL_UNLOCK(pool) (g_rec_mutex_unlock(&pool->priv->rec_lock))
struct _GstBufferPoolPrivate
{
GStaticRecMutex rec_lock;
GRecMutex rec_lock;
guint size;
guint min_buffers;
guint max_buffers;
......@@ -112,7 +109,7 @@ gst_buffer_pool_init (GstBufferPool * pool)
{
pool->priv = GST_BUFFER_POOL_GET_PRIVATE (pool);
g_static_rec_mutex_init (&pool->priv->rec_lock);
g_rec_mutex_init (&pool->priv->rec_lock);
pool->poll = gst_poll_new_timer ();
pool->queue = gst_atomic_queue_new (10);
......@@ -140,7 +137,7 @@ gst_buffer_pool_finalize (GObject * object)
gst_atomic_queue_unref (pool->queue);
gst_poll_free (pool->poll);
gst_structure_free (pool->config);
g_static_rec_mutex_free (&pool->priv->rec_lock);
g_rec_mutex_clear (&pool->priv->rec_lock);
G_OBJECT_CLASS (gst_buffer_pool_parent_class)->finalize (object);
}
......
......@@ -211,7 +211,7 @@ static void
gst_bus_init (GstBus * bus)
{
bus->queue = gst_atomic_queue_new (32);
bus->queue_lock = g_mutex_new ();
g_mutex_init (&bus->queue_lock);
bus->priv = G_TYPE_INSTANCE_GET_PRIVATE (bus, GST_TYPE_BUS, GstBusPrivate);
bus->priv->enable_async = DEFAULT_ENABLE_ASYNC;
......@@ -227,7 +227,7 @@ gst_bus_dispose (GObject * object)
if (bus->queue) {
GstMessage *message;
g_mutex_lock (bus->queue_lock);
g_mutex_lock (&bus->queue_lock);
do {
message = gst_atomic_queue_pop (bus->queue);
if (message)
......@@ -235,9 +235,8 @@ gst_bus_dispose (GObject * object)
} while (message != NULL);
gst_atomic_queue_unref (bus->queue);
bus->queue = NULL;
g_mutex_unlock (bus->queue_lock);
g_mutex_free (bus->queue_lock);
bus->queue_lock = NULL;
g_mutex_unlock (&bus->queue_lock);
g_mutex_clear (&bus->queue_lock);
if (bus->priv->poll)
gst_poll_free (bus->priv->poll);
......@@ -334,11 +333,11 @@ gst_bus_post (GstBus * bus, GstMessage * message)
{
/* async delivery, we need a mutex and a cond to block
* on */
GMutex *lock = g_mutex_new ();
GCond *cond = g_cond_new ();
GCond *cond = GST_MESSAGE_GET_COND (message);
GMutex *lock = GST_MESSAGE_GET_LOCK (message);
GST_MESSAGE_COND (message) = cond;
GST_MESSAGE_GET_LOCK (message) = lock;
g_cond_init (cond);
g_mutex_init (lock);
GST_DEBUG_OBJECT (bus, "[msg %p] waiting for async delivery", message);
......@@ -356,8 +355,8 @@ gst_bus_post (GstBus * bus, GstMessage * message)
GST_DEBUG_OBJECT (bus, "[msg %p] delivered asynchronously", message);
g_mutex_free (lock);
g_cond_free (cond);
g_mutex_clear (lock);
g_cond_clear (cond);
break;
}
default:
......@@ -471,7 +470,7 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
g_return_val_if_fail (types != 0, NULL);
g_return_val_if_fail (timeout == 0 || bus->priv->poll != NULL, NULL);
g_mutex_lock (bus->queue_lock);
g_mutex_lock (&bus->queue_lock);
while (TRUE) {
gint ret;
......@@ -516,9 +515,9 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
/* only here in timeout case */
g_assert (bus->priv->poll);
g_mutex_unlock (bus->queue_lock);
g_mutex_unlock (&bus->queue_lock);
ret = gst_poll_wait (bus->priv->poll, timeout - elapsed);
g_mutex_lock (bus->queue_lock);
g_mutex_lock (&bus->queue_lock);
if (ret == 0) {
GST_INFO_OBJECT (bus, "timed out, breaking loop");
......@@ -530,7 +529,7 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
beach:
g_mutex_unlock (bus->queue_lock);
g_mutex_unlock (&bus->queue_lock);
return message;
}
......@@ -550,7 +549,7 @@ beach:
* Returns: (transfer full): the #GstMessage that is on the bus after the
* specified timeout or NULL if the bus is empty after the timeout expired.
* The message is taken from the bus and needs to be unreffed with
* gst_message_unref() after usage.
* gst_message_unre:f() after usage.
*
* MT safe.
*
......@@ -632,11 +631,11 @@ gst_bus_peek (GstBus * bus)
g_return_val_if_fail (GST_IS_BUS (bus), NULL);
g_mutex_lock (bus->queue_lock);
g_mutex_lock (&bus->queue_lock);
message = gst_atomic_queue_peek (bus->queue);
if (message)
gst_message_ref (message);
g_mutex_unlock (bus->queue_lock);
g_mutex_unlock (&bus->queue_lock);
GST_DEBUG_OBJECT (bus, "peek on bus, got message %p", message);
......
......@@ -117,7 +117,7 @@ struct _GstBus
/*< private >*/
GstAtomicQueue *queue;
GMutex *queue_lock;
GMutex queue_lock;
GstBusSyncHandler sync_handler;
gpointer sync_handler_data;
......
......@@ -693,7 +693,7 @@ gst_clock_init (GstClock * clock)
{
clock->last_time = 0;
clock->entries = NULL;
clock->entries_changed = g_cond_new ();
g_cond_init (&clock->entries_changed);
clock->stats = FALSE;
clock->priv =
......@@ -704,7 +704,7 @@ gst_clock_init (GstClock * clock)
clock->rate_numerator = 1;
clock->rate_denominator = 1;
clock->slave_lock = g_mutex_new ();
g_mutex_init (&clock->slave_lock);
clock->window_size = DEFAULT_WINDOW_SIZE;
clock->window_threshold = DEFAULT_WINDOW_THRESHOLD;
clock->filling = TRUE;
......@@ -742,8 +742,8 @@ gst_clock_finalize (GObject * object)
clock->times = NULL;
GST_CLOCK_SLAVE_UNLOCK (clock);
g_cond_free (clock->entries_changed);
g_mutex_free (clock->slave_lock);
g_cond_clear (&clock->entries_changed);
g_mutex_clear (&clock->slave_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......
......@@ -35,8 +35,8 @@ G_BEGIN_DECLS
#define GST_CLOCK_GET_CLASS(clock) (G_TYPE_INSTANCE_GET_CLASS ((clock), GST_TYPE_CLOCK, GstClockClass))
#define GST_CLOCK_CAST(clock) ((GstClock*)(clock))
#define GST_CLOCK_SLAVE_LOCK(clock) g_mutex_lock (GST_CLOCK_CAST (clock)->slave_lock)
#define GST_CLOCK_SLAVE_UNLOCK(clock) g_mutex_unlock (GST_CLOCK_CAST (clock)->slave_lock)
#define GST_CLOCK_SLAVE_LOCK(clock) g_mutex_lock (&GST_CLOCK_CAST (clock)->slave_lock)
#define GST_CLOCK_SLAVE_UNLOCK(clock) g_mutex_unlock (&GST_CLOCK_CAST (clock)->slave_lock)
/**
* GstClockTime:
......@@ -409,20 +409,20 @@ typedef enum {
#define GST_CLOCK_FLAGS(clock) GST_OBJECT_FLAGS(clock)
/**
* GST_CLOCK_COND:
* GST_CLOCK_GET_COND:
* @clock: the clock to query
*
* Gets the #GCond that gets signalled when the entries of the clock
* changed.
*/
#define GST_CLOCK_COND(clock) (GST_CLOCK_CAST(clock)->entries_changed)
#define GST_CLOCK_GET_COND(clock) (&GST_CLOCK_CAST(clock)->entries_changed)
/**
* GST_CLOCK_WAIT:
* @clock: the clock to wait on
*
* Wait on the clock until the entries changed.
*/
#define GST_CLOCK_WAIT(clock) g_cond_wait(GST_CLOCK_COND(clock),GST_OBJECT_GET_LOCK(clock))
#define GST_CLOCK_WAIT(clock) g_cond_wait(GST_CLOCK_GET_COND(clock),GST_OBJECT_GET_LOCK(clock))
/**
* GST_CLOCK_TIMED_WAIT:
* @clock: the clock to wait on
......@@ -431,14 +431,14 @@ typedef enum {
* Wait on the clock until the entries changed or the specified timeout
* occurred.
*/
#define GST_CLOCK_TIMED_WAIT(clock,tv) g_cond_timed_wait(GST_CLOCK_COND(clock),GST_OBJECT_GET_LOCK(clock),tv)
#define GST_CLOCK_TIMED_WAIT(clock,tv) g_cond_timed_wait(GST_CLOCK_GET_COND(clock),GST_OBJECT_GET_LOCK(clock),tv)
/**
* GST_CLOCK_BROADCAST:
* @clock: the clock to broadcast
*
* Signal that the entries in the clock have changed.
*/
#define GST_CLOCK_BROADCAST(clock) g_cond_broadcast(GST_CLOCK_COND(clock))
#define GST_CLOCK_BROADCAST(clock) g_cond_broadcast(GST_CLOCK_GET_COND(clock))
/**
* GstClock:
......@@ -449,7 +449,7 @@ typedef enum {
struct _GstClock {
GstObject object;
GMutex *slave_lock; /* order: SLAVE_LOCK, OBJECT_LOCK */
GMutex slave_lock; /* order: SLAVE_LOCK, OBJECT_LOCK */
/*< protected >*/ /* with LOCK */
GstClockTime internal_calibration;
......@@ -458,7 +458,7 @@ struct _GstClock {
GstClockTime rate_denominator;
GstClockTime last_time;
GList *entries;
GCond *entries_changed;
GCond entries_changed;
/*< private >*/ /* with LOCK */
GstClockTime resolution;
......
......@@ -79,9 +79,6 @@
* Last reviewed on 2009-05-29 (0.10.24)
*/
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gst_private.h"
#include <glib.h>
#include <stdarg.h>
......@@ -294,8 +291,8 @@ gst_element_init (GstElement * element)
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
GST_STATE_RETURN (element) = GST_STATE_CHANGE_SUCCESS;
g_static_rec_mutex_init (&element->state_lock);
element->state_cond = g_cond_new ();
g_rec_mutex_init (&element->state_lock);
g_cond_init (&element->state_cond);
}
/**
......@@ -1922,22 +1919,9 @@ gst_element_get_state_func (GstElement * element,
old_pending = GST_STATE_PENDING (element);
if (old_pending != GST_STATE_VOID_PENDING) {
GTimeVal *timeval, abstimeout;
gboolean signaled;
guint32 cookie;
if (timeout != GST_CLOCK_TIME_NONE) {
glong add = timeout / 1000;
if (add == 0)
goto done;
/* make timeout absolute */
g_get_current_time (&abstimeout);
g_time_val_add (&abstimeout, add);
timeval = &abstimeout;
} else {
timeval = NULL;
}
/* get cookie to detect state changes during waiting */
cookie = element->state_cookie;
......@@ -1945,7 +1929,17 @@ gst_element_get_state_func (GstElement * element,
"waiting for element to commit state");
/* we have a pending state change, wait for it to complete */
if (!GST_STATE_TIMED_WAIT (element, timeval)) {
if (timeout != GST_CLOCK_TIME_NONE) {
gint64 end_time;
/* make timeout absolute */
end_time = g_get_monotonic_time () + (timeout / 1000);
signaled = GST_STATE_WAIT_UNTIL (element, end_time);
} else {
GST_STATE_WAIT (element);
signaled = TRUE;
}
if (!signaled) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "timed out");
/* timeout triggered */
ret = GST_STATE_CHANGE_ASYNC;
......@@ -2811,8 +2805,8 @@ gst_element_finalize (GObject * object)
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize");
g_cond_free (element->state_cond);
g_static_rec_mutex_free (&element->state_lock);
g_cond_clear (&element->state_cond);
g_rec_mutex_clear (&element->state_lock);
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize parent");
......
......@@ -499,17 +499,17 @@ G_STMT_START { \
*
* Get the conditional used to signal the completion of a state change.
*/
#define GST_STATE_GET_COND(elem) (GST_ELEMENT_CAST(elem)->state_cond)
#define GST_STATE_GET_COND(elem) (&GST_ELEMENT_CAST(elem)->state_cond)
#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_LOCK(elem) g_rec_mutex_lock(GST_STATE_GET_LOCK(elem))
#define GST_STATE_TRYLOCK(elem) g_rec_mutex_trylock(GST_STATE_GET_LOCK(elem))
#define GST_STATE_UNLOCK(elem) g_rec_mutex_unlock(GST_STATE_GET_LOCK(elem))
#define GST_STATE_UNLOCK_FULL(elem) g_rec_mutex_unlock_full(GST_STATE_GET_LOCK(elem))
#define GST_STATE_LOCK_FULL(elem,t) g_rec_mutex_lock_full(GST_STATE_GET_LOCK(elem), t)
#define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), \
GST_OBJECT_GET_LOCK (elem))
#define GST_STATE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_STATE_GET_COND (elem), \
GST_OBJECT_GET_LOCK (elem), timeval)
#define GST_STATE_WAIT_UNTIL(elem, end_time) g_cond_wait_until (GST_STATE_GET_COND (elem), \
GST_OBJECT_GET_LOCK (elem), end_time)
#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));
......@@ -549,10 +549,10 @@ struct _GstElement
GstObject object;
/*< public >*/ /* with LOCK */
GStaticRecMutex state_lock;
GRecMutex state_lock;
/* element state */
GCond *state_cond;
GCond state_cond;
guint32 state_cookie;
GstState target_state;
GstState current_state;
......
......@@ -67,9 +67,6 @@
#include "config.h"
#endif
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gst_private.h"
#include "gstmemory.h"
......@@ -339,7 +336,7 @@ _fallback_is_span (GstMemory * mem1, GstMemory * mem2, gsize * offset)
return FALSE;
}
static GStaticRWLock lock = G_STATIC_RW_LOCK_INIT;
static GRWLock lock;
static GHashTable *allocators;
void
......@@ -358,6 +355,7 @@ _priv_gst_memory_initialize (void)
NULL
};
g_rw_lock_init (&lock);
allocators = g_hash_table_new (g_str_hash, g_str_equal);
#ifdef HAVE_GETPAGESIZE
......@@ -711,9 +709,9 @@ gst_allocator_register (const gchar * name, const GstMemoryInfo * info)
GST_DEBUG ("registering allocator \"%s\"", name);
g_static_rw_lock_writer_lock (&lock);
g_rw_lock_writer_lock (&lock);
g_hash_table_insert (allocators, (gpointer) name, (gpointer) allocator);
g_static_rw_lock_writer_unlock (&lock);
g_rw_lock_writer_unlock (&lock);
return allocator;
}
......@@ -733,13 +731,13 @@ gst_allocator_find (const gchar * name)
{
const GstAllocator *allocator;
g_static_rw_lock_reader_lock (&lock);
g_rw_lock_reader_lock (&lock);
if (name) {
allocator = g_hash_table_lookup (allocators, (gconstpointer) name);
} else {
allocator = _default_allocator;
}
g_static_rw_lock_reader_unlock (&lock);
g_rw_lock_reader_unlock (&lock);
return allocator;
}
......@@ -755,9 +753,9 @@ gst_allocator_set_default (const GstAllocator * allocator)
{
g_return_if_fail (allocator != NULL);
g_static_rw_lock_writer_lock (&lock);
g_rw_lock_writer_lock (&lock);
_default_allocator = allocator;
g_static_rw_lock_writer_unlock (&lock);
g_rw_lock_writer_unlock (&lock);
}
/**
......
......@@ -185,7 +185,7 @@ _gst_message_free (GstMessage * message)
GST_MESSAGE_SRC (message) = NULL;
}
if (message->lock) {
if (message->lock.p) {
GST_MESSAGE_LOCK (message);
GST_MESSAGE_SIGNAL (message);
GST_MESSAGE_UNLOCK (message);
......@@ -227,9 +227,6 @@ _gst_message_copy (GstMessage * message)
GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
}
GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
structure = GST_MESSAGE_STRUCTURE (message);
if (structure) {
copy->structure = gst_structure_copy (structure);
......
......@@ -149,12 +149,12 @@ typedef enum
/* the lock is used to handle the synchronous handling of messages,
* the emiting thread is block until the handling thread processed
* the message using this mutex/cond pair */
#define GST_MESSAGE_GET_LOCK(message) (GST_MESSAGE_CAST(message)->lock)
#define GST_MESSAGE_GET_LOCK(message) (&GST_MESSAGE_CAST(message)->lock)
#define GST_MESSAGE_LOCK(message) g_mutex_lock(GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_UNLOCK(message) g_mutex_unlock(GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_COND(message) (GST_MESSAGE_CAST(message)->cond)
#define GST_MESSAGE_WAIT(message) g_cond_wait(GST_MESSAGE_COND(message),GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_SIGNAL(message) g_cond_signal(GST_MESSAGE_COND(message))
#define GST_MESSAGE_GET_COND(message) (&GST_MESSAGE_CAST(message)->cond)
#define GST_MESSAGE_WAIT(message) g_cond_wait(GST_MESSAGE_GET_COND(message),GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_SIGNAL(message) g_cond_signal(GST_MESSAGE_GET_COND(message))
/**
* GST_MESSAGE_TYPE:
......@@ -282,17 +282,17 @@ typedef enum {
*/
struct _GstMessage
{
GstMiniObject mini_object;
GstMiniObject mini_object;
/*< public > *//* with COW */
GstMessageType type;
guint64 timestamp;
GstObject *src;
guint32 seqnum;
GstMessageType type;
guint64 timestamp;
GstObject *src;
guint32 seqnum;
/*< private >*//* with MESSAGE_LOCK */
GMutex *lock; /* lock and cond for async delivery */
GCond *cond;
GMutex lock; /* lock and cond for async delivery */
GCond cond;
};
GType gst_message_get_type (void);
......
......@@ -25,9 +25,6 @@
*
* Last reviewed on December 17th, 2009 (0.10.26)
*/
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gst_private.h"
#include "gstbuffer.h"
......@@ -36,11 +33,12 @@
#include "gstutils.h"
static GHashTable *metainfo = NULL;
static GStaticRWLock lock = G_STATIC_RW_LOCK_INIT;
static GRWLock lock;
void
_priv_gst_meta_initialize (void)
{
g_rw_lock_init (&lock);
metainfo = g_hash_table_new (g_str_hash, g_str_equal);
}
......@@ -85,9 +83,9 @@ gst_meta_register (const gchar * api, const gchar * impl, gsize size,
GST_DEBUG ("register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
api, impl, size);
g_static_rw_lock_writer_lock (&lock);
g_rw_lock_writer_lock (&lock);
g_hash_table_insert (metainfo, (gpointer) impl, (gpointer) info);
g_static_rw_lock_writer_unlock (&lock);
g_rw_lock_writer_unlock (&lock);
return info;
}
......@@ -109,9 +107,9 @@ gst_meta_get_info (const gchar * impl)
g_return_val_if_fail (impl != NULL, NULL);
g_static_rw_lock_reader_lock (&lock);
g_rw_lock_reader_lock (&lock);
info = g_hash_table_lookup (metainfo, impl);
g_static_rw_lock_reader_unlock (&lock);
g_rw_lock_reader_unlock (&lock);
return info;
}
......@@ -252,7 +252,7 @@ gst_object_class_init (GstObjectClass * klass)
static void
gst_object_init (GstObject * object)
{
object->lock = g_mutex_new ();
g_mutex_init (&object->lock);
object->parent = NULL;
object->name = NULL;
GST_CAT_TRACE_OBJECT (GST_CAT_REFCOUNTING, object, "%p new", object);
......@@ -450,7 +450,7 @@ gst_object_finalize (GObject * object)
g_signal_handlers_destroy (object);
g_free (gstobject->name);
g_mutex_free (gstobject->lock);
g_mutex_clear (&gstobject->lock);
#ifndef GST_DISABLE_TRACE
gst_alloc_trace_free (_gst_object_trace, object);
......
......@@ -75,7 +75,7 @@ typedef enum