aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:07 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:07 +0200
commitefde884a134a3b9f1468eb743898f579fc88746e (patch)
treedc6b9644d16ecb4c46dbbd821dc643ecb821bead /src/decode.c
parentc7384b65ac422e1dd5eadcb06b74931de37a6f58 (diff)
downloadmpd-efde884a134a3b9f1468eb743898f579fc88746e.tar.gz
mpd-efde884a134a3b9f1468eb743898f579fc88746e.tar.xz
mpd-efde884a134a3b9f1468eb743898f579fc88746e.zip
added PlayerControl.command
PlayerControl.command replaces the old attributes play, stop, pause, closeAudio, lockQueue, unlockQueue, seek. The main thread waits for each command synchronously, so there can only be one command enabled at a time anyway.
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/decode.c b/src/decode.c
index ec69a2f46..7b9df996d 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -60,9 +60,7 @@ static void quitDecode(void)
stopDecode();
pc.state = PLAYER_STATE_STOP;
dc.command = DECODE_COMMAND_NONE;
- pc.play = 0;
- pc.stop = 0;
- pc.pause = 0;
+ pc.command = PLAYER_COMMAND_NONE;
wakeup_main_task();
}
@@ -141,8 +139,8 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
ret = 0;
}
}
- pc.seek = 0;
- wakeup_main_task();
+
+ player_command_finished();
return ret;
}
@@ -152,17 +150,24 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
int *decodeWaitedOn_r,
int *next_r)
{
- if(pc.lockQueue) {
+ switch (pc.command) {
+ case PLAYER_COMMAND_NONE:
+ case PLAYER_COMMAND_PLAY:
+ case PLAYER_COMMAND_STOP:
+ case PLAYER_COMMAND_CLOSE_AUDIO:
+ break;
+
+ case PLAYER_COMMAND_LOCK_QUEUE:
pc.queueLockState = PLAYER_QUEUE_LOCKED;
- pc.lockQueue = 0;
- wakeup_main_task();
- }
- if(pc.unlockQueue) {
+ player_command_finished();
+ break;
+
+ case PLAYER_COMMAND_UNLOCK_QUEUE:
pc.queueLockState = PLAYER_QUEUE_UNLOCKED;
- pc.unlockQueue = 0;
- wakeup_main_task();
- }
- if(pc.pause) {
+ player_command_finished();
+ break;
+
+ case PLAYER_COMMAND_PAUSE:
*pause_r = !*pause_r;
if (*pause_r) {
pc.state = PLAYER_STATE_PAUSE;
@@ -179,21 +184,22 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
*pause_r = -1;
}
}
- pc.pause = 0;
- wakeup_main_task();
+ player_command_finished();
if (*pause_r == -1) {
*pause_r = 1;
} else if (*pause_r) {
dropBufferedAudio();
closeAudioDevice();
}
- }
- if(pc.seek) {
+ break;
+
+ case PLAYER_COMMAND_SEEK:
dropBufferedAudio();
if (decodeSeek(decodeWaitedOn_r, next_r) == 0) {
*do_xfade_r = XFADE_UNKNOWN;
*bbp_r = 0;
}
+ break;
}
}
@@ -410,13 +416,12 @@ static void decodeParent(void)
pc.elapsedTime = 0;
pc.state = PLAYER_STATE_PLAY;
- pc.play = 0;
- wakeup_main_task();
+ player_command_finished();
while (1) {
processDecodeInput(&do_pause, &bbp, &do_xfade,
&decodeWaitedOn, &next);
- if (pc.stop) {
+ if (pc.command == PLAYER_COMMAND_STOP) {
dropBufferedAudio();
break;
}