[rhythmbox] allocate GMutex and GCond statically, or embed in structures
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] allocate GMutex and GCond statically, or embed in structures
- Date: Sat, 21 Jul 2012 10:14:37 +0000 (UTC)
commit 30fde08f523f72c2e90ca547d8952ce6ce39c727
Author: Jonathan Matthew <jonathan d14n org>
Date: Sat Jul 21 16:38:13 2012 +1000
allocate GMutex and GCond statically, or embed in structures
backends/gstreamer/rb-player-gst-xfade.c | 181 +++++++++++++++---------------
lib/rb-file-helpers.c | 13 +-
lib/rb-util.c | 33 +++---
plugins/mtpdevice/rb-mtp-gst-sink.c | 30 ++---
plugins/mtpdevice/rb-mtp-gst-src.c | 21 ++--
rhythmdb/rb-refstring.c | 19 ++--
rhythmdb/rhythmdb-import-job.c | 38 +++----
rhythmdb/rhythmdb-monitor.c | 10 +-
rhythmdb/rhythmdb-private.h | 16 ++--
rhythmdb/rhythmdb-tree.c | 138 +++++++++++------------
rhythmdb/rhythmdb.c | 104 +++++++----------
shell/rb-playlist-manager.c | 17 +--
12 files changed, 285 insertions(+), 335 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index d0c0beb..f07c13a 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -254,12 +254,12 @@ struct _RBPlayerGstXFadePrivate
SINK_STOPPED,
SINK_PLAYING
} sink_state;
- GStaticRecMutex sink_lock;
+ GRecMutex sink_lock;
GList *waiting_tees;
GList *waiting_filters;
- GStaticRecMutex stream_list_lock;
+ GRecMutex stream_list_lock;
GList *streams;
gint linked_streams;
@@ -309,7 +309,7 @@ typedef struct
GstBin parent;
RBPlayerGstXFade *player;
- GMutex *lock;
+ GMutex lock;
char *uri;
gpointer stream_data;
@@ -397,7 +397,7 @@ rb_xfade_stream_send_event (GstElement *element, GstEvent *event)
static void
rb_xfade_stream_init (RBXFadeStream *stream)
{
- stream->lock = g_mutex_new ();
+ g_mutex_init (&stream->lock);
}
static void
@@ -462,7 +462,6 @@ rb_xfade_stream_finalize (GObject *object)
{
RBXFadeStream *sd = RB_XFADE_STREAM (object);
- g_mutex_free (sd->lock);
g_free (sd->uri);
if (sd->error != NULL) {
@@ -724,8 +723,8 @@ rb_player_gst_xfade_init (RBPlayerGstXFade *player)
{
player->priv = GET_PRIVATE (player);
- g_static_rec_mutex_init (&player->priv->stream_list_lock);
- g_static_rec_mutex_init (&player->priv->sink_lock);
+ g_rec_mutex_init (&player->priv->stream_list_lock);
+ g_rec_mutex_init (&player->priv->sink_lock);
player->priv->cur_volume = 1.0f;
}
@@ -739,7 +738,7 @@ rb_player_gst_xfade_dispose (GObject *object)
player = RB_PLAYER_GST_XFADE (object);
/* clean up streams */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (l = player->priv->streams; l != NULL; l = l->next) {
RBXFadeStream *stream = (RBXFadeStream *)l->data;
@@ -750,16 +749,16 @@ rb_player_gst_xfade_dispose (GObject *object)
}
g_list_free (player->priv->streams);
player->priv->streams = NULL;
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (player->priv->volume_handler) {
g_object_unref (player->priv->volume_handler);
player->priv->volume_handler = NULL;
}
- g_static_rec_mutex_lock (&player->priv->sink_lock);
+ g_rec_mutex_lock (&player->priv->sink_lock);
stop_sink (player);
- g_static_rec_mutex_unlock (&player->priv->sink_lock);
+ g_rec_mutex_unlock (&player->priv->sink_lock);
if (player->priv->pipeline != NULL) {
/* maybe we should keep references to the adder, sink, etc.? */
@@ -864,11 +863,11 @@ adjust_stream_base_time (RBXFadeStream *stream)
gint64 output_pos = -1;
gint64 stream_pos = -1;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->adder_pad == NULL) {
rb_debug ("stream isn't linked, can't adjust base time");
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
return;
}
@@ -906,7 +905,7 @@ adjust_stream_base_time (RBXFadeStream *stream)
}
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
}
/* called on a streaming thread when the volume level for a stream changes. */
@@ -921,16 +920,16 @@ volume_changed_cb (GObject *object, GParamSpec *pspec, RBPlayerGstXFade *player)
* our bus callback will handle them on the main thread.
*/
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_element (player, GST_ELEMENT (object));
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (stream == NULL) {
rb_debug ("got volume change for unknown stream");
return;
}
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
/* check if the fade is complete */
g_object_get (stream->volume, "volume", &vol, NULL);
@@ -968,7 +967,7 @@ volume_changed_cb (GObject *object, GParamSpec *pspec, RBPlayerGstXFade *player)
break;
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
if (message != NULL) {
GstMessage *msg;
@@ -1057,12 +1056,12 @@ static void
link_unblocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
{
GstStateChangeReturn state_ret;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
/* sometimes we seem to get called twice */
if (stream->state == FADING_IN || stream->state == PLAYING) {
rb_debug ("stream %s already unblocked", stream->uri);
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
return;
}
@@ -1073,7 +1072,7 @@ link_unblocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
else
stream->state = PLAYING;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
adjust_stream_base_time (stream);
@@ -1247,7 +1246,7 @@ post_eos_seek_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
{
GError *error = NULL;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
rb_debug ("stream %s is blocked; linking and unblocking", stream->uri);
stream->src_blocked = TRUE;
@@ -1255,7 +1254,7 @@ post_eos_seek_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
emit_stream_error (stream, error);
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
}
/*
@@ -1273,7 +1272,7 @@ unlink_reuse_relink (RBPlayerGstXFade *player, RBXFadeStream *stream)
{
GError *error = NULL;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->adder_pad == NULL) {
rb_debug ("stream %s doesn't need to be unlinked.. weird.", stream->uri);
@@ -1294,7 +1293,7 @@ unlink_reuse_relink (RBPlayerGstXFade *player, RBXFadeStream *stream)
stream->needs_unlink = FALSE;
stream->emitted_playing = FALSE;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
/* block the src pad so we don't get not-linked errors if it pushes a buffer
* before we get around to relinking
@@ -1322,11 +1321,11 @@ unlink_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
RBPlayerGstXFade *player;
GError *error = NULL;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->needs_unlink == FALSE || stream->adder_pad == NULL) {
rb_debug ("stream %s doesn't need to be unlinked", stream->uri);
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
return;
}
@@ -1346,7 +1345,7 @@ unlink_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
stream_state = stream->state;
player = stream->player;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
/* might want a stream-paused signal here? */
@@ -1427,7 +1426,7 @@ unlink_and_dispose_stream (RBPlayerGstXFade *player, RBXFadeStream *stream)
gst_element_get_state (GST_ELEMENT (stream), NULL, NULL, GST_CLOCK_TIME_NONE);
}
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->adder_pad != NULL) {
rb_debug ("unlinking stream %s", stream->uri);
@@ -1443,7 +1442,7 @@ unlink_and_dispose_stream (RBPlayerGstXFade *player, RBXFadeStream *stream)
was_in_pipeline = (GST_ELEMENT_PARENT (GST_ELEMENT (stream)) == player->priv->pipeline);
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
if (was_in_pipeline)
gst_bin_remove (GST_BIN (player->priv->pipeline), GST_ELEMENT (stream));
@@ -1459,10 +1458,10 @@ unlink_and_dispose_stream (RBPlayerGstXFade *player, RBXFadeStream *stream)
}
}
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
player->priv->streams = g_list_remove (player->priv->streams, stream);
dump_stream_list (player);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
g_object_unref (stream);
}
@@ -1474,7 +1473,7 @@ reap_streams (RBPlayerGstXFade *player)
GList *t;
GList *reap = NULL;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
player->priv->stream_reap_id = 0;
dump_stream_list (player);
for (t = player->priv->streams; t != NULL; t = t->next) {
@@ -1484,7 +1483,7 @@ reap_streams (RBPlayerGstXFade *player)
reap = g_list_prepend (reap, stream);
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
for (t = reap; t != NULL; t = t->next) {
RBXFadeStream *stream = (RBXFadeStream *)t->data;
@@ -1500,14 +1499,14 @@ reap_streams (RBPlayerGstXFade *player)
static void
schedule_stream_reap (RBPlayerGstXFade *player)
{
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
if (player->priv->stream_reap_id == 0) {
dump_stream_list (player);
player->priv->stream_reap_id = g_idle_add ((GSourceFunc) reap_streams, player);
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
}
/* emits a tag signal from the player, maybe */
@@ -1619,7 +1618,7 @@ start_waiting_eos_streams (RBPlayerGstXFade *player)
GList *l;
GList *to_start = NULL;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (l = player->priv->streams; l != NULL; l = l->next) {
RBXFadeStream *pstream = l->data;
if (pstream->state == WAITING_EOS && pstream->starting_eos == FALSE) {
@@ -1627,7 +1626,7 @@ start_waiting_eos_streams (RBPlayerGstXFade *player)
to_start = g_list_prepend (to_start, g_object_ref (pstream));
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
for (l = to_start; l != NULL; l = l->next) {
RBXFadeStream *pstream = l->data;
@@ -1652,14 +1651,14 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
g_return_val_if_fail (player != NULL, FALSE);
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
message_src = GST_MESSAGE_SRC (message);
if (GST_IS_PAD (message_src)) {
message_src = GST_OBJECT_PARENT (message_src);
}
stream = find_stream_by_element (player, GST_ELEMENT (message_src));
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:
@@ -1713,14 +1712,14 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
GstTagList *tags;
gst_message_parse_tag (message, &tags);
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->emitted_playing) {
gst_tag_list_foreach (tags, (GstTagForeachFunc) process_tag, stream);
gst_tag_list_free (tags);
} else {
stream->tags = g_list_append (stream->tags, tags);
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
}
break;
@@ -1756,10 +1755,10 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
_rb_player_emit_playing_stream (RB_PLAYER (player), stream->stream_data);
/* process any buffered tag lists we received while prerolling the stream */
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
l = stream->tags;
stream->tags = NULL;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
for (t = l; t != NULL; t = t->next) {
GstTagList *tags;
@@ -1778,9 +1777,9 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
case FADING_OUT:
/* stop the stream and dispose of it */
rb_debug ("got fade-out-done for stream %s -> PENDING_REMOVE", stream->uri);
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
stream->state = PENDING_REMOVE;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
schedule_stream_reap (player);
break;
@@ -1790,7 +1789,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
GstFormat format = GST_FORMAT_TIME;
gint64 pos = -1;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
gst_element_query_position (stream->volume, &format, &pos);
if (pos != -1) {
stream->seek_target = pos > PAUSE_FADE_LENGTH ? pos - PAUSE_FADE_LENGTH : 0;
@@ -1802,7 +1801,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
rb_debug ("got fade-out-done for stream %s -> PAUSED (position query failed)",
stream->uri);
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
}
unlink_and_block_stream (stream);
break;
@@ -1851,7 +1850,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
break;
}
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (progress >= 100) {
GError *error = NULL;
switch (stream->state) {
@@ -1900,7 +1899,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
break;
}
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
if (stream == NULL) {
rb_debug ("got buffering message for unknown stream (%d)", progress);
@@ -2305,7 +2304,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
case RB_PLAYER_PLAY_CROSSFADE:
to_fade = NULL;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (l = player->priv->streams; l != NULL; l = l->next) {
RBXFadeStream *pstream = (RBXFadeStream *)l->data;
@@ -2337,7 +2336,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
for (l = to_fade; l != NULL; l = l->next) {
RBXFadeStream *pstream = (RBXFadeStream *)l->data;
@@ -2384,7 +2383,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
case RB_PLAYER_PLAY_AFTER_EOS:
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
playing = FALSE;
for (l = player->priv->streams; l != NULL; l = l->next) {
@@ -2410,7 +2409,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (playing) {
/* wait for current stream's EOS */
@@ -2425,7 +2424,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
case RB_PLAYER_PLAY_REPLACE:
/* replace any existing playing stream */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (l = player->priv->streams; l != NULL; l = l->next) {
RBXFadeStream *pstream = (RBXFadeStream *)l->data;
@@ -2449,7 +2448,7 @@ actually_start_stream (RBXFadeStream *stream, GError **error)
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
ret = link_and_unblock_stream (stream, error);
break;
@@ -2476,10 +2475,10 @@ stream_src_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
GError *error = NULL;
gboolean start_stream = FALSE;
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
if (stream->src_blocked) {
rb_debug ("stream %s already blocked", stream->uri);
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
return;
}
stream->src_blocked = TRUE;
@@ -2498,7 +2497,7 @@ stream_src_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
default:
break;
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
return;
}
@@ -2517,7 +2516,7 @@ stream_src_blocked_cb (GstPad *pad, gboolean blocked, RBXFadeStream *stream)
break;
}
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
if (start_stream == TRUE) {
/* not sure this is actually an acceptable thing to do on a streaming thread.. */
@@ -2606,7 +2605,7 @@ get_times_and_stream (RBPlayerGstXFade *player, RBXFadeStream **pstream, gint64
if (player->priv->pipeline == NULL)
return FALSE;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
/* first look for a network stream that is buffering during preroll */
stream = find_stream_by_state (player, PREROLLING | PREROLL_PLAY);
@@ -2624,7 +2623,7 @@ get_times_and_stream (RBPlayerGstXFade *player, RBXFadeStream **pstream, gint64
if (stream == NULL) {
stream = find_stream_by_state (player, FADING_IN | PLAYING | FADING_OUT_PAUSED | PAUSED | PENDING_REMOVE | REUSING);
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (stream != NULL) {
if (pstream != NULL) {
@@ -2949,7 +2948,7 @@ start_sink (RBPlayerGstXFade *player, GError **error)
GstBus *bus;
gboolean ret;
- g_static_rec_mutex_lock (&player->priv->sink_lock);
+ g_rec_mutex_lock (&player->priv->sink_lock);
switch (player->priv->sink_state) {
case SINK_NULL:
g_assert_not_reached ();
@@ -2969,7 +2968,7 @@ start_sink (RBPlayerGstXFade *player, GError **error)
default:
g_assert_not_reached ();
}
- g_static_rec_mutex_unlock (&player->priv->sink_lock);
+ g_rec_mutex_unlock (&player->priv->sink_lock);
bus = gst_element_get_bus (GST_ELEMENT (player->priv->pipeline));
for (t = messages; t != NULL; t = t->next) {
@@ -3282,7 +3281,7 @@ rb_player_gst_xfade_open (RBPlayer *iplayer,
return FALSE;
/* see if anyone wants us to reuse an existing stream */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (t = player->priv->streams; t != NULL; t = t->next) {
RBXFadeStream *stream = (RBXFadeStream *)t->data;
@@ -3325,7 +3324,7 @@ rb_player_gst_xfade_open (RBPlayer *iplayer,
break;
}
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (reused) {
return TRUE;
}
@@ -3342,10 +3341,10 @@ rb_player_gst_xfade_open (RBPlayer *iplayer,
return FALSE;
}
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
player->priv->streams = g_list_prepend (player->priv->streams, stream);
dump_stream_list (player);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
/* start prerolling it */
preroll_stream (player, stream);
@@ -3356,12 +3355,12 @@ rb_player_gst_xfade_open (RBPlayer *iplayer,
static gboolean
stop_sink_later (RBPlayerGstXFade *player)
{
- g_static_rec_mutex_lock (&player->priv->sink_lock);
+ g_rec_mutex_lock (&player->priv->sink_lock);
player->priv->stop_sink_id = 0;
if (g_atomic_int_get (&player->priv->linked_streams) == 0) {
stop_sink (player);
}
- g_static_rec_mutex_unlock (&player->priv->sink_lock);
+ g_rec_mutex_unlock (&player->priv->sink_lock);
return FALSE;
}
@@ -3369,14 +3368,14 @@ stop_sink_later (RBPlayerGstXFade *player)
static void
maybe_stop_sink (RBPlayerGstXFade *player)
{
- g_static_rec_mutex_lock (&player->priv->sink_lock);
+ g_rec_mutex_lock (&player->priv->sink_lock);
if (player->priv->stop_sink_id == 0) {
player->priv->stop_sink_id =
g_timeout_add (1000,
(GSourceFunc) stop_sink_later,
player);
}
- g_static_rec_mutex_unlock (&player->priv->sink_lock);
+ g_rec_mutex_unlock (&player->priv->sink_lock);
}
static gboolean
@@ -3390,13 +3389,13 @@ rb_player_gst_xfade_close (RBPlayer *iplayer, const char *uri, GError **error)
GList *l;
/* need to copy the list as unlink_and_dispose_stream modifies it */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
list = g_list_copy (player->priv->streams);
for (l = list; l != NULL; l = l->next) {
RBXFadeStream *stream = (RBXFadeStream *)l->data;
g_object_ref (stream);
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
for (l = list; l != NULL; l = l->next) {
RBXFadeStream *stream = (RBXFadeStream *)l->data;
@@ -3408,9 +3407,9 @@ rb_player_gst_xfade_close (RBPlayer *iplayer, const char *uri, GError **error)
/* just stop and close the stream for the specified uri */
RBXFadeStream *stream;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_uri (player, uri);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (stream != NULL) {
unlink_and_dispose_stream (player, stream);
@@ -3435,7 +3434,7 @@ rb_player_gst_xfade_opened (RBPlayer *iplayer)
/* maybe replace this with just a flag somewhere? */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_state (player, PREROLLING | PREROLL_PLAY | WAITING_EOS | WAITING | FADING_IN | PLAYING | PAUSED);
if (stream != NULL) {
@@ -3443,7 +3442,7 @@ rb_player_gst_xfade_opened (RBPlayer *iplayer)
g_object_unref (stream);
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
return opened;
}
@@ -3459,7 +3458,7 @@ rb_player_gst_xfade_play (RBPlayer *iplayer,
RBPlayerGstXFade *player = RB_PLAYER_GST_XFADE (iplayer);
gboolean ret = TRUE;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
/* is there anything to play? */
if (player->priv->streams == NULL) {
@@ -3468,13 +3467,13 @@ rb_player_gst_xfade_play (RBPlayer *iplayer,
RB_PLAYER_ERROR_GENERAL,
"Nothing to play"); /* should never happen */
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
return FALSE;
}
stream = g_list_first (player->priv->streams)->data;
g_object_ref (stream);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
/* make sure the sink is playing */
if (start_sink (player, error) == FALSE) {
@@ -3482,7 +3481,7 @@ rb_player_gst_xfade_play (RBPlayer *iplayer,
return FALSE;
}
- g_mutex_lock (stream->lock);
+ g_mutex_lock (&stream->lock);
rb_debug ("playing stream %s, play type %d, crossfade %" G_GINT64_FORMAT, stream->uri, play_type, crossfade);
@@ -3512,7 +3511,7 @@ rb_player_gst_xfade_play (RBPlayer *iplayer,
}
stream_state = stream->state;
- g_mutex_unlock (stream->lock);
+ g_mutex_unlock (&stream->lock);
/* is the head stream already playing? */
switch (stream_state) {
@@ -3578,7 +3577,7 @@ rb_player_gst_xfade_pause (RBPlayer *iplayer)
double fade_out_start = 1.0f;
gint64 fade_out_time = PAUSE_FADE_LENGTH;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
for (l = player->priv->streams; l != NULL; l = l->next) {
RBXFadeStream *stream;
@@ -3636,7 +3635,7 @@ rb_player_gst_xfade_pause (RBPlayer *iplayer)
break;
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
for (l = to_fade; l != NULL; l = l->next) {
RBXFadeStream *stream = (RBXFadeStream *)l->data;
@@ -3675,14 +3674,14 @@ rb_player_gst_xfade_playing (RBPlayer *iplayer)
/* XXX maybe replace with just a flag? */
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_state (player, PLAYING | FADING_IN);
if (stream != NULL) {
playing = TRUE;
g_object_unref (stream);
}
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
return playing;
}
@@ -3732,9 +3731,9 @@ rb_player_gst_xfade_seekable (RBPlayer *iplayer)
/* is this supposed to query the most recently opened stream,
* or the current playing stream? I really don't know.
*/
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_state (player, FADING_IN | PAUSED | PLAYING);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (stream) {
GstQuery *query = NULL;
@@ -3760,9 +3759,9 @@ rb_player_gst_xfade_set_time (RBPlayer *iplayer, gint64 time)
RBPlayerGstXFade *player = RB_PLAYER_GST_XFADE (iplayer);
RBXFadeStream *stream;
- g_static_rec_mutex_lock (&player->priv->stream_list_lock);
+ g_rec_mutex_lock (&player->priv->stream_list_lock);
stream = find_stream_by_state (player, FADING_IN | PLAYING | PAUSED | FADING_OUT_PAUSED | PENDING_REMOVE);
- g_static_rec_mutex_unlock (&player->priv->stream_list_lock);
+ g_rec_mutex_unlock (&player->priv->stream_list_lock);
if (stream == NULL) {
rb_debug ("got seek while no playing streams exist");
diff --git a/lib/rb-file-helpers.c b/lib/rb-file-helpers.c
index b3424fe..deaa64d 100644
--- a/lib/rb-file-helpers.c
+++ b/lib/rb-file-helpers.c
@@ -679,7 +679,7 @@ typedef struct {
gpointer user_data;
GDestroyNotify data_destroy;
- GMutex *results_lock;
+ GMutex results_lock;
guint results_idle_id;
GList *file_results;
GList *dir_results;
@@ -844,7 +844,7 @@ _recurse_async_idle_cb (RBUriHandleRecursivelyAsyncData *data)
{
GList *ul, *dl;
- g_mutex_lock (data->results_lock);
+ g_mutex_lock (&data->results_lock);
for (ul = data->file_results, dl = data->dir_results;
ul != NULL;
@@ -862,7 +862,7 @@ _recurse_async_idle_cb (RBUriHandleRecursivelyAsyncData *data)
data->dir_results = NULL;
data->results_idle_id = 0;
- g_mutex_unlock (data->results_lock);
+ g_mutex_unlock (&data->results_lock);
return FALSE;
}
@@ -895,7 +895,6 @@ _recurse_async_data_free (RBUriHandleRecursivelyAsyncData *data)
}
g_free (data->uri);
- g_mutex_free (data->results_lock);
return FALSE;
}
@@ -903,7 +902,7 @@ _recurse_async_data_free (RBUriHandleRecursivelyAsyncData *data)
static gboolean
_recurse_async_cb (GFile *file, gboolean dir, RBUriHandleRecursivelyAsyncData *data)
{
- g_mutex_lock (data->results_lock);
+ g_mutex_lock (&data->results_lock);
data->file_results = g_list_prepend (data->file_results, g_object_ref (file));
data->dir_results = g_list_prepend (data->dir_results, GINT_TO_POINTER (dir ? 1 : 0));
@@ -911,7 +910,7 @@ _recurse_async_cb (GFile *file, gboolean dir, RBUriHandleRecursivelyAsyncData *d
g_idle_add ((GSourceFunc)_recurse_async_idle_cb, data);
}
- g_mutex_unlock (data->results_lock);
+ g_mutex_unlock (&data->results_lock);
return TRUE;
}
@@ -961,7 +960,7 @@ rb_uri_handle_recursively_async (const char *uri,
}
data->data_destroy = data_destroy;
- data->results_lock = g_mutex_new ();
+ g_mutex_init (&data->results_lock);
data->func = func;
data->user_data = user_data;
diff --git a/lib/rb-util.c b/lib/rb-util.c
index f934139..5445cff 100644
--- a/lib/rb-util.c
+++ b/lib/rb-util.c
@@ -49,7 +49,7 @@
#include "rb-util.h"
#include "rb-debug.h"
-static GPrivate * private_is_primary_thread;
+static GPrivate private_is_primary_thread;
/**
* rb_true_function: (skip):
@@ -139,9 +139,9 @@ rb_gvalue_compare (GValue *a, GValue *b)
retval = 1;
break;
case G_TYPE_CHAR:
- if (g_value_get_char (a) < g_value_get_char (b))
+ if (g_value_get_schar (a) < g_value_get_schar (b))
retval = -1;
- else if (g_value_get_char (a) == g_value_get_char (b))
+ else if (g_value_get_schar (a) == g_value_get_schar (b))
retval = 0;
else
retval = 1;
@@ -409,7 +409,7 @@ gboolean
rb_is_main_thread (void)
{
if (g_thread_supported()) {
- return GPOINTER_TO_UINT(g_private_get (private_is_primary_thread)) == 1;
+ return GPOINTER_TO_UINT(g_private_get (&private_is_primary_thread)) == 1;
} else {
return TRUE;
}
@@ -423,19 +423,19 @@ purge_useless_threads (gpointer data)
}
-static GStaticRecMutex rb_gdk_mutex;
+static GRecMutex rb_gdk_mutex;
static gboolean mutex_recurses;
static void
_threads_enter (void)
{
- g_static_rec_mutex_lock (&rb_gdk_mutex);
+ g_rec_mutex_lock (&rb_gdk_mutex);
}
static void
_threads_leave (void)
{
- g_static_rec_mutex_unlock (&rb_gdk_mutex);
+ g_rec_mutex_unlock (&rb_gdk_mutex);
}
@@ -461,23 +461,20 @@ rb_assert_locked (GMutex *mutex)
void
rb_threads_init (void)
{
- GMutex *m;
+ GMutex m;
- private_is_primary_thread = g_private_new (NULL);
- g_private_set (private_is_primary_thread, GUINT_TO_POINTER (1));
+ g_private_set (&private_is_primary_thread, GUINT_TO_POINTER (1));
- g_static_rec_mutex_init (&rb_gdk_mutex);
+ g_rec_mutex_init (&rb_gdk_mutex);
gdk_threads_set_lock_functions (_threads_enter, _threads_leave);
gdk_threads_init ();
- m = g_mutex_new ();
-
- g_mutex_lock (m);
- mutex_recurses = g_mutex_trylock (m);
+ g_mutex_init (&m);
+ g_mutex_lock (&m);
+ mutex_recurses = g_mutex_trylock (&m);
if (mutex_recurses)
- g_mutex_unlock (m);
- g_mutex_unlock (m);
- g_mutex_free (m);
+ g_mutex_unlock (&m);
+ g_mutex_unlock (&m);
rb_debug ("GMutex %s recursive", mutex_recurses ? "is" : "isn't");
diff --git a/plugins/mtpdevice/rb-mtp-gst-sink.c b/plugins/mtpdevice/rb-mtp-gst-sink.c
index bc89012..13cd28a 100644
--- a/plugins/mtpdevice/rb-mtp-gst-sink.c
+++ b/plugins/mtpdevice/rb-mtp-gst-sink.c
@@ -61,8 +61,8 @@ struct _RBMTPSink
GstPad *ghostpad;
GError *upload_error;
- GMutex *upload_mutex;
- GCond *upload_cond;
+ GMutex upload_mutex;
+ GCond upload_cond;
gboolean got_folder;
gboolean upload_done;
};
@@ -124,9 +124,6 @@ rb_mtp_sink_init (RBMTPSink *sink, RBMTPSinkClass *klass)
{
GstPad *pad;
- sink->upload_mutex = g_mutex_new ();
- sink->upload_cond = g_cond_new ();
-
/* create actual sink */
sink->fdsink = gst_element_factory_make ("fdsink", NULL);
if (sink->fdsink == NULL) {
@@ -179,7 +176,7 @@ rb_mtp_sink_close_tempfile (RBMTPSink *sink)
static void
folder_callback (uint32_t folder_id, RBMTPSink *sink)
{
- g_mutex_lock (sink->upload_mutex);
+ g_mutex_lock (&sink->upload_mutex);
if (folder_id == 0) {
rb_debug ("mtp folder create failed");
} else {
@@ -189,23 +186,23 @@ folder_callback (uint32_t folder_id, RBMTPSink *sink)
sink->got_folder = TRUE;
- g_cond_signal (sink->upload_cond);
- g_mutex_unlock (sink->upload_mutex);
+ g_cond_signal (&sink->upload_cond);
+ g_mutex_unlock (&sink->upload_mutex);
}
static void
upload_callback (LIBMTP_track_t *track, GError *error, RBMTPSink *sink)
{
rb_debug ("mtp upload callback for %s: item ID %d", track->filename, track->item_id);
- g_mutex_lock (sink->upload_mutex);
+ g_mutex_lock (&sink->upload_mutex);
if (error != NULL) {
sink->upload_error = g_error_copy (error);
}
sink->upload_done = TRUE;
- g_cond_signal (sink->upload_cond);
- g_mutex_unlock (sink->upload_mutex);
+ g_cond_signal (&sink->upload_cond);
+ g_mutex_unlock (&sink->upload_mutex);
}
static void
@@ -231,7 +228,7 @@ rb_mtp_sink_handle_message (GstBin *bin, GstMessage *message)
/* we can just block waiting for mtp thread operations to finish here
* as we're on a streaming thread.
*/
- g_mutex_lock (sink->upload_mutex);
+ g_mutex_lock (&sink->upload_mutex);
if (sink->folder_path != NULL) {
/* find or create the target folder.
@@ -245,7 +242,7 @@ rb_mtp_sink_handle_message (GstBin *bin, GstMessage *message)
g_object_ref (sink),
g_object_unref);
while (sink->got_folder == FALSE) {
- g_cond_wait (sink->upload_cond, sink->upload_mutex);
+ g_cond_wait (&sink->upload_cond, &sink->upload_mutex);
}
}
@@ -259,9 +256,9 @@ rb_mtp_sink_handle_message (GstBin *bin, GstMessage *message)
g_object_unref);
while (sink->upload_done == FALSE) {
- g_cond_wait (sink->upload_cond, sink->upload_mutex);
+ g_cond_wait (&sink->upload_cond, &sink->upload_mutex);
}
- g_mutex_unlock (sink->upload_mutex);
+ g_mutex_unlock (&sink->upload_mutex);
/* post error message if the upload failed - this should get there before
* this EOS message does, so it should work OK.
@@ -406,9 +403,6 @@ rb_mtp_sink_finalize (GObject *object)
RBMTPSink *sink;
sink = RB_MTP_SINK (object);
- g_mutex_free (sink->upload_mutex);
- g_cond_free (sink->upload_cond);
-
if (sink->upload_error) {
g_error_free (sink->upload_error);
}
diff --git a/plugins/mtpdevice/rb-mtp-gst-src.c b/plugins/mtpdevice/rb-mtp-gst-src.c
index 9b431e5..2f33910 100644
--- a/plugins/mtpdevice/rb-mtp-gst-src.c
+++ b/plugins/mtpdevice/rb-mtp-gst-src.c
@@ -65,8 +65,8 @@ struct _RBMTPSrc
guint64 read_position;
GError *download_error;
- GMutex *download_mutex;
- GCond *download_cond;
+ GMutex download_mutex;
+ GCond download_cond;
gboolean download_done;
};
@@ -121,8 +121,6 @@ rb_mtp_src_base_init (gpointer g_class)
static void
rb_mtp_src_init (RBMTPSrc *src, RBMTPSrcClass *klass)
{
- src->download_mutex = g_mutex_new ();
- src->download_cond = g_cond_new ();
}
static gboolean
@@ -222,7 +220,7 @@ static void
download_cb (LIBMTP_track_t *track, const char *filename, GError *error, RBMTPSrc *src)
{
rb_debug ("mtp download callback for %s: %s", filename, error ? error->message : "OK");
- g_mutex_lock (src->download_mutex);
+ g_mutex_lock (&src->download_mutex);
if (filename == NULL) {
src->download_error = g_error_copy (error);
@@ -231,8 +229,8 @@ download_cb (LIBMTP_track_t *track, const char *filename, GError *error, RBMTPSr
}
src->download_done = TRUE;
- g_cond_signal (src->download_cond);
- g_mutex_unlock (src->download_mutex);
+ g_cond_signal (&src->download_cond);
+ g_mutex_unlock (&src->download_mutex);
}
static gboolean
@@ -242,7 +240,7 @@ rb_mtp_src_start (GstBaseSrc *basesrc)
/* download the file, if we haven't already */
if (src->tempfile == NULL) {
- g_mutex_lock (src->download_mutex);
+ g_mutex_lock (&src->download_mutex);
src->download_done = FALSE;
rb_mtp_thread_download_track (src->device_thread,
src->track_id,
@@ -252,9 +250,9 @@ rb_mtp_src_start (GstBaseSrc *basesrc)
g_object_unref);
while (src->download_done == FALSE) {
- g_cond_wait (src->download_cond, src->download_mutex);
+ g_cond_wait (&src->download_cond, &src->download_mutex);
}
- g_mutex_unlock (src->download_mutex);
+ g_mutex_unlock (&src->download_mutex);
rb_debug ("download finished");
if (src->download_error) {
@@ -371,9 +369,6 @@ rb_mtp_src_finalize (GObject *object)
RBMTPSrc *src;
src = RB_MTP_SRC (object);
- g_mutex_free (src->download_mutex);
- g_cond_free (src->download_cond);
-
if (src->download_error) {
g_error_free (src->download_error);
}
diff --git a/rhythmdb/rb-refstring.c b/rhythmdb/rb-refstring.c
index 5a05d78..6f3df6a 100644
--- a/rhythmdb/rb-refstring.c
+++ b/rhythmdb/rb-refstring.c
@@ -34,7 +34,7 @@
#include "rb-refstring.h"
GHashTable *rb_refstrings;
-GMutex *rb_refstrings_mutex;
+GMutex rb_refstrings_mutex;
struct RBRefString
{
@@ -63,8 +63,6 @@ rb_refstring_free (RBRefString *refstr)
void
rb_refstring_system_init ()
{
- rb_refstrings_mutex = g_mutex_new ();
-
rb_refstrings = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, (GDestroyNotify) rb_refstring_free);
}
@@ -84,12 +82,12 @@ rb_refstring_new (const char *init)
{
RBRefString *ret;
- g_mutex_lock (rb_refstrings_mutex);
+ g_mutex_lock (&rb_refstrings_mutex);
ret = g_hash_table_lookup (rb_refstrings, init);
if (ret) {
rb_refstring_ref (ret);
- g_mutex_unlock (rb_refstrings_mutex);
+ g_mutex_unlock (&rb_refstrings_mutex);
return ret;
}
@@ -101,7 +99,7 @@ rb_refstring_new (const char *init)
ret->sortkey = NULL;
g_hash_table_insert (rb_refstrings, ret->value, ret);
- g_mutex_unlock (rb_refstrings_mutex);
+ g_mutex_unlock (&rb_refstrings_mutex);
return ret;
}
@@ -120,13 +118,13 @@ rb_refstring_find (const char *init)
{
RBRefString *ret;
- g_mutex_lock (rb_refstrings_mutex);
+ g_mutex_lock (&rb_refstrings_mutex);
ret = g_hash_table_lookup (rb_refstrings, init);
if (ret)
rb_refstring_ref (ret);
- g_mutex_unlock (rb_refstrings_mutex);
+ g_mutex_unlock (&rb_refstrings_mutex);
return ret;
}
@@ -146,12 +144,12 @@ rb_refstring_unref (RBRefString *val)
g_return_if_fail (g_atomic_int_get (&val->refcount) > 0);
if (g_atomic_int_dec_and_test (&val->refcount)) {
- g_mutex_lock (rb_refstrings_mutex);
+ g_mutex_lock (&rb_refstrings_mutex);
/* ensure it's still not referenced, as something may have called
* rb_refstring_new since we decremented the count */
if (g_atomic_int_get (&val->refcount) == 0)
g_hash_table_remove (rb_refstrings, val->value);
- g_mutex_unlock (rb_refstrings_mutex);
+ g_mutex_unlock (&rb_refstrings_mutex);
}
}
@@ -165,7 +163,6 @@ void
rb_refstring_system_shutdown (void)
{
g_hash_table_destroy (rb_refstrings);
- g_mutex_free (rb_refstrings_mutex);
}
/**
diff --git a/rhythmdb/rhythmdb-import-job.c b/rhythmdb/rhythmdb-import-job.c
index 8dc57c8..e9fcde3 100644
--- a/rhythmdb/rhythmdb-import-job.c
+++ b/rhythmdb/rhythmdb-import-job.c
@@ -68,7 +68,7 @@ struct _RhythmDBImportJobPrivate
RhythmDBEntryType *entry_type;
RhythmDBEntryType *ignore_type;
RhythmDBEntryType *error_type;
- GStaticMutex lock;
+ GMutex lock;
GSList *uri_list;
gboolean started;
GCancellable *cancel;
@@ -139,9 +139,9 @@ rhythmdb_import_job_add_uri (RhythmDBImportJob *job, const char *uri)
{
g_assert (job->priv->started == FALSE);
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
job->priv->uri_list = g_slist_prepend (job->priv->uri_list, g_strdup (uri));
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
}
static void
@@ -150,7 +150,7 @@ missing_plugins_retry_cb (gpointer instance, gboolean installed, RhythmDBImportJ
GSList *retry = NULL;
GSList *i;
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
g_assert (job->priv->retried == FALSE);
if (installed == FALSE) {
rb_debug ("plugin installation was not successful; job complete");
@@ -177,7 +177,7 @@ missing_plugins_retry_cb (gpointer instance, gboolean installed, RhythmDBImportJ
rhythmdb_commit (job->priv->db);
retry = g_slist_reverse (retry);
}
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
for (i = retry; i != NULL; i = i->next) {
char *uri = (char *)i->data;
@@ -195,7 +195,7 @@ missing_plugins_retry_cb (gpointer instance, gboolean installed, RhythmDBImportJ
static gboolean
emit_status_changed (RhythmDBImportJob *job)
{
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
job->priv->status_changed_id = 0;
rb_debug ("emitting status changed: %d/%d", job->priv->imported, job->priv->total);
@@ -252,7 +252,7 @@ emit_status_changed (RhythmDBImportJob *job)
g_signal_emit (job, signals[COMPLETE], 0, job->priv->total);
}
}
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
g_object_unref (job);
return FALSE;
@@ -276,7 +276,7 @@ uri_recurse_func (GFile *file, gboolean dir, RhythmDBImportJob *job)
entry = rhythmdb_entry_lookup_by_location (job->priv->db, uri);
if (entry == NULL) {
rb_debug ("waiting for entry %s", uri);
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
job->priv->total++;
g_hash_table_insert (job->priv->outstanding, g_strdup (uri), GINT_TO_POINTER (1));
@@ -284,7 +284,7 @@ uri_recurse_func (GFile *file, gboolean dir, RhythmDBImportJob *job)
job->priv->status_changed_id = g_idle_add ((GSourceFunc) emit_status_changed, job);
}
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
}
rhythmdb_add_uri_with_types (job->priv->db,
@@ -307,7 +307,7 @@ emit_scan_complete_idle (RhythmDBImportJob *job)
static void
next_uri (RhythmDBImportJob *job)
{
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
if (job->priv->uri_list == NULL) {
rb_debug ("no more uris to scan");
job->priv->scan_complete = TRUE;
@@ -326,7 +326,7 @@ next_uri (RhythmDBImportJob *job)
g_free (uri);
}
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
}
/**
@@ -343,10 +343,10 @@ rhythmdb_import_job_start (RhythmDBImportJob *job)
g_assert (job->priv->started == FALSE);
rb_debug ("starting");
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
job->priv->started = TRUE;
job->priv->uri_list = g_slist_reverse (job->priv->uri_list);
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
/* reference is released in emit_scan_complete_idle */
next_uri (g_object_ref (job));
@@ -422,9 +422,9 @@ rhythmdb_import_job_complete (RhythmDBImportJob *job)
void
rhythmdb_import_job_cancel (RhythmDBImportJob *job)
{
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
g_cancellable_cancel (job->priv->cancel);
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
}
static void
@@ -437,7 +437,7 @@ entry_added_cb (RhythmDB *db,
uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
- g_static_mutex_lock (&job->priv->lock);
+ g_mutex_lock (&job->priv->lock);
ours = g_hash_table_remove (job->priv->outstanding, uri);
if (ours) {
@@ -459,7 +459,7 @@ entry_added_cb (RhythmDB *db,
job->priv->status_changed_id = g_idle_add ((GSourceFunc) emit_status_changed, job);
}
}
- g_static_mutex_unlock (&job->priv->lock);
+ g_mutex_unlock (&job->priv->lock);
}
static void
@@ -469,7 +469,7 @@ rhythmdb_import_job_init (RhythmDBImportJob *job)
RHYTHMDB_TYPE_IMPORT_JOB,
RhythmDBImportJobPrivate);
- g_static_mutex_init (&job->priv->lock);
+ g_mutex_init (&job->priv->lock);
job->priv->outstanding = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
job->priv->cancel = g_cancellable_new ();
@@ -559,8 +559,6 @@ impl_finalize (GObject *object)
rb_slist_deep_free (job->priv->uri_list);
- g_static_mutex_free (&job->priv->lock);
-
G_OBJECT_CLASS (rhythmdb_import_job_parent_class)->finalize (object);
}
diff --git a/rhythmdb/rhythmdb-monitor.c b/rhythmdb/rhythmdb-monitor.c
index 023978a..9a29917 100644
--- a/rhythmdb/rhythmdb-monitor.c
+++ b/rhythmdb/rhythmdb-monitor.c
@@ -59,8 +59,6 @@ static void rhythmdb_mount_removed_cb (GVolumeMonitor *monitor,
void
rhythmdb_init_monitoring (RhythmDB *db)
{
- db->priv->monitor_mutex = g_mutex_new ();
-
db->priv->monitored_directories = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
(GDestroyNotify) g_object_unref,
(GDestroyNotify)g_file_monitor_cancel);
@@ -106,8 +104,6 @@ rhythmdb_finalize_monitoring (RhythmDB *db)
g_hash_table_destroy (db->priv->monitored_directories);
g_hash_table_destroy (db->priv->changed_files);
-
- g_mutex_free (db->priv->monitor_mutex);
}
void
@@ -127,10 +123,10 @@ actually_add_monitor (RhythmDB *db, GFile *directory, GError **error)
return;
}
- g_mutex_lock (db->priv->monitor_mutex);
+ g_mutex_lock (&db->priv->monitor_mutex);
if (g_hash_table_lookup (db->priv->monitored_directories, directory)) {
- g_mutex_unlock (db->priv->monitor_mutex);
+ g_mutex_unlock (&db->priv->monitor_mutex);
return;
}
@@ -145,7 +141,7 @@ actually_add_monitor (RhythmDB *db, GFile *directory, GError **error)
monitor);
}
- g_mutex_unlock (db->priv->monitor_mutex);
+ g_mutex_unlock (&db->priv->monitor_mutex);
}
static void
diff --git a/rhythmdb/rhythmdb-private.h b/rhythmdb/rhythmdb-private.h
index b4d2524..f0ed813 100644
--- a/rhythmdb/rhythmdb-private.h
+++ b/rhythmdb/rhythmdb-private.h
@@ -139,7 +139,7 @@ struct _RhythmDBPrivate
GList *outstanding_stats;
GList *active_mounts;
GList *mount_list;
- GMutex *stat_mutex;
+ GMutex stat_mutex;
gboolean stat_thread_running;
int stat_thread_count;
int stat_thread_done;
@@ -149,23 +149,23 @@ struct _RhythmDBPrivate
GHashTable *changed_files;
guint changed_files_id;
char **library_locations;
- GMutex *monitor_mutex;
+ GMutex monitor_mutex;
gboolean dry_run;
gboolean no_update;
- GMutex *change_mutex;
+ GMutex change_mutex;
GHashTable *added_entries;
GHashTable *changed_entries;
GHashTable *deleted_entries;
GHashTable *propname_map;
- GMutex *exit_mutex;
+ GMutex exit_mutex;
GCancellable *exiting; /* hrm, name? */
- GCond *saving_condition;
- GMutex *saving_mutex;
+ GCond saving_condition;
+ GMutex saving_mutex;
guint save_count;
guint event_queue_watch_id;
@@ -182,8 +182,8 @@ struct _RhythmDBPrivate
gboolean dirty;
GHashTable *entry_type_map;
- GMutex *entry_type_map_mutex;
- GMutex *entry_type_mutex;
+ GMutex entry_type_map_mutex;
+ GMutex entry_type_mutex;
gint next_entry_id;
diff --git a/rhythmdb/rhythmdb-tree.c b/rhythmdb/rhythmdb-tree.c
index dfd349a..aef651b 100644
--- a/rhythmdb/rhythmdb-tree.c
+++ b/rhythmdb/rhythmdb-tree.c
@@ -137,13 +137,13 @@ struct RhythmDBTreePrivate
{
GHashTable *entries;
GHashTable *entry_ids;
- GMutex *entries_lock;
+ GMutex entries_lock;
GHashTable *keywords; /* GHashTable<RBRefString, GHashTable<RhyhmDBEntry, 1>> */
- GMutex *keywords_lock;
+ GMutex keywords_lock;
GHashTable *genres;
- GMutex *genres_lock; /* must be held while using the tree */
+ GMutex genres_lock; /* must be held while using the tree */
GHashTable *unknown_entry_types;
gboolean finalizing;
@@ -220,13 +220,10 @@ rhythmdb_tree_init (RhythmDBTree *db)
db->priv->entries = g_hash_table_new (rb_refstring_hash, rb_refstring_equal);
db->priv->entry_ids = g_hash_table_new (g_direct_hash, g_direct_equal);
- db->priv->entries_lock = g_mutex_new();
db->priv->keywords = g_hash_table_new_full (rb_refstring_hash, rb_refstring_equal,
(GDestroyNotify)rb_refstring_unref, (GDestroyNotify)g_hash_table_destroy);
- db->priv->keywords_lock = g_mutex_new();
- db->priv->genres_lock = g_mutex_new();
db->priv->genres = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify)g_hash_table_destroy);
@@ -239,7 +236,7 @@ unparent_entries (gpointer key,
RhythmDBEntry *entry,
RhythmDBTree *db)
{
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->genres_lock);
remove_entry_from_album (db, entry);
}
@@ -284,19 +281,16 @@ rhythmdb_tree_finalize (GObject *object)
db->priv->finalizing = TRUE;
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
g_hash_table_foreach (db->priv->entries, (GHFunc) unparent_entries, db);
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
g_hash_table_destroy (db->priv->entries);
g_hash_table_destroy (db->priv->entry_ids);
- g_mutex_free (db->priv->entries_lock);
g_hash_table_destroy (db->priv->keywords);
- g_mutex_free (db->priv->keywords_lock);
g_hash_table_destroy (db->priv->genres);
- g_mutex_free (db->priv->genres_lock);
g_hash_table_foreach (db->priv->unknown_entry_types,
(GHFunc) free_unknown_entries,
@@ -570,7 +564,7 @@ rhythmdb_tree_parser_end_element (struct RhythmDBTreeLoadContext *ctx,
if (ctx->entry->location != NULL && rb_refstring_get (ctx->entry->location)[0] != '\0') {
RhythmDBEntry *entry;
- g_mutex_lock (ctx->db->priv->entries_lock);
+ g_mutex_lock (&ctx->db->priv->entries_lock);
entry = g_hash_table_lookup (ctx->db->priv->entries, ctx->entry->location);
if (entry == NULL) {
rhythmdb_tree_entry_new_internal (RHYTHMDB (ctx->db), ctx->entry);
@@ -590,9 +584,9 @@ rhythmdb_tree_parser_end_element (struct RhythmDBTreeLoadContext *ctx,
/* Remove the song entry,
* deleting requires relinquishing the locks */
- g_mutex_unlock (ctx->db->priv->entries_lock);
+ g_mutex_unlock (&ctx->db->priv->entries_lock);
rhythmdb_entry_delete (RHYTHMDB(ctx->db), entry);
- g_mutex_lock (ctx->db->priv->entries_lock);
+ g_mutex_lock (&ctx->db->priv->entries_lock);
rhythmdb_commit (RHYTHMDB (ctx->db));
/* And add the Podcast entry to the database */
@@ -624,7 +618,7 @@ rhythmdb_tree_parser_end_element (struct RhythmDBTreeLoadContext *ctx,
rhythmdb_entry_unref (ctx->entry);
}
- g_mutex_unlock (ctx->db->priv->entries_lock);
+ g_mutex_unlock (&ctx->db->priv->entries_lock);
} else {
rb_debug ("found entry without location");
rhythmdb_entry_unref (ctx->entry);
@@ -640,11 +634,11 @@ rhythmdb_tree_parser_end_element (struct RhythmDBTreeLoadContext *ctx,
rb_debug ("finished reading unknown entry");
ctx->unknown_entry->properties = g_list_reverse (ctx->unknown_entry->properties);
- g_mutex_lock (ctx->db->priv->entries_lock);
+ g_mutex_lock (&ctx->db->priv->entries_lock);
entry_list = g_hash_table_lookup (ctx->db->priv->unknown_entry_types, ctx->unknown_entry->typename);
entry_list = g_list_prepend (entry_list, ctx->unknown_entry);
g_hash_table_insert (ctx->db->priv->unknown_entry_types, ctx->unknown_entry->typename, entry_list);
- g_mutex_unlock (ctx->db->priv->entries_lock);
+ g_mutex_unlock (&ctx->db->priv->entries_lock);
ctx->state = RHYTHMDB_TREE_PARSER_STATE_RHYTHMDB;
ctx->unknown_entry = NULL;
@@ -1253,11 +1247,11 @@ rhythmdb_tree_save (RhythmDB *rdb)
ctx.handle, ctx.error);
rhythmdb_entry_type_foreach (rdb, (GHFunc) save_entry_type, &ctx);
- g_mutex_lock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_lock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
g_hash_table_foreach (db->priv->unknown_entry_types,
(GHFunc) save_unknown_entry_type,
&ctx);
- g_mutex_unlock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_unlock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
RHYTHMDB_FWRITE_STATICSTR ("</rhythmdb>\n", ctx.handle, ctx.error);
@@ -1321,9 +1315,9 @@ static void
rhythmdb_tree_entry_new (RhythmDB *rdb,
RhythmDBEntry *entry)
{
- g_mutex_lock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_lock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
rhythmdb_tree_entry_new_internal (rdb, entry);
- g_mutex_unlock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_unlock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
}
/* must be called with the entry lock held */
@@ -1334,7 +1328,7 @@ rhythmdb_tree_entry_new_internal (RhythmDB *rdb, RhythmDBEntry *entry)
RhythmDBTreeProperty *artist;
RhythmDBTreeProperty *genre;
- rb_assert_locked (db->priv->entries_lock);
+ rb_assert_locked (&db->priv->entries_lock);
g_assert (entry != NULL);
g_return_if_fail (entry->location != NULL);
@@ -1361,11 +1355,11 @@ rhythmdb_tree_entry_new_internal (RhythmDB *rdb, RhythmDBEntry *entry)
}
/* Initialize the tree structure. */
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
genre = get_or_create_genre (db, entry->type, entry->genre);
artist = get_or_create_artist (db, genre, entry->artist);
set_entry_album (db, entry, artist, entry->album);
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
/* this accounts for the initial reference on the entry */
g_hash_table_insert (db->priv->entries, entry->location, entry);
@@ -1444,7 +1438,7 @@ get_or_create_genre (RhythmDBTree *db,
RhythmDBTreeProperty *genre;
GHashTable *table;
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->genres_lock);
table = get_genres_hash_for_type (db, type);
genre = g_hash_table_lookup (table, name);
@@ -1470,7 +1464,7 @@ get_or_create_artist (RhythmDBTree *db,
{
RhythmDBTreeProperty *artist;
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->genres_lock);
artist = g_hash_table_lookup (genre->children, name);
@@ -1495,7 +1489,7 @@ get_or_create_album (RhythmDBTree *db,
{
RhythmDBTreeProperty *album;
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->genres_lock);
album = g_hash_table_lookup (artist->children, name);
@@ -1528,7 +1522,7 @@ remove_entry_from_album (RhythmDBTree *db,
{
GHashTable *table;
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->genres_lock);
rb_refstring_ref (entry->genre);
rb_refstring_ref (entry->artist);
@@ -1584,14 +1578,14 @@ rhythmdb_tree_entry_set (RhythmDB *adb,
* GValue is freed; this means we have to do the entry modification
* here, rather than letting rhythmdb_entry_set_internal do it.
*/
- g_mutex_lock (db->priv->entries_lock);
+ g_mutex_lock (&db->priv->entries_lock);
g_assert (g_hash_table_remove (db->priv->entries, entry->location));
s = rb_refstring_new (g_value_get_string (value));
rb_refstring_unref (entry->location);
entry->location = s;
g_hash_table_insert (db->priv->entries, entry->location, entry);
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
return TRUE;
}
@@ -1607,12 +1601,12 @@ rhythmdb_tree_entry_set (RhythmDB *adb,
rb_refstring_ref (entry->artist);
rb_refstring_ref (entry->album);
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
remove_entry_from_album (db, entry);
genre = get_or_create_genre (db, type, entry->genre);
artist = get_or_create_artist (db, genre, entry->artist);
set_entry_album (db, entry, artist, rb_refstring_new (albumname));
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
rb_refstring_unref (entry->genre);
rb_refstring_unref (entry->artist);
@@ -1632,13 +1626,13 @@ rhythmdb_tree_entry_set (RhythmDB *adb,
rb_refstring_ref (entry->artist);
rb_refstring_ref (entry->album);
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
remove_entry_from_album (db, entry);
genre = get_or_create_genre (db, type, entry->genre);
new_artist = get_or_create_artist (db, genre,
rb_refstring_new (artistname));
set_entry_album (db, entry, new_artist, entry->album);
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
rb_refstring_unref (entry->genre);
rb_refstring_unref (entry->artist);
@@ -1658,13 +1652,13 @@ rhythmdb_tree_entry_set (RhythmDB *adb,
rb_refstring_ref (entry->artist);
rb_refstring_ref (entry->album);
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
remove_entry_from_album (db, entry);
new_genre = get_or_create_genre (db, type,
rb_refstring_new (genrename));
new_artist = get_or_create_artist (db, new_genre, entry->artist);
set_entry_album (db, entry, new_artist, entry->album);
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
rb_refstring_unref (entry->genre);
rb_refstring_unref (entry->artist);
@@ -1685,22 +1679,22 @@ rhythmdb_tree_entry_delete (RhythmDB *adb,
{
RhythmDBTree *db = RHYTHMDB_TREE (adb);
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
remove_entry_from_album (db, entry);
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
/* remove all keywords */
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
remove_entry_from_keywords (db, entry);
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
- g_mutex_lock (db->priv->entries_lock);
+ g_mutex_lock (&db->priv->entries_lock);
g_assert (g_hash_table_remove (db->priv->entries, entry->location));
g_assert (g_hash_table_remove (db->priv->entry_ids, GINT_TO_POINTER (entry->id)));
entry->flags |= RHYTHMDB_ENTRY_TREE_REMOVED;
rhythmdb_entry_unref (entry);
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
}
typedef struct {
@@ -1716,16 +1710,16 @@ remove_one_song (gpointer key,
{
RhythmDBTree *db = RHYTHMDB_TREE(ctxt->db);
- rb_assert_locked (db->priv->entries_lock);
- rb_assert_locked (db->priv->genres_lock);
+ rb_assert_locked (&db->priv->entries_lock);
+ rb_assert_locked (&db->priv->genres_lock);
g_return_val_if_fail (entry != NULL, FALSE);
if (entry->type == ctxt->type) {
rhythmdb_emit_entry_deleted (ctxt->db, entry);
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
remove_entry_from_keywords (db, entry);
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
remove_entry_from_album (db, entry);
g_hash_table_remove (db->priv->entry_ids, GINT_TO_POINTER (entry->id));
entry->flags |= RHYTHMDB_ENTRY_TREE_REMOVED;
@@ -1744,12 +1738,12 @@ rhythmdb_tree_entry_delete_by_type (RhythmDB *adb,
ctxt.db = adb;
ctxt.type = type;
- g_mutex_lock (db->priv->entries_lock);
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->entries_lock);
+ g_mutex_lock (&db->priv->genres_lock);
g_hash_table_foreach_remove (db->priv->entries,
(GHRFunc) remove_one_song, &ctxt);
- g_mutex_unlock (db->priv->genres_lock);
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
}
static void
@@ -2217,7 +2211,7 @@ conjunctive_query (RhythmDBTree *db,
traversal_data->data = data;
traversal_data->cancel = cancel;
- g_mutex_lock (db->priv->genres_lock);
+ g_mutex_lock (&db->priv->genres_lock);
if (type_query_idx >= 0) {
GHashTable *genres;
RhythmDBEntryType *etype;
@@ -2238,7 +2232,7 @@ conjunctive_query (RhythmDBTree *db,
genres_hash_foreach (db, (RBHFunc)conjunctive_query_genre,
traversal_data);
}
- g_mutex_unlock (db->priv->genres_lock);
+ g_mutex_unlock (&db->priv->genres_lock);
g_free (traversal_data);
}
@@ -2369,9 +2363,9 @@ rhythmdb_tree_entry_lookup_by_location (RhythmDB *adb,
RhythmDBTree *db = RHYTHMDB_TREE (adb);
RhythmDBEntry *entry;
- g_mutex_lock (db->priv->entries_lock);
+ g_mutex_lock (&db->priv->entries_lock);
entry = g_hash_table_lookup (db->priv->entries, uri);
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
return entry;
}
@@ -2383,9 +2377,9 @@ rhythmdb_tree_entry_lookup_by_id (RhythmDB *adb,
RhythmDBTree *db = RHYTHMDB_TREE (adb);
RhythmDBEntry *entry;
- g_mutex_lock (db->priv->entries_lock);
+ g_mutex_lock (&db->priv->entries_lock);
entry = g_hash_table_lookup (db->priv->entry_ids, GINT_TO_POINTER (id));
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
return entry;
}
@@ -2411,11 +2405,11 @@ rhythmdb_tree_entry_foreach (RhythmDB *rdb, GFunc foreach_func, gpointer user_da
GPtrArray *list;
guint size, i;
- g_mutex_lock (db->priv->entries_lock);
+ g_mutex_lock (&db->priv->entries_lock);
size = g_hash_table_size (db->priv->entries);
list = g_ptr_array_sized_new (size);
g_hash_table_foreach (db->priv->entries, (GHFunc)rhythmdb_tree_entry_foreach_func, list);
- g_mutex_unlock (db->priv->entries_lock);
+ g_mutex_unlock (&db->priv->entries_lock);
for (i = 0; i < size; i++) {
RhythmDBEntry *entry = (RhythmDBEntry*)g_ptr_array_index (list, i);
@@ -2497,7 +2491,7 @@ rhythmdb_tree_entry_keyword_add (RhythmDB *rdb,
GHashTable *keyword_table;
gboolean present;
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
keyword_table = g_hash_table_lookup (db->priv->keywords, keyword);
if (keyword_table != NULL) {
/* it would be nice if _insert told us whether it was replacing a value */
@@ -2513,7 +2507,7 @@ rhythmdb_tree_entry_keyword_add (RhythmDB *rdb,
g_hash_table_insert (db->priv->keywords, rb_refstring_ref (keyword), keyword_table);
}
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
return present;
}
@@ -2527,14 +2521,14 @@ rhythmdb_tree_entry_keyword_remove (RhythmDB *rdb,
GHashTable *keyword_table;
gboolean ret;
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
keyword_table = g_hash_table_lookup (db->priv->keywords, keyword);
if (keyword_table != NULL) {
ret = remove_entry_from_keyword_table (keyword, keyword_table, entry);
} else {
ret = FALSE;
}
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
return ret;
}
@@ -2548,14 +2542,14 @@ rhythmdb_tree_entry_keyword_has (RhythmDB *rdb,
GHashTable *keyword_table;
gboolean ret;
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
keyword_table = g_hash_table_lookup (db->priv->keywords, keyword);
if (keyword_table != NULL) {
ret = (g_hash_table_lookup (keyword_table, entry) != NULL);
} else {
ret = FALSE;
}
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
return ret;
}
@@ -2598,9 +2592,9 @@ rhythmdb_tree_entry_keywords_get (RhythmDB *rdb,
data.entry = entry;
data.keywords = NULL;
- g_mutex_lock (db->priv->keywords_lock);
+ g_mutex_lock (&db->priv->keywords_lock);
g_hash_table_foreach (db->priv->keywords, (GHFunc)check_entry_existance, &data);
- g_mutex_unlock (db->priv->keywords_lock);
+ g_mutex_unlock (&db->priv->keywords_lock);
return data.keywords;
}
@@ -2704,7 +2698,7 @@ rhythmdb_hash_tree_foreach (RhythmDB *adb,
ctxt.entry_func = entry_func;
ctxt.data = data;
- g_mutex_lock (ctxt.db->priv->genres_lock);
+ g_mutex_lock (&ctxt.db->priv->genres_lock);
table = get_genres_hash_for_type (RHYTHMDB_TREE (adb), type);
if (table == NULL) {
return;
@@ -2715,7 +2709,7 @@ rhythmdb_hash_tree_foreach (RhythmDB *adb,
|| (ctxt.entry_func != NULL)) {
g_hash_table_foreach (table, hash_tree_genres_foreach, &ctxt);
}
- g_mutex_unlock (ctxt.db->priv->genres_lock);
+ g_mutex_unlock (&ctxt.db->priv->genres_lock);
}
static void
@@ -2730,7 +2724,7 @@ rhythmdb_tree_entry_type_registered (RhythmDB *db,
RBRefString *rs_name;
rdb = RHYTHMDB_TREE (db);
- g_mutex_lock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_lock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
/* ugh, this sucks, maybe store the name as a refstring in the object? */
g_object_get (entry_type, "name", &name, NULL);
@@ -2739,7 +2733,7 @@ rhythmdb_tree_entry_type_registered (RhythmDB *db,
if (rs_name)
entries = g_hash_table_lookup (rdb->priv->unknown_entry_types, rs_name);
if (entries == NULL) {
- g_mutex_unlock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_unlock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
rb_refstring_unref (rs_name);
rb_debug ("no entries of newly registered type %s loaded from db", name);
g_free (name);
@@ -2775,7 +2769,7 @@ rhythmdb_tree_entry_type_registered (RhythmDB *db,
rhythmdb_commit (db);
g_hash_table_remove (rdb->priv->unknown_entry_types, rs_name);
- g_mutex_unlock (RHYTHMDB_TREE(rdb)->priv->entries_lock);
+ g_mutex_unlock (&RHYTHMDB_TREE(rdb)->priv->entries_lock);
free_unknown_entries (rs_name, entries, NULL);
rb_refstring_unref (rs_name);
}
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index d83671f..9af8aa8 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -720,16 +720,10 @@ rhythmdb_init (RhythmDB *db)
}
db->priv->entry_type_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- db->priv->entry_type_map_mutex = g_mutex_new ();
- db->priv->entry_type_mutex = g_mutex_new ();
rhythmdb_register_song_entry_types (db);
rb_podcast_register_entry_types (db);
- db->priv->stat_mutex = g_mutex_new ();
-
- db->priv->change_mutex = g_mutex_new ();
-
db->priv->changed_entries = g_hash_table_new_full (NULL,
NULL,
(GDestroyNotify) rhythmdb_entry_unref,
@@ -743,9 +737,6 @@ rhythmdb_init (RhythmDB *db)
(GDestroyNotify) rhythmdb_entry_unref,
NULL);
- db->priv->saving_condition = g_cond_new ();
- db->priv->saving_mutex = g_mutex_new ();
-
db->priv->can_save = TRUE;
db->priv->exiting = g_cancellable_new ();
db->priv->saving = FALSE;
@@ -921,7 +912,7 @@ perform_next_mount (RhythmDB *db)
void
rhythmdb_start_action_thread (RhythmDB *db)
{
- g_mutex_lock (db->priv->stat_mutex);
+ g_mutex_lock (&db->priv->stat_mutex);
db->priv->action_thread_running = TRUE;
rhythmdb_thread_create (db, NULL, (GThreadFunc) action_thread_main, db);
@@ -938,7 +929,7 @@ rhythmdb_start_action_thread (RhythmDB *db)
perform_next_mount (db);
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
}
static void
@@ -1021,11 +1012,11 @@ rhythmdb_shutdown (RhythmDB *db)
db->priv->library_locations = NULL;
/* abort all async io operations */
- g_mutex_lock (db->priv->stat_mutex);
+ g_mutex_lock (&db->priv->stat_mutex);
g_list_foreach (db->priv->outstanding_stats, (GFunc)_shutdown_foreach_swapped, db);
g_list_free (db->priv->outstanding_stats);
db->priv->outstanding_stats = NULL;
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
rb_debug ("%d outstanding threads", g_atomic_int_get (&db->priv->outstanding_threads));
while (g_atomic_int_get (&db->priv->outstanding_threads) > 0) {
@@ -1120,13 +1111,7 @@ rhythmdb_finalize (GObject *object)
g_async_queue_unref (db->priv->restored_queue);
g_async_queue_unref (db->priv->delayed_write_queue);
- g_mutex_free (db->priv->saving_mutex);
- g_cond_free (db->priv->saving_condition);
-
g_list_free (db->priv->stat_list);
- g_mutex_free (db->priv->stat_mutex);
-
- g_mutex_free (db->priv->change_mutex);
g_hash_table_destroy (db->priv->propname_map);
@@ -1138,8 +1123,6 @@ rhythmdb_finalize (GObject *object)
rb_refstring_unref (db->priv->octet_stream_str);
g_hash_table_destroy (db->priv->entry_type_map);
- g_mutex_free (db->priv->entry_type_map_mutex);
- g_mutex_free (db->priv->entry_type_mutex);
g_free (db->priv->name);
@@ -1315,7 +1298,7 @@ rhythmdb_emit_entry_signals_idle (RhythmDB *db)
GSList *entry_changes;
/* get lists of entries to emit, reset source id value */
- g_mutex_lock (db->priv->change_mutex);
+ g_mutex_lock (&db->priv->change_mutex);
added_entries = db->priv->added_entries_to_emit;
db->priv->added_entries_to_emit = NULL;
@@ -1328,7 +1311,7 @@ rhythmdb_emit_entry_signals_idle (RhythmDB *db)
db->priv->emit_entry_signals_id = 0;
- g_mutex_unlock (db->priv->change_mutex);
+ g_mutex_unlock (&db->priv->change_mutex);
GDK_THREADS_ENTER ();
@@ -1405,7 +1388,7 @@ process_added_entries_cb (RhythmDBEntry *entry,
* - for local mountpoints that are mounted, add to stat list
* - for everything else, hide entries on those mountpoints
*/
- g_mutex_lock (db->priv->stat_mutex);
+ g_mutex_lock (&db->priv->stat_mutex);
if (db->priv->action_thread_running == FALSE) {
const char *mountpoint;
@@ -1437,7 +1420,7 @@ process_added_entries_cb (RhythmDBEntry *entry,
}
}
}
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
}
g_assert ((entry->flags & RHYTHMDB_ENTRY_INSERTED) == 0);
@@ -1535,7 +1518,7 @@ rhythmdb_commit_internal (RhythmDB *db,
gboolean sync_changes,
GThread *thread)
{
- g_mutex_lock (db->priv->change_mutex);
+ g_mutex_lock (&db->priv->change_mutex);
if (sync_changes) {
g_hash_table_foreach (db->priv->changed_entries, (GHFunc) sync_entry_changed, db);
@@ -1552,7 +1535,7 @@ rhythmdb_commit_internal (RhythmDB *db,
db->priv->emit_entry_signals_id = g_idle_add ((GSourceFunc) rhythmdb_emit_entry_signals_idle, db);
}
- g_mutex_unlock (db->priv->change_mutex);
+ g_mutex_unlock (&db->priv->change_mutex);
}
typedef struct {
@@ -1728,9 +1711,9 @@ rhythmdb_entry_insert (RhythmDB *db,
/* ref the entry before adding to hash, it is unreffed when removed */
rhythmdb_entry_ref (entry);
- g_mutex_lock (db->priv->change_mutex);
+ g_mutex_lock (&db->priv->change_mutex);
g_hash_table_insert (db->priv->added_entries, entry, g_thread_self ());
- g_mutex_unlock (db->priv->change_mutex);
+ g_mutex_unlock (&db->priv->change_mutex);
}
/**
@@ -2579,9 +2562,9 @@ rhythmdb_execute_stat_mount_ready_cb (GObject *source, GAsyncResult *result, Rhy
rhythmdb_file_info_query (event->db, G_FILE (source), event);
}
- g_mutex_lock (event->db->priv->stat_mutex);
+ g_mutex_lock (&event->db->priv->stat_mutex);
event->db->priv->outstanding_stats = g_list_remove (event->db->priv->outstanding_stats, event);
- g_mutex_unlock (event->db->priv->stat_mutex);
+ g_mutex_unlock (&event->db->priv->stat_mutex);
g_object_unref (source);
rhythmdb_push_event (event->db, event);
@@ -2598,9 +2581,9 @@ rhythmdb_execute_stat (RhythmDB *db,
event->real_uri = rb_refstring_new (uri);
file = g_file_new_for_uri (uri);
- g_mutex_lock (db->priv->stat_mutex);
+ g_mutex_lock (&db->priv->stat_mutex);
db->priv->outstanding_stats = g_list_prepend (db->priv->outstanding_stats, event);
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
rhythmdb_file_info_query (db, file, event);
@@ -2635,9 +2618,9 @@ rhythmdb_execute_stat (RhythmDB *db,
/* either way, we're done now */
- g_mutex_lock (event->db->priv->stat_mutex);
+ g_mutex_lock (&event->db->priv->stat_mutex);
event->db->priv->outstanding_stats = g_list_remove (event->db->priv->outstanding_stats, event);
- g_mutex_unlock (event->db->priv->stat_mutex);
+ g_mutex_unlock (&event->db->priv->stat_mutex);
rhythmdb_push_event (event->db, event);
g_object_unref (file);
@@ -3006,10 +2989,10 @@ rhythmdb_add_uri_with_types (RhythmDB *db,
* when the action thread is already running, stat actions go through
* the normal action queue and are processed by the action thread.
*/
- g_mutex_lock (db->priv->stat_mutex);
+ g_mutex_lock (&db->priv->stat_mutex);
if (db->priv->action_thread_running) {
RhythmDBAction *action;
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
action = g_slice_new0 (RhythmDBAction);
action->type = RHYTHMDB_ACTION_STAT;
@@ -3025,7 +3008,7 @@ rhythmdb_add_uri_with_types (RhythmDB *db,
entry = rhythmdb_entry_lookup_by_location (db, uri);
rhythmdb_add_to_stat_list (db, uri, entry, type, ignore_type, error_type);
- g_mutex_unlock (db->priv->stat_mutex);
+ g_mutex_unlock (&db->priv->stat_mutex);
}
}
@@ -3060,7 +3043,8 @@ rhythmdb_load_thread_main (RhythmDB *db)
db->priv->active_mounts = rhythmdb_get_active_mounts (db);
- g_mutex_lock (db->priv->saving_mutex);
+ rb_profile_start ("loading db");
+ g_mutex_lock (&db->priv->saving_mutex);
if (klass->impl_load (db, db->priv->exiting, &error) == FALSE) {
rb_debug ("db load failed: disabling saving");
db->priv->can_save = FALSE;
@@ -3069,7 +3053,7 @@ rhythmdb_load_thread_main (RhythmDB *db)
g_idle_add ((GSourceFunc) rhythmdb_load_error_cb, error);
}
}
- g_mutex_unlock (db->priv->saving_mutex);
+ g_mutex_unlock (&db->priv->saving_mutex);
rb_list_deep_free (db->priv->active_mounts);
db->priv->active_mounts = NULL;
@@ -3110,19 +3094,19 @@ rhythmdb_save_thread_main (RhythmDB *db)
rb_debug ("entering save thread");
- g_mutex_lock (db->priv->saving_mutex);
+ g_mutex_lock (&db->priv->saving_mutex);
db->priv->save_count++;
- g_cond_broadcast (db->priv->saving_condition);
+ g_cond_broadcast (&db->priv->saving_condition);
if (!(db->priv->dirty && db->priv->can_save)) {
rb_debug ("no save needed, ignoring");
- g_mutex_unlock (db->priv->saving_mutex);
+ g_mutex_unlock (&db->priv->saving_mutex);
goto out;
}
while (db->priv->saving)
- g_cond_wait (db->priv->saving_condition, db->priv->saving_mutex);
+ g_cond_wait (&db->priv->saving_condition, &db->priv->saving_mutex);
db->priv->saving = TRUE;
@@ -3134,9 +3118,9 @@ rhythmdb_save_thread_main (RhythmDB *db)
db->priv->saving = FALSE;
db->priv->dirty = FALSE;
- g_mutex_unlock (db->priv->saving_mutex);
+ g_mutex_unlock (&db->priv->saving_mutex);
- g_cond_broadcast (db->priv->saving_condition);
+ g_cond_broadcast (&db->priv->saving_condition);
out:
result = g_slice_new0 (RhythmDBEvent);
@@ -3180,24 +3164,24 @@ rhythmdb_save (RhythmDB *db)
rb_debug("saving the rhythmdb and blocking");
- g_mutex_lock (db->priv->saving_mutex);
+ g_mutex_lock (&db->priv->saving_mutex);
new_save_count = db->priv->save_count + 1;
rhythmdb_save_async (db);
/* wait until this save request is being processed */
while (db->priv->save_count < new_save_count) {
- g_cond_wait (db->priv->saving_condition, db->priv->saving_mutex);
+ g_cond_wait (&db->priv->saving_condition, &db->priv->saving_mutex);
}
/* wait until it's done */
while (db->priv->saving) {
- g_cond_wait (db->priv->saving_condition, db->priv->saving_mutex);
+ g_cond_wait (&db->priv->saving_condition, &db->priv->saving_mutex);
}
rb_debug ("done");
- g_mutex_unlock (db->priv->saving_mutex);
+ g_mutex_unlock (&db->priv->saving_mutex);
}
/**
@@ -3272,13 +3256,13 @@ record_entry_change (RhythmDB *db,
g_value_copy (old_value, &changedata->old);
g_value_copy (new_value, &changedata->new);
- g_mutex_lock (db->priv->change_mutex);
+ g_mutex_lock (&db->priv->change_mutex);
/* ref the entry before adding to hash, it is unreffed when removed */
rhythmdb_entry_ref (entry);
changelist = g_hash_table_lookup (db->priv->changed_entries, entry);
changelist = g_slist_append (changelist, changedata);
g_hash_table_insert (db->priv->changed_entries, entry, changelist);
- g_mutex_unlock (db->priv->change_mutex);
+ g_mutex_unlock (&db->priv->change_mutex);
}
void
@@ -3712,9 +3696,9 @@ rhythmdb_entry_delete (RhythmDB *db,
klass->impl_entry_delete (db, entry);
- g_mutex_lock (db->priv->change_mutex);
+ g_mutex_lock (&db->priv->change_mutex);
g_hash_table_insert (db->priv->deleted_entries, entry, g_thread_self ());
- g_mutex_unlock (db->priv->change_mutex);
+ g_mutex_unlock (&db->priv->change_mutex);
/* deleting an entry makes the db dirty */
db->priv->dirty = TRUE;
@@ -4579,9 +4563,9 @@ rhythmdb_register_entry_type (RhythmDB *db, RhythmDBEntryType *entry_type)
g_object_get (entry_type, "name", &name, NULL);
g_assert (name != NULL);
- g_mutex_lock (db->priv->entry_type_map_mutex);
+ g_mutex_lock (&db->priv->entry_type_map_mutex);
g_hash_table_insert (db->priv->entry_type_map, name, g_object_ref (entry_type));
- g_mutex_unlock (db->priv->entry_type_map_mutex);
+ g_mutex_unlock (&db->priv->entry_type_map_mutex);
if (klass->impl_entry_type_registered)
klass->impl_entry_type_registered (db, entry_type);
@@ -4600,9 +4584,9 @@ rhythmdb_entry_type_foreach (RhythmDB *db,
GHFunc func,
gpointer data)
{
- g_mutex_lock (db->priv->entry_type_mutex);
+ g_mutex_lock (&db->priv->entry_type_mutex);
g_hash_table_foreach (db->priv->entry_type_map, func, data);
- g_mutex_unlock (db->priv->entry_type_mutex);
+ g_mutex_unlock (&db->priv->entry_type_mutex);
}
/**
@@ -4621,11 +4605,11 @@ rhythmdb_entry_type_get_by_name (RhythmDB *db,
{
gpointer t = NULL;
- g_mutex_lock (db->priv->entry_type_map_mutex);
+ g_mutex_lock (&db->priv->entry_type_map_mutex);
if (db->priv->entry_type_map) {
t = g_hash_table_lookup (db->priv->entry_type_map, name);
}
- g_mutex_unlock (db->priv->entry_type_map_mutex);
+ g_mutex_unlock (&db->priv->entry_type_map_mutex);
return (RhythmDBEntryType *) t;
}
diff --git a/shell/rb-playlist-manager.c b/shell/rb-playlist-manager.c
index 5b3cad7..31ed951 100644
--- a/shell/rb-playlist-manager.c
+++ b/shell/rb-playlist-manager.c
@@ -139,7 +139,7 @@ struct RBPlaylistManagerPrivate
gint dirty;
gint saving;
- GMutex *saving_mutex;
+ GMutex saving_mutex;
};
enum
@@ -236,8 +236,8 @@ rb_playlist_manager_shutdown (RBPlaylistManager *mgr)
{
g_return_if_fail (RB_IS_PLAYLIST_MANAGER (mgr));
- g_mutex_lock (mgr->priv->saving_mutex);
- g_mutex_unlock (mgr->priv->saving_mutex);
+ g_mutex_lock (&mgr->priv->saving_mutex);
+ g_mutex_unlock (&mgr->priv->saving_mutex);
}
/**
@@ -422,7 +422,7 @@ rb_playlist_manager_load_playlists (RBPlaylistManager *mgr)
file = g_strdup (mgr->priv->playlists_file);
/* block saves until the playlists have loaded */
- g_mutex_lock (mgr->priv->saving_mutex);
+ g_mutex_lock (&mgr->priv->saving_mutex);
exists = g_file_test (file, G_FILE_TEST_EXISTS);
if (! exists) {
@@ -459,7 +459,7 @@ rb_playlist_manager_load_playlists (RBPlaylistManager *mgr)
xmlFreeDoc (doc);
out:
- g_mutex_unlock (mgr->priv->saving_mutex);
+ g_mutex_unlock (&mgr->priv->saving_mutex);
g_free (file);
}
@@ -545,7 +545,7 @@ rb_playlist_manager_save_data (struct RBPlaylistManagerSaveData *data)
char *file;
char *tmpname;
- g_mutex_lock (data->mgr->priv->saving_mutex);
+ g_mutex_lock (&data->mgr->priv->saving_mutex);
file = g_strdup (data->mgr->priv->playlists_file);
tmpname = g_strconcat (file, ".tmp", NULL);
@@ -562,7 +562,7 @@ rb_playlist_manager_save_data (struct RBPlaylistManagerSaveData *data)
g_free (file);
g_atomic_int_compare_and_exchange (&data->mgr->priv->saving, 1, 0);
- g_mutex_unlock (data->mgr->priv->saving_mutex);
+ g_mutex_unlock (&data->mgr->priv->saving_mutex);
g_object_unref (data->mgr);
@@ -1928,7 +1928,6 @@ rb_playlist_manager_init (RBPlaylistManager *mgr)
RB_TYPE_PLAYLIST_MANAGER,
RBPlaylistManagerPrivate);
- mgr->priv->saving_mutex = g_mutex_new ();
mgr->priv->dirty = 0;
mgr->priv->saving = 0;
}
@@ -1989,8 +1988,6 @@ rb_playlist_manager_finalize (GObject *object)
g_return_if_fail (mgr->priv != NULL);
- g_mutex_free (mgr->priv->saving_mutex);
-
g_free (mgr->priv->playlists_file);
G_OBJECT_CLASS (rb_playlist_manager_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]