summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-11-11 01:53:36 +0100
committerChristian Soffke <christian.soffke@gmail.com>2024-04-21 18:28:16 +0200
commitea5ce8034b4a1ead1227114308889511dbfa9539 (patch)
tree398889c4b91ce8781bfbd4f7751d5c0e7bb65e79 /apps/playlist.c
parente5c65a00392f801e39d7e3287c62bd8e4ec17cda (diff)
downloadrockbox-ea5ce8034b4a1ead1227114308889511dbfa9539.tar.gz
rockbox-ea5ce8034b4a1ead1227114308889511dbfa9539.zip
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
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c16
1 files changed, 16 insertions, 0 deletions
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 @@
99#include "filetypes.h" 99#include "filetypes.h"
100#include "icons.h" 100#include "icons.h"
101#include "system.h" 101#include "system.h"
102#include "misc.h"
102 103
103#include "lang.h" 104#include "lang.h"
104#include "talk.h" 105#include "talk.h"
@@ -3977,6 +3978,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3977 char tmpbuf[MAX_PATH+1]; 3978 char tmpbuf[MAX_PATH+1];
3978 ssize_t pathlen; 3979 ssize_t pathlen;
3979 int rc = 0; 3980 int rc = 0;
3981 bool reload_tracks = false;
3980 3982
3981 if (!playlist) 3983 if (!playlist)
3982 playlist = &current_playlist; 3984 playlist = &current_playlist;
@@ -3996,6 +3998,17 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3996 goto error; 3998 goto error;
3997 } 3999 }
3998 4000
4001 /* Ask if queued tracks should be removed, so that
4002 playlist can be bookmarked after it's been saved */
4003 for (int i = playlist->amount - 1; i >= 0; i--)
4004 if (playlist->indices[i] & PLAYLIST_QUEUED)
4005 {
4006 if (reload_tracks || (reload_tracks = (confirm_remove_queued_yesno() == YESNO_YES)))
4007 remove_track_unlocked(playlist, i, false);
4008 else
4009 break;
4010 }
4011
3999 rc = pl_save_playlist(playlist, save_path, tmpbuf, sizeof(tmpbuf)); 4012 rc = pl_save_playlist(playlist, save_path, tmpbuf, sizeof(tmpbuf));
4000 if (rc < 0) 4013 if (rc < 0)
4001 { 4014 {
@@ -4030,5 +4043,8 @@ error:
4030 playlist_write_unlock(playlist); 4043 playlist_write_unlock(playlist);
4031 dc_thread_start(playlist, true); 4044 dc_thread_start(playlist, true);
4032 cpu_boost(false); 4045 cpu_boost(false);
4046 if (reload_tracks && playlist->started &&
4047 (audio_status() & AUDIO_STATUS_PLAY))
4048 audio_flush_and_reload_tracks();
4033 return rc; 4049 return rc;
4034} 4050}