aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-23 00:10:33 +0100
committerMax Kellermann <max@duempel.org>2009-01-23 00:10:33 +0100
commit0d4319ed302d0cfd8afb4cc32caf727b23f25805 (patch)
tree93d2b6a425ea7fe3e582c95e541fe0b9768b81f7 /src
parentbd71d3ea78c23c9d344208c823e21cb7f900ba97 (diff)
downloadmpd-0d4319ed302d0cfd8afb4cc32caf727b23f25805.tar.gz
mpd-0d4319ed302d0cfd8afb4cc32caf727b23f25805.tar.xz
mpd-0d4319ed302d0cfd8afb4cc32caf727b23f25805.zip
playlist: calculate next song before deleting the current one
By calling queue_next_order() before playlist.current is invalidated (by the deletion of a song), we get more robust results, and the code becomes a little bit easier. incrPlaylistCurrent() is unused now, and can be removed.
Diffstat (limited to 'src')
-rw-r--r--src/playlist.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 3b370f9fe..9a6347770 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -89,14 +89,6 @@ void playlistVersionChange(void)
idle_add(IDLE_PLAYLIST);
}
-static void incrPlaylistCurrent(void)
-{
- if (playlist.current < 0)
- return;
-
- playlist.current = queue_next_order(&playlist.queue, playlist.current);
-}
-
static void
playlist_tag_event(void)
{
@@ -603,6 +595,11 @@ enum playlist_result deleteFromPlaylist(unsigned song)
else return playPlaylistOrderNumber(fd,playlist.current); */
playerWait();
playlist_noGoToNext = 1;
+
+ playlist.current = queue_next_order(&playlist.queue,
+ playlist.current);
+ if (playlist.current == (int)songOrder)
+ playlist.current = -1;
}
if (!song_in_database(queue_get(&playlist.queue, song)))
@@ -614,9 +611,6 @@ enum playlist_result deleteFromPlaylist(unsigned song)
if (playlist.current > (int)songOrder) {
playlist.current--;
- } else if (playlist.current >= (int)queue_length(&playlist.queue)) {
- --playlist.current;
- incrPlaylistCurrent();
}
if (playlist.queued > (int)songOrder) {