core/playlists/library: Add pl_library_get_queue() function
Called to access the track queue associated with the given playlist. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4d5569ef7a
commit
c5a0a3470e
|
@ -43,7 +43,20 @@ static bool __lib_pl_load(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct playlist_type pl_library;
|
static struct queue *pl_library_get_queue(const gchar *name)
|
||||||
|
{
|
||||||
|
struct library *library = library_lookup(name);
|
||||||
|
struct playlist *playlist = NULL;
|
||||||
|
|
||||||
|
if (library)
|
||||||
|
playlist = (struct playlist *)library->li_playlist;
|
||||||
|
return playlist ? &playlist->pl_queue : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct playlist_type pl_library = {
|
||||||
|
.pl_get_queue = pl_library_get_queue,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static bool __lib_pl_init(void *data)
|
static bool __lib_pl_init(void *data)
|
||||||
|
|
|
@ -22,13 +22,17 @@ void test_library()
|
||||||
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
|
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
|
||||||
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
|
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
|
||||||
test_equal(library->li_playlist, NULL);
|
test_equal(library->li_playlist, NULL);
|
||||||
|
test_equal((void *)pl_library.pl_get_queue("tests/Music"), NULL);
|
||||||
|
|
||||||
pl_library_init(NULL);
|
pl_library_init(NULL);
|
||||||
while (idle_run_task()) {};
|
while (idle_run_task()) {};
|
||||||
playlist = (struct playlist *)library->li_playlist;
|
playlist = (struct playlist *)library->li_playlist;
|
||||||
|
|
||||||
test_not_equal(library->li_playlist, NULL);
|
test_not_equal(library->li_playlist, NULL);
|
||||||
|
test_not_equal((void *)pl_library.pl_get_queue("tests/Music"), NULL);
|
||||||
test_equal(queue_size(&playlist->pl_queue), 2);
|
test_equal(queue_size(&playlist->pl_queue), 2);
|
||||||
|
test_equal((void *)pl_library.pl_get_queue("tests/Music"),
|
||||||
|
(void *)&playlist->pl_queue);
|
||||||
|
|
||||||
pl_library_deinit();
|
pl_library_deinit();
|
||||||
test_equal(library->li_playlist, NULL);
|
test_equal(library->li_playlist, NULL);
|
||||||
|
|
Loading…
Reference in New Issue