From ea5ce8034b4a1ead1227114308889511dbfa9539 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sat, 11 Nov 2023 01:53:36 +0100 Subject: Replace "Reload After Saving" with option to remove queued tracks The "Reload After Saving" setting was added in g3347 (4f83e66) to solve FS#13287, by allowing you to bookmark a modified playlist after saving, without having to manually reload it first. Since the rewrite of playlist_save in g5192 (90e3571), a modified playlist doesn't have to be reloaded anymore in order to be bookmarked after it's been saved, unless it contains queued tracks. To cover the remaining use cases of the previously available option, Rockbox will now offer to remove any queued tracks from a playlist when saving it. Change-Id: I2d6f12bcce14d8ff41a4d921ce84d628774103ac --- apps/playlist.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'apps/playlist.c') diff --git a/apps/playlist.c b/apps/playlist.c index 67d59d1aac..024f98d2f3 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -99,6 +99,7 @@ #include "filetypes.h" #include "icons.h" #include "system.h" +#include "misc.h" #include "lang.h" #include "talk.h" @@ -3977,6 +3978,7 @@ int playlist_save(struct playlist_info* playlist, char *filename) char tmpbuf[MAX_PATH+1]; ssize_t pathlen; int rc = 0; + bool reload_tracks = false; if (!playlist) playlist = ¤t_playlist; @@ -3996,6 +3998,17 @@ int playlist_save(struct playlist_info* playlist, char *filename) goto error; } + /* Ask if queued tracks should be removed, so that + playlist can be bookmarked after it's been saved */ + for (int i = playlist->amount - 1; i >= 0; i--) + if (playlist->indices[i] & PLAYLIST_QUEUED) + { + if (reload_tracks || (reload_tracks = (confirm_remove_queued_yesno() == YESNO_YES))) + remove_track_unlocked(playlist, i, false); + else + break; + } + rc = pl_save_playlist(playlist, save_path, tmpbuf, sizeof(tmpbuf)); if (rc < 0) { @@ -4030,5 +4043,8 @@ error: playlist_write_unlock(playlist); dc_thread_start(playlist, true); cpu_boost(false); + if (reload_tracks && playlist->started && + (audio_status() & AUDIO_STATUS_PLAY)) + audio_flush_and_reload_tracks(); return rc; } -- cgit v1.2.3