From c16dbbfd1fb7bf4bc268a4693bbed21497456b30 Mon Sep 17 00:00:00 2001 From: Paul Sauro Date: Wed, 28 Aug 2024 22:55:52 +0200 Subject: Reworks to the shuffle system to improve performance and allow fast shuffling from a big library (but this work for all database views) This improvement brings a huge performance improvement to start a random mix of your library. Previously, the only way to do this was to increase the size of a playlist with absurd sizes number. Now it will respect the limitation but will insert random songs from the current view. Database: Add true random songs in playlist if it is gonna exceed its maximum capacity More context is available here : https://www.reddit.com/r/rockbox/comments/1ez0mq4/i_developped_true_full_library_shuffle_for/ Also : - Improved layout in the DB browser - New default max playlists capacity is now 2000 on old PortalPlayer targets to give a better user experience and not having to wait dozens of seconds while creating a playlist - "Show insert shuffled" option is now true by default - Add a new shortcut to play all songs shuffled in the DB browser - Now the feature is fully optional and enabled only on targets that have more than 2MB of RAM - Add entries about this feature in the manual to explain it to the users Change-Id: I1aebaf7ebcff2bf907080f1861027d530619097c Change-Id: I3354923b148eeef1975171990e814a1a505d1df0 --- apps/onplay.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'apps/onplay.c') diff --git a/apps/onplay.c b/apps/onplay.c index 4f748204df..045af275bc 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -302,7 +302,7 @@ static int add_to_playlist(void* arg) /* warn if replacing the playlist */ if (new_playlist && !warn_on_pl_erase()) - return 0; + return 1; splash(0, ID2P(LANG_WAIT)); @@ -340,7 +340,7 @@ static int add_to_playlist(void* arg) } playlist_set_modified(NULL, true); - return false; + return 0; } static bool view_playlist(void) @@ -1255,7 +1255,7 @@ static int execute_hotkey(bool is_wps) } #endif /* HOTKEY */ -int onplay(char* file, int attr, int from_context, bool hotkey) +int onplay(char* file, int attr, int from_context, bool hotkey, int customaction) { const struct menu_item_ex *menu; onplay_result = ONPLAY_OK; @@ -1294,6 +1294,13 @@ int onplay(char* file, int attr, int from_context, bool hotkey) #else (void)hotkey; #endif + if (customaction == ONPLAY_CUSTOMACTION_SHUFFLE_SONGS) { + int returnCode = add_to_playlist(&addtopl_replace_shuffled); + if (returnCode == 1) + // User did not want to erase his current playlist, so let's show again the database main menu + return ONPLAY_RELOAD_DIR; + return ONPLAY_START_PLAY; + } push_current_activity(ACTIVITY_CONTEXTMENU); if (from_context == CONTEXT_WPS) -- cgit v1.2.3