Commit 0e5af7d0 authored by Max Kellermann's avatar Max Kellermann

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.
parent 62159e88
...@@ -231,6 +231,7 @@ void readPlaylistState(FILE *fp) ...@@ -231,6 +231,7 @@ void readPlaylistState(FILE *fp)
int seek_time = 0; int seek_time = 0;
int state = PLAYER_STATE_STOP; int state = PLAYER_STATE_STOP;
char buffer[PLAYLIST_BUFFER_SIZE]; char buffer[PLAYLIST_BUFFER_SIZE];
bool random_mode = false;
while (fgets(buffer, sizeof(buffer), fp)) { while (fgets(buffer, sizeof(buffer), fp)) {
g_strchomp(buffer); g_strchomp(buffer);
...@@ -264,14 +265,9 @@ void readPlaylistState(FILE *fp) ...@@ -264,14 +265,9 @@ void readPlaylistState(FILE *fp)
[strlen [strlen
(PLAYLIST_STATE_FILE_CROSSFADE)]))); (PLAYLIST_STATE_FILE_CROSSFADE)])));
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) { } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) {
if (strcmp random_mode =
(& strcmp(buffer + strlen(PLAYLIST_STATE_FILE_RANDOM),
(buffer "1") == 0;
[strlen(PLAYLIST_STATE_FILE_RANDOM)]),
"1") == 0) {
setPlaylistRandomStatus(true);
} else
setPlaylistRandomStatus(false);
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CURRENT)) { } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CURRENT)) {
current = atoi(&(buffer current = atoi(&(buffer
[strlen [strlen
...@@ -284,6 +280,8 @@ void readPlaylistState(FILE *fp) ...@@ -284,6 +280,8 @@ void readPlaylistState(FILE *fp)
current, seek_time); current, seek_time);
} }
} }
setPlaylistRandomStatus(random_mode);
} }
int playlistChanges(struct client *client, uint32_t version) int playlistChanges(struct client *client, uint32_t version)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment