diff --git a/core/playlists/artist.c b/core/playlists/artist.c index 2b8f6e40..f6967124 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -26,6 +26,19 @@ static void __artist_pl_free(struct playlist *playlist) } } +static bool __artist_pl_load(void *data) +{ + struct playlist *playlist; + struct db_entry *dbe, *next; + + db_for_each(dbe, next, track_db_get()) { + playlist = TRACK(dbe)->tr_artist->ar_playlist; + queue_add(&playlist->pl_queue, TRACK(dbe)); + } + + return true; +} + struct playlist_type pl_artist; @@ -47,6 +60,7 @@ void pl_artist_init(struct queue_ops *ops) { artist_ops = ops; idle_schedule(IDLE_SYNC, __artist_pl_init, NULL); + idle_schedule(IDLE_SYNC, __artist_pl_load, NULL); } void pl_artist_deinit() diff --git a/tests/core/playlists/artist.c b/tests/core/playlists/artist.c index 56c2af26..e1bf9d0c 100644 --- a/tests/core/playlists/artist.c +++ b/tests/core/playlists/artist.c @@ -5,25 +5,36 @@ #include #include #include +#include #include #include void test_artist() { - struct artist *artist; + struct playlist *playlist; + struct library *library; + struct artist *artist; idle_init_sync(); filter_init(); tags_init(); while (idle_run_task()) {}; + /* Add tracks to the collection. */ + library = library_find("tests/Music"); + track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg"); + track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg"); + artist = artist_find("Koji Kondo"); test_equal(artist->ar_playlist, NULL); pl_artist_init(NULL); while (idle_run_task()) {}; + playlist = (struct playlist *)artist->ar_playlist; + test_not_equal(artist->ar_playlist, NULL); + test_equal(queue_size(&playlist->pl_queue), 2); pl_artist_deinit(); test_equal(artist->ar_playlist, NULL);