diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-01-19 09:27:04 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-01-19 09:27:04 +0100 |
commit | 252327f87a420a4f019a5731c6a214809c9a12cc (patch) | |
tree | 821a05f2eec6c720ba032331e0ddc94dc4aa4b63 | |
parent | 8af013f3346471abc92c4f660f7ff65638809d40 (diff) |
Update for new gthread API
53 files changed, 383 insertions, 499 deletions
diff --git a/gst/glib-compat-private.h b/gst/glib-compat-private.h index b9248e686..3f46b6237 100644 --- a/gst/glib-compat-private.h +++ b/gst/glib-compat-private.h @@ -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 diff --git a/gst/gstbin.c b/gst/gstbin.c index 73517410d..2f466e8d6 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -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" diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index cd821c821..2bcd5d9e3 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -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); } diff --git a/gst/gstbus.c b/gst/gstbus.c index 99e2fa633..37ae07077 100644 --- a/gst/gstbus.c +++ b/gst/gstbus.c @@ -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); diff --git a/gst/gstbus.h b/gst/gstbus.h index 818c38d81..46ae371ee 100644 --- a/gst/gstbus.h +++ b/gst/gstbus.h @@ -117,7 +117,7 @@ struct _GstBus /*< private >*/ GstAtomicQueue *queue; - GMutex *queue_lock; + GMutex queue_lock; GstBusSyncHandler sync_handler; gpointer sync_handler_data; diff --git a/gst/gstclock.c b/gst/gstclock.c index 61b5adce0..760feff3a 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -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); } diff --git a/gst/gstclock.h b/gst/gstclock.h index de9a9f104..627222112 100644 --- a/gst/gstclock.h +++ b/gst/gstclock.h @@ -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; diff --git a/gst/gstelement.c b/gst/gstelement.c index d6deca813..91a4c4c9e 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -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"); diff --git a/gst/gstelement.h b/gst/gstelement.h index f923f4947..594174eb6 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -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; diff --git a/gst/gstmemory.c b/gst/gstmemory.c index 480c6c840..7fea1b105 100644 --- a/gst/gstmemory.c +++ b/gst/gstmemory.c @@ -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); } /** diff --git a/gst/gstmessage.c b/gst/gstmessage.c index 91881bb08..9bbbbd5df 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -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); diff --git a/gst/gstmessage.h b/gst/gstmessage.h index 74092571d..0c97a52bc 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -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); diff --git a/gst/gstmeta.c b/gst/gstmeta.c index 3657ffc17..525885565 100644 --- a/gst/gstmeta.c +++ b/gst/gstmeta.c @@ -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; } diff --git a/gst/gstobject.c b/gst/gstobject.c index 18ce6587c..3fa372a9f 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -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); diff --git a/gst/gstobject.h b/gst/gstobject.h index 193301dde..b954e5212 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -75,7 +75,7 @@ typedef enum * * Acquire a reference to the mutex of this object. */ -#define GST_OBJECT_GET_LOCK(obj) (GST_OBJECT_CAST(obj)->lock) +#define GST_OBJECT_GET_LOCK(obj) (&GST_OBJECT_CAST(obj)->lock) /** * GST_OBJECT_LOCK: * @obj: a #GstObject to lock @@ -165,7 +165,7 @@ struct _GstObject { GInitiallyUnowned object; /*< public >*/ /* with LOCK */ - GMutex *lock; /* object LOCK */ + GMutex lock; /* object LOCK */ gchar *name; /* object name */ GstObject *parent; /* this object's parent, weak ref */ guint32 flags; diff --git a/gst/gstpad.c b/gst/gstpad.c index 4fafa29c7..8aec51ce7 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -60,9 +60,6 @@ * Last reviewed on 2006-07-06 (0.10.9) */ -/* 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 "gstpad.h" @@ -325,9 +322,9 @@ gst_pad_init (GstPad * pad) GST_PAD_SET_FLUSHING (pad); - g_static_rec_mutex_init (&pad->stream_rec_lock); + g_rec_mutex_init (&pad->stream_rec_lock); - pad->block_cond = g_cond_new (); + g_cond_init (&pad->block_cond); g_hook_list_init (&pad->probes, sizeof (GstProbe)); @@ -614,8 +611,8 @@ gst_pad_finalize (GObject * object) if (pad->iterintlinknotify) pad->iterintlinknotify (pad); - g_static_rec_mutex_free (&pad->stream_rec_lock); - g_cond_free (pad->block_cond); + g_rec_mutex_clear (&pad->stream_rec_lock); + g_cond_clear (&pad->block_cond); g_array_free (pad->priv->events, TRUE); G_OBJECT_CLASS (parent_class)->finalize (object); diff --git a/gst/gstpad.h b/gst/gstpad.h index 45b6a3789..93c497070 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -635,11 +635,11 @@ struct _GstPad { /*< private >*/ /* streaming rec_lock */ - GStaticRecMutex stream_rec_lock; + GRecMutex stream_rec_lock; GstTask *task; /* block cond, mutex is from the object */ - GCond *block_cond; + GCond block_cond; GHookList probes; GstPadMode mode; @@ -757,7 +757,7 @@ struct _GstPadClass { * * Lock the stream lock of @pad. */ -#define GST_PAD_STREAM_LOCK(pad) (g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad))) +#define GST_PAD_STREAM_LOCK(pad) (g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad))) /** * GST_PAD_STREAM_TRYLOCK: * @pad: a #GstPad @@ -765,16 +765,16 @@ struct _GstPadClass { * Try to Lock the stream lock of the pad, return TRUE if the lock could be * taken. */ -#define GST_PAD_STREAM_TRYLOCK(pad) (g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad))) +#define GST_PAD_STREAM_TRYLOCK(pad) (g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad))) /** * GST_PAD_STREAM_UNLOCK: * @pad: a #GstPad * * Unlock the stream lock of @pad. */ -#define GST_PAD_STREAM_UNLOCK(pad) (g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad))) +#define GST_PAD_STREAM_UNLOCK(pad) (g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad))) -#define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_CAST(pad)->block_cond) +#define GST_PAD_BLOCK_GET_COND(pad) (&GST_PAD_CAST(pad)->block_cond) #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad))) #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad))) #define GST_PAD_BLOCK_BROADCAST(pad) (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad))) diff --git a/gst/gstpoll.c b/gst/gstpoll.c index 3125681d4..3236085fd 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -125,7 +125,7 @@ struct _GstPoll { GstPollMode mode; - GMutex *lock; + GMutex lock; /* array of fds, always written to and read from with lock */ GArray *fds; /* array of active fds, only written to from the waiting thread with the @@ -276,20 +276,20 @@ selectable_fds (const GstPoll * set) { guint i; - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); for (i = 0; i < set->fds->len; i++) { struct pollfd *pfd = &g_array_index (set->fds, struct pollfd, i); if (pfd->fd >= FD_SETSIZE) goto too_many; } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return TRUE; too_many: { - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return FALSE; } } @@ -352,7 +352,7 @@ pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds, FD_ZERO (writefds); FD_ZERO (errorfds); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); for (i = 0; i < set->active_fds->len; i++) { struct pollfd *pfd = &g_array_index (set->fds, struct pollfd, i); @@ -369,7 +369,7 @@ pollfd_to_fd_set (GstPoll * set, fd_set * readfds, fd_set * writefds, } } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return max_fd; } @@ -380,7 +380,7 @@ fd_set_to_pollfd (GstPoll * set, fd_set * readfds, fd_set * writefds, { guint i; - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); for (i = 0; i < set->active_fds->len; i++) { struct pollfd *pfd = &g_array_index (set->active_fds, struct pollfd, i); @@ -396,7 +396,7 @@ fd_set_to_pollfd (GstPoll * set, fd_set * readfds, fd_set * writefds, } } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); } #else /* G_OS_WIN32 */ /* @@ -559,7 +559,7 @@ gst_poll_new (gboolean controllable) GST_DEBUG ("controllable : %d", controllable); nset = g_slice_new0 (GstPoll); - nset->lock = g_mutex_new (); + g_mutex_init (&nset->lock); #ifndef G_OS_WIN32 nset->mode = GST_POLL_MODE_AUTO; nset->fds = g_array_new (FALSE, FALSE, sizeof (struct pollfd)); @@ -679,7 +679,7 @@ gst_poll_free (GstPoll * set) g_array_free (set->active_fds, TRUE); g_array_free (set->fds, TRUE); - g_mutex_free (set->lock); + g_mutex_clear (&set->lock); g_slice_free (GstPoll, set); } @@ -792,11 +792,11 @@ gst_poll_add_fd (GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); ret = gst_poll_add_fd_unlocked (set, fd); - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return ret; } @@ -824,7 +824,7 @@ gst_poll_remove_fd (GstPoll * set, GstPollFD * fd) GST_DEBUG ("%p: fd (fd:%d, idx:%d)", set, fd->fd, fd->idx); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); /* get the index, -1 is an fd that is not added */ idx = find_index (set->fds, fd); @@ -845,7 +845,7 @@ gst_poll_remove_fd (GstPoll * set, GstPollFD * fd) GST_WARNING ("%p: couldn't find fd !", set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return idx >= 0; } @@ -875,7 +875,7 @@ gst_poll_fd_ctl_write (GstPoll * set, GstPollFD * fd, gboolean active) GST_DEBUG ("%p: fd (fd:%d, idx:%d), active : %d", set, fd->fd, fd->idx, active); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); idx = find_index (set->fds, fd); if (idx >= 0) { @@ -897,7 +897,7 @@ gst_poll_fd_ctl_write (GstPoll * set, GstPollFD * fd, gboolean active) GST_WARNING ("%p: couldn't find fd !", set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return idx >= 0; } @@ -953,11 +953,11 @@ gst_poll_fd_ctl_read (GstPoll * set, GstPollFD * fd, gboolean active) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); ret = gst_poll_fd_ctl_read_unlocked (set, fd, active); - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); return ret; } @@ -988,7 +988,7 @@ gst_poll_fd_ignored (GstPoll * set, GstPollFD * fd) g_return_if_fail (fd != NULL); g_return_if_fail (fd->fd >= 0); - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); idx = find_index (set->fds, fd); if (idx >= 0) { @@ -998,7 +998,7 @@ gst_poll_fd_ignored (GstPoll * set, GstPollFD * fd) MARK_REBUILD (set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); #endif } @@ -1025,7 +1025,7 @@ gst_poll_fd_has_closed (const GstPoll * set, GstPollFD * fd) GST_DEBUG ("%p: fd (fd:%d, idx:%d)", set, fd->fd, fd->idx); - g_mutex_lock (set->lock); + g_mutex_lock (&((GstPoll *) set)->lock); idx = find_index (set->active_fds, fd); if (idx >= 0) { @@ -1042,7 +1042,7 @@ gst_poll_fd_has_closed (const GstPoll * set, GstPollFD * fd) GST_WARNING ("%p: couldn't find fd !", set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&((GstPoll *) set)->lock); return res; } @@ -1070,7 +1070,7 @@ gst_poll_fd_has_error (const GstPoll * set, GstPollFD * fd) GST_DEBUG ("%p: fd (fd:%d, idx:%d)", set, fd->fd, fd->idx); - g_mutex_lock (set->lock); + g_mutex_lock (&((GstPoll *) set)->lock); idx = find_index (set->active_fds, fd); if (idx >= 0) { @@ -1091,7 +1091,7 @@ gst_poll_fd_has_error (const GstPoll * set, GstPollFD * fd) GST_WARNING ("%p: couldn't find fd !", set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&((GstPoll *) set)->lock); return res; } @@ -1142,11 +1142,11 @@ gst_poll_fd_can_read (const GstPoll * set, GstPollFD * fd) g_return_val_if_fail (fd != NULL, FALSE); g_return_val_if_fail (fd->fd >= 0, FALSE); - g_mutex_lock (set->lock); + g_mutex_lock (&((GstPoll *) set)->lock); res = gst_poll_fd_can_read_unlocked (set, fd); - g_mutex_unlock (set->lock); + g_mutex_unlock (&((GstPoll *) set)->lock); return res; } @@ -1174,7 +1174,7 @@ gst_poll_fd_can_write (const GstPoll * set, GstPollFD * fd) GST_DEBUG ("%p: fd (fd:%d, idx:%d)", set, fd->fd, fd->idx); - g_mutex_lock (set->lock); + g_mutex_lock (&((GstPoll *) set)->lock); idx = find_index (set->active_fds, fd); if (idx >= 0) { @@ -1191,7 +1191,7 @@ gst_poll_fd_can_write (const GstPoll * set, GstPollFD * fd) GST_WARNING ("%p: couldn't find fd !", set); } - g_mutex_unlock (set->lock); + g_mutex_unlock (&((GstPoll *) set)->lock); return res; } @@ -1252,7 +1252,7 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) mode = choose_mode (set, timeout); if (TEST_REBUILD (set)) { - g_mutex_lock (set->lock); + g_mutex_lock (&set->lock); #ifndef G_OS_WIN32 g_array_set_size (set->active_fds, set->fds->len); memcpy (set->active_fds->data, set->fds->data, @@ -1261,7 +1261,7 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) if (!gst_poll_prepare_winsock_active_sets (set)) goto winsock_error; #endif - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); } switch (mode) { @@ -1454,7 +1454,7 @@ flushing: winsock_error: { GST_LOG ("%p: winsock error", set); - g_mutex_unlock (set->lock); + g_mutex_unlock (&set->lock); DEC_WAITING (set); return -1; } diff --git a/gst/gsttask.c b/gst/gsttask.c index 5ebed394e..444b292b8 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -68,9 +68,6 @@ * Last reviewed on 2010-03-15 (0.10.29) */ -/* 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 "gstinfo.h" @@ -191,7 +188,7 @@ gst_task_init (GstTask * task) task->running = FALSE; task->thread = NULL; task->lock = NULL; - task->cond = g_cond_new (); + g_cond_init (&task->cond); SET_TASK_STATE (task, GST_TASK_STOPPED); task->priv->prio_set = FALSE; @@ -219,8 +216,7 @@ gst_task_finalize (GObject * object) /* task thread cannot be running here since it holds a ref * to the task so that the finalize could not have happened */ - g_cond_free (task->cond); - task->cond = NULL; + g_cond_clear (&task->cond); G_OBJECT_CLASS (gst_task_parent_class)->finalize (object); } @@ -259,7 +255,7 @@ gst_task_configure_name (GstTask * task) static void gst_task_func (GstTask * task) { - GStaticRecMutex *lock; + GRecMutex *lock; GThread *tself; GstTaskPrivate *priv; @@ -294,7 +290,7 @@ gst_task_func (GstTask * task) priv->thr_callbacks.enter_thread (task, tself, priv->thr_user_data); /* locking order is TASK_LOCK, LOCK */ - g_static_rec_mutex_lock (lock); + g_rec_mutex_lock (lock); /* configure the thread name now */ gst_task_configure_name (task); @@ -302,13 +298,13 @@ gst_task_func (GstTask * task) if (G_UNLIKELY (GET_TASK_STATE (task) == GST_TASK_PAUSED)) { GST_OBJECT_LOCK (task); while (G_UNLIKELY (GST_TASK_STATE (task) == GST_TASK_PAUSED)) { - g_static_rec_mutex_unlock (lock); + g_rec_mutex_unlock (lock); GST_TASK_SIGNAL (task); GST_TASK_WAIT (task); GST_OBJECT_UNLOCK (task); /* locking order.. */ - g_static_rec_mutex_lock (lock); + g_rec_mutex_lock (lock); GST_OBJECT_LOCK (task); if (G_UNLIKELY (GET_TASK_STATE (task) == GST_TASK_STOPPED)) { @@ -322,7 +318,7 @@ gst_task_func (GstTask * task) task->func (task->data); } done: - g_static_rec_mutex_unlock (lock); + g_rec_mutex_unlock (lock); GST_OBJECT_LOCK (task); task->thread = NULL; @@ -422,7 +418,7 @@ gst_task_new (GstTaskFunction func, gpointer data) /** * gst_task_set_lock: * @task: The #GstTask to use - * @mutex: The #GMutex to use + * @mutex: The #GRecMutex to use * * Set the mutex used by the task. The mutex will be acquired before * calling the #GstTaskFunction. @@ -433,7 +429,7 @@ gst_task_new (GstTaskFunction func, gpointer data) * MT safe. */ void -gst_task_set_lock (GstTask * task, GStaticRecMutex * mutex) +gst_task_set_lock (GstTask * task, GRecMutex * mutex) { GST_OBJECT_LOCK (task); if (G_UNLIKELY (task->running)) diff --git a/gst/gsttask.h b/gst/gsttask.h index 02b2e281d..492052b20 100644 --- a/gst/gsttask.h +++ b/gst/gsttask.h @@ -78,7 +78,7 @@ typedef enum { * * Get access to the cond of the task. */ -#define GST_TASK_GET_COND(task) (GST_TASK_CAST(task)->cond) +#define GST_TASK_GET_COND(task) (&GST_TASK_CAST(task)->cond) /** * GST_TASK_WAIT: * @task: Task to wait for @@ -144,9 +144,9 @@ struct _GstTask { /*< public >*/ /* with LOCK */ GstTaskState state; - GCond *cond; + GCond cond; - GStaticRecMutex *lock; + GRecMutex *lock; GstTaskFunction func; gpointer data; @@ -176,7 +176,7 @@ void gst_task_cleanup_all (void); GType gst_task_get_type (void); GstTask* gst_task_new (GstTaskFunction func, gpointer data); -void gst_task_set_lock (GstTask *task, GStaticRecMutex *mutex); +void gst_task_set_lock (GstTask *task, GRecMutex *mutex); void gst_task_set_priority (GstTask *task, GThreadPriority priority); GstTaskPool * gst_task_get_pool (GstTask *task); diff --git a/gst/gstutils.c b/gst/gstutils.c index 7516d6daf..f6a34741d 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -27,9 +27,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 <stdio.h> #include <string.h> diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 0014c6984..53702814d 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -201,9 +201,6 @@ #include <stdlib.h> #include <string.h> -/* 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/base/gstadapter.h> #include "gstbaseparse.h" diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 1afdfd997..fdecd9e72 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -142,9 +142,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/gst_private.h> #include "gstbasesink.h" @@ -639,8 +636,8 @@ gst_base_sink_init (GstBaseSink * basesink, gpointer g_class) gst_element_add_pad (GST_ELEMENT_CAST (basesink), basesink->sinkpad); basesink->pad_mode = GST_PAD_MODE_NONE; - basesink->preroll_lock = g_mutex_new (); - basesink->preroll_cond = g_cond_new (); + g_mutex_init (&basesink->preroll_lock); + g_cond_init (&basesink->preroll_cond); priv->have_latency = FALSE; basesink->can_activate_push = DEFAULT_CAN_ACTIVATE_PUSH; @@ -667,8 +664,8 @@ gst_base_sink_finalize (GObject * object) basesink = GST_BASE_SINK (object); - g_mutex_free (basesink->preroll_lock); - g_cond_free (basesink->preroll_cond); + g_mutex_clear (&basesink->preroll_lock); + g_cond_clear (&basesink->preroll_cond); G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/libs/gst/base/gstbasesink.h b/libs/gst/base/gstbasesink.h index ede3abc8c..5c4755c06 100644 --- a/libs/gst/base/gstbasesink.h +++ b/libs/gst/base/gstbasesink.h @@ -44,16 +44,16 @@ G_BEGIN_DECLS */ #define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad) -#define GST_BASE_SINK_GET_PREROLL_LOCK(pad) (GST_BASE_SINK_CAST(pad)->preroll_lock) +#define GST_BASE_SINK_GET_PREROLL_LOCK(pad) (&GST_BASE_SINK_CAST(pad)->preroll_lock) #define GST_BASE_SINK_PREROLL_LOCK(pad) (g_mutex_lock(GST_BASE_SINK_GET_PREROLL_LOCK(pad))) #define GST_BASE_SINK_PREROLL_TRYLOCK(pad) (g_mutex_trylock(GST_BASE_SINK_GET_PREROLL_LOCK(pad))) #define GST_BASE_SINK_PREROLL_UNLOCK(pad) (g_mutex_unlock(GST_BASE_SINK_GET_PREROLL_LOCK(pad))) -#define GST_BASE_SINK_GET_PREROLL_COND(pad) (GST_BASE_SINK_CAST(pad)->preroll_cond) +#define GST_BASE_SINK_GET_PREROLL_COND(pad) (&GST_BASE_SINK_CAST(pad)->preroll_cond) #define GST_BASE_SINK_PREROLL_WAIT(pad) \ g_cond_wait (GST_BASE_SINK_GET_PREROLL_COND (pad), GST_BASE_SINK_GET_PREROLL_LOCK (pad)) -#define GST_BASE_SINK_PREROLL_TIMED_WAIT(pad, timeval) \ - g_cond_timed_wait (GST_BASE_SINK_GET_PREROLL_COND (pad), GST_BASE_SINK_GET_PREROLL_LOCK (pad), timeval) +#define GST_BASE_SINK_PREROLL_WAIT_UNTIL(pad, end_time) \ + g_cond_wait_until (GST_BASE_SINK_GET_PREROLL_COND (pad), GST_BASE_SINK_GET_PREROLL_LOCK (pad), end_time) #define GST_BASE_SINK_PREROLL_SIGNAL(pad) g_cond_signal (GST_BASE_SINK_GET_PREROLL_COND (pad)); #define GST_BASE_SINK_PREROLL_BROADCAST(pad) g_cond_broadcast (GST_BASE_SINK_GET_PREROLL_COND (pad)); @@ -79,8 +79,8 @@ struct _GstBaseSink { gboolean can_activate_push; /*< protected >*/ /* with PREROLL_LOCK */ - GMutex *preroll_lock; - GCond *preroll_cond; + GMutex preroll_lock; + GCond preroll_cond; gboolean eos; gboolean need_preroll; gboolean have_preroll; diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index a0775d10d..bc37bf100 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -159,9 +159,6 @@ #include <stdlib.h> #include <string.h> -/* 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/gst_private.h> #include <gst/glib-compat-private.h> @@ -173,14 +170,13 @@ GST_DEBUG_CATEGORY_STATIC (gst_base_src_debug); #define GST_CAT_DEFAULT gst_base_src_debug -#define GST_LIVE_GET_LOCK(elem) (GST_BASE_SRC_CAST(elem)->live_lock) +#define GST_LIVE_GET_LOCK(elem) (&GST_BASE_SRC_CAST(elem)->live_lock) #define GST_LIVE_LOCK(elem) g_mutex_lock(GST_LIVE_GET_LOCK(elem)) #define GST_LIVE_TRYLOCK(elem) g_mutex_trylock(GST_LIVE_GET_LOCK(elem)) #define GST_LIVE_UNLOCK(elem) g_mutex_unlock(GST_LIVE_GET_LOCK(elem)) -#define GST_LIVE_GET_COND(elem) (GST_BASE_SRC_CAST(elem)->live_cond) +#define GST_LIVE_GET_COND(elem) (&GST_BASE_SRC_CAST(elem)->live_cond) #define GST_LIVE_WAIT(elem) g_cond_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem)) -#define GST_LIVE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem),\ - timeval) +#define GST_LIVE_WAIT_UNTIL(elem, end_time) g_cond_timed_wait (GST_LIVE_GET_COND (elem), GST_LIVE_GET_LOCK (elem), end_time) #define GST_LIVE_SIGNAL(elem) g_cond_signal (GST_LIVE_GET_COND (elem)); #define GST_LIVE_BROADCAST(elem) g_cond_broadcast (GST_LIVE_GET_COND (elem)); @@ -406,8 +402,8 @@ gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class) basesrc->priv = GST_BASE_SRC_GET_PRIVATE (basesrc); basesrc->is_live = FALSE; - basesrc->live_lock = g_mutex_new (); - basesrc->live_cond = g_cond_new (); + g_mutex_init (&basesrc->live_lock); + g_cond_init (&basesrc->live_cond); basesrc->num_buffers = DEFAULT_NUM_BUFFERS; basesrc->num_buffers_left = -1; @@ -455,8 +451,8 @@ gst_base_src_finalize (GObject * object) basesrc = GST_BASE_SRC (object); - g_mutex_free (basesrc->live_lock); - g_cond_free (basesrc->live_cond); + g_mutex_clear (&basesrc->live_lock); + g_cond_clear (&basesrc->live_cond); event_p = &basesrc->pending_seek; gst_event_replace (event_p, NULL); diff --git a/libs/gst/base/gstbasesrc.h b/libs/gst/base/gstbasesrc.h index 59568669b..31345bd9e 100644 --- a/libs/gst/base/gstbasesrc.h +++ b/libs/gst/base/gstbasesrc.h @@ -80,8 +80,8 @@ struct _GstBaseSrc { /* available to subclass implementations */ /* MT-protected (with LIVE_LOCK) */ - GMutex *live_lock; - GCond *live_cond; + GMutex live_lock; + GCond live_cond; gboolean is_live; gboolean live_running; diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 0883555d7..67806fb51 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -205,9 +205,6 @@ #include <stdlib.h> #include <string.h> -/* 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/gst_private.h" #include "../../../gst/gst-i18n-lib.h" #include "../../../gst/glib-compat-private.h" @@ -356,7 +353,7 @@ gst_base_transform_finalize (GObject * object) trans = GST_BASE_TRANSFORM (object); - g_mutex_free (trans->transform_lock); + g_mutex_clear (&trans->transform_lock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -442,7 +439,7 @@ gst_base_transform_init (GstBaseTransform * trans, GST_DEBUG_FUNCPTR (gst_base_transform_query)); gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad); - trans->transform_lock = g_mutex_new (); + g_mutex_init (&trans->transform_lock); trans->priv->qos_enabled = DEFAULT_PROP_QOS; trans->cache_caps1 = NULL; trans->cache_caps2 = NULL; diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index cdcbe81a5..d9bc24fa6 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -85,7 +85,7 @@ G_BEGIN_DECLS * * Since: 0.10.13 */ -#define GST_BASE_TRANSFORM_LOCK(obj) g_mutex_lock (GST_BASE_TRANSFORM_CAST (obj)->transform_lock) +#define GST_BASE_TRANSFORM_LOCK(obj) g_mutex_lock (&GST_BASE_TRANSFORM_CAST (obj)->transform_lock) /** * GST_BASE_TRANSFORM_UNLOCK: @@ -95,7 +95,7 @@ G_BEGIN_DECLS * * Since: 0.10.13 */ -#define GST_BASE_TRANSFORM_UNLOCK(obj) g_mutex_unlock (GST_BASE_TRANSFORM_CAST (obj)->transform_lock) +#define GST_BASE_TRANSFORM_UNLOCK(obj) g_mutex_unlock (&GST_BASE_TRANSFORM_CAST (obj)->transform_lock) typedef struct _GstBaseTransform GstBaseTransform; typedef struct _GstBaseTransformClass GstBaseTransformClass; @@ -131,7 +131,7 @@ struct _GstBaseTransform { /* MT-protected (with STREAM_LOCK) */ GstSegment segment; - GMutex *transform_lock; + GMutex transform_lock; /*< private >*/ GstBaseTransformPrivate *priv; diff --git a/libs/gst/base/gstcollectpads.c b/libs/gst/base/gstcollectpads.c index d02fd303f..1ad5015c0 100644 --- a/libs/gst/base/gstcollectpads.c +++ b/libs/gst/base/gstcollectpads.c @@ -119,7 +119,7 @@ gst_collect_pads_init (GstCollectPads * pads) { pads->priv = GST_COLLECT_PADS_GET_PRIVATE (pads); - pads->cond = g_cond_new (); + g_cond_init (&pads->cond); pads->data = NULL; pads->cookie = 0; pads->numpads = 0; @@ -128,7 +128,7 @@ gst_collect_pads_init (GstCollectPads * pads) pads->started = FALSE; /* members to manage the pad list */ - pads->pad_lock = g_mutex_new (); + g_mutex_init (&pads->pad_lock); pads->pad_cookie = 0; pads->pad_list = NULL; } @@ -141,8 +141,8 @@ gst_collect_pads_finalize (GObject * object) GST_DEBUG ("finalize"); - g_cond_free (pads->cond); - g_mutex_free (pads->pad_lock); + g_cond_clear (&pads->cond); + g_mutex_clear (&pads->pad_lock); /* Remove pads */ collected = pads->pad_list; diff --git a/libs/gst/base/gstcollectpads.h b/libs/gst/base/gstcollectpads.h index 094c9f913..9dbd8caff 100644 --- a/libs/gst/base/gstcollectpads.h +++ b/libs/gst/base/gstcollectpads.h @@ -119,11 +119,11 @@ struct _GstCollectData */ typedef GstFlowReturn (*GstCollectPadsFunction) (GstCollectPads *pads, gpointer user_data); -#define GST_COLLECT_PADS_GET_PAD_LOCK(pads) (((GstCollectPads *)pads)->pad_lock) +#define GST_COLLECT_PADS_GET_PAD_LOCK(pads) (&((GstCollectPads *)pads)->pad_lock) #define GST_COLLECT_PADS_PAD_LOCK(pads) (g_mutex_lock(GST_COLLECT_PADS_GET_PAD_LOCK (pads))) #define GST_COLLECT_PADS_PAD_UNLOCK(pads) (g_mutex_unlock(GST_COLLECT_PADS_GET_PAD_LOCK (pads))) -#define GST_COLLECT_PADS_GET_COND(pads) (((GstCollectPads *)pads)->cond) +#define GST_COLLECT_PADS_GET_COND(pads) (&((GstCollectPads *)pads)->cond) #define GST_COLLECT_PADS_WAIT(pads) (g_cond_wait (GST_COLLECT_PADS_GET_COND (pads), GST_OBJECT_GET_LOCK (pads))) #define GST_COLLECT_PADS_SIGNAL(pads) (g_cond_signal (GST_COLLECT_PADS_GET_COND (pads))) #define GST_COLLECT_PADS_BROADCAST(pads)(g_cond_broadcast (GST_COLLECT_PADS_GET_COND (pads))) @@ -146,7 +146,7 @@ struct _GstCollectPads { guint32 cookie; /* @data list cookie */ /* with LOCK */ - GCond *cond; /* to signal removal of data */ + GCond cond; /* to signal removal of data */ GstCollectPadsFunction func; /* function and user_data for callback */ gpointer user_data; @@ -159,7 +159,7 @@ struct _GstCollectPads { gboolean started; /* with PAD_LOCK */ - GMutex *pad_lock; /* used to serialize add/remove */ + GMutex pad_lock; /* used to serialize add/remove */ GSList *pad_list; /* updated pad list */ guint32 pad_cookie; /* updated cookie */ GstCollectPadsPrivate *priv; diff --git a/libs/gst/base/gstcollectpads2.c b/libs/gst/base/gstcollectpads2.c index cf1f50097..3d1457766 100644 --- a/libs/gst/base/gstcollectpads2.c +++ b/libs/gst/base/gstcollectpads2.c @@ -86,9 +86,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/gst_private.h> #include "gstcollectpads2.h" @@ -123,8 +120,8 @@ static void unref_data (GstCollectData2 * data); * Alternative implementations are possible, e.g. some low-level re-implementing * of the 2 above locks to drop both of them atomically when going into _WAIT. */ -#define GST_COLLECT_PADS2_GET_EVT_COND(pads) (((GstCollectPads2 *)pads)->evt_cond) -#define GST_COLLECT_PADS2_GET_EVT_LOCK(pads) (((GstCollectPads2 *)pads)->evt_lock) +#define GST_COLLECT_PADS2_GET_EVT_COND(pads) (&((GstCollectPads2 *)pads)->evt_cond) +#define GST_COLLECT_PADS2_GET_EVT_LOCK(pads) (&((GstCollectPads2 *)pads)->evt_lock) #define GST_COLLECT_PADS2_EVT_WAIT(pads, cookie) G_STMT_START { \ g_mutex_lock (GST_COLLECT_PADS2_GET_EVT_LOCK (pads)); \ /* should work unless a lot of event'ing and thread starvation */\ @@ -182,7 +179,7 @@ gst_collect_pads2_init (GstCollectPads2 * pads) pads->eospads = 0; pads->started = FALSE; - g_static_rec_mutex_init (&pads->stream_lock); + g_rec_mutex_init (&pads->stream_lock); pads->func = gst_collect_pads2_default_collected; pads->user_data = NULL; @@ -202,8 +199,8 @@ gst_collect_pads2_init (GstCollectPads2 * pads) pads->pad_list = NULL; /* members for event */ - pads->evt_lock = g_mutex_new (); - pads->evt_cond = g_cond_new (); + g_mutex_init (&pads->evt_lock); + g_cond_init (&pads->evt_cond); pads->evt_cookie = 0; } @@ -214,10 +211,10 @@ gst_collect_pads2_finalize (GObject * object) GST_DEBUG_OBJECT (object, "finalize"); - g_static_rec_mutex_free (&pads->stream_lock); + g_rec_mutex_clear (&pads->stream_lock); - g_cond_free (pads->evt_cond); - g_mutex_free (pads->evt_lock); + g_cond_clear (&pads->evt_cond); + g_mutex_clear (&pads->evt_lock); /* Remove pads and free pads list */ g_slist_foreach (pads->pad_list, (GFunc) unref_data, NULL); diff --git a/libs/gst/base/gstcollectpads2.h b/libs/gst/base/gstcollectpads2.h index 8625e733d..165203a57 100644 --- a/libs/gst/base/gstcollectpads2.h +++ b/libs/gst/base/gstcollectpads2.h @@ -260,7 +260,7 @@ typedef GstFlowReturn (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, Gst * * Since: 0.10.36 */ -#define GST_COLLECT_PADS2_STREAM_LOCK(pads) (g_static_rec_mutex_lock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))) +#define GST_COLLECT_PADS2_STREAM_LOCK(pads) (g_rec_mutex_lock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))) /** * GST_COLLECT_PADS2_STREAM_UNLOCK: * @pads: a #GstCollectPads2 @@ -269,7 +269,7 @@ typedef GstFlowReturn (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, Gst * * Since: 0.10.36 */ -#define GST_COLLECT_PADS2_STREAM_UNLOCK(pads) (g_static_rec_mutex_unlock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))) +#define GST_COLLECT_PADS2_STREAM_UNLOCK(pads) (g_rec_mutex_unlock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads))) /** * GstCollectPads2: @@ -286,7 +286,7 @@ struct _GstCollectPads2 { GSList *data; /* list of CollectData items */ /*< private >*/ - GStaticRecMutex stream_lock; /* used to serialize collection among several streams */ + GRecMutex stream_lock; /* used to serialize collection among several streams */ /* with LOCK and/or STREAM_LOCK*/ gboolean started; @@ -314,8 +314,8 @@ struct _GstCollectPads2 { gpointer clip_user_data; /* no other lock needed */ - GMutex *evt_lock; /* these make up sort of poor man's event signaling */ - GCond *evt_cond; + GMutex evt_lock; /* these make up sort of poor man's event signaling */ + GCond evt_cond; guint32 evt_cookie; gpointer _gst_reserved[GST_PADDING]; diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c index 7b625fde4..07eb4d201 100644 --- a/libs/gst/controller/gstinterpolationcontrolsource.c +++ b/libs/gst/controller/gstinterpolationcontrolsource.c @@ -63,7 +63,7 @@ interpolate_none_get (GstTimedValueControlSource * self, GstClockTime timestamp, gboolean ret = FALSE; GSequenceIter *iter; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); iter = gst_timed_value_control_source_find_control_point_iter (self, timestamp); @@ -71,7 +71,7 @@ interpolate_none_get (GstTimedValueControlSource * self, GstClockTime timestamp, *value = _interpolate_none (self, iter); ret = TRUE; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -87,7 +87,7 @@ interpolate_none_get_value_array (GstTimedValueControlSource * self, gdouble val; GSequenceIter *iter1 = NULL, *iter2 = NULL; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); for (i = 0; i < n_values; i++) { GST_LOG ("values[%3d] : ts=%" GST_TIME_FORMAT ", next_ts=%" GST_TIME_FORMAT, @@ -124,7 +124,7 @@ interpolate_none_get_value_array (GstTimedValueControlSource * self, ts += interval; values++; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -155,7 +155,7 @@ interpolate_linear_get (GstTimedValueControlSource * self, GSequenceIter *iter; GstControlPoint *cp1, *cp2; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); iter = gst_timed_value_control_source_find_control_point_iter (self, timestamp); @@ -173,7 +173,7 @@ interpolate_linear_get (GstTimedValueControlSource * self, (cp2 ? cp2->value : 0.0), timestamp); ret = TRUE; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -190,7 +190,7 @@ interpolate_linear_get_value_array (GstTimedValueControlSource * self, GSequenceIter *iter1, *iter2 = NULL; GstControlPoint *cp1 = NULL, *cp2 = NULL; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); for (i = 0; i < n_values; i++) { GST_LOG ("values[%3d] : ts=%" GST_TIME_FORMAT ", next_ts=%" GST_TIME_FORMAT, @@ -229,7 +229,7 @@ interpolate_linear_get_value_array (GstTimedValueControlSource * self, ts += interval; values++; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -372,7 +372,7 @@ interpolate_cubic_get (GstTimedValueControlSource * self, if (self->nvalues <= 2) return interpolate_linear_get (self, timestamp, value); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); iter = gst_timed_value_control_source_find_control_point_iter (self, timestamp); @@ -388,7 +388,7 @@ interpolate_cubic_get (GstTimedValueControlSource * self, (cp2 ? cp2->value : 0.0), timestamp); ret = TRUE; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -409,7 +409,7 @@ interpolate_cubic_get_value_array (GstTimedValueControlSource * self, return interpolate_linear_get_value_array (self, timestamp, interval, n_values, values); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); for (i = 0; i < n_values; i++) { GST_LOG ("values[%3d] : ts=%" GST_TIME_FORMAT ", next_ts=%" GST_TIME_FORMAT, @@ -447,7 +447,7 @@ interpolate_cubic_get_value_array (GstTimedValueControlSource * self, ts += interval; values++; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c index fdb454444..24f530786 100644 --- a/libs/gst/controller/gstlfocontrolsource.c +++ b/libs/gst/controller/gstlfocontrolsource.c @@ -96,10 +96,10 @@ waveform_sine_get (GstLFOControlSource * self, GstClockTime timestamp, GstLFOControlSourcePrivate *priv = self->priv; gst_object_sync_values (GST_OBJECT (self), timestamp); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *value = _sine_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, timestamp); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -114,10 +114,10 @@ waveform_sine_get_value_array (GstLFOControlSource * self, for (i = 0; i < n_values; i++) { gst_object_sync_values (GST_OBJECT (self), ts); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *values = _sine_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, ts); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); ts += interval; values++; } @@ -149,10 +149,10 @@ waveform_square_get (GstLFOControlSource * self, GstClockTime timestamp, GstLFOControlSourcePrivate *priv = self->priv; gst_object_sync_values (GST_OBJECT (self), timestamp); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *value = _square_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, timestamp); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -167,10 +167,10 @@ waveform_square_get_value_array (GstLFOControlSource * self, for (i = 0; i < n_values; i++) { gst_object_sync_values (GST_OBJECT (self), ts); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *values = _square_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, ts); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); ts += interval; values++; } @@ -200,10 +200,10 @@ waveform_saw_get (GstLFOControlSource * self, GstClockTime timestamp, GstLFOControlSourcePrivate *priv = self->priv; gst_object_sync_values (GST_OBJECT (self), timestamp); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *value = _saw_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, timestamp); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -218,10 +218,10 @@ waveform_saw_get_value_array (GstLFOControlSource * self, for (i = 0; i < n_values; i++) { gst_object_sync_values (GST_OBJECT (self), ts); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *values = _saw_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, ts); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); ts += interval; values++; } @@ -251,10 +251,10 @@ waveform_rsaw_get (GstLFOControlSource * self, GstClockTime timestamp, GstLFOControlSourcePrivate *priv = self->priv; gst_object_sync_values (GST_OBJECT (self), timestamp); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *value = _rsaw_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, timestamp); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -269,10 +269,10 @@ waveform_rsaw_get_value_array (GstLFOControlSource * self, for (i = 0; i < n_values; i++) { gst_object_sync_values (GST_OBJECT (self), ts); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *values = _rsaw_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, ts); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); ts += interval; values++; } @@ -312,10 +312,10 @@ waveform_triangle_get (GstLFOControlSource * self, GstClockTime timestamp, GstLFOControlSourcePrivate *priv = self->priv; gst_object_sync_values (GST_OBJECT (self), timestamp); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *value = _triangle_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, timestamp); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -330,11 +330,11 @@ waveform_triangle_get_value_array (GstLFOControlSource * self, for (i = 0; i < n_values; i++) { gst_object_sync_values (GST_OBJECT (self), ts); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); *values = _triangle_get (self, priv->amplitude, priv->offset, priv->timeshift, priv->period, priv->frequency, ts); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); ts += interval; values++; } @@ -455,7 +455,7 @@ gst_lfo_control_source_init (GstLFOControlSource * self) self->priv->period = GST_SECOND / self->priv->frequency; self->priv->timeshift = 0; - self->lock = g_mutex_new (); + g_mutex_init (&self->lock); } static void @@ -464,7 +464,7 @@ gst_lfo_control_source_finalize (GObject * obj) GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (obj); gst_lfo_control_source_reset (self); - g_mutex_free (self->lock); + g_mutex_clear (&self->lock); G_OBJECT_CLASS (gst_lfo_control_source_parent_class)->finalize (obj); } @@ -477,10 +477,10 @@ gst_lfo_control_source_set_property (GObject * object, guint prop_id, switch (prop_id) { case PROP_WAVEFORM: - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); gst_lfo_control_source_set_waveform (self, (GstLFOWaveform) g_value_get_enum (value)); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); break; case PROP_FREQUENCY:{ gdouble frequency = g_value_get_double (value); @@ -488,26 +488,26 @@ gst_lfo_control_source_set_property (GObject * object, guint prop_id, g_return_if_fail (frequency > 0 || ((GstClockTime) (GST_SECOND / frequency)) != 0); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); self->priv->frequency = frequency; self->priv->period = GST_SECOND / frequency; - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); break; } case PROP_TIMESHIFT: - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); self->priv->timeshift = g_value_get_uint64 (value); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); break; case PROP_AMPLITUDE: - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); self->priv->amplitude = g_value_get_double (value); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); break; case PROP_OFFSET: - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); self->priv->offset = g_value_get_double (value); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/libs/gst/controller/gstlfocontrolsource.h b/libs/gst/controller/gstlfocontrolsource.h index 026ccacf8..581e9d3d4 100644 --- a/libs/gst/controller/gstlfocontrolsource.h +++ b/libs/gst/controller/gstlfocontrolsource.h @@ -77,7 +77,7 @@ struct _GstLFOControlSource { /* <private> */ GstLFOControlSourcePrivate *priv; - GMutex *lock; + GMutex lock; gpointer _gst_reserved[GST_PADDING]; }; diff --git a/libs/gst/controller/gsttimedvaluecontrolsource.c b/libs/gst/controller/gsttimedvaluecontrolsource.c index 6174df647..38723eb56 100644 --- a/libs/gst/controller/gsttimedvaluecontrolsource.c +++ b/libs/gst/controller/gsttimedvaluecontrolsource.c @@ -222,9 +222,9 @@ gst_timed_value_control_source_set (GstTimedValueControlSource * self, g_return_val_if_fail (GST_IS_TIMED_VALUE_CONTROL_SOURCE (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); gst_timed_value_control_source_set_internal (self, timestamp, value); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return TRUE; } @@ -255,10 +255,10 @@ gst_timed_value_control_source_set_from_list (GstTimedValueControlSource * GST_WARNING ("GstTimedValued with invalid timestamp passed to %s", GST_FUNCTION); } else { - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); gst_timed_value_control_source_set_internal (self, tv->timestamp, tv->value); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); res = TRUE; } } @@ -285,7 +285,7 @@ gst_timed_value_control_source_unset (GstTimedValueControlSource * self, g_return_val_if_fail (GST_IS_TIMED_VALUE_CONTROL_SOURCE (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); /* check if a control point for the timestamp exists */ if (G_LIKELY (self->values) && (iter = g_sequence_search (self->values, ×tamp, @@ -304,7 +304,7 @@ gst_timed_value_control_source_unset (GstTimedValueControlSource * self, res = TRUE; } } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return res; } @@ -321,7 +321,7 @@ gst_timed_value_control_source_unset_all (GstTimedValueControlSource * self) { g_return_if_fail (GST_IS_TIMED_VALUE_CONTROL_SOURCE (self)); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); /* free GstControlPoint structures */ if (self->values) { g_sequence_free (self->values); @@ -330,7 +330,7 @@ gst_timed_value_control_source_unset_all (GstTimedValueControlSource * self) self->nvalues = 0; self->valid_cache = FALSE; - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); } static void @@ -356,10 +356,10 @@ gst_timed_value_control_source_get_all (GstTimedValueControlSource * self) g_return_val_if_fail (GST_IS_TIMED_VALUE_CONTROL_SOURCE (self), NULL); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); if (G_LIKELY (self->values)) g_sequence_foreach (self->values, (GFunc) _append_control_point, &res); - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return res.head; } @@ -395,7 +395,7 @@ gst_timed_value_control_invalidate_cache (GstTimedValueControlSource * self) static void gst_timed_value_control_source_init (GstTimedValueControlSource * self) { - self->lock = g_mutex_new (); + g_mutex_init (&self->lock); } static void @@ -403,10 +403,10 @@ gst_timed_value_control_source_finalize (GObject * obj) { GstTimedValueControlSource *self = GST_TIMED_VALUE_CONTROL_SOURCE (obj); - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); gst_timed_value_control_source_reset (self); - g_mutex_unlock (self->lock); - g_mutex_free (self->lock); + g_mutex_unlock (&self->lock); + g_mutex_clear (&self->lock); G_OBJECT_CLASS (gst_timed_value_control_source_parent_class)->finalize (obj); } diff --git a/libs/gst/controller/gsttimedvaluecontrolsource.h b/libs/gst/controller/gsttimedvaluecontrolsource.h index 53a91d144..e1dde55b0 100644 --- a/libs/gst/controller/gsttimedvaluecontrolsource.h +++ b/libs/gst/controller/gsttimedvaluecontrolsource.h @@ -84,7 +84,7 @@ struct _GstTimedValueControlSource { GstControlSource parent; /*< protected >*/ - GMutex *lock; + GMutex lock; GSequence *values; /* List of GstControlPoint */ gint nvalues; /* Number of control points */ @@ -102,9 +102,9 @@ struct _GstTimedValueControlSourceClass { }; #define GST_TIMED_VALUE_CONTROL_SOURCE_LOCK(o) \ - g_mutex_lock(((GstTimedValueControlSource *)o)->lock) + g_mutex_lock(&((GstTimedValueControlSource *)o)->lock) #define GST_TIMED_VALUE_CONTROL_SOURCE_UNLOCK(o) \ - g_mutex_unlock(((GstTimedValueControlSource *)o)->lock) + g_mutex_unlock(&((GstTimedValueControlSource *)o)->lock) GType gst_timed_value_control_source_get_type (void); diff --git a/libs/gst/controller/gsttriggercontrolsource.c b/libs/gst/controller/gsttriggercontrolsource.c index 6633fe583..6c8329d90 100644 --- a/libs/gst/controller/gsttriggercontrolsource.c +++ b/libs/gst/controller/gsttriggercontrolsource.c @@ -88,7 +88,7 @@ interpolate_trigger_get (GstTimedValueControlSource * self, gboolean ret = FALSE; GSequenceIter *iter; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); iter = gst_timed_value_control_source_find_control_point_iter (self, timestamp); @@ -97,7 +97,7 @@ interpolate_trigger_get (GstTimedValueControlSource * self, if (!isnan (*value)) ret = TRUE; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } @@ -114,7 +114,7 @@ interpolate_trigger_get_value_array (GstTimedValueControlSource * self, GSequenceIter *iter1 = NULL, *iter2 = NULL; gboolean triggered = FALSE; - g_mutex_lock (self->lock); + g_mutex_lock (&self->lock); for (i = 0; i < n_values; i++) { val = NAN; if (ts >= next_ts) { @@ -142,7 +142,7 @@ interpolate_trigger_get_value_array (GstTimedValueControlSource * self, if (!isnan (val)) ret = TRUE; } else { - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return FALSE; } triggered = TRUE; @@ -152,7 +152,7 @@ interpolate_trigger_get_value_array (GstTimedValueControlSource * self, if (!isnan (val)) ret = TRUE; } else { - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return FALSE; } triggered = FALSE; @@ -161,7 +161,7 @@ interpolate_trigger_get_value_array (GstTimedValueControlSource * self, ts += interval; values++; } - g_mutex_unlock (self->lock); + g_mutex_unlock (&self->lock); return ret; } diff --git a/plugins/elements/gstdataqueue.c b/plugins/elements/gstdataqueue.c index bb0a43152..c1b8820ad 100644 --- a/plugins/elements/gstdataqueue.c +++ b/plugins/elements/gstdataqueue.c @@ -61,7 +61,7 @@ enum GST_CAT_LOG (data_queue_dataflow, \ "locking qlock from thread %p", \ g_thread_self ()); \ - g_mutex_lock (q->qlock); \ + g_mutex_lock (&q->qlock); \ GST_CAT_LOG (data_queue_dataflow, \ "locked qlock from thread %p", \ g_thread_self ()); \ @@ -77,7 +77,7 @@ enum GST_CAT_LOG (data_queue_dataflow, \ "unlocking qlock from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (q->qlock); \ + g_mutex_unlock (&q->qlock); \ } G_STMT_END #define STATUS(q, msg) \ @@ -178,9 +178,9 @@ gst_data_queue_init (GstDataQueue * queue) queue->checkfull = NULL; - queue->qlock = g_mutex_new (); - queue->item_add = g_cond_new (); - queue->item_del = g_cond_new (); + g_mutex_init (&queue->qlock); + g_cond_init (&queue->item_add); + g_cond_init (&queue->item_del); queue->queue = g_queue_new (); GST_DEBUG ("initialized queue's not_empty & not_full conditions"); @@ -262,11 +262,11 @@ gst_data_queue_finalize (GObject * object) g_queue_free (queue->queue); GST_DEBUG ("free mutex"); - g_mutex_free (queue->qlock); + g_mutex_clear (&queue->qlock); GST_DEBUG ("done free mutex"); - g_cond_free (queue->item_add); - g_cond_free (queue->item_del); + g_cond_clear (&queue->item_add); + g_cond_clear (&queue->item_del); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -279,7 +279,7 @@ gst_data_queue_locked_flush (GstDataQueue * queue) STATUS (queue, "after flushing"); /* we deleted something... */ if (queue->waiting_del) - g_cond_signal (queue->item_del); + g_cond_signal (&queue->item_del); } static inline gboolean @@ -386,9 +386,9 @@ gst_data_queue_set_flushing (GstDataQueue * queue, gboolean flushing) if (flushing) { /* release push/pop functions */ if (queue->waiting_add) - g_cond_signal (queue->item_add); + g_cond_signal (&queue->item_add); if (queue->waiting_del) - g_cond_signal (queue->item_del); + g_cond_signal (&queue->item_del); } GST_DATA_QUEUE_MUTEX_UNLOCK (queue); } @@ -434,7 +434,7 @@ gst_data_queue_push (GstDataQueue * queue, GstDataQueueItem * item) /* signal might have removed some items */ while (gst_data_queue_locked_is_full (queue)) { queue->waiting_del = TRUE; - g_cond_wait (queue->item_del, queue->qlock); + g_cond_wait (&queue->item_del, &queue->qlock); queue->waiting_del = FALSE; if (queue->flushing) goto flushing; @@ -450,7 +450,7 @@ gst_data_queue_push (GstDataQueue * queue, GstDataQueueItem * item) STATUS (queue, "after pushing"); if (queue->waiting_add) - g_cond_signal (queue->item_add); + g_cond_signal (&queue->item_add); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); @@ -499,7 +499,7 @@ gst_data_queue_pop (GstDataQueue * queue, GstDataQueueItem ** item) while (gst_data_queue_locked_is_empty (queue)) { queue->waiting_add = TRUE; - g_cond_wait (queue->item_add, queue->qlock); + g_cond_wait (&queue->item_add, &queue->qlock); queue->waiting_add = FALSE; if (queue->flushing) goto flushing; @@ -517,7 +517,7 @@ gst_data_queue_pop (GstDataQueue * queue, GstDataQueueItem ** item) STATUS (queue, "after popping"); if (queue->waiting_del) - g_cond_signal (queue->item_del); + g_cond_signal (&queue->item_del); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); @@ -603,7 +603,7 @@ gst_data_queue_limits_changed (GstDataQueue * queue) GST_DATA_QUEUE_MUTEX_LOCK (queue); if (queue->waiting_del) { GST_DEBUG ("signal del"); - g_cond_signal (queue->item_del); + g_cond_signal (&queue->item_del); } GST_DATA_QUEUE_MUTEX_UNLOCK (queue); } diff --git a/plugins/elements/gstdataqueue.h b/plugins/elements/gstdataqueue.h index b6878fae1..36f4be7e9 100644 --- a/plugins/elements/gstdataqueue.h +++ b/plugins/elements/gstdataqueue.h @@ -127,11 +127,11 @@ struct _GstDataQueue GstDataQueueCheckFullFunction checkfull; /* Callback to check if the queue is full */ gpointer *checkdata; - GMutex *qlock; /* lock for queue (vs object lock) */ + GMutex qlock; /* lock for queue (vs object lock) */ gboolean waiting_add; - GCond *item_add; /* signals buffers now available for reading */ + GCond item_add; /* signals buffers now available for reading */ gboolean waiting_del; - GCond *item_del; /* signals space now available for writing */ + GCond item_del; /* signals space now available for writing */ gboolean flushing; /* indicates whether conditions where signalled because * of external flushing */ GstDataQueueFullCallback fullcallback; diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c index 17a0bfc51..5f70f6e2b 100644 --- a/plugins/elements/gstinputselector.c +++ b/plugins/elements/gstinputselector.c @@ -69,18 +69,10 @@ GST_DEBUG_CATEGORY_STATIC (input_selector_debug); #define NOTIFY_MUTEX_UNLOCK() #else static GStaticRecMutex notify_mutex = G_STATIC_REC_MUTEX_INIT; -#define NOTIFY_MUTEX_LOCK() g_static_rec_mutex_lock (¬ify_mutex) -#define NOTIFY_MUTEX_UNLOCK() g_static_rec_mutex_unlock (¬ify_mutex) +#define NOTIFY_MUTEX_LOCK() g_rec_mutex_lock (¬ify_mutex) +#define NOTIFY_MUTEX_UNLOCK() g_rec_mutex_unlock (¬ify_mutex) #endif -#define GST_INPUT_SELECTOR_GET_LOCK(sel) (((GstInputSelector*)(sel))->lock) -#define GST_INPUT_SELECTOR_GET_COND(sel) (((GstInputSelector*)(sel))->cond) -#define GST_INPUT_SELECTOR_LOCK(sel) (g_mutex_lock (GST_INPUT_SELECTOR_GET_LOCK(sel))) -#define GST_INPUT_SELECTOR_UNLOCK(sel) (g_mutex_unlock (GST_INPUT_SELECTOR_GET_LOCK(sel))) -#define GST_INPUT_SELECTOR_WAIT(sel) (g_cond_wait (GST_INPUT_SELECTOR_GET_COND(sel), \ - GST_INPUT_SELECTOR_GET_LOCK(sel))) -#define GST_INPUT_SELECTOR_BROADCAST(sel) (g_cond_broadcast (GST_INPUT_SELECTOR_GET_COND(sel))) - static GstStaticPadTemplate gst_input_selector_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u", GST_PAD_SINK, @@ -748,6 +740,7 @@ flushing: } static void gst_input_selector_dispose (GObject * object); +static void gst_input_selector_finalize (GObject * object); static void gst_input_selector_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -813,6 +806,7 @@ gst_input_selector_class_init (GstInputSelectorClass * klass) GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); gobject_class->dispose = gst_input_selector_dispose; + gobject_class->finalize = gst_input_selector_finalize; gobject_class->set_property = gst_input_selector_set_property; gobject_class->get_property = gst_input_selector_get_property; @@ -890,8 +884,8 @@ gst_input_selector_init (GstInputSelector * sel) sel->padcount = 0; sel->sync_streams = DEFAULT_SYNC_STREAMS; - sel->lock = g_mutex_new (); - sel->cond = g_cond_new (); + g_mutex_init (&sel->lock); + g_cond_init (&sel->cond); sel->blocked = FALSE; } @@ -904,18 +898,20 @@ gst_input_selector_dispose (GObject * object) gst_object_unref (sel->active_sinkpad); sel->active_sinkpad = NULL; } - if (sel->lock) { - g_mutex_free (sel->lock); - sel->lock = NULL; - } - if (sel->cond) { - g_cond_free (sel->cond); - sel->cond = NULL; - } - G_OBJECT_CLASS (parent_class)->dispose (object); } +static void +gst_input_selector_finalize (GObject * object) +{ + GstInputSelector *sel = GST_INPUT_SELECTOR (object); + + g_mutex_clear (&sel->lock); + g_cond_clear (&sel->cond); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + /* this function must be called with the SELECTOR_LOCK. It returns TRUE when the * active pad changed. */ static gboolean diff --git a/plugins/elements/gstinputselector.h b/plugins/elements/gstinputselector.h index 116c31cfe..8a5248a0d 100644 --- a/plugins/elements/gstinputselector.h +++ b/plugins/elements/gstinputselector.h @@ -40,8 +40,8 @@ G_BEGIN_DECLS typedef struct _GstInputSelector GstInputSelector; typedef struct _GstInputSelectorClass GstInputSelectorClass; -#define GST_INPUT_SELECTOR_GET_LOCK(sel) (((GstInputSelector*)(sel))->lock) -#define GST_INPUT_SELECTOR_GET_COND(sel) (((GstInputSelector*)(sel))->cond) +#define GST_INPUT_SELECTOR_GET_LOCK(sel) (&((GstInputSelector*)(sel))->lock) +#define GST_INPUT_SELECTOR_GET_COND(sel) (&((GstInputSelector*)(sel))->cond) #define GST_INPUT_SELECTOR_LOCK(sel) (g_mutex_lock (GST_INPUT_SELECTOR_GET_LOCK(sel))) #define GST_INPUT_SELECTOR_UNLOCK(sel) (g_mutex_unlock (GST_INPUT_SELECTOR_GET_LOCK(sel))) #define GST_INPUT_SELECTOR_WAIT(sel) (g_cond_wait (GST_INPUT_SELECTOR_GET_COND(sel), \ @@ -58,8 +58,8 @@ struct _GstInputSelector { guint padcount; gboolean sync_streams; - GMutex *lock; - GCond *cond; + GMutex lock; + GCond cond; gboolean blocked; gboolean flushing; }; diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c index 5aee6bd1d..1b4f4b9c7 100644 --- a/plugins/elements/gstmultiqueue.c +++ b/plugins/elements/gstmultiqueue.c @@ -109,10 +109,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/gst.h> #include <stdio.h> #include "gstmultiqueue.h" @@ -163,7 +159,7 @@ struct _GstSingleQueue guint32 last_oldid; /* Previously observed old_id, reset to MAXUINT32 on flush */ GstClockTime next_time; /* End running time of next buffer to be pushed */ GstClockTime last_time; /* Start running time of last pushed buffer */ - GCond *turn; /* SingleQueue turn waiting conditional */ + GCond turn; /* SingleQueue turn waiting conditional */ }; @@ -251,11 +247,11 @@ enum }; #define GST_MULTI_QUEUE_MUTEX_LOCK(q) G_STMT_START { \ - g_mutex_lock (q->qlock); \ + g_mutex_lock (&q->qlock); \ } G_STMT_END #define GST_MULTI_QUEUE_MUTEX_UNLOCK(q) G_STMT_START { \ - g_mutex_unlock (q->qlock); \ + g_mutex_unlock (&q->qlock); \ } G_STMT_END static void gst_multi_queue_finalize (GObject * object); @@ -451,7 +447,7 @@ gst_multi_queue_init (GstMultiQueue * mqueue) mqueue->highid = -1; mqueue->high_time = GST_CLOCK_TIME_NONE; - mqueue->qlock = g_mutex_new (); + g_mutex_init (&mqueue->qlock); } static void @@ -465,7 +461,7 @@ gst_multi_queue_finalize (GObject * object) mqueue->queues_cookie++; /* free/unref instance data */ - g_mutex_free (mqueue->qlock); + g_mutex_clear (&mqueue->qlock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -713,7 +709,7 @@ gst_multi_queue_change_state (GstElement * element, GstStateChange transition) for (tmp = mqueue->queues; tmp; tmp = g_list_next (tmp)) { sq = (GstSingleQueue *) tmp->data; sq->flushing = TRUE; - g_cond_signal (sq->turn); + g_cond_signal (&sq->turn); } GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue); break; @@ -753,7 +749,7 @@ gst_single_queue_flush (GstMultiQueue * mq, GstSingleQueue * sq, gboolean flush) GST_LOG_OBJECT (mq, "SingleQueue %d : waking up eventually waiting task", sq->id); GST_MULTI_QUEUE_MUTEX_LOCK (mq); - g_cond_signal (sq->turn); + g_cond_signal (&sq->turn); GST_MULTI_QUEUE_MUTEX_UNLOCK (mq); GST_LOG_OBJECT (mq, "SingleQueue %d : pausing task", sq->id); @@ -1234,7 +1230,7 @@ gst_multi_queue_loop (GstPad * pad) wake_up_next_non_linked (mq); mq->numwaiting++; - g_cond_wait (sq->turn, mq->qlock); + g_cond_wait (&sq->turn, &mq->qlock); mq->numwaiting--; if (sq->flushing) { @@ -1609,7 +1605,7 @@ wake_up_next_non_linked (GstMultiQueue * mq) && sq->next_time >= mq->high_time) || (sq->nextid != 0 && sq->nextid <= mq->highid)) { GST_LOG_OBJECT (mq, "Waking up singlequeue %d", sq->id); - g_cond_signal (sq->turn); + g_cond_signal (&sq->turn); } } } @@ -1839,7 +1835,7 @@ gst_single_queue_free (GstSingleQueue * sq) /* DRAIN QUEUE */ gst_data_queue_flush (sq->queue); g_object_unref (sq->queue); - g_cond_free (sq->turn); + g_cond_clear (&sq->turn); g_free (sq); } @@ -1903,7 +1899,7 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id) sq->oldid = 0; sq->next_time = GST_CLOCK_TIME_NONE; sq->last_time = GST_CLOCK_TIME_NONE; - sq->turn = g_cond_new (); + g_cond_init (&sq->turn); sq->sinktime = GST_CLOCK_TIME_NONE; sq->srctime = GST_CLOCK_TIME_NONE; @@ -1948,14 +1944,14 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id) /* only activate the pads when we are not in the NULL state * and add the pad under the state_lock to prevend state changes * between activating and adding */ - g_static_rec_mutex_lock (GST_STATE_GET_LOCK (mqueue)); + g_rec_mutex_lock (GST_STATE_GET_LOCK (mqueue)); if (GST_STATE_TARGET (mqueue) != GST_STATE_NULL) { gst_pad_set_active (sq->srcpad, TRUE); gst_pad_set_active (sq->sinkpad, TRUE); } gst_element_add_pad (GST_ELEMENT (mqueue), sq->srcpad); gst_element_add_pad (GST_ELEMENT (mqueue), sq->sinkpad); - g_static_rec_mutex_unlock (GST_STATE_GET_LOCK (mqueue)); + g_rec_mutex_unlock (GST_STATE_GET_LOCK (mqueue)); GST_DEBUG_OBJECT (mqueue, "GstSingleQueue [%d] created and pads added", sq->id); diff --git a/plugins/elements/gstmultiqueue.h b/plugins/elements/gstmultiqueue.h index ee20a7153..1da03680e 100644 --- a/plugins/elements/gstmultiqueue.h +++ b/plugins/elements/gstmultiqueue.h @@ -69,7 +69,7 @@ struct _GstMultiQueue { guint32 highid; /* contains highest id of last outputted object */ GstClockTime high_time; /* highest start running time */ - GMutex * qlock; /* Global queue lock (vs object lock or individual */ + GMutex qlock; /* Global queue lock (vs object lock or individual */ /* queues lock). Protects nbqueues, queues, global */ /* GstMultiQueueSize, counter and highid */ diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index a1cb42d2a..274017d22 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -128,7 +128,7 @@ enum #define DEFAULT_MAX_SIZE_TIME GST_SECOND /* 1 second */ #define GST_QUEUE_MUTEX_LOCK(q) G_STMT_START { \ - g_mutex_lock (q->qlock); \ + g_mutex_lock (&q->qlock); \ } G_STMT_END #define GST_QUEUE_MUTEX_LOCK_CHECK(q,label) G_STMT_START { \ @@ -138,13 +138,13 @@ enum } G_STMT_END #define GST_QUEUE_MUTEX_UNLOCK(q) G_STMT_START { \ - g_mutex_unlock (q->qlock); \ + g_mutex_unlock (&q->qlock); \ } G_STMT_END #define GST_QUEUE_WAIT_DEL_CHECK(q, label) G_STMT_START { \ STATUS (q, q->sinkpad, "wait for DEL"); \ q->waiting_del = TRUE; \ - g_cond_wait (q->item_del, q->qlock); \ + g_cond_wait (&q->item_del, &q->qlock); \ q->waiting_del = FALSE; \ if (q->srcresult != GST_FLOW_OK) { \ STATUS (q, q->srcpad, "received DEL wakeup"); \ @@ -156,7 +156,7 @@ enum #define GST_QUEUE_WAIT_ADD_CHECK(q, label) G_STMT_START { \ STATUS (q, q->srcpad, "wait for ADD"); \ q->waiting_add = TRUE; \ - g_cond_wait (q->item_add, q->qlock); \ + g_cond_wait (&q->item_add, &q->qlock); \ q->waiting_add = FALSE; \ if (q->srcresult != GST_FLOW_OK) { \ STATUS (q, q->srcpad, "received ADD wakeup"); \ @@ -168,14 +168,14 @@ enum #define GST_QUEUE_SIGNAL_DEL(q) G_STMT_START { \ if (q->waiting_del) { \ STATUS (q, q->srcpad, "signal DEL"); \ - g_cond_signal (q->item_del); \ + g_cond_signal (&q->item_del); \ } \ } G_STMT_END #define GST_QUEUE_SIGNAL_ADD(q) G_STMT_START { \ if (q->waiting_add) { \ STATUS (q, q->sinkpad, "signal ADD"); \ - g_cond_signal (q->item_add); \ + g_cond_signal (&q->item_add); \ } \ } G_STMT_END @@ -421,9 +421,9 @@ gst_queue_init (GstQueue * queue) queue->leaky = GST_QUEUE_NO_LEAK; queue->srcresult = GST_FLOW_WRONG_STATE; - queue->qlock = g_mutex_new (); - queue->item_add = g_cond_new (); - queue->item_del = g_cond_new (); + g_mutex_init (&queue->qlock); + g_cond_init (&queue->item_add); + g_cond_init (&queue->item_del); g_queue_init (&queue->queue); @@ -452,9 +452,9 @@ gst_queue_finalize (GObject * object) gst_mini_object_unref (data); g_queue_clear (&queue->queue); - g_mutex_free (queue->qlock); - g_cond_free (queue->item_add); - g_cond_free (queue->item_del); + g_mutex_clear (&queue->qlock); + g_cond_clear (&queue->item_add); + g_cond_clear (&queue->item_del); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -1347,7 +1347,7 @@ gst_queue_src_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode, GST_QUEUE_MUTEX_LOCK (queue); queue->srcresult = GST_FLOW_WRONG_STATE; /* the item add signal will unblock */ - g_cond_signal (queue->item_add); + g_cond_signal (&queue->item_add); GST_QUEUE_MUTEX_UNLOCK (queue); /* step 2, make sure streaming finishes */ diff --git a/plugins/elements/gstqueue.h b/plugins/elements/gstqueue.h index 2d4be6f6a..3b0752c94 100644 --- a/plugins/elements/gstqueue.h +++ b/plugins/elements/gstqueue.h @@ -118,11 +118,11 @@ struct _GstQueue { /* whether we leak data, and at which end */ gint leaky; - GMutex *qlock; /* lock for queue (vs object lock) */ + GMutex qlock; /* lock for queue (vs object lock) */ gboolean waiting_add; - GCond *item_add; /* signals buffers now available for reading */ + GCond item_add; /* signals buffers now available for reading */ gboolean waiting_del; - GCond *item_del; /* signals space now available for writing */ + GCond item_del; /* signals space now available for writing */ gboolean head_needs_discont, tail_needs_discont; gboolean push_newsegment; diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 1a2ba1783..6b761fca6 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -159,7 +159,7 @@ enum queue->queue.length)) #define GST_QUEUE2_MUTEX_LOCK(q) G_STMT_START { \ - g_mutex_lock (q->qlock); \ + g_mutex_lock (&q->qlock); \ } G_STMT_END #define GST_QUEUE2_MUTEX_LOCK_CHECK(q,res,label) G_STMT_START { \ @@ -169,13 +169,13 @@ enum } G_STMT_END #define GST_QUEUE2_MUTEX_UNLOCK(q) G_STMT_START { \ - g_mutex_unlock (q->qlock); \ + g_mutex_unlock (&q->qlock); \ } G_STMT_END #define GST_QUEUE2_WAIT_DEL_CHECK(q, res, label) G_STMT_START { \ STATUS (queue, q->sinkpad, "wait for DEL"); \ q->waiting_del = TRUE; \ - g_cond_wait (q->item_del, queue->qlock); \ + g_cond_wait (&q->item_del, &queue->qlock); \ q->waiting_del = FALSE; \ if (res != GST_FLOW_OK) { \ STATUS (queue, q->srcpad, "received DEL wakeup"); \ @@ -187,7 +187,7 @@ enum #define GST_QUEUE2_WAIT_ADD_CHECK(q, res, label) G_STMT_START { \ STATUS (queue, q->srcpad, "wait for ADD"); \ q->waiting_add = TRUE; \ - g_cond_wait (q->item_add, q->qlock); \ + g_cond_wait (&q->item_add, &q->qlock); \ q->waiting_add = FALSE; \ if (res != GST_FLOW_OK) { \ STATUS (queue, q->srcpad, "received ADD wakeup"); \ @@ -199,14 +199,14 @@ enum #define GST_QUEUE2_SIGNAL_DEL(q) G_STMT_START { \ if (q->waiting_del) { \ STATUS (q, q->srcpad, "signal DEL"); \ - g_cond_signal (q->item_del); \ + g_cond_signal (&q->item_del); \ } \ } G_STMT_END #define GST_QUEUE2_SIGNAL_ADD(q) G_STMT_START { \ if (q->waiting_add) { \ STATUS (q, q->sinkpad, "signal ADD"); \ - g_cond_signal (q->item_add); \ + g_cond_signal (&q->item_add); \ } \ } G_STMT_END @@ -439,11 +439,11 @@ gst_queue2_init (GstQueue2 * queue) queue->in_timer = g_timer_new (); queue->out_timer = g_timer_new (); - queue->qlock = g_mutex_new (); + g_mutex_init (&queue->qlock); queue->waiting_add = FALSE; - queue->item_add = g_cond_new (); + g_cond_init (&queue->item_add); queue->waiting_del = FALSE; - queue->item_del = g_cond_new (); + g_cond_init (&queue->item_del); g_queue_init (&queue->queue); queue->buffering_percent = 100; @@ -476,9 +476,9 @@ gst_queue2_finalize (GObject * object) } g_queue_clear (&queue->queue); - g_mutex_free (queue->qlock); - g_cond_free (queue->item_add); - g_cond_free (queue->item_del); + g_mutex_clear (&queue->qlock); + g_cond_clear (&queue->item_add); + g_cond_clear (&queue->item_del); g_timer_destroy (queue->in_timer); g_timer_destroy (queue->out_timer); diff --git a/plugins/elements/gstqueue2.h b/plugins/elements/gstqueue2.h index 02a38f264..66947a785 100644 --- a/plugins/elements/gstqueue2.h +++ b/plugins/elements/gstqueue2.h @@ -124,11 +124,11 @@ struct _GstQueue2 guint64 bytes_out; gdouble byte_out_rate; - GMutex *qlock; /* lock for queue (vs object lock) */ + GMutex qlock; /* lock for queue (vs object lock) */ gboolean waiting_add; - GCond *item_add; /* signals buffers now available for reading */ + GCond item_add; /* signals buffers now available for reading */ gboolean waiting_del; - GCond *item_del; /* signals space now available for writing */ + GCond item_del; /* signals space now available for writing */ /* temp location stuff */ gchar *temp_template; diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index d27d202bf..498f8587c 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -79,8 +79,8 @@ gst_tee_pull_mode_get_type (void) } /* lock to protect request pads from being removed while downstream */ -#define GST_TEE_DYN_LOCK(tee) g_mutex_lock ((tee)->dyn_lock) -#define GST_TEE_DYN_UNLOCK(tee) g_mutex_unlock ((tee)->dyn_lock) +#define GST_TEE_DYN_LOCK(tee) g_mutex_lock (&(tee)->dyn_lock) +#define GST_TEE_DYN_UNLOCK(tee) g_mutex_unlock (&(tee)->dyn_lock) #define DEFAULT_PROP_NUM_SRC_PADS 0 #define DEFAULT_PROP_HAS_SINK_LOOP FALSE @@ -180,7 +180,7 @@ gst_tee_finalize (GObject * object) g_free (tee->last_message); - g_mutex_free (tee->dyn_lock); + g_mutex_clear (&tee->dyn_lock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -250,7 +250,7 @@ gst_tee_class_init (GstTeeClass * klass) static void gst_tee_init (GstTee * tee) { - tee->dyn_lock = g_mutex_new (); + g_mutex_init (&tee->dyn_lock); tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); tee->sink_mode = GST_PAD_MODE_NONE; diff --git a/plugins/elements/gsttee.h b/plugins/elements/gsttee.h index eee7c0e98..5d6cc51c1 100644 --- a/plugins/elements/gsttee.h +++ b/plugins/elements/gsttee.h @@ -67,7 +67,7 @@ struct _GstTee { /*< private >*/ /* lock protecting dynamic pads */ - GMutex *dyn_lock; + GMutex dyn_lock; GstPad *sinkpad; GstPad *allocpad; diff --git a/tests/benchmarks/gstbufferstress.c b/tests/benchmarks/gstbufferstress.c index e7ec274eb..b5c2997b1 100644 --- a/tests/benchmarks/gstbufferstress.c +++ b/tests/benchmarks/gstbufferstress.c @@ -25,7 +25,7 @@ #define MAX_THREADS 1000 static guint64 nbbuffers; -static GMutex *mutex; +static GMutex mutex; static void * @@ -36,8 +36,8 @@ run_test (void *user_data) GstBuffer *buf; GstClockTime start, end; - g_mutex_lock (mutex); - g_mutex_unlock (mutex); + g_mutex_lock (&mutex); + g_mutex_unlock (&mutex); start = gst_util_get_timestamp (); @@ -68,7 +68,7 @@ main (gint argc, gchar * argv[]) GstClockTime start, end; gst_init (&argc, &argv); - mutex = g_mutex_new (); + g_mutex_init (&mutex); if (argc != 3) { g_print ("usage: %s <num_threads> <nbbuffers>\n", argv[0]); @@ -88,7 +88,7 @@ main (gint argc, gchar * argv[]) exit (-3); } - g_mutex_lock (mutex); + g_mutex_lock (&mutex); /* Let's just make sure the GstBufferClass is loaded ... */ tmp = gst_buffer_new (); @@ -110,7 +110,7 @@ main (gint argc, gchar * argv[]) /* Signal all threads to start */ start = gst_util_get_timestamp (); - g_mutex_unlock (mutex); + g_mutex_unlock (&mutex); for (t = 0; t < num_threads; t++) { if (threads[t]) diff --git a/tests/benchmarks/gstpollstress.c b/tests/benchmarks/gstpollstress.c index b384f9554..807737d90 100644 --- a/tests/benchmarks/gstpollstress.c +++ b/tests/benchmarks/gstpollstress.c @@ -25,7 +25,7 @@ static GstPoll *set; static GList *fds = NULL; -static GMutex *fdlock; +static GMutex fdlock; static GTimer *timer; #define MAX_THREADS 100 @@ -37,7 +37,7 @@ mess_some_more (void) gint random; gint removed = 0; - g_mutex_lock (fdlock); + g_mutex_lock (&fdlock); for (walk = fds; walk;) { GstPollFD *fd = (GstPollFD *) walk->data; @@ -106,7 +106,7 @@ mess_some_more (void) } } - g_mutex_unlock (fdlock); + g_mutex_unlock (&fdlock); } static void * @@ -124,10 +124,10 @@ run_test (void *threadid) } else { mess_some_more (); if (g_timer_elapsed (timer, NULL) > 0.5) { - g_mutex_lock (fdlock); + g_mutex_lock (&fdlock); g_print ("active fds :%d\n", g_list_length (fds)); g_timer_start (timer); - g_mutex_unlock (fdlock); + g_mutex_unlock (&fdlock); } g_usleep (1); } @@ -145,7 +145,7 @@ main (gint argc, gchar * argv[]) gst_init (&argc, &argv); - fdlock = g_mutex_new (); + g_mutex_init (&fdlock); timer = g_timer_new (); if (argc != 2) { diff --git a/tests/check/gst/gsttask.c b/tests/check/gst/gsttask.c index 12791d286..824f92669 100644 --- a/tests/check/gst/gsttask.c +++ b/tests/check/gst/gsttask.c @@ -21,10 +21,10 @@ #include <gst/check/gstcheck.h> -static GMutex *task_lock; -static GCond *task_cond; +static GMutex task_lock; +static GCond task_cond; -static GStaticRecMutex task_mutex = G_STATIC_REC_MUTEX_INIT; +static GRecMutex task_mutex; static void task_func2 (void *data) @@ -32,10 +32,10 @@ task_func2 (void *data) gboolean ret; GstTask *t = *((GstTask **) data); - g_mutex_lock (task_lock); + g_mutex_lock (&task_lock); GST_DEBUG ("signal"); - g_cond_signal (task_cond); - g_mutex_unlock (task_lock); + g_cond_signal (&task_cond); + g_mutex_unlock (&task_lock); ASSERT_WARNING (ret = gst_task_join (t)); fail_unless (ret == FALSE); @@ -49,20 +49,21 @@ GST_START_TEST (test_join) t = gst_task_new (task_func2, &t); fail_if (t == NULL); + g_rec_mutex_init (&task_mutex); gst_task_set_lock (t, &task_mutex); - task_cond = g_cond_new (); - task_lock = g_mutex_new (); + g_cond_init (&task_cond); + g_mutex_init (&task_lock); - g_mutex_lock (task_lock); + g_mutex_lock (&task_lock); GST_DEBUG ("starting"); ret = gst_task_start (t); fail_unless (ret == TRUE); /* wait for it to spin up */ GST_DEBUG ("waiting"); - g_cond_wait (task_cond, task_lock); + g_cond_wait (&task_cond, &task_lock); GST_DEBUG ("done waiting"); - g_mutex_unlock (task_lock); + g_mutex_unlock (&task_lock); GST_DEBUG ("joining"); ret = gst_task_join (t); @@ -78,10 +79,10 @@ GST_END_TEST; static void task_func (void *data) { - g_mutex_lock (task_lock); + g_mutex_lock (&task_lock); GST_DEBUG ("signal"); - g_cond_signal (task_cond); - g_mutex_unlock (task_lock); + g_cond_signal (&task_cond); + g_mutex_unlock (&task_lock); } GST_START_TEST (test_lock_start) @@ -92,20 +93,21 @@ GST_START_TEST (test_lock_start) t = gst_task_new (task_func, NULL); fail_if (t == NULL); + g_rec_mutex_init (&task_mutex); gst_task_set_lock (t, &task_mutex); - task_cond = g_cond_new (); - task_lock = g_mutex_new (); + g_cond_init (&task_cond); + g_mutex_init (&task_lock); - g_mutex_lock (task_lock); + g_mutex_lock (&task_lock); GST_DEBUG ("starting"); ret = gst_task_start (t); fail_unless (ret == TRUE); /* wait for it to spin up */ GST_DEBUG ("waiting"); - g_cond_wait (task_cond, task_lock); + g_cond_wait (&task_cond, &task_lock); GST_DEBUG ("done waiting"); - g_mutex_unlock (task_lock); + g_mutex_unlock (&task_lock); /* cannot set mutex now */ ASSERT_WARNING (gst_task_set_lock (t, &task_mutex)); @@ -129,6 +131,7 @@ GST_START_TEST (test_lock) t = gst_task_new (task_func, NULL); fail_if (t == NULL); + g_rec_mutex_init (&task_mutex); gst_task_set_lock (t, &task_mutex); GST_DEBUG ("pause"); |