From d77c417fd1bfb79013bbd2c47920d89b95a5ac76 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sun, 29 Oct 2023 17:01:51 +0100 Subject: Fix bookmarking/reloading after saving shuffled playlist The resume index into the playlist file that was used for bookmarks created immediately after saving a shuffled playlist, or for reloading the saved playlist (in case "Reload After Saving" was enabled), tended to be incorrect. The playlist file effectively isn't shuffled anymore after saving it to a file, but the resume index may still have to be rotated unless playback has been stopped and resumed before bookmarking, due to indices that are shifted by first_index. Change-Id: Id335a7a71adc216989d7b415bfa48237d92fd7b0 --- apps/bookmark.c | 6 +++++- apps/menus/playlist_menu.c | 2 +- apps/playlist.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/bookmark.c b/apps/bookmark.c index 3db049475d..2411ddb0ee 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -520,7 +520,11 @@ static char* create_bookmark(char **name, /* ----------------------------------------------------------------------- */ static void get_track_resume_info(struct resume_info *resume_info) { - playlist_get_resume_info(&(resume_info->resume_index)); + if (global_settings.playlist_shuffle) + playlist_get_resume_info(&(resume_info->resume_index)); + else + resume_info->resume_index = playlist_get_display_index() - 1; + resume_info->resume_seed = playlist_get_seed(NULL); resume_info->id3 = audio_current_track(); resume_info->repeat_mode = global_settings.repeat_mode; diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index e527e3ebef..affe20418d 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -121,7 +121,7 @@ int save_playlist_screen(struct playlist_info* playlist) } /* can't trust index from id3 (don't know why), get it from playlist */ - resume_index = playlist_get_current()->index; + resume_index = playlist_get_display_index() - 1; struct mp3entry* id3 = audio_current_track(); diff --git a/apps/playlist.c b/apps/playlist.c index 8071874be0..972d0ea755 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -3886,6 +3886,8 @@ static int pl_save_update_control(struct playlist_info* playlist, /* Reset shuffle seed */ playlist->seed = 0; + if (playlist == ¤t_playlist) + global_settings.playlist_shuffle = false; pl_close_control(playlist); close(old_fd); -- cgit v1.2.3