Only sync playlist once when adding bunch of files from tagcache.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10508 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-08-10 09:50:45 +00:00
parent 19fe37de6f
commit 887cfeb9f5
5 changed files with 32 additions and 18 deletions

View file

@ -409,9 +409,10 @@ int ft_enter(struct tree_context* c)
break;
}
if (global_settings.party_mode) {
if (global_settings.party_mode)
{
playlist_insert_track(NULL, buf,
PLAYLIST_INSERT_LAST, true);
PLAYLIST_INSERT_LAST, true, true);
gui_syncsplash(HZ, true, str(LANG_QUEUE_LAST));
}
else if (playlist_create(c->currdir, NULL) != -1)

View file

@ -182,7 +182,7 @@ static bool add_to_playlist(int position, bool queue)
else
{
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA)
playlist_insert_track(NULL, selected_file, position, queue);
playlist_insert_track(NULL, selected_file, position, queue, true);
else if (selected_file_attr & ATTR_DIRECTORY)
{
bool recurse = false;

View file

@ -2700,12 +2700,26 @@ void playlist_close(struct playlist_info* playlist)
remove(playlist->control_filename);
}
void playlist_sync(struct playlist_info* playlist)
{
if (!playlist)
playlist = &current_playlist;
sync_control(playlist, false);
if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started)
audio_flush_and_reload_tracks();
#ifdef HAVE_DIRCACHE
queue_post(&playlist_queue, PLAYLIST_LOAD_POINTERS, 0);
#endif
}
/*
* Insert track into playlist at specified position (or one of the special
* positions). Returns position where track was inserted or -1 if error.
*/
int playlist_insert_track(struct playlist_info* playlist,
const char *filename, int position, bool queue)
int playlist_insert_track(struct playlist_info* playlist, const char *filename,
int position, bool queue, bool sync)
{
int result;
@ -2720,16 +2734,11 @@ int playlist_insert_track(struct playlist_info* playlist,
result = add_track_to_playlist(playlist, filename, position, queue, -1);
if (result != -1)
{
sync_control(playlist, false);
if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started)
audio_flush_and_reload_tracks();
}
#ifdef HAVE_DIRCACHE
queue_post(&playlist_queue, PLAYLIST_LOAD_POINTERS, 0);
#endif
/* Check if we want manually sync later. For example when adding
* bunch of files from tagcache, syncing after every file wouldn't be
* a good thing to do. */
if (sync && result >= 0)
playlist_sync(playlist);
return result;
}

View file

@ -134,8 +134,9 @@ int playlist_create_ex(struct playlist_info* playlist,
void* temp_buffer, int temp_buffer_size);
int playlist_set_current(struct playlist_info* playlist);
void playlist_close(struct playlist_info* playlist);
void playlist_sync(struct playlist_info* playlist);
int playlist_insert_track(struct playlist_info* playlist, const char *filename,
int position, bool queue);
int position, bool queue, bool sync);
int playlist_insert_directory(struct playlist_info* playlist,
const char *dirname, int position, bool queue,
bool recurse);

View file

@ -975,8 +975,10 @@ bool insert_all_playlist(struct tree_context *c, int position, bool queue)
continue;
}
playlist_insert_track(NULL, buf, position, queue);
if (playlist_insert_track(NULL, buf, position, queue, false) < 0)
break;
}
playlist_sync(NULL);
tagcache_search_finish(&tcs);
cpu_boost(false);
@ -999,12 +1001,13 @@ bool tagtree_insert_selection_playlist(int position, bool queue)
logf("tagtree_get_filename failed");
return false;
}
playlist_insert_track(NULL, buf, position, queue);
playlist_insert_track(NULL, buf, position, queue, true);
return true;
}
/* We need to set the table to allsubentries. */
show_search_progress(true, 0);
if (dptr->newtable == navibrowse)
{
tagtree_enter(tc);