aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-06-19 13:33:32 +0200
committerMax Kellermann <max@duempel.org>2010-06-19 13:33:32 +0200
commitcff727644d7cc9f2e5c8767896706f1e8d41a767 (patch)
tree972c28abd7da5bda8b2f985dc530a3b3cd24f064 /src/playlist.c
parent7f803494945895da596cffa23970d84cb9bc5e9f (diff)
downloadmpd-cff727644d7cc9f2e5c8767896706f1e8d41a767.tar.gz
mpd-cff727644d7cc9f2e5c8767896706f1e8d41a767.tar.xz
mpd-cff727644d7cc9f2e5c8767896706f1e8d41a767.zip
playlist: move checks out of playlist_sync_with_queue()
Rename the function to playlist_song_started(), which gets only called if the song has actually started.
Diffstat (limited to '')
-rw-r--r--src/playlist.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 40990bff5..99feb28da 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -93,33 +93,33 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order)
}
/**
- * Check if the player thread has already started playing the "queued"
- * song.
+ * Called if the player thread has started playing the "queued" song.
*/
static void
-playlist_sync_with_queue(struct playlist *playlist)
+playlist_song_started(struct playlist *playlist)
{
- if (pc.next_song == NULL && playlist->queued != -1) {
- /* queued song has started: copy queued to current,
- and notify the clients */
+ assert(pc.next_song == NULL);
+ assert(playlist->queued >= -1);
- int current = playlist->current;
- playlist->current = playlist->queued;
- playlist->queued = -1;
-
- /* Set pause and remove the single mode. */
- if(playlist->queue.single && !playlist->queue.repeat) {
- playlist->queue.single = false;
- idle_add(IDLE_OPTIONS);
+ /* queued song has started: copy queued to current,
+ and notify the clients */
- pc_set_pause(true);
- }
+ int current = playlist->current;
+ playlist->current = playlist->queued;
+ playlist->queued = -1;
- if(playlist->queue.consume)
- playlist_delete(playlist, queue_order_to_position(&playlist->queue, current));
+ /* Set pause and remove the single mode. */
+ if(playlist->queue.single && !playlist->queue.repeat) {
+ playlist->queue.single = false;
+ idle_add(IDLE_OPTIONS);
- idle_add(IDLE_PLAYER);
+ pc_set_pause(true);
}
+
+ if(playlist->queue.consume)
+ playlist_delete(playlist, queue_order_to_position(&playlist->queue, current));
+
+ idle_add(IDLE_PLAYER);
}
const struct song *
@@ -228,7 +228,8 @@ playlist_sync(struct playlist *playlist)
else {
/* check if the player thread has already started
playing the queued song */
- playlist_sync_with_queue(playlist);
+ if (pc.next_song == NULL && playlist->queued != -1)
+ playlist_song_started(playlist);
/* make sure the queued song is always set (if
possible) */