core/playlist: Remove playlist_get_queue()
We can just look up the playlist instead, and then access the queue variable from there. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
72d0f9a248
commit
1fa31c51a6
|
@ -47,9 +47,9 @@ static struct track *__audio_load_basic(struct track *track, GstState state)
|
||||||
audio_ops->on_load(track);
|
audio_ops->on_load(track);
|
||||||
__audio_change_state(state);
|
__audio_change_state(state);
|
||||||
|
|
||||||
queue_updated(playlist_get_queue(PL_SYSTEM, "Queued Tracks"), prev);
|
queue_updated(&playlist_lookup(PL_SYSTEM, "Queued Tracks")->pl_queue, prev);
|
||||||
queue_updated(playlist_get_queue(PL_SYSTEM, "Collection"), prev);
|
queue_updated(&playlist_lookup(PL_SYSTEM, "Collection")->pl_queue, prev);
|
||||||
queue_updated(playlist_get_queue(PL_SYSTEM, "Collection"), audio_track);
|
queue_updated(&playlist_lookup(PL_SYSTEM, "Collection")->pl_queue, audio_track);
|
||||||
|
|
||||||
audio_save();
|
audio_save();
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
|
|
|
@ -209,9 +209,3 @@ struct track *playlist_prev(void)
|
||||||
{
|
{
|
||||||
return playlist_types[PL_SYSTEM]->pl_next("History");
|
return playlist_types[PL_SYSTEM]->pl_next("History");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct queue *playlist_get_queue(enum playlist_type_t type, const gchar *name)
|
|
||||||
{
|
|
||||||
struct playlist *playlist = playlist_lookup(type, name);
|
|
||||||
return playlist ? &playlist->pl_queue : NULL;
|
|
||||||
}
|
|
||||||
|
|
|
@ -77,8 +77,4 @@ struct track *playlist_next(void);
|
||||||
/* Called to get a previously played track. */
|
/* Called to get a previously played track. */
|
||||||
struct track *playlist_prev(void);
|
struct track *playlist_prev(void);
|
||||||
|
|
||||||
|
|
||||||
/* Called to access the playlist queue. */
|
|
||||||
struct queue *playlist_get_queue(enum playlist_type_t, const gchar *);
|
|
||||||
|
|
||||||
#endif /* OCARINA_CORE_PLAYLIST_H */
|
#endif /* OCARINA_CORE_PLAYLIST_H */
|
||||||
|
|
|
@ -131,7 +131,7 @@ static void test_playback()
|
||||||
|
|
||||||
static void test_next()
|
static void test_next()
|
||||||
{
|
{
|
||||||
struct queue *history_q = playlist_get_queue(PL_SYSTEM, "History");
|
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
state_count = 0;
|
state_count = 0;
|
||||||
|
@ -169,7 +169,7 @@ static void test_next()
|
||||||
|
|
||||||
static void test_prev()
|
static void test_prev()
|
||||||
{
|
{
|
||||||
struct queue *history_q = playlist_get_queue(PL_SYSTEM, "History");
|
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||||
struct track *track = queue_at(history_q, 0);
|
struct track *track = queue_at(history_q, 0);
|
||||||
|
|
||||||
state_count = 0;
|
state_count = 0;
|
||||||
|
@ -207,7 +207,7 @@ static void test_prev()
|
||||||
|
|
||||||
void test_autopause()
|
void test_autopause()
|
||||||
{
|
{
|
||||||
struct queue *history_q = playlist_get_queue(PL_SYSTEM, "History");
|
struct queue *history_q = &playlist_lookup(PL_SYSTEM, "History")->pl_queue;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
audio_pause_after(3);
|
audio_pause_after(3);
|
||||||
|
|
|
@ -16,7 +16,7 @@ void test_artist()
|
||||||
struct artist *artist;
|
struct artist *artist;
|
||||||
|
|
||||||
g_assert_null(playlist_new(PL_ARTIST, "Koji Kondo"));
|
g_assert_null(playlist_new(PL_ARTIST, "Koji Kondo"));
|
||||||
g_assert_null(playlist_get_queue(PL_ARTIST, "Koji Kondo"));
|
g_assert_null(playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
||||||
|
|
||||||
artist = artist_find("Koji Kondo");
|
artist = artist_find("Koji Kondo");
|
||||||
g_assert_null(artist->ar_playlist);
|
g_assert_null(artist->ar_playlist);
|
||||||
|
|
|
@ -14,14 +14,14 @@ void test_library()
|
||||||
struct library *library;
|
struct library *library;
|
||||||
|
|
||||||
g_assert_null(playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg"));
|
g_assert_null(playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg"));
|
||||||
|
g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||||
|
|
||||||
g_assert_null(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
|
||||||
g_assert_false(playlist_select(NULL));
|
g_assert_false(playlist_select(NULL));
|
||||||
|
|
||||||
playlist = playlist_new(PL_LIBRARY, "tests/Music");
|
playlist = playlist_new(PL_LIBRARY, "tests/Music");
|
||||||
g_assert_nonnull(playlist);
|
g_assert_nonnull(playlist);
|
||||||
g_assert_null(playlist_new(PL_LIBRARY, "tests/Music"));
|
g_assert_null(playlist_new(PL_LIBRARY, "tests/Music"));
|
||||||
g_assert_nonnull(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
g_assert_nonnull(playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||||
|
|
||||||
library = library_get(0);
|
library = library_get(0);
|
||||||
playlist = library->li_playlist;
|
playlist = library->li_playlist;
|
||||||
|
@ -51,16 +51,14 @@ void test_library()
|
||||||
g_assert_false(playlist_remove(playlist, track_get(1)));
|
g_assert_false(playlist_remove(playlist, track_get(1)));
|
||||||
|
|
||||||
pl_library_deinit();
|
pl_library_deinit();
|
||||||
g_assert_null(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music"));
|
||||||
g_assert_null(library->li_playlist);
|
g_assert_null(library->li_playlist);
|
||||||
pl_library_init(NULL);
|
pl_library_init(NULL);
|
||||||
while (idle_run_task()) {};
|
while (idle_run_task()) {};
|
||||||
|
|
||||||
playlist = library->li_playlist;
|
playlist = library->li_playlist;
|
||||||
g_assert_nonnull(library->li_playlist);
|
g_assert_nonnull(library->li_playlist);
|
||||||
g_assert_nonnull(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
|
||||||
g_assert_cmpuint(playlist_size(playlist), ==, 48);
|
g_assert_cmpuint(playlist_size(playlist), ==, 48);
|
||||||
g_assert(playlist_get_queue(PL_LIBRARY, "tests/Music"));
|
|
||||||
|
|
||||||
g_assert_false(playlist_add(playlist, track_get(0)));
|
g_assert_false(playlist_add(playlist, track_get(0)));
|
||||||
g_assert_false(playlist_add(playlist, track_get(1)));
|
g_assert_false(playlist_add(playlist, track_get(1)));
|
||||||
|
|
|
@ -55,11 +55,11 @@
|
||||||
|
|
||||||
#define __test_playlist_reinit(name, ex_size, ex_track0, ex_track1) \
|
#define __test_playlist_reinit(name, ex_size, ex_track0, ex_track1) \
|
||||||
do { \
|
do { \
|
||||||
struct queue *queue; \
|
struct playlist *playlist; \
|
||||||
pl_system_deinit(); \
|
pl_system_deinit(); \
|
||||||
pl_system_init(NULL); \
|
pl_system_init(NULL); \
|
||||||
queue = playlist_get_queue(PL_SYSTEM, name); \
|
playlist = playlist_lookup(PL_SYSTEM, name); \
|
||||||
g_assert_nonnull(queue); \
|
g_assert_nonnull(playlist); \
|
||||||
__test_playlist_state(name, 0, false, false); \
|
__test_playlist_state(name, 0, false, false); \
|
||||||
while (idle_run_task()) {}; \
|
while (idle_run_task()) {}; \
|
||||||
__test_playlist_state(name, ex_size, ex_track0, ex_track1); \
|
__test_playlist_state(name, ex_size, ex_track0, ex_track1); \
|
||||||
|
@ -118,18 +118,11 @@ static void test_init()
|
||||||
|
|
||||||
static void test_invalid()
|
static void test_invalid()
|
||||||
{
|
{
|
||||||
g_assert_null(playlist_get_queue(PL_SYSTEM, NULL));
|
|
||||||
g_assert_null(playlist_get_queue(PL_SYSTEM, "Invalid"));
|
|
||||||
playlist_update(PL_SYSTEM, NULL);
|
playlist_update(PL_SYSTEM, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_favorites()
|
static void test_favorites()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "Favorites");
|
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_add("Favorites");
|
__test_playlist_add("Favorites");
|
||||||
__test_playlist_reinit("Favorites", 2, true, true);
|
__test_playlist_reinit("Favorites", 2, true, true);
|
||||||
__test_playlist_update("Favorites", 2, true, true);
|
__test_playlist_update("Favorites", 2, true, true);
|
||||||
|
@ -138,12 +131,6 @@ static void test_favorites()
|
||||||
|
|
||||||
static void test_hidden()
|
static void test_hidden()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "Hidden");
|
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_null(playlist_get_queue(PL_SYSTEM, "Banned"));
|
|
||||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_add("Hidden");
|
__test_playlist_add("Hidden");
|
||||||
__test_playlist_reinit("Hidden", 2, true, true);
|
__test_playlist_reinit("Hidden", 2, true, true);
|
||||||
__test_playlist_update("Hidden", 2, true, true);
|
__test_playlist_update("Hidden", 2, true, true);
|
||||||
|
@ -152,12 +139,6 @@ static void test_hidden()
|
||||||
|
|
||||||
static void test_queued()
|
static void test_queued()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "Queued Tracks");
|
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_false(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
g_assert_cmpuint(g_slist_length(queue->q_sort), ==, 0);
|
|
||||||
|
|
||||||
__test_playlist_add("Queued Tracks");
|
__test_playlist_add("Queued Tracks");
|
||||||
__test_playlist_reinit("Queued Tracks", 2, true, true);
|
__test_playlist_reinit("Queued Tracks", 2, true, true);
|
||||||
|
|
||||||
|
@ -178,14 +159,9 @@ static void test_queued()
|
||||||
|
|
||||||
static void test_collection()
|
static void test_collection()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "Collection");
|
|
||||||
|
|
||||||
pl_system_deinit();
|
pl_system_deinit();
|
||||||
pl_system_init(NULL);
|
pl_system_init(NULL);
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_update("Collection", 2, true, true);
|
__test_playlist_update("Collection", 2, true, true);
|
||||||
__test_playlist_hide_track("Collection", 1, false, true);
|
__test_playlist_hide_track("Collection", 1, false, true);
|
||||||
__test_playlist_reinit("Collection", 1, false, true);
|
__test_playlist_reinit("Collection", 1, false, true);
|
||||||
|
@ -197,11 +173,6 @@ static void test_collection()
|
||||||
|
|
||||||
static void test_history()
|
static void test_history()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "History");
|
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_state("History", 0, false, false);
|
__test_playlist_state("History", 0, false, false);
|
||||||
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
||||||
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
||||||
|
@ -221,14 +192,9 @@ static void test_history()
|
||||||
|
|
||||||
static void test_unplayed()
|
static void test_unplayed()
|
||||||
{
|
{
|
||||||
struct queue *queue = playlist_get_queue(PL_SYSTEM, "Unplayed");
|
|
||||||
|
|
||||||
pl_system_deinit();
|
pl_system_deinit();
|
||||||
pl_system_init(NULL);
|
pl_system_init(NULL);
|
||||||
|
|
||||||
g_assert_nonnull(queue);
|
|
||||||
g_assert_true(queue_has_flag(queue, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_reinit("Unplayed", 2, true, true);
|
__test_playlist_reinit("Unplayed", 2, true, true);
|
||||||
|
|
||||||
track_get(1)->tr_count = 1;
|
track_get(1)->tr_count = 1;
|
||||||
|
@ -251,8 +217,6 @@ static void test_unplayed()
|
||||||
|
|
||||||
static void test_most_played()
|
static void test_most_played()
|
||||||
{
|
{
|
||||||
struct queue *most = playlist_get_queue(PL_SYSTEM, "Most Played");
|
|
||||||
|
|
||||||
/* Set average = (4 / 2) = 2 */
|
/* Set average = (4 / 2) = 2 */
|
||||||
track_played(track_get(0));
|
track_played(track_get(0));
|
||||||
track_played(track_get(1));
|
track_played(track_get(1));
|
||||||
|
@ -262,9 +226,6 @@ static void test_most_played()
|
||||||
pl_system_deinit();
|
pl_system_deinit();
|
||||||
pl_system_init(NULL);
|
pl_system_init(NULL);
|
||||||
|
|
||||||
g_assert_nonnull(most);
|
|
||||||
g_assert_true(queue_has_flag(most, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_reinit("Most Played", 1, false, true);
|
__test_playlist_reinit("Most Played", 1, false, true);
|
||||||
|
|
||||||
track_get(0)->tr_count = 3;
|
track_get(0)->tr_count = 3;
|
||||||
|
@ -281,8 +242,6 @@ static void test_most_played()
|
||||||
|
|
||||||
static void test_least_played()
|
static void test_least_played()
|
||||||
{
|
{
|
||||||
struct queue *least = playlist_get_queue(PL_SYSTEM, "Least Played");
|
|
||||||
|
|
||||||
/* Reset playcounts so track 1 is "least played" */
|
/* Reset playcounts so track 1 is "least played" */
|
||||||
track_get(0)->tr_count = 3;
|
track_get(0)->tr_count = 3;
|
||||||
track_get(1)->tr_count = 1;
|
track_get(1)->tr_count = 1;
|
||||||
|
@ -290,9 +249,6 @@ static void test_least_played()
|
||||||
pl_system_deinit();
|
pl_system_deinit();
|
||||||
pl_system_init(NULL);
|
pl_system_init(NULL);
|
||||||
|
|
||||||
g_assert_nonnull(least);
|
|
||||||
g_assert_true(queue_has_flag(least, Q_REPEAT));
|
|
||||||
|
|
||||||
__test_playlist_reinit("Least Played", 1, false, true);
|
__test_playlist_reinit("Least Played", 1, false, true);
|
||||||
|
|
||||||
track_get(0)->tr_count = 1;
|
track_get(0)->tr_count = 1;
|
||||||
|
|
|
@ -61,7 +61,7 @@ void test_filter()
|
||||||
|
|
||||||
entry = GTK_ENTRY(gui_filter_search());
|
entry = GTK_ENTRY(gui_filter_search());
|
||||||
model = GTK_TREE_MODEL(gui_filter_get());
|
model = GTK_TREE_MODEL(gui_filter_get());
|
||||||
playlist_get_queue(PL_SYSTEM, "Collection")->q_private =
|
playlist_lookup(PL_SYSTEM, "Collection")->pl_queue.q_private =
|
||||||
playlist_lookup(PL_SYSTEM, "Collection");
|
playlist_lookup(PL_SYSTEM, "Collection");
|
||||||
|
|
||||||
g_assert_false(gtk_tree_model_get_iter_first(model, &iter));
|
g_assert_false(gtk_tree_model_get_iter_first(model, &iter));
|
||||||
|
|
|
@ -186,7 +186,7 @@ static void test_model()
|
||||||
while (idle_run_task() == true) {}
|
while (idle_run_task() == true) {}
|
||||||
g_assert_cmpuint(playlist_size(collection), ==, 13);
|
g_assert_cmpuint(playlist_size(collection), ==, 13);
|
||||||
g_assert_cmpuint(count_insert, ==, 13);
|
g_assert_cmpuint(count_insert, ==, 13);
|
||||||
queue_resort(playlist_get_queue(PL_SYSTEM, "Collection"));
|
queue_resort(&playlist_lookup(PL_SYSTEM, "Collection")->pl_queue);
|
||||||
g_assert_cmpuint(count_update, ==, 13);
|
g_assert_cmpuint(count_update, ==, 13);
|
||||||
playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0));
|
playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0));
|
||||||
playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(1));
|
playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(1));
|
||||||
|
|
Loading…
Reference in New Issue