port to new glib thread API

This commit is contained in:
Wim Taymans 2012-01-19 09:48:38 +01:00
parent b3eacd7dec
commit 3d42f0f6ed
16 changed files with 58 additions and 105 deletions

View file

@ -34,10 +34,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 "gstalsamixer.h"
#include "gst/glib-compat-private.h"
#include <errno.h>
@ -497,7 +493,7 @@ gst_alsa_mixer_new (const char *device, GstAlsaMixerDirection dir)
goto error;
g_rec_mutex_init (&ret->rec_mutex);
g_static_rec_mutex_init (&ret->task_mutex);
g_rec_mutex_init (&ret->task_mutex);
ret->task = gst_task_new (task_monitor_alsa, ret);
gst_task_set_lock (ret->task, &ret->task_mutex);
@ -542,7 +538,7 @@ gst_alsa_mixer_free (GstAlsaMixer * mixer)
mixer->task = NULL;
}
g_static_rec_mutex_free (&mixer->task_mutex);
g_rec_mutex_clear (&mixer->task_mutex);
if (mixer->pfd[0] > 0) {
close (mixer->pfd[0]);

View file

@ -53,7 +53,7 @@ struct _GstAlsaMixer
snd_mixer_t * handle;
GstTask * task;
GStaticRecMutex task_mutex;
GRecMutex task_mutex;
GRecMutex rec_mutex;

View file

@ -40,10 +40,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 <string.h>
#include <gst/gst-i18n-plugin.h>
#include <gst/tag/tag.h>

View file

@ -34,9 +34,6 @@
#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 "gstaudiobasesink.h"
GST_DEBUG_CATEGORY_STATIC (gst_audio_base_sink_debug);

View file

@ -149,10 +149,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 "gstaudiodecoder.h"
#include <gst/pbutils/descriptions.h>
@ -411,7 +407,7 @@ gst_audio_decoder_init (GstAudioDecoder * dec, GstAudioDecoderClass * klass)
dec->priv->adapter_out = gst_adapter_new ();
g_queue_init (&dec->priv->frames);
g_static_rec_mutex_init (&dec->stream_lock);
g_rec_mutex_init (&dec->stream_lock);
/* property default */
dec->priv->latency = DEFAULT_LATENCY;
@ -485,7 +481,7 @@ gst_audio_decoder_finalize (GObject * object)
g_object_unref (dec->priv->adapter_out);
}
g_static_rec_mutex_free (&dec->stream_lock);
g_rec_mutex_clear (&dec->stream_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View file

@ -79,8 +79,8 @@ G_BEGIN_DECLS
*/
#define GST_AUDIO_DECODER_SINK_PAD(obj) (((GstAudioDecoder *) (obj))->sinkpad)
#define GST_AUDIO_DECODER_STREAM_LOCK(dec) g_static_rec_mutex_lock (&GST_AUDIO_DECODER (dec)->stream_lock)
#define GST_AUDIO_DECODER_STREAM_UNLOCK(dec) g_static_rec_mutex_unlock (&GST_AUDIO_DECODER (dec)->stream_lock)
#define GST_AUDIO_DECODER_STREAM_LOCK(dec) g_rec_mutex_lock (&GST_AUDIO_DECODER (dec)->stream_lock)
#define GST_AUDIO_DECODER_STREAM_UNLOCK(dec) g_rec_mutex_unlock (&GST_AUDIO_DECODER (dec)->stream_lock)
typedef struct _GstAudioDecoder GstAudioDecoder;
typedef struct _GstAudioDecoderClass GstAudioDecoderClass;
@ -156,7 +156,7 @@ struct _GstAudioDecoder
/* protects all data processing, i.e. is locked
* in the chain function, finish_frame and when
* processing serialized events */
GStaticRecMutex stream_lock;
GRecMutex stream_lock;
/* MT-protected (with STREAM_LOCK) */
GstSegment segment;

View file

@ -151,10 +151,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 "gstaudioencoder.h"
#include <gst/base/gstadapter.h>
#include <gst/audio/audio.h>
@ -393,7 +389,7 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass)
enc->priv->adapter = gst_adapter_new ();
g_static_rec_mutex_init (&enc->stream_lock);
g_rec_mutex_init (&enc->stream_lock);
/* property default */
enc->priv->granule = DEFAULT_GRANULE;
@ -450,7 +446,7 @@ gst_audio_encoder_finalize (GObject * object)
g_object_unref (enc->priv->adapter);
g_static_rec_mutex_free (&enc->stream_lock);
g_rec_mutex_clear (&enc->stream_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View file

@ -82,8 +82,8 @@ G_BEGIN_DECLS
*/
#define GST_AUDIO_ENCODER_SEGMENT(obj) (GST_AUDIO_ENCODER_CAST (obj)->segment)
#define GST_AUDIO_ENCODER_STREAM_LOCK(enc) g_static_rec_mutex_lock (&GST_AUDIO_ENCODER (enc)->stream_lock)
#define GST_AUDIO_ENCODER_STREAM_UNLOCK(enc) g_static_rec_mutex_unlock (&GST_AUDIO_ENCODER (enc)->stream_lock)
#define GST_AUDIO_ENCODER_STREAM_LOCK(enc) g_rec_mutex_lock (&GST_AUDIO_ENCODER (enc)->stream_lock)
#define GST_AUDIO_ENCODER_STREAM_UNLOCK(enc) g_rec_mutex_unlock (&GST_AUDIO_ENCODER (enc)->stream_lock)
typedef struct _GstAudioEncoder GstAudioEncoder;
typedef struct _GstAudioEncoderClass GstAudioEncoderClass;
@ -108,7 +108,7 @@ struct _GstAudioEncoder {
/* protects all data processing, i.e. is locked
* in the chain function, finish_frame and when
* processing serialized events */
GStaticRecMutex stream_lock;
GRecMutex stream_lock;
/* MT-protected (with STREAM_LOCK) */
GstSegment segment;

View file

@ -40,10 +40,6 @@
*/
/* Element-Checklist-Version: 5 */
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View file

@ -40,10 +40,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-i18n-plugin.h>
#include <string.h>

View file

@ -85,10 +85,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-i18n-plugin.h>
#include <string.h>

View file

@ -217,10 +217,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 <string.h>
#include <gst/gst.h>
@ -272,7 +268,7 @@ struct _GstSourceSelect
gulong block_id;
};
#define GST_SOURCE_GROUP_GET_LOCK(group) (((GstSourceGroup*)(group))->lock)
#define GST_SOURCE_GROUP_GET_LOCK(group) (&((GstSourceGroup*)(group))->lock)
#define GST_SOURCE_GROUP_LOCK(group) (g_mutex_lock (GST_SOURCE_GROUP_GET_LOCK(group)))
#define GST_SOURCE_GROUP_UNLOCK(group) (g_mutex_unlock (GST_SOURCE_GROUP_GET_LOCK(group)))
@ -290,7 +286,7 @@ struct _GstSourceGroup
{
GstPlayBin *playbin;
GMutex *lock;
GMutex lock;
gboolean valid; /* the group has valid info to start playback */
gboolean active; /* the group is active */
@ -330,7 +326,7 @@ struct _GstSourceGroup
gulong block_id;
GMutex *stream_changed_pending_lock;
GMutex stream_changed_pending_lock;
GList *stream_changed_pending;
/* selectors for different streams */
@ -338,12 +334,12 @@ struct _GstSourceGroup
};
#define GST_PLAY_BIN_GET_LOCK(bin) (&((GstPlayBin*)(bin))->lock)
#define GST_PLAY_BIN_LOCK(bin) (g_static_rec_mutex_lock (GST_PLAY_BIN_GET_LOCK(bin)))
#define GST_PLAY_BIN_UNLOCK(bin) (g_static_rec_mutex_unlock (GST_PLAY_BIN_GET_LOCK(bin)))
#define GST_PLAY_BIN_LOCK(bin) (g_rec_mutex_lock (GST_PLAY_BIN_GET_LOCK(bin)))
#define GST_PLAY_BIN_UNLOCK(bin) (g_rec_mutex_unlock (GST_PLAY_BIN_GET_LOCK(bin)))
/* lock to protect dynamic callbacks, like no-more-pads */
#define GST_PLAY_BIN_DYN_LOCK(bin) g_mutex_lock ((bin)->dyn_lock)
#define GST_PLAY_BIN_DYN_UNLOCK(bin) g_mutex_unlock ((bin)->dyn_lock)
#define GST_PLAY_BIN_DYN_LOCK(bin) g_mutex_lock (&(bin)->dyn_lock)
#define GST_PLAY_BIN_DYN_UNLOCK(bin) g_mutex_unlock (&(bin)->dyn_lock)
/* lock for shutdown */
#define GST_PLAY_BIN_SHUTDOWN_LOCK(bin,label) \
@ -370,7 +366,7 @@ struct _GstPlayBin
{
GstPipeline parent;
GStaticRecMutex lock; /* to protect group switching */
GRecMutex lock; /* to protect group switching */
/* the groups, we use a double buffer to switch between current and next */
GstSourceGroup groups[2]; /* array with group info */
@ -393,11 +389,11 @@ struct _GstPlayBin
GstElement *source;
/* lock protecting dynamic adding/removing */
GMutex *dyn_lock;
GMutex dyn_lock;
/* if we are shutting down or not */
gint shutdown;
GMutex *elements_lock;
GMutex elements_lock;
guint32 elements_cookie;
GList *elements; /* factories we can use for selecting elements */
@ -1130,7 +1126,7 @@ init_group (GstPlayBin * playbin, GstSourceGroup * group)
group->video_channels = g_ptr_array_new ();
group->audio_channels = g_ptr_array_new ();
group->text_channels = g_ptr_array_new ();
group->lock = g_mutex_new ();
g_mutex_init (&group->lock);
/* init selectors. The selector is found by finding the first prefix that
* matches the media. */
group->playbin = playbin;
@ -1181,7 +1177,7 @@ free_group (GstPlayBin * playbin, GstSourceGroup * group)
g_ptr_array_free (group->audio_channels, TRUE);
g_ptr_array_free (group->text_channels, TRUE);
g_mutex_free (group->lock);
g_mutex_clear (&group->lock);
if (group->audio_sink) {
if (group->audio_sink != playbin->audio_sink)
gst_element_set_state (group->audio_sink, GST_STATE_NULL);
@ -1198,9 +1194,9 @@ free_group (GstPlayBin * playbin, GstSourceGroup * group)
g_list_free (group->stream_changed_pending);
group->stream_changed_pending = NULL;
if (group->stream_changed_pending_lock)
g_mutex_free (group->stream_changed_pending_lock);
group->stream_changed_pending_lock = NULL;
if (group->stream_changed_pending_lock.p)
g_mutex_clear (&group->stream_changed_pending_lock);
group->stream_changed_pending_lock.p = NULL;
}
static void
@ -1242,8 +1238,8 @@ gst_play_bin_update_elements_list (GstPlayBin * playbin)
static void
gst_play_bin_init (GstPlayBin * playbin)
{
g_static_rec_mutex_init (&playbin->lock);
playbin->dyn_lock = g_mutex_new ();
g_rec_mutex_init (&playbin->lock);
g_mutex_init (&playbin->dyn_lock);
/* assume we can create a selector */
playbin->have_selector = TRUE;
@ -1255,7 +1251,7 @@ gst_play_bin_init (GstPlayBin * playbin)
init_group (playbin, &playbin->groups[1]);
/* first filter out the interesting element factories */
playbin->elements_lock = g_mutex_new ();
g_mutex_init (&playbin->elements_lock);
/* add sink */
playbin->playsink = g_object_new (GST_TYPE_PLAY_SINK, NULL);
@ -1304,9 +1300,9 @@ gst_play_bin_finalize (GObject * object)
if (playbin->elements)
gst_plugin_feature_list_free (playbin->elements);
g_static_rec_mutex_free (&playbin->lock);
g_mutex_free (playbin->dyn_lock);
g_mutex_free (playbin->elements_lock);
g_rec_mutex_clear (&playbin->lock);
g_mutex_clear (&playbin->dyn_lock);
g_mutex_clear (&playbin->elements_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -2210,10 +2206,10 @@ gst_play_bin_query (GstElement * element, GstQuery * query)
gboolean pending;
GST_SOURCE_GROUP_LOCK (group);
if (group->stream_changed_pending_lock) {
g_mutex_lock (group->stream_changed_pending_lock);
if (group->stream_changed_pending_lock.p) {
g_mutex_lock (&group->stream_changed_pending_lock);
pending = group->pending || group->stream_changed_pending;
g_mutex_unlock (group->stream_changed_pending_lock);
g_mutex_unlock (&group->stream_changed_pending_lock);
} else {
pending = group->pending;
}
@ -2288,7 +2284,7 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * msg)
GList *l, *l_prev;
group = playbin->curr_group;
g_mutex_lock (group->stream_changed_pending_lock);
g_mutex_lock (&group->stream_changed_pending_lock);
for (l = group->stream_changed_pending; l;) {
guint32 l_seqnum = GPOINTER_TO_UINT (l->data);
@ -2306,7 +2302,7 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * msg)
l = l->next;
}
}
g_mutex_unlock (group->stream_changed_pending_lock);
g_mutex_unlock (&group->stream_changed_pending_lock);
}
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_START ||
GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) {
@ -2920,7 +2916,7 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group)
msg = gst_message_new_element (GST_OBJECT_CAST (playbin), s);
seqnum = gst_message_get_seqnum (msg);
event = gst_event_new_sink_message (msg);
g_mutex_lock (group->stream_changed_pending_lock);
g_mutex_lock (&group->stream_changed_pending_lock);
group->stream_changed_pending =
g_list_prepend (group->stream_changed_pending,
GUINT_TO_POINTER (seqnum));
@ -2942,7 +2938,7 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group)
GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
stream_changed_data_probe, (gpointer) select, NULL);
g_mutex_unlock (group->stream_changed_pending_lock);
g_mutex_unlock (&group->stream_changed_pending_lock);
gst_message_unref (msg);
}
@ -3059,12 +3055,12 @@ autoplug_factories_cb (GstElement * decodebin, GstPad * pad,
group, GST_DEBUG_PAD_NAME (pad), caps);
/* filter out the elements based on the caps. */
g_mutex_lock (playbin->elements_lock);
g_mutex_lock (&playbin->elements_lock);
gst_play_bin_update_elements_list (playbin);
mylist =
gst_element_factory_list_filter (playbin->elements, caps, GST_PAD_SINK,
FALSE);
g_mutex_unlock (playbin->elements_lock);
g_mutex_unlock (&playbin->elements_lock);
GST_DEBUG_OBJECT (playbin, "found factories %p", mylist);
GST_PLUGIN_FEATURE_LIST_DEBUG (mylist);
@ -3495,8 +3491,8 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target)
g_list_free (group->stream_changed_pending);
group->stream_changed_pending = NULL;
if (!group->stream_changed_pending_lock)
group->stream_changed_pending_lock = g_mutex_new ();
if (!group->stream_changed_pending_lock.p)
g_mutex_init (&group->stream_changed_pending_lock);
if (group->uridecodebin) {
GST_DEBUG_OBJECT (playbin, "reusing existing uridecodebin");

View file

@ -22,10 +22,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 <string.h>
#include <gst/gst.h>
@ -123,12 +119,12 @@ typedef struct
#define GST_PLAY_SINK_GET_LOCK(playsink) (&((GstPlaySink *)playsink)->lock)
#define GST_PLAY_SINK_LOCK(playsink) G_STMT_START { \
GST_LOG_OBJECT (playsink, "locking from thread %p", g_thread_self ()); \
g_static_rec_mutex_lock (GST_PLAY_SINK_GET_LOCK (playsink)); \
g_rec_mutex_lock (GST_PLAY_SINK_GET_LOCK (playsink)); \
GST_LOG_OBJECT (playsink, "locked from thread %p", g_thread_self ()); \
} G_STMT_END
#define GST_PLAY_SINK_UNLOCK(playsink) G_STMT_START { \
GST_LOG_OBJECT (playsink, "unlocking from thread %p", g_thread_self ()); \
g_static_rec_mutex_unlock (GST_PLAY_SINK_GET_LOCK (playsink)); \
g_rec_mutex_unlock (GST_PLAY_SINK_GET_LOCK (playsink)); \
} G_STMT_END
#define PENDING_FLAG_SET(playsink, flagtype) \
@ -148,7 +144,7 @@ struct _GstPlaySink
{
GstBin bin;
GStaticRecMutex lock;
GRecMutex lock;
gboolean async_pending;
gboolean need_async_start;
@ -524,7 +520,7 @@ gst_play_sink_init (GstPlaySink * playsink)
gst_bin_add (GST_BIN_CAST (playsink),
GST_ELEMENT_CAST (playsink->stream_synchronizer));
g_static_rec_mutex_init (&playsink->lock);
g_rec_mutex_init (&playsink->lock);
GST_OBJECT_FLAG_SET (playsink, GST_ELEMENT_FLAG_SINK);
}
@ -627,7 +623,7 @@ gst_play_sink_finalize (GObject * object)
playsink = GST_PLAY_SINK (object);
g_static_rec_mutex_free (&playsink->lock);
g_rec_mutex_clear (&playsink->lock);
G_OBJECT_CLASS (gst_play_sink_parent_class)->finalize (object);
}

