From d628eb3e8bb2b7e9db5ef6f5b907ac2a81afc86a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 25 Jan 2009 13:44:33 +0100 Subject: player_control: added player_control.thread player_control.thread contains the handle of the player thread, or NULL if the player thread isn't running. --- src/player_control.c | 4 ++++ src/player_control.h | 4 ++++ src/player_thread.c | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/player_control.c b/src/player_control.c index 60b5b8350..94d3aa938 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -90,7 +90,11 @@ void playerWait(void) void playerKill(void) { + assert(pc.thread != NULL); + player_command(PLAYER_COMMAND_EXIT); + g_thread_join(pc.thread); + pc.thread = NULL; idle_add(IDLE_PLAYER); } diff --git a/src/player_control.h b/src/player_control.h index 441c055cd..508798fff 100644 --- a/src/player_control.h +++ b/src/player_control.h @@ -62,6 +62,10 @@ enum player_error { struct player_control { unsigned int buffered_before_play; + /** the handle of the player thread, or NULL if the player + thread isn't running */ + GThread *thread; + struct notify notify; volatile enum player_command command; volatile enum player_state state; diff --git a/src/player_thread.c b/src/player_thread.c index dc263b6ad..c8f4f69f1 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -548,8 +548,10 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg) void player_create(void) { GError *e = NULL; - GThread *t; - if (!(t = g_thread_create(player_task, NULL, FALSE, &e))) + assert(pc.thread == NULL); + + pc.thread = g_thread_create(player_task, NULL, true, &e); + if (pc.thread == NULL) g_error("Failed to spawn player task: %s", e->message); } -- cgit v1.2.3