playlist: don't preserve "current" song after "random" toggle

When MPD is not playing, it may still remember which is the "current"
song.  When you switch to "random" mode, MPD will always start playing
exactly this song.  This defies the goal of "random" mode a little.
Clear the "current" song when MPD is not playing during the "random"
mode switch.
This commit is contained in:
Max Kellermann 2009-02-11 18:02:50 +01:00
parent 9d447dda1d
commit 58a5d30826
1 changed files with 4 additions and 2 deletions

View File

@ -300,7 +300,8 @@ void setPlaylistRandomStatus(struct playlist *playlist, bool status)
/* shuffle the queue order, but preserve
playlist->current */
int current_position = playlist->current >= 0
int current_position =
playlist->playing && playlist->current >= 0
? (int)queue_order_to_position(&playlist->queue,
playlist->current)
: -1;
@ -316,7 +317,8 @@ void setPlaylistRandomStatus(struct playlist *playlist, bool status)
current_position);
queue_swap_order(&playlist->queue, 0, current_order);
playlist->current = 0;
}
} else
playlist->current = -1;
} else
orderPlaylist(playlist);