core/playlists/system: Load collection in a separate idle task

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-07-25 07:57:26 -04:00
parent 81aea3017e
commit d3e2f069fd
1 changed files with 10 additions and 11 deletions

View File

@ -113,14 +113,18 @@ static void sys_pl_collection_save(struct playlist *playlist)
}
}
static void sys_pl_collection_load(struct playlist *playlist)
static bool sys_pl_collection_load()
{
struct playlist *playlist = &sys_playlists[SYS_PL_COLLECTION]->spl_playlist;
if (file_open(&sys_collection_f, OPEN_READ)) {
queue_load_flags(&playlist->pl_queue, &sys_collection_f);
queue_unset_flag(&playlist->pl_queue, Q_SAVE_FLAGS);
queue_unset_flag(&playlist->pl_queue, Q_SAVE_SORT);
file_close(&sys_collection_f);
}
return true;
}
static bool sys_pl_collection_add(struct playlist *playlist, struct track *track)
@ -331,14 +335,14 @@ static void __sys_pl_save()
file_close(&sys_file);
}
static void __sys_pl_load_playlists()
static bool __sys_pl_load()
{
struct sys_playlist *plist;
unsigned int i, n;
gchar *name;
if (!file_open(&sys_file, OPEN_READ))
return;
return true;
file_readf(&sys_file, "%u\n", &n);
for (i = 0; i < n; i++) {
@ -351,13 +355,6 @@ static void __sys_pl_load_playlists()
}
file_close(&sys_file);
return;
}
static bool __sys_pl_load()
{
__sys_pl_load_playlists();
sys_pl_collection_load(&__sys_pl_lookup("Collection")->spl_playlist);
return true;
}
@ -425,7 +422,9 @@ void pl_system_init(struct queue_ops *ops)
struct sys_playlist *sys_pl;
unsigned int i;
idle_schedule(IDLE_SYNC, __sys_pl_load, NULL);
idle_schedule(IDLE_SYNC, __sys_pl_load, NULL);
idle_schedule(IDLE_SYNC, sys_pl_collection_load, NULL);
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
sys_pl = sys_playlists[i];
sys_pl->spl_init(&sys_pl->spl_playlist, 0, ops);