From ae0033028595b96352c1c769eaeeeaa0c12bccb9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:16 +0200 Subject: rewrote playerKill() playerKill() was marked as deprecated, but it seems like a good idea to do proper cleanup in all threads (e.g. for usable valgrind results). Introduce the command "EXIT" which makes the player thread exit cleanly. --- src/player.c | 4 ++-- src/player.h | 1 + src/player_thread.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/player.c b/src/player.c index 5c3319491..59b8c9237 100644 --- a/src/player.c +++ b/src/player.c @@ -76,9 +76,9 @@ void playerWait(void) playerQueueUnlock(); } -void playerKill(void) /* deprecated */ +void playerKill(void) { - playerPause(); + player_command(PLAYER_COMMAND_EXIT); } void playerPause(void) diff --git a/src/player.h b/src/player.h index 2b1e6d992..5df32e154 100644 --- a/src/player.h +++ b/src/player.h @@ -32,6 +32,7 @@ enum player_state { enum player_command { PLAYER_COMMAND_NONE = 0, + PLAYER_COMMAND_EXIT, PLAYER_COMMAND_STOP, PLAYER_COMMAND_PLAY, PLAYER_COMMAND_PAUSE, diff --git a/src/player_thread.c b/src/player_thread.c index 3784445e9..2abb367db 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -127,6 +127,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r, case PLAYER_COMMAND_NONE: case PLAYER_COMMAND_PLAY: case PLAYER_COMMAND_STOP: + case PLAYER_COMMAND_EXIT: case PLAYER_COMMAND_CLOSE_AUDIO: break; @@ -225,6 +226,7 @@ static void decodeParent(void) processDecodeInput(&do_pause, &bbp, &do_xfade, &decodeWaitedOn, &next); if (pc.command == PLAYER_COMMAND_STOP || + pc.command == PLAYER_COMMAND_EXIT || pc.command == PLAYER_COMMAND_CLOSE_AUDIO) { dropBufferedAudio(); break; @@ -442,6 +444,12 @@ static void * player_task(mpd_unused void *arg) player_command_finished(); break; + case PLAYER_COMMAND_EXIT: + closeAudioDevice(); + player_command_finished(); + pthread_exit(NULL); + break; + case PLAYER_COMMAND_LOCK_QUEUE: pc.queueLockState = PLAYER_QUEUE_LOCKED; player_command_finished(); -- cgit v1.2.3