use g_thread_new() if GLib is recent enough
Fixes deprecation warnings.
This commit is contained in:
parent
a28df6123f
commit
a4a13a3825
@ -494,13 +494,16 @@ decoder_task(gpointer arg)
|
|||||||
void
|
void
|
||||||
decoder_thread_start(struct decoder_control *dc)
|
decoder_thread_start(struct decoder_control *dc)
|
||||||
{
|
{
|
||||||
GError *e = NULL;
|
|
||||||
|
|
||||||
assert(dc->thread == NULL);
|
assert(dc->thread == NULL);
|
||||||
|
|
||||||
dc->quit = false;
|
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);
|
dc->thread = g_thread_create(decoder_task, dc, true, &e);
|
||||||
if (dc->thread == NULL)
|
if (dc->thread == NULL)
|
||||||
MPD_ERROR("Failed to spawn decoder task: %s", e->message);
|
MPD_ERROR("Failed to spawn decoder task: %s", e->message);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -64,16 +64,20 @@ io_thread_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
io_thread_start(GError **error_r)
|
io_thread_start(gcc_unused GError **error_r)
|
||||||
{
|
{
|
||||||
assert(io.loop != NULL);
|
assert(io.loop != NULL);
|
||||||
assert(io.thread == 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.thread = g_thread_create(io_thread_func, NULL, true, error_r);
|
||||||
io.mutex.unlock();
|
|
||||||
if (io.thread == NULL)
|
if (io.thread == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -673,10 +673,13 @@ static gpointer audio_output_task(gpointer arg)
|
|||||||
|
|
||||||
void audio_output_thread_start(struct audio_output *ao)
|
void audio_output_thread_start(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
GError *e = NULL;
|
|
||||||
|
|
||||||
assert(ao->command == AO_COMMAND_NONE);
|
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)))
|
if (!(ao->thread = g_thread_create(audio_output_task, ao, true, &e)))
|
||||||
MPD_ERROR("Failed to spawn output task: %s\n", e->message);
|
MPD_ERROR("Failed to spawn output task: %s\n", e->message);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1202,8 +1202,12 @@ player_create(struct player_control *pc)
|
|||||||
{
|
{
|
||||||
assert(pc->thread == NULL);
|
assert(pc->thread == NULL);
|
||||||
|
|
||||||
|
#if GLIB_CHECK_VERSION(2,32,0)
|
||||||
|
pc->thread = g_thread_new("player", player_task, pc);
|
||||||
|
#else
|
||||||
GError *e = NULL;
|
GError *e = NULL;
|
||||||
pc->thread = g_thread_create(player_task, pc, true, &e);
|
pc->thread = g_thread_create(player_task, pc, true, &e);
|
||||||
if (pc->thread == NULL)
|
if (pc->thread == NULL)
|
||||||
MPD_ERROR("Failed to spawn player task: %s", e->message);
|
MPD_ERROR("Failed to spawn player task: %s", e->message);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -99,16 +99,19 @@ static void * update_task(void *_path)
|
|||||||
static void
|
static void
|
||||||
spawn_update_task(const char *path)
|
spawn_update_task(const char *path)
|
||||||
{
|
{
|
||||||
GError *e = NULL;
|
|
||||||
|
|
||||||
assert(g_thread_self() == main_task);
|
assert(g_thread_self() == main_task);
|
||||||
|
|
||||||
progress = UPDATE_PROGRESS_RUNNING;
|
progress = UPDATE_PROGRESS_RUNNING;
|
||||||
modified = false;
|
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);
|
update_thr = g_thread_create(update_task, g_strdup(path), TRUE, &e);
|
||||||
if (update_thr == NULL)
|
if (update_thr == NULL)
|
||||||
MPD_ERROR("Failed to spawn update task: %s", e->message);
|
MPD_ERROR("Failed to spawn update task: %s", e->message);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (++update_task_id > update_task_id_max)
|
if (++update_task_id > update_task_id_max)
|
||||||
update_task_id = 1;
|
update_task_id = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user