View file

@ -21,10 +21,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 "gststreamsynchronizer.h"
#include "gst/glib-compat-private.h"
@ -677,14 +673,14 @@ gst_stream_synchronizer_request_new_pad (GstElement * element,
GST_STREAM_SYNCHRONIZER_UNLOCK (self);
/* Add pads and activate unless we're going to NULL */
g_static_rec_mutex_lock (GST_STATE_GET_LOCK (self));
g_rec_mutex_lock (GST_STATE_GET_LOCK (self));
if (GST_STATE_TARGET (self) != GST_STATE_NULL) {
gst_pad_set_active (stream->srcpad, TRUE);
gst_pad_set_active (stream->sinkpad, TRUE);
}
gst_element_add_pad (GST_ELEMENT_CAST (self), stream->srcpad);
gst_element_add_pad (GST_ELEMENT_CAST (self), stream->sinkpad);
g_static_rec_mutex_unlock (GST_STATE_GET_LOCK (self));
g_rec_mutex_unlock (GST_STATE_GET_LOCK (self));
return stream->sinkpad;
}

View file

@ -104,10 +104,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-i18n-plugin.h>
#include "gstmultisocketsink.h"
@ -666,7 +662,7 @@ gst_multi_socket_sink_finalize (GObject * object)
this = GST_MULTI_SOCKET_SINK (object);
CLIENTS_LOCK_FREE (this);
CLIENTS_LOCK_CLEAR (this);
g_hash_table_destroy (this->socket_hash);
g_array_free (this->bufqueue, TRUE);

