mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
[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
This commit is contained in:
parent
ffebb9e244
commit
a0e95c888d
1 changed files with 13 additions and 9 deletions
|
@ -2205,34 +2205,35 @@ static bool insert_all_playlist(struct tree_context *c,
|
||||||
bool fill_randomly = false;
|
bool fill_randomly = false;
|
||||||
bool *rand_bool_array = NULL;
|
bool *rand_bool_array = NULL;
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
|
struct playlist_insert_context context;
|
||||||
|
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
|
|
||||||
if (!tagcache_search(&tcs, tag_filename))
|
if (!tagcache_search(&tcs, tag_filename))
|
||||||
{
|
{
|
||||||
splash(HZ, ID2P(LANG_TAGCACHE_BUSY));
|
splash(HZ, ID2P(LANG_TAGCACHE_BUSY));
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
} /* NOTE: you need to close this search before returning */
|
||||||
|
|
||||||
if (playlist == NULL && position == PLAYLIST_REPLACE)
|
if (playlist == NULL)
|
||||||
{
|
{
|
||||||
if (playlist_remove_all_tracks(NULL) == 0)
|
if (playlist_insert_context_create(NULL, &context, position, queue, false) < 0)
|
||||||
position = PLAYLIST_INSERT_LAST;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
tagcache_search_finish(&tcs);
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (playlist != NULL)
|
else
|
||||||
{
|
{
|
||||||
if (new_playlist)
|
if (new_playlist)
|
||||||
fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC);
|
fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC);
|
||||||
else
|
else
|
||||||
fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666);
|
fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666);
|
||||||
|
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
{
|
{
|
||||||
|
tagcache_search_finish(&tcs);
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2249,6 +2250,7 @@ static bool insert_all_playlist(struct tree_context *c,
|
||||||
if (slots_remaining <= 0)
|
if (slots_remaining <= 0)
|
||||||
{
|
{
|
||||||
logf("Playlist has no space remaining");
|
logf("Playlist has no space remaining");
|
||||||
|
tagcache_search_finish(&tcs);
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2332,7 +2334,7 @@ static bool insert_all_playlist(struct tree_context *c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlist_insert_track(NULL, buf, position, queue, false) < 0) {
|
if (playlist_insert_context_add(&context, buf) < 0) {
|
||||||
logf("playlist_insert_track failed");
|
logf("playlist_insert_track failed");
|
||||||
exit_loop_now = true;
|
exit_loop_now = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2350,10 +2352,12 @@ static bool insert_all_playlist(struct tree_context *c,
|
||||||
if (exit_loop_now)
|
if (exit_loop_now)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlist == NULL)
|
if (playlist == NULL)
|
||||||
playlist_sync(NULL);
|
playlist_insert_context_release(&context);
|
||||||
else
|
else
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
tagcache_search_finish(&tcs);
|
tagcache_search_finish(&tcs);
|
||||||
cpu_boost(false);
|
cpu_boost(false);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue