diff options
author | Max Kellermann <max@duempel.org> | 2013-04-17 01:49:43 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-04-17 01:49:43 +0200 |
commit | a4a13a382525527afeecd18f97e948bd6d0de64c (patch) | |
tree | 19af72f5bfb5dc9dae8e82e7ff3c9d99b2c88335 | |
parent | a28df6123fef2047ec631d13c91156def6f7ab83 (diff) | |
download | mpd-a4a13a382525527afeecd18f97e948bd6d0de64c.tar.gz mpd-a4a13a382525527afeecd18f97e948bd6d0de64c.tar.xz mpd-a4a13a382525527afeecd18f97e948bd6d0de64c.zip |
use g_thread_new() if GLib is recent enough
Fixes deprecation warnings.
Diffstat (limited to '')
-rw-r--r-- | src/DecoderThread.cxx | 7 | ||||
-rw-r--r-- | src/IOThread.cxx | 10 | ||||
-rw-r--r-- | src/OutputThread.cxx | 7 | ||||
-rw-r--r-- | src/PlayerThread.cxx | 4 | ||||
-rw-r--r-- | src/UpdateGlue.cxx | 7 |
5 files changed, 26 insertions, 9 deletions
diff --git a/src/DecoderThread.cxx b/src/DecoderThread.cxx index 18bbad6df..fdc900abd 100644 --- a/src/DecoderThread.cxx +++ b/src/DecoderThread.cxx @@ -494,13 +494,16 @@ decoder_task(gpointer arg) void decoder_thread_start(struct decoder_control *dc) { - GError *e = NULL; - assert(dc->thread == NULL); dc->quit = false; +#if GLIB_CHECK_VERSION(2,32,0) + dc->thread = g_thread_new("thread", decoder_task, dc); +#else + GError *e = NULL; dc->thread = g_thread_create(decoder_task, dc, true, &e); if (dc->thread == NULL) MPD_ERROR("Failed to spawn decoder task: %s", e->message); +#endif } diff --git a/src/IOThread.cxx b/src/IOThread.cxx index 192d4cc49..bbd4b9c3c 100644 --- a/src/IOThread.cxx +++ b/src/IOThread.cxx @@ -64,16 +64,20 @@ io_thread_init(void) } bool -io_thread_start(GError **error_r) +io_thread_start(gcc_unused GError **error_r) { assert(io.loop != NULL); assert(io.thread == NULL); - io.mutex.lock(); + const ScopeLock protect(io.mutex); + +#if GLIB_CHECK_VERSION(2,32,0) + io.thread = g_thread_new("io", io_thread_func, nullptr); +#else io.thread = g_thread_create(io_thread_func, NULL, true, error_r); - io.mutex.unlock(); if (io.thread == NULL) return false; +#endif return true; } diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index 734c5783c..d072b50cd 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -673,10 +673,13 @@ static gpointer audio_output_task(gpointer arg) void audio_output_thread_start(struct audio_output *ao) { - GError *e = NULL; - assert(ao->command == AO_COMMAND_NONE); +#if GLIB_CHECK_VERSION(2,32,0) + ao->thread = g_thread_new("output", audio_output_task, ao); +#else + GError *e = nullptr; if (!(ao->thread = g_thread_create(audio_output_task, ao, true, &e))) MPD_ERROR("Failed to spawn output task: %s\n", e->message); +#endif } diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 2d8e6caaf..ccf16bb39 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -1202,8 +1202,12 @@ player_create(struct player_control *pc) { assert(pc->thread == NULL); +#if GLIB_CHECK_VERSION(2,32,0) + pc->thread = g_thread_new("player", player_task, pc); +#else GError *e = NULL; pc->thread = g_thread_create(player_task, pc, true, &e); if (pc->thread == NULL) MPD_ERROR("Failed to spawn player task: %s", e->message); +#endif } diff --git a/src/UpdateGlue.cxx b/src/UpdateGlue.cxx index 664638782..e9906b84a 100644 --- a/src/UpdateGlue.cxx +++ b/src/UpdateGlue.cxx @@ -99,16 +99,19 @@ static void * update_task(void *_path) static void spawn_update_task(const char *path) { - GError *e = NULL; - assert(g_thread_self() == main_task); progress = UPDATE_PROGRESS_RUNNING; modified = false; +#if GLIB_CHECK_VERSION(2,32,0) + update_thr = g_thread_new("updadte", update_task, g_strdup(path)); +#else + GError *e = NULL; update_thr = g_thread_create(update_task, g_strdup(path), TRUE, &e); if (update_thr == NULL) MPD_ERROR("Failed to spawn update task: %s", e->message); +#endif if (++update_task_id > update_task_id_max) update_task_id = 1; |