View file

@ -161,10 +161,10 @@ typedef struct {
guint64 last_buffer_ts;
} GstSocketClient;
#define CLIENTS_LOCK_INIT(socketsink) (g_static_rec_mutex_init(&socketsink->clientslock))
#define CLIENTS_LOCK_FREE(socketsink) (g_static_rec_mutex_free(&socketsink->clientslock))
#define CLIENTS_LOCK(socketsink) (g_static_rec_mutex_lock(&socketsink->clientslock))
#define CLIENTS_UNLOCK(socketsink) (g_static_rec_mutex_unlock(&socketsink->clientslock))
#define CLIENTS_LOCK_INIT(socketsink) (g_rec_mutex_init(&socketsink->clientslock))
#define CLIENTS_LOCK_CLEAR(socketsink) (g_rec_mutex_clear(&socketsink->clientslock))
#define CLIENTS_LOCK(socketsink) (g_rec_mutex_lock(&socketsink->clientslock))
#define CLIENTS_UNLOCK(socketsink) (g_rec_mutex_unlock(&socketsink->clientslock))
/**
* GstMultiSocketSink:
@ -178,7 +178,7 @@ struct _GstMultiSocketSink {
guint64 bytes_to_serve; /* how much bytes we must serve */
guint64 bytes_served; /* how much bytes have we served */
GStaticRecMutex clientslock; /* lock to protect the clients list */
GRecMutex clientslock; /* lock to protect the clients list */
GList *clients; /* list of clients we are serving */
GHashTable *socket_hash; /* index on socket to client */
guint clients_cookie; /* Cookie to detect changes to the clients list */