From 3d15723da3723c08a8cb118cdfbbd238367f0a98 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 Aug 2008 00:36:44 -0700 Subject: playlist: fix "currentsong" after song movement When moving songs around, we forgot to update the playlist.queue value, causing syncPlaylistWithQueue to trigger a false sync and screw with the playlist.current pointer; causing the currentsong command to return an incorrect song. --- src/playlist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/playlist.c b/src/playlist.c index 7a9a0ea6c..1c743edc0 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -1056,6 +1056,7 @@ int moveSongInPlaylist(int fd, int from, int to) Song *tmpSong; int tmpId; int currentSong; + int queued_is_current = (playlist.queued == playlist.current); if (from < 0 || from >= playlist.length) { commandError(fd, ACK_ERROR_NO_EXIST, @@ -1085,7 +1086,7 @@ int moveSongInPlaylist(int fd, int from, int to) to = (currentSong + abs(to)) % playlist.length; } - if (playlist_state == PLAYLIST_STATE_PLAY) { + if (playlist_state == PLAYLIST_STATE_PLAY && !queued_is_current) { int queuedSong = -1; if (playlist.queued >= 0) @@ -1130,6 +1131,8 @@ int moveSongInPlaylist(int fd, int from, int to) } else if (playlist.current >= to && playlist.current < from) { playlist.current++; } + if (queued_is_current) + playlist.queued = playlist.current; } queueNextSongInPlaylist(); incrPlaylistVersion(); -- cgit v1.2.3