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.
This commit is contained in:
Max Kellermann 2009-01-23 00:10:33 +01:00
parent bd71d3ea78
commit 0d4319ed30

View File

@ -89,14 +89,6 @@ void playlistVersionChange(void)
idle_add(IDLE_PLAYLIST); idle_add(IDLE_PLAYLIST);
} }
static void incrPlaylistCurrent(void)
{
if (playlist.current < 0)
return;
playlist.current = queue_next_order(&playlist.queue, playlist.current);
}
static void static void
playlist_tag_event(void) playlist_tag_event(void)
{ {
@ -603,6 +595,11 @@ enum playlist_result deleteFromPlaylist(unsigned song)
else return playPlaylistOrderNumber(fd,playlist.current); */ else return playPlaylistOrderNumber(fd,playlist.current); */
playerWait(); playerWait();
playlist_noGoToNext = 1; 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))) if (!song_in_database(queue_get(&playlist.queue, song)))
@ -614,9 +611,6 @@ enum playlist_result deleteFromPlaylist(unsigned song)
if (playlist.current > (int)songOrder) { if (playlist.current > (int)songOrder) {
playlist.current--; playlist.current--;
} else if (playlist.current >= (int)queue_length(&playlist.queue)) {
--playlist.current;
incrPlaylistCurrent();
} }
if (playlist.queued > (int)songOrder) { if (playlist.queued > (int)songOrder) {