From e5c9846cb49543dee0ba9b07939e817d115c2085 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Wed, 8 Jan 2025 12:35:59 +0100 Subject: [PATCH] Playlist Catalogue: fix: "Save Current Playlist" may fail silently - After rebooting, unless the current playlist had been manually resumed already, the "Save Current Playlist" option in the root menu's/ playlist catalogue's context menu failed to work. - Eliminate error message attempting to view current playlist when no control file present. Change-Id: I58f1d3dc6f256fcee106ff5a17f69fa46d67b2e4 --- apps/menus/playlist_menu.c | 15 +++++++++++++++ apps/playlist.c | 1 + apps/playlist_viewer.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index bfb94ccdad..4e01b29103 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -48,6 +48,21 @@ int save_playlist_screen(struct playlist_info* playlist) char temp[MAX_PATH+1], *p; int len; + bool audio_stopped = !(audio_status() & AUDIO_STATUS_PLAY); + + /* After a reboot, we may need to resume the playlist + first, or it will not contain any indices when + user selects "Save Current Playlist" from playlist + catalogue's context menu in root menu */ + if (!playlist && audio_stopped && !playlist_get_current()->started) + { + if (!file_exists(PLAYLIST_CONTROL_FILE) || playlist_resume() == -1) + { + splash(HZ, ID2P(LANG_CATALOG_NO_PLAYLISTS)); + return 0; + } + } + catalog_get_directory(directoryonly, sizeof(directoryonly)); playlist_get_name(playlist, temp, sizeof(temp)-1); diff --git a/apps/playlist.c b/apps/playlist.c index c843e646d9..de6a47d3e6 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -2048,6 +2048,7 @@ struct playlist_info* playlist_load(const char* dir, const char* file, { playlist->max_playlist_size = current_playlist.max_playlist_size; playlist->indices = current_playlist.indices; + current_playlist.started = false; } new_playlist_unlocked(playlist, dir, file); diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 3cb1047583..4426d0da81 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -387,7 +387,7 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer, if (!filename && !is_playing) { /* Try to restore the list from control file */ - if (playlist_resume() == -1) + if (!file_exists(PLAYLIST_CONTROL_FILE) || playlist_resume() == -1) { /* Nothing to view, exit */ splash(HZ, ID2P(LANG_CATALOG_NO_PLAYLISTS));