Commit ae003302 authored by Max Kellermann's avatar Max Kellermann

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.
parent 92d9797b
...@@ -76,9 +76,9 @@ void playerWait(void) ...@@ -76,9 +76,9 @@ void playerWait(void)
playerQueueUnlock(); playerQueueUnlock();
} }
void playerKill(void) /* deprecated */ void playerKill(void)
{ {
playerPause(); player_command(PLAYER_COMMAND_EXIT);
} }
void playerPause(void) void playerPause(void)
......
...@@ -32,6 +32,7 @@ enum player_state { ...@@ -32,6 +32,7 @@ enum player_state {
enum player_command { enum player_command {
PLAYER_COMMAND_NONE = 0, PLAYER_COMMAND_NONE = 0,
PLAYER_COMMAND_EXIT,
PLAYER_COMMAND_STOP, PLAYER_COMMAND_STOP,
PLAYER_COMMAND_PLAY, PLAYER_COMMAND_PLAY,
PLAYER_COMMAND_PAUSE, PLAYER_COMMAND_PAUSE,
......
...@@ -127,6 +127,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r, ...@@ -127,6 +127,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
case PLAYER_COMMAND_NONE: case PLAYER_COMMAND_NONE:
case PLAYER_COMMAND_PLAY: case PLAYER_COMMAND_PLAY:
case PLAYER_COMMAND_STOP: case PLAYER_COMMAND_STOP:
case PLAYER_COMMAND_EXIT:
case PLAYER_COMMAND_CLOSE_AUDIO: case PLAYER_COMMAND_CLOSE_AUDIO:
break; break;
...@@ -225,6 +226,7 @@ static void decodeParent(void) ...@@ -225,6 +226,7 @@ static void decodeParent(void)
processDecodeInput(&do_pause, &bbp, &do_xfade, processDecodeInput(&do_pause, &bbp, &do_xfade,
&decodeWaitedOn, &next); &decodeWaitedOn, &next);
if (pc.command == PLAYER_COMMAND_STOP || if (pc.command == PLAYER_COMMAND_STOP ||
pc.command == PLAYER_COMMAND_EXIT ||
pc.command == PLAYER_COMMAND_CLOSE_AUDIO) { pc.command == PLAYER_COMMAND_CLOSE_AUDIO) {
dropBufferedAudio(); dropBufferedAudio();
break; break;
...@@ -442,6 +444,12 @@ static void * player_task(mpd_unused void *arg) ...@@ -442,6 +444,12 @@ static void * player_task(mpd_unused void *arg)
player_command_finished(); player_command_finished();
break; break;
case PLAYER_COMMAND_EXIT:
closeAudioDevice();
player_command_finished();
pthread_exit(NULL);
break;
case PLAYER_COMMAND_LOCK_QUEUE: case PLAYER_COMMAND_LOCK_QUEUE:
pc.queueLockState = PLAYER_QUEUE_LOCKED; pc.queueLockState = PLAYER_QUEUE_LOCKED;
player_command_finished(); player_command_finished();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment