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.

[Feature/Bugfix] Tagtree use insert context to speed up adding tracks to playlist

I forgot we had duplicated code between playlist.c and tagtree.c this saves
a bit of space and should speed up adding tracks a bit

further I noticed a buf here where there was the potential to return without closing
the opened track search

Change-Id: I15ed8447fc4fe13de5bfeb9fbb59b151e2fbf36a

authored by

William Wilgus and committed by
William Wilgus
a0e95c88 ffebb9e2

+13 -9
+13 -9
apps/tagtree.c
··· 2205 2205 bool fill_randomly = false; 2206 2206 bool *rand_bool_array = NULL; 2207 2207 char buf[MAX_PATH]; 2208 + struct playlist_insert_context context; 2208 2209 2209 2210 cpu_boost(true); 2211 + 2210 2212 if (!tagcache_search(&tcs, tag_filename)) 2211 2213 { 2212 2214 splash(HZ, ID2P(LANG_TAGCACHE_BUSY)); 2213 2215 cpu_boost(false); 2214 2216 return false; 2215 - } 2217 + } /* NOTE: you need to close this search before returning */ 2216 2218 2217 - if (playlist == NULL && position == PLAYLIST_REPLACE) 2219 + if (playlist == NULL) 2218 2220 { 2219 - if (playlist_remove_all_tracks(NULL) == 0) 2220 - position = PLAYLIST_INSERT_LAST; 2221 - else 2221 + if (playlist_insert_context_create(NULL, &context, position, queue, false) < 0) 2222 2222 { 2223 + tagcache_search_finish(&tcs); 2223 2224 cpu_boost(false); 2224 2225 return false; 2225 2226 } 2226 2227 } 2227 - else if (playlist != NULL) 2228 + else 2228 2229 { 2229 2230 if (new_playlist) 2230 2231 fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC); 2231 2232 else 2232 2233 fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666); 2233 - 2234 2234 if(fd < 0) 2235 2235 { 2236 + tagcache_search_finish(&tcs); 2236 2237 cpu_boost(false); 2237 2238 return false; 2238 2239 } ··· 2249 2250 if (slots_remaining <= 0) 2250 2251 { 2251 2252 logf("Playlist has no space remaining"); 2253 + tagcache_search_finish(&tcs); 2252 2254 cpu_boost(false); 2253 2255 return false; 2254 2256 } ··· 2332 2334 } 2333 2335 } 2334 2336 2335 - if (playlist_insert_track(NULL, buf, position, queue, false) < 0) { 2337 + if (playlist_insert_context_add(&context, buf) < 0) { 2336 2338 logf("playlist_insert_track failed"); 2337 2339 exit_loop_now = true; 2338 2340 break; ··· 2350 2352 if (exit_loop_now) 2351 2353 break; 2352 2354 } 2355 + 2353 2356 if (playlist == NULL) 2354 - playlist_sync(NULL); 2357 + playlist_insert_context_release(&context); 2355 2358 else 2356 2359 close(fd); 2360 + 2357 2361 tagcache_search_finish(&tcs); 2358 2362 cpu_boost(false); 2359 2363