diff options
author | Max Kellermann <max@duempel.org> | 2009-01-23 18:41:12 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-23 18:41:12 +0100 |
commit | 0e5af7d0f6406ada62500a30cedf0089073ee8cb (patch) | |
tree | f5c8bacf5ce548138d9b6a679e22977f79b8c611 | |
parent | 62159e8875259641de98e9ec1c2f90bc2e31727a (diff) | |
download | mpd-0e5af7d0f6406ada62500a30cedf0089073ee8cb.tar.gz mpd-0e5af7d0f6406ada62500a30cedf0089073ee8cb.tar.xz mpd-0e5af7d0f6406ada62500a30cedf0089073ee8cb.zip |
playlist: restore random mode after playlist is loaded
When the playlist was loaded from the state file, the order numbers
were the same as the positions. In random mode, we need to shuffle
the queue order. To accomplish that, call setPlaylistRandomStatus()
at the end of readPlaylistState(), and do a fresh shuffle.
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/playlist.c b/src/playlist.c index 04b57649d..f6e3d6e2f 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -231,6 +231,7 @@ void readPlaylistState(FILE *fp) int seek_time = 0; int state = PLAYER_STATE_STOP; char buffer[PLAYLIST_BUFFER_SIZE]; + bool random_mode = false; while (fgets(buffer, sizeof(buffer), fp)) { g_strchomp(buffer); @@ -264,14 +265,9 @@ void readPlaylistState(FILE *fp) [strlen (PLAYLIST_STATE_FILE_CROSSFADE)]))); } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) { - if (strcmp - (& - (buffer - [strlen(PLAYLIST_STATE_FILE_RANDOM)]), - "1") == 0) { - setPlaylistRandomStatus(true); - } else - setPlaylistRandomStatus(false); + random_mode = + strcmp(buffer + strlen(PLAYLIST_STATE_FILE_RANDOM), + "1") == 0; } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CURRENT)) { current = atoi(&(buffer [strlen @@ -284,6 +280,8 @@ void readPlaylistState(FILE *fp) current, seek_time); } } + + setPlaylistRandomStatus(random_mode); } int playlistChanges(struct client *client, uint32_t version) |