From f704b3f9757d22fe2cd17d59cdefdfa2e5f06a84 Mon Sep 17 00:00:00 2001 From: Marc Leeman Date: Thu, 7 Feb 2013 10:49:33 +0100 Subject: [PATCH] decodebin: g_mutex_new -> g_mutex_init Don't use deprecated GLib API. https://bugzilla.gnome.org/show_bug.cgi?id=693302 --- gst/playback/gstdecodebin2.c | 65 +++++++++++++--------------------- gst/playback/gsturidecodebin.c | 21 ++++++----- 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 09626b16f8..8aedbd11b9 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -157,15 +157,15 @@ struct _GstDecodeBin GstElement *typefind; /* this holds the typefind object */ - GMutex *expose_lock; /* Protects exposal and removal of groups */ + GMutex expose_lock; /* Protects exposal and removal of groups */ GstDecodeChain *decode_chain; /* Top level decode chain */ guint nbpads; /* unique identifier for source pads */ - GMutex *factories_lock; + GMutex factories_lock; guint32 factories_cookie; /* Cookie from last time when factories was updated */ GList *factories; /* factories we can use for selecting elements */ - GMutex *subtitle_lock; /* Protects changes to subtitles and encoding */ + GMutex subtitle_lock; /* Protects changes to subtitles and encoding */ GList *subtitles; /* List of elements with subtitle-encoding, * protected by above mutex! */ @@ -174,7 +174,7 @@ struct _GstDecodeBin gboolean async_pending; /* async-start has been emitted */ - GMutex *dyn_lock; /* lock protecting pad blocking */ + GMutex dyn_lock; /* lock protecting pad blocking */ gboolean shutdown; /* if we are shutting down */ GList *blocked_pads; /* pads that have set to block */ @@ -306,7 +306,7 @@ static gboolean check_upstream_seekable (GstDecodeBin * dbin, GstPad * pad); GST_LOG_OBJECT (dbin, \ "expose locking from thread %p", \ g_thread_self ()); \ - g_mutex_lock (GST_DECODE_BIN_CAST(dbin)->expose_lock); \ + g_mutex_lock (&GST_DECODE_BIN_CAST(dbin)->expose_lock); \ GST_LOG_OBJECT (dbin, \ "expose locked from thread %p", \ g_thread_self ()); \ @@ -316,14 +316,14 @@ static gboolean check_upstream_seekable (GstDecodeBin * dbin, GstPad * pad); GST_LOG_OBJECT (dbin, \ "expose unlocking from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (GST_DECODE_BIN_CAST(dbin)->expose_lock); \ + g_mutex_unlock (&GST_DECODE_BIN_CAST(dbin)->expose_lock); \ } G_STMT_END #define DYN_LOCK(dbin) G_STMT_START { \ GST_LOG_OBJECT (dbin, \ "dynlocking from thread %p", \ g_thread_self ()); \ - g_mutex_lock (GST_DECODE_BIN_CAST(dbin)->dyn_lock); \ + g_mutex_lock (&GST_DECODE_BIN_CAST(dbin)->dyn_lock); \ GST_LOG_OBJECT (dbin, \ "dynlocked from thread %p", \ g_thread_self ()); \ @@ -333,14 +333,14 @@ static gboolean check_upstream_seekable (GstDecodeBin * dbin, GstPad * pad); GST_LOG_OBJECT (dbin, \ "dynunlocking from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (GST_DECODE_BIN_CAST(dbin)->dyn_lock); \ + g_mutex_unlock (&GST_DECODE_BIN_CAST(dbin)->dyn_lock); \ } G_STMT_END #define SUBTITLE_LOCK(dbin) G_STMT_START { \ GST_LOG_OBJECT (dbin, \ "subtitle locking from thread %p", \ g_thread_self ()); \ - g_mutex_lock (GST_DECODE_BIN_CAST(dbin)->subtitle_lock); \ + g_mutex_lock (&GST_DECODE_BIN_CAST(dbin)->subtitle_lock); \ GST_LOG_OBJECT (dbin, \ "subtitle lock from thread %p", \ g_thread_self ()); \ @@ -350,7 +350,7 @@ static gboolean check_upstream_seekable (GstDecodeBin * dbin, GstPad * pad); GST_LOG_OBJECT (dbin, \ "subtitle unlocking from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (GST_DECODE_BIN_CAST(dbin)->subtitle_lock); \ + g_mutex_unlock (&GST_DECODE_BIN_CAST(dbin)->subtitle_lock); \ } G_STMT_END struct _GstPendingPad @@ -397,7 +397,7 @@ struct _GstDecodeChain GstDecodeGroup *parent; GstDecodeBin *dbin; - GMutex *lock; /* Protects this chain and its groups */ + GMutex lock; /* Protects this chain and its groups */ GstPad *pad; /* srcpad that caused creation of this chain */ @@ -454,7 +454,7 @@ static gboolean gst_decode_bin_expose (GstDecodeBin * dbin); GST_LOG_OBJECT (chain->dbin, \ "locking chain %p from thread %p", \ chain, g_thread_self ()); \ - g_mutex_lock (chain->lock); \ + g_mutex_lock (&chain->lock); \ GST_LOG_OBJECT (chain->dbin, \ "locked chain %p from thread %p", \ chain, g_thread_self ()); \ @@ -464,7 +464,7 @@ static gboolean gst_decode_bin_expose (GstDecodeBin * dbin); GST_LOG_OBJECT (chain->dbin, \ "unlocking chain %p from thread %p", \ chain, g_thread_self ()); \ - g_mutex_unlock (chain->lock); \ + g_mutex_unlock (&chain->lock); \ } G_STMT_END /* GstDecodePad @@ -993,7 +993,7 @@ gst_decode_bin_init (GstDecodeBin * decode_bin) GST_OBJECT_FLAG_SET (decode_bin, GST_BIN_FLAG_NO_RESYNC); /* first filter out the interesting element factories */ - decode_bin->factories_lock = g_mutex_new (); + g_mutex_init (&decode_bin->factories_lock); /* we create the typefind element only once */ decode_bin->typefind = gst_element_factory_make ("typefind", "typefind"); @@ -1032,14 +1032,14 @@ gst_decode_bin_init (GstDecodeBin * decode_bin) G_CALLBACK (type_found), decode_bin); } - decode_bin->expose_lock = g_mutex_new (); + g_mutex_init (&decode_bin->expose_lock); decode_bin->decode_chain = NULL; - decode_bin->dyn_lock = g_mutex_new (); + g_mutex_init (&decode_bin->dyn_lock); decode_bin->shutdown = FALSE; decode_bin->blocked_pads = NULL; - decode_bin->subtitle_lock = g_mutex_new (); + g_mutex_init (&decode_bin->subtitle_lock); decode_bin->encoding = g_strdup (DEFAULT_SUBTITLE_ENCODING); decode_bin->caps = gst_static_caps_get (&default_raw_caps); @@ -1090,25 +1090,10 @@ gst_decode_bin_finalize (GObject * object) decode_bin = GST_DECODE_BIN (object); - if (decode_bin->expose_lock) { - g_mutex_free (decode_bin->expose_lock); - decode_bin->expose_lock = NULL; - } - - if (decode_bin->dyn_lock) { - g_mutex_free (decode_bin->dyn_lock); - decode_bin->dyn_lock = NULL; - } - - if (decode_bin->subtitle_lock) { - g_mutex_free (decode_bin->subtitle_lock); - decode_bin->subtitle_lock = NULL; - } - - if (decode_bin->factories_lock) { - g_mutex_free (decode_bin->factories_lock); - decode_bin->factories_lock = NULL; - } + g_mutex_clear (&decode_bin->expose_lock); + g_mutex_clear (&decode_bin->dyn_lock); + g_mutex_clear (&decode_bin->subtitle_lock); + g_mutex_clear (&decode_bin->factories_lock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -1336,12 +1321,12 @@ gst_decode_bin_autoplug_factories (GstElement * element, GstPad * pad, GST_DEBUG_OBJECT (element, "finding factories"); /* return all compatible factories for caps */ - g_mutex_lock (dbin->factories_lock); + g_mutex_lock (&dbin->factories_lock); gst_decode_bin_update_factories_list (dbin); list = gst_element_factory_list_filter (dbin->factories, caps, GST_PAD_SINK, FALSE); - g_mutex_unlock (dbin->factories_lock); + g_mutex_unlock (&dbin->factories_lock); result = g_value_array_new (g_list_length (list)); for (tmp = list; tmp; tmp = tmp->next) { @@ -2827,7 +2812,7 @@ gst_decode_chain_free_internal (GstDecodeChain * chain, gboolean hide) chain); CHAIN_MUTEX_UNLOCK (chain); if (!hide) { - g_mutex_free (chain->lock); + g_mutex_clear (&chain->lock); g_slice_free (GstDecodeChain, chain); } } @@ -2864,7 +2849,7 @@ gst_decode_chain_new (GstDecodeBin * dbin, GstDecodeGroup * parent, chain->dbin = dbin; chain->parent = parent; - chain->lock = g_mutex_new (); + g_mutex_init (&chain->lock); chain->pad = gst_object_ref (pad); return chain; diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index e12aa00fa2..d271daebd5 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -60,9 +60,8 @@ gint _decode_bin_compare_factories_func (gconstpointer p1, gconstpointer p2); typedef struct _GstURIDecodeBin GstURIDecodeBin; typedef struct _GstURIDecodeBinClass GstURIDecodeBinClass; -#define GST_URI_DECODE_BIN_GET_LOCK(dec) (((GstURIDecodeBin*)(dec))->lock) -#define GST_URI_DECODE_BIN_LOCK(dec) (g_mutex_lock(GST_URI_DECODE_BIN_GET_LOCK(dec))) -#define GST_URI_DECODE_BIN_UNLOCK(dec) (g_mutex_unlock(GST_URI_DECODE_BIN_GET_LOCK(dec))) +#define GST_URI_DECODE_BIN_LOCK(dec) (g_mutex_lock(&((GstURIDecodeBin*)(dec))->lock)) +#define GST_URI_DECODE_BIN_UNLOCK(dec) (g_mutex_unlock(&((GstURIDecodeBin*)(dec))->lock)) typedef struct _GstURIDecodeBinStream { @@ -79,9 +78,9 @@ struct _GstURIDecodeBin { GstBin parent_instance; - GMutex *lock; /* lock for constructing */ + GMutex lock; /* lock for constructing */ - GMutex *factories_lock; + GMutex factories_lock; guint32 factories_cookie; GList *factories; /* factories we can use for selecting elements */ @@ -310,12 +309,12 @@ gst_uri_decode_bin_autoplug_factories (GstElement * element, GstPad * pad, GST_DEBUG_OBJECT (element, "finding factories"); /* return all compatible factories for caps */ - g_mutex_lock (dec->factories_lock); + g_mutex_lock (&dec->factories_lock); gst_uri_decode_bin_update_factories_list (dec); list = gst_element_factory_list_filter (dec->factories, caps, GST_PAD_SINK, FALSE); - g_mutex_unlock (dec->factories_lock); + g_mutex_unlock (&dec->factories_lock); result = g_value_array_new (g_list_length (list)); for (tmp = list; tmp; tmp = tmp->next) { @@ -667,9 +666,9 @@ static void gst_uri_decode_bin_init (GstURIDecodeBin * dec) { /* first filter out the interesting element factories */ - dec->factories_lock = g_mutex_new (); + g_mutex_init (&dec->factories_lock); - dec->lock = g_mutex_new (); + g_mutex_init (&dec->lock); dec->uri = g_strdup (DEFAULT_PROP_URI); dec->connection_speed = DEFAULT_CONNECTION_SPEED; @@ -692,8 +691,8 @@ gst_uri_decode_bin_finalize (GObject * obj) GstURIDecodeBin *dec = GST_URI_DECODE_BIN (obj); remove_decoders (dec, TRUE); - g_mutex_free (dec->lock); - g_mutex_free (dec->factories_lock); + g_mutex_clear (&dec->lock); + g_mutex_clear (&dec->factories_lock); g_free (dec->uri); g_free (dec->encoding); if (dec->factories)