aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-12 00:07:54 +0200
committerMax Kellermann <max@duempel.org>2008-10-12 00:07:54 +0200
commit35a939e3e766975776ecaf99e0e46f8a3a68faf2 (patch)
treebde09a92e04ff41ac4502d86b2d2eaa504258d44 /src/playlist.c
parent35a16b99238a7daea97bedd244861f5b82e0b0cf (diff)
downloadmpd-35a939e3e766975776ecaf99e0e46f8a3a68faf2.tar.gz
mpd-35a939e3e766975776ecaf99e0e46f8a3a68faf2.tar.xz
mpd-35a939e3e766975776ecaf99e0e46f8a3a68faf2.zip
player: added commands QUEUE and CANCEL
QUEUE adds a new song to the player's queue. CANCEL clears the queue. These two commands replace the old and complex queueState and queueLockState code.
Diffstat (limited to '')
-rw-r--r--src/playlist.c49
1 files changed, 4 insertions, 45 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 74b2d60d2..840c9c6b5 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -499,28 +499,9 @@ static void queueNextSongInPlaylist(void)
static void syncPlaylistWithQueue(void)
{
- switch (getPlayerQueueState()) {
- case PLAYER_QUEUE_EMPTY:
- setQueueState(PLAYER_QUEUE_BLANK);
- if (playlist.queued >= 0) {
- DEBUG("playlist: now playing queued song\n");
- playlist.current = playlist.queued;
- }
+ if (pc.next_song == NULL && playlist.queued != -1) {
+ playlist.current = playlist.queued;
playlist.queued = -1;
- break;
-
- case PLAYER_QUEUE_DECODE:
- if (playlist.queued != -1)
- setQueueState(PLAYER_QUEUE_PLAY);
- else
- setQueueState(PLAYER_QUEUE_STOP);
- break;
-
- case PLAYER_QUEUE_FULL:
- case PLAYER_QUEUE_PLAY:
- case PLAYER_QUEUE_STOP:
- case PLAYER_QUEUE_BLANK:
- break;
}
}
@@ -528,31 +509,9 @@ static void clearPlayerQueue(void)
{
assert(playlist.queued >= 0);
- if (getPlayerQueueState() == PLAYER_QUEUE_PLAY ||
- getPlayerQueueState() == PLAYER_QUEUE_FULL) {
- playerQueueLock();
- syncPlaylistWithQueue();
- }
-
playlist.queued = -1;
- switch (getPlayerQueueState()) {
- case PLAYER_QUEUE_BLANK:
- case PLAYER_QUEUE_DECODE:
- case PLAYER_QUEUE_STOP:
- case PLAYER_QUEUE_EMPTY:
- break;
-
- case PLAYER_QUEUE_FULL:
- DEBUG("playlist: dequeue song\n");
- setQueueState(PLAYER_QUEUE_BLANK);
- break;
- case PLAYER_QUEUE_PLAY:
- DEBUG("playlist: stop decoding queued song\n");
- setQueueState(PLAYER_QUEUE_STOP);
- break;
- }
- playerQueueUnlock();
+ pc_cancel();
}
enum playlist_result addToPlaylist(const char *url, int *added_id)
@@ -907,7 +866,7 @@ void syncPlayerAndPlaylist(void)
playPlaylistIfPlayerStopped();
else {
syncPlaylistWithQueue();
- if (getPlayerQueueState() == PLAYER_QUEUE_BLANK)
+ if (pc.next_song == NULL)
queueNextSongInPlaylist();
}