diff options
Diffstat (limited to '')
-rw-r--r-- | src/update_remove.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/update_remove.c b/src/update_remove.c index 8bec5fd6d..68cbb22b7 100644 --- a/src/update_remove.c +++ b/src/update_remove.c @@ -19,7 +19,6 @@ #include "config.h" /* must be first for large file support */ #include "update_internal.h" -#include "notify.h" #include "event_pipe.h" #include "song.h" #include "playlist.h" @@ -36,7 +35,8 @@ static const struct song *removed_song; -static struct notify remove_notify; +static GMutex *remove_mutex; +static GCond *remove_cond; /** * Safely remove a song from the database. This must be done in the @@ -60,15 +60,19 @@ song_remove_event(void) #endif playlist_delete_song(&g_playlist, global_player_control, removed_song); - removed_song = NULL; - notify_signal(&remove_notify); + /* clear "removed_song" and send signal to update thread */ + g_mutex_lock(remove_mutex); + removed_song = NULL; + g_cond_signal(remove_cond); + g_mutex_unlock(remove_mutex); } void update_remove_global_init(void) { - notify_init(&remove_notify); + remove_mutex = g_mutex_new(); + remove_cond = g_cond_new(); event_pipe_register(PIPE_EVENT_DELETE, song_remove_event); } @@ -76,7 +80,8 @@ update_remove_global_init(void) void update_remove_global_finish(void) { - notify_deinit(&remove_notify); + g_mutex_free(remove_mutex); + g_cond_free(remove_cond); } void @@ -88,8 +93,10 @@ update_remove_song(const struct song *song) event_pipe_emit(PIPE_EVENT_DELETE); - do { - notify_wait(&remove_notify); - } while (removed_song != NULL); + g_mutex_lock(remove_mutex); + + while (removed_song != NULL) + g_cond_wait(remove_cond, remove_mutex); + g_mutex_unlock(remove_mutex); } |