summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-10-29 17:01:51 +0100
committerChristian Soffke <christian.soffke@gmail.com>2023-10-30 14:09:51 -0400
commitd77c417fd1bfb79013bbd2c47920d89b95a5ac76 (patch)
tree8eb87c407faf1a56e04886c2bb2c39e6dcc46c00
parent3f3e185460b1204ed9420b3d9129f1371a01b6ec (diff)
downloadrockbox-d77c417fd1bfb79013bbd2c47920d89b95a5ac76.tar.gz
rockbox-d77c417fd1bfb79013bbd2c47920d89b95a5ac76.zip
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
-rw-r--r--apps/bookmark.c6
-rw-r--r--apps/menus/playlist_menu.c2
-rw-r--r--apps/playlist.c2
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,
520/* ----------------------------------------------------------------------- */ 520/* ----------------------------------------------------------------------- */
521static void get_track_resume_info(struct resume_info *resume_info) 521static void get_track_resume_info(struct resume_info *resume_info)
522{ 522{
523 playlist_get_resume_info(&(resume_info->resume_index)); 523 if (global_settings.playlist_shuffle)
524 playlist_get_resume_info(&(resume_info->resume_index));
525 else
526 resume_info->resume_index = playlist_get_display_index() - 1;
527
524 resume_info->resume_seed = playlist_get_seed(NULL); 528 resume_info->resume_seed = playlist_get_seed(NULL);
525 resume_info->id3 = audio_current_track(); 529 resume_info->id3 = audio_current_track();
526 resume_info->repeat_mode = global_settings.repeat_mode; 530 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)
121 } 121 }
122 122
123 /* can't trust index from id3 (don't know why), get it from playlist */ 123 /* can't trust index from id3 (don't know why), get it from playlist */
124 resume_index = playlist_get_current()->index; 124 resume_index = playlist_get_display_index() - 1;
125 125
126 struct mp3entry* id3 = audio_current_track(); 126 struct mp3entry* id3 = audio_current_track();
127 127
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,
3886 3886
3887 /* Reset shuffle seed */ 3887 /* Reset shuffle seed */
3888 playlist->seed = 0; 3888 playlist->seed = 0;
3889 if (playlist == &current_playlist)
3890 global_settings.playlist_shuffle = false;
3889 3891
3890 pl_close_control(playlist); 3892 pl_close_control(playlist);
3891 close(old_fd); 3893 close(old_fd);