Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

tagtree: defer context menu disk access

When the database isn't loaded into RAM,
or the "quick" load setting is enabled,
filenames for tracks must be retrieved
from disk.

With a single track selected, this
can cause a delay before its context
menu is displayed.

Since filenames are only needed after the
user has selected something from the menu,
it makes sense to defer retrieval until
disk access becomes inevitable.

Change-Id: I72b57eff3102b50f3e19441119e20aad903b1f2b

authored by

Christian Soffke and committed by
Solomon Peachy
93b16114 be47d646

+57 -23
+39 -15
apps/onplay.c
··· 64 64 #include "pathfuncs.h" 65 65 #include "shortcuts.h" 66 66 #include "misc.h" 67 + #ifdef HAVE_DISK_STORAGE 68 + #include "storage.h" 69 + #endif 67 70 68 71 static int onplay_result = ONPLAY_OK; 69 72 static bool in_queue_submenu = false; ··· 267 270 ctx_current_playlist_insert(position, queue, false); 268 271 return; 269 272 } 273 + else if (selected_file.context == CONTEXT_ID3DB) 274 + { 275 + tagtree_current_playlist_insert(position, queue); 276 + return; 277 + } 270 278 #endif 271 279 if ((selected_file.attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) 272 280 playlist_insert_track(NULL, selected_file.path, position, queue, true); ··· 274 282 playlist_insert_playlist(NULL, selected_file.path, position, queue); 275 283 else if (selected_file.attr & ATTR_DIRECTORY) 276 284 { 277 - #ifdef HAVE_TAGCACHE 278 - if (selected_file.context == CONTEXT_ID3DB) 279 - { 280 - tagtree_current_playlist_insert(position, queue); 281 - return; 282 - } 283 - #endif 284 285 bool recurse = (global_settings.recursive_dir_insert == RECURSE_ON); 285 286 if (global_settings.recursive_dir_insert == RECURSE_ASK) 286 287 { ··· 839 840 #ifdef HAVE_TAGCACHE 840 841 static bool prepare_database_sel(void *param) 841 842 { 842 - if (selected_file.context == CONTEXT_ID3DB && 843 - (selected_file.attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) 843 + if (selected_file.context == CONTEXT_ID3DB) 844 844 { 845 - if (!strcmp(param, "properties")) 845 + if (param && !strcmp(param, "properties") 846 + && (selected_file.attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) 847 + { 846 848 strmemccpy(selected_file.buf, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER), 847 849 sizeof(selected_file.buf)); 848 - else if (!tagtree_get_subentry_filename(selected_file.buf, MAX_PATH)) 850 + } 851 + else 849 852 { 850 - onplay_result = ONPLAY_RELOAD_DIR; 851 - return false; 853 + /* If database is not loaded into RAM, or tagcache_ram is 854 + set to "quick", filename needs to be retrieved from disk! */ 855 + #ifdef HAVE_DISK_STORAGE 856 + if ((selected_file.attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO 857 + && !storage_disk_is_active() 858 + #ifdef HAVE_TC_RAMCACHE 859 + && (global_settings.tagcache_ram != TAGCACHE_RAM_ON 860 + || !tagcache_is_in_ram()) 861 + #endif 862 + ) 863 + splash(0, ID2P(LANG_WAIT)); 864 + #endif 865 + if (!tagtree_get_subentry_filename(selected_file.buf, MAX_PATH)) 866 + { 867 + onplay_result = ONPLAY_RELOAD_DIR; 868 + return false; 869 + } 852 870 } 853 871 854 872 selected_file.path = selected_file.buf; ··· 1173 1191 if (selected_file.context == CONTEXT_ID3DB && 1174 1192 (selected_file.attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) 1175 1193 return false; 1194 + 1195 + if (!prepare_database_sel(NULL)) 1196 + return false; 1176 1197 #endif 1177 1198 1178 1199 return clipboard_delete_selected_fileobject(); ··· 1185 1206 return false; 1186 1207 #ifdef HAVE_MULTIVOLUME 1187 1208 if (selected_file.attr & ATTR_VOLUME) 1209 + return false; 1210 + #endif 1211 + #ifdef HAVE_TAGCACHE 1212 + if (!prepare_database_sel(NULL)) 1188 1213 return false; 1189 1214 #endif 1190 1215 return list_viewers(); ··· 1341 1366 selected_file_set(from_context, NULL, attr); 1342 1367 1343 1368 #ifdef HAVE_TAGCACHE 1344 - if (from_context == CONTEXT_ID3DB && 1345 - (attr & FILE_ATTR_MASK) != FILE_ATTR_AUDIO) 1369 + if (from_context == CONTEXT_ID3DB) 1346 1370 { 1347 1371 ctx_add_to_playlist = tagtree_add_to_playlist; 1348 1372 if (file != NULL)
+3 -3
apps/playlist_catalog.c
··· 286 286 287 287 /* Add "sel" file into specified "playlist". How to insert depends on type 288 288 of file */ 289 - static int add_to_playlist(const char* playlist, bool new_playlist, 290 - const char* sel, int sel_attr) 289 + int catalog_insert_into(const char* playlist, bool new_playlist, 290 + const char* sel, int sel_attr) 291 291 { 292 292 int fd; 293 293 int result = -1; ··· 514 514 result = ctx_add_to_playlist(playlist, new_playlist); 515 515 } 516 516 else 517 - result = add_to_playlist(playlist, new_playlist, sel, sel_attr); 517 + result = catalog_insert_into(playlist, new_playlist, sel, sel_attr); 518 518 519 519 return (result == 0); 520 520 }
+5 -2
apps/playlist_catalog.h
··· 27 27 /* Set the playlist catalog dir */ 28 28 void catalog_set_directory(const char* directory); 29 29 30 - /* 30 + /* 31 31 * View list of playlists in catalog. 32 32 * ret : true if item was selected 33 33 */ ··· 36 36 bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size, 37 37 const char* curr_pl_name); 38 38 39 - /* 39 + int catalog_insert_into(const char* playlist, bool new_playlist, 40 + const char* sel, int sel_attr); 41 + 42 + /* 40 43 * Add something to a playlist (new or select from list of playlists in 41 44 * catalog). 42 45 * sel : the path of the music file, playlist or directory to add
+5 -1
apps/tagtree.c
··· 59 59 #include "onplay.h" 60 60 #include "plugin.h" 61 61 #include "language.h" 62 + #include "playlist_catalog.h" 62 63 63 64 #define str_or_empty(x) (x ? x : "(NULL)") 64 65 ··· 2544 2545 if (tagtree_get_filename(tc, buf, sizeof buf) < 0) 2545 2546 return false; 2546 2547 2547 - playlist_insert_track(NULL, buf, position, queue, true); 2548 + if (!playlist) 2549 + playlist_insert_track(NULL, buf, position, queue, true); 2550 + else 2551 + catalog_insert_into(playlist, new_playlist, buf, FILE_ATTR_AUDIO); 2548 2552 2549 2553 return true; 2550 2554 }
+5 -2
apps/tree.c
··· 919 919 if (tagtree_get_attr(&tc) == FILE_ATTR_AUDIO) 920 920 { 921 921 attr = FILE_ATTR_AUDIO; 922 - tagtree_get_filename(&tc, buf, sizeof(buf)); 922 + 923 + /* Look up the filename only once it is needed, so we 924 + don't have to wait for the disk to wake up here. */ 925 + buf[0] = '\0'; 923 926 } 924 927 else 925 928 { ··· 1261 1264 1262 1265 if (peek_filename == NULL) 1263 1266 { 1264 - if (index == 0) /* searched every entry didn't find a match */ 1267 + if (index == 0) /* searched every entry didn't find a match */ 1265 1268 return false; 1266 1269 /* playlist has shrunk, search from the top */ 1267 1270 i = 0;