From 448b4a16f4c10dabc8fbaf3808330e67077c31be Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 22 Sep 2016 13:37:34 -0400 Subject: [PATCH] Remove core/queue.c and associated files Everything has been merged into the playlist layer to better match how playlists are actually used. This means we can remove the queue files. Signed-off-by: Anna Schumaker --- core/core.c | 2 +- core/playlist.c | 10 ++--- core/playlists/artist.c | 10 ++--- core/playlists/generic.c | 17 +++---- core/playlists/library.c | 10 ++--- core/playlists/system.c | 6 +-- core/playlists/user.c | 6 +-- core/queue.c | 20 --------- gui/ocarina.c | 1 - gui/playlist.c | 9 ---- include/core/core.h | 4 +- include/core/playlist.h | 2 +- include/core/playlists/artist.h | 2 +- include/core/playlists/generic.h | 7 ++- include/core/playlists/iterator.h | 1 - include/core/playlists/library.h | 2 +- include/core/playlists/playlist.h | 2 - include/core/playlists/system.h | 2 +- include/core/playlists/user.h | 2 +- include/core/queue.h | 33 -------------- include/gui/playlist.h | 3 -- tests/core/.gitignore | 1 - tests/core/CMakeLists.txt | 1 - tests/core/playlist.c | 18 +++++--- tests/core/playlists/artist.c | 4 +- tests/core/playlists/library.c | 4 +- tests/core/playlists/system.c | 2 +- tests/core/playlists/user.c | 4 +- tests/core/queue.c | 74 ------------------------------- tests/gui/artwork.c | 1 - tests/gui/filter.c | 12 +---- tests/gui/model.c | 9 ---- tests/gui/playlist.c | 4 +- tests/gui/playlists/library.c | 4 +- tests/gui/playlists/system.c | 4 +- tests/gui/playlists/user.c | 4 +- 36 files changed, 57 insertions(+), 240 deletions(-) delete mode 100644 core/queue.c delete mode 100644 include/core/queue.h delete mode 100644 tests/core/queue.c diff --git a/core/core.c b/core/core.c index 5a621c5c..871bb173 100644 --- a/core/core.c +++ b/core/core.c @@ -28,7 +28,7 @@ void core_init(int *argc, char ***argv, struct core_init_data *init) idle_init(); settings_init(); tags_init(); - playlist_init(init->playlist_ops, init->playlist_cb); + playlist_init(init->playlist_cb); audio_init(argc, argv, init->audio_ops); idle_schedule(IDLE_SYNC, core_defragment, NULL); diff --git a/core/playlist.c b/core/playlist.c index 7f664e99..9c1503ae 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -33,13 +33,13 @@ static struct playlist *__playlist_saved(const gchar *s_type, const gchar *s_id) return playlist_types[type]->pl_get(id); } -void playlist_init(struct queue_ops *ops, struct playlist_callbacks *cb) +void playlist_init(struct playlist_callbacks *cb) { playlist_generic_set_callbacks(cb); - pl_system_init(ops); - pl_artist_init(ops); - pl_user_init(ops); - pl_library_init(ops); + pl_system_init(); + pl_artist_init(); + pl_user_init(); + pl_library_init(); current = __playlist_saved(SETTINGS_CUR_TYPE, SETTINGS_CUR_ID); previous = __playlist_saved(SETTINGS_PREV_TYPE, SETTINGS_PREV_ID); diff --git a/core/playlists/artist.c b/core/playlists/artist.c index 46601941..8157a0f6 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -5,8 +5,7 @@ #include #include -static struct queue_ops *artist_ops = NULL; -static struct file artist_file = FILE_INIT("playlist.artist", 0); +static struct file artist_file = FILE_INIT("playlist.artist", 0); static struct playlist_ops pl_artist_ops = { .pl_can_select = playlist_generic_can_select, @@ -18,8 +17,7 @@ static struct playlist_ops pl_artist_ops = { static struct playlist *__artist_pl_alloc(struct artist *artist) { return playlist_generic_alloc(artist->ar_name, PL_ARTIST, - artist_index(artist), &pl_artist_ops, - artist_ops); + artist_index(artist), &pl_artist_ops); } static bool __artist_pl_add(void *data) @@ -112,13 +110,11 @@ struct playlist_type pl_artist = { }; -void pl_artist_init(struct queue_ops *ops) +void pl_artist_init(void) { struct db_entry *dbe, *next; struct playlist *playlist; - artist_ops = ops; - db_for_each(dbe, next, artist_db_get()) { playlist = __artist_pl_alloc(ARTIST(dbe)); ARTIST(dbe)->ar_playlist = playlist; diff --git a/core/playlists/generic.c b/core/playlists/generic.c index 0504b692..39317f10 100644 --- a/core/playlists/generic.c +++ b/core/playlists/generic.c @@ -38,22 +38,20 @@ void playlist_generic_set_callbacks(struct playlist_callbacks *cb) callbacks = cb; } -void playlist_generic_init(struct playlist *playlist, struct queue_ops *ops) +void playlist_generic_init(struct playlist *playlist) { if (playlist) { g_queue_init(&playlist->pl_tracks); - queue_init(&playlist->pl_queue, ops, playlist); playlist->pl_sort = NULL; playlist->pl_current = NULL; playlist->pl_search = NULL; } } -void playlist_generic_init_sorted(struct playlist *playlist, - struct queue_ops *ops) +void playlist_generic_init_sorted(struct playlist *playlist) { if (playlist) { - playlist_generic_init(playlist, ops); + playlist_generic_init(playlist); playlist_generic_sort(playlist, COMPARE_ARTIST); playlist_generic_sort(playlist, COMPARE_YEAR); playlist_generic_sort(playlist, COMPARE_TRACK); @@ -71,11 +69,8 @@ void playlist_generic_deinit(struct playlist *playlist) } } -struct playlist *playlist_generic_alloc(gchar *name, - enum playlist_type_t type, - unsigned int id, - struct playlist_ops *ops, - struct queue_ops *qops) +struct playlist *playlist_generic_alloc(gchar *name, enum playlist_type_t type, + unsigned int id, struct playlist_ops *ops) { struct playlist *playlist = g_malloc(sizeof(struct playlist)); @@ -84,7 +79,7 @@ struct playlist *playlist_generic_alloc(gchar *name, playlist->pl_id = id; playlist->pl_ops = ops; - playlist_generic_init_sorted(playlist, qops); + playlist_generic_init_sorted(playlist); if (callbacks) callbacks->pl_cb_alloc(playlist); return playlist; diff --git a/core/playlists/library.c b/core/playlists/library.c index de42b9e2..6bd7c7a2 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -14,8 +14,7 @@ struct scan_data { }; static bool __lib_pl_scan_dir(void *); -static struct queue_ops *lib_ops = NULL; -static struct file lib_file = FILE_INIT("playlist.library", 0); +static struct file lib_file = FILE_INIT("playlist.library", 0); static struct playlist_ops pl_library_ops; @@ -23,8 +22,7 @@ static struct playlist_ops pl_library_ops; static struct playlist *__lib_pl_alloc(struct library *library) { return playlist_generic_alloc(library->li_path, PL_LIBRARY, - library_index(library), &pl_library_ops, - lib_ops); + library_index(library), &pl_library_ops); } static bool __lib_pl_add(void *data) @@ -244,13 +242,11 @@ struct playlist_type pl_library = { }; -void pl_library_init(struct queue_ops *ops) +void pl_library_init(void) { struct db_entry *dbe, *next; struct playlist *playlist; - lib_ops = ops; - db_for_each(dbe, next, library_db_get()) { playlist = __lib_pl_alloc(LIBRARY(dbe)); LIBRARY(dbe)->li_playlist = playlist; diff --git a/core/playlists/system.c b/core/playlists/system.c index af8c32c2..1045c609 100644 --- a/core/playlists/system.c +++ b/core/playlists/system.c @@ -385,7 +385,7 @@ struct playlist_type pl_system = { }; -void pl_system_init(struct queue_ops *ops) +void pl_system_init(void) { struct playlist *playlist; unsigned int i; @@ -396,7 +396,7 @@ void pl_system_init(struct queue_ops *ops) switch (i) { case SYS_PL_QUEUED: case SYS_PL_HISTORY: - playlist_generic_init(playlist, ops); + playlist_generic_init(playlist); break; case SYS_PL_COLLECTION: case SYS_PL_UNPLAYED: @@ -405,7 +405,7 @@ void pl_system_init(struct queue_ops *ops) sys_pl_update(playlist); case SYS_PL_FAVORITES: case SYS_PL_HIDDEN: - playlist_generic_init_sorted(playlist, ops); + playlist_generic_init_sorted(playlist); break; } } diff --git a/core/playlists/user.c b/core/playlists/user.c index 61a4cc2a..b13a6304 100644 --- a/core/playlists/user.c +++ b/core/playlists/user.c @@ -3,7 +3,6 @@ */ #include -static struct queue_ops *user_pl_ops = NULL; static struct database user_db; static struct playlist_ops user_ops; @@ -16,7 +15,7 @@ static struct user_playlist *__user_db_alloc(gchar *name, unsigned int index) playlist->pl_playlist.pl_type = PL_USER; playlist->pl_playlist.pl_id = index; playlist->pl_playlist.pl_ops = &user_ops; - playlist_generic_init_sorted(&playlist->pl_playlist, user_pl_ops); + playlist_generic_init_sorted(&playlist->pl_playlist); return playlist; } @@ -131,9 +130,8 @@ struct playlist_type pl_user = { }; -void pl_user_init(struct queue_ops *ops) +void pl_user_init(void) { - user_pl_ops = ops; db_init(&user_db, "playlist.user", true, &user_db_ops, 0); db_load(&user_db); } diff --git a/core/queue.c b/core/queue.c deleted file mode 100644 index d280a0be..00000000 --- a/core/queue.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2013 (c) Anna Schumaker. - */ -#include -#include -#include - - -static inline void *__queue_init(struct queue *queue, void *data) -{ - if (queue->q_ops) - return queue->q_ops->qop_init(queue, data); - return NULL; -} - -void queue_init(struct queue *queue, const struct queue_ops *ops, void *data) -{ - queue->q_ops = ops; - queue->q_private = __queue_init(queue, data); -} diff --git a/gui/ocarina.c b/gui/ocarina.c index be494256..15f2ce80 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -33,7 +33,6 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina-debug"; struct core_init_data init_data = { .playlist_cb = &playlist_cb, - .playlist_ops = &playlist_ops, .audio_ops = &audio_ops, }; diff --git a/gui/playlist.c b/gui/playlist.c index 2a10964b..d32611cd 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -28,11 +28,6 @@ static inline void __gui_playlist_update_size(struct playlist *playlist) update_size[playlist->pl_type](playlist); } -static void *__gui_playlist_init(struct queue *queue, void *data) -{ - return data; -} - static void __gui_playlist_alloc(struct playlist *playlist) { if (playlist->pl_type == PL_ARTIST) @@ -53,10 +48,6 @@ static void __gui_playlist_removed(struct playlist *playlist, struct track *trac } -struct queue_ops playlist_ops = { - .qop_init = __gui_playlist_init, -}; - struct playlist_callbacks playlist_cb = { .pl_cb_alloc = __gui_playlist_alloc, .pl_cb_added = __gui_playlist_added, diff --git a/include/core/core.h b/include/core/core.h index 3f2dd021..85b315d3 100644 --- a/include/core/core.h +++ b/include/core/core.h @@ -3,12 +3,10 @@ */ #ifndef OCARINA_CORE_CORE_H #define OCARINA_CORE_CORE_H -#include - +#include struct core_init_data { struct playlist_callbacks *playlist_cb; - struct queue_ops *playlist_ops; struct audio_ops *audio_ops; #ifdef CONFIG_TESTING bool idle_async; diff --git a/include/core/playlist.h b/include/core/playlist.h index f22901c2..52f74744 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -14,7 +14,7 @@ /* Called to initialize the playlist manager. */ -void playlist_init(struct queue_ops *, struct playlist_callbacks *); +void playlist_init(struct playlist_callbacks *); /* Called to deinitialize the playlist manager. */ void playlist_deinit(); diff --git a/include/core/playlists/artist.h b/include/core/playlists/artist.h index 5e18a356..35da6bde 100644 --- a/include/core/playlists/artist.h +++ b/include/core/playlists/artist.h @@ -10,7 +10,7 @@ extern struct playlist_type pl_artist; /* Called to initialize artist playlists. */ -void pl_artist_init(struct queue_ops *ops); +void pl_artist_init(void); /* Called to deinitialize library playlists. */ void pl_artist_deinit(); diff --git a/include/core/playlists/generic.h b/include/core/playlists/generic.h index 45c00652..4d167047 100644 --- a/include/core/playlists/generic.h +++ b/include/core/playlists/generic.h @@ -40,16 +40,15 @@ struct playlist_callbacks { void playlist_generic_set_callbacks(struct playlist_callbacks *); /* Generic playlist init functions. */ -void playlist_generic_init(struct playlist *, struct queue_ops *); -void playlist_generic_init_sorted(struct playlist *, struct queue_ops *); +void playlist_generic_init(struct playlist *); +void playlist_generic_init_sorted(struct playlist *); /* Generic playlist deinit function. */ void playlist_generic_deinit(struct playlist *); /* Generic playlist alloc function. */ struct playlist *playlist_generic_alloc(gchar *, enum playlist_type_t, - unsigned int, struct playlist_ops *, - struct queue_ops *); + unsigned int, struct playlist_ops *); /* Generic playlist free function. */ void playlist_generic_free(struct playlist *); diff --git a/include/core/playlists/iterator.h b/include/core/playlists/iterator.h index 98abe5aa..2b8123bb 100644 --- a/include/core/playlists/iterator.h +++ b/include/core/playlists/iterator.h @@ -6,7 +6,6 @@ #ifndef OCARINA_CORE_PLAYLISTS_ITERATOR_H #define OCARINA_CORE_PLAYLISTS_ITERATOR_H #include -#include /* Called to set the playlist iterator to a specific position. */ static inline playlist_iter playlist_iter_get(struct playlist *playlist, diff --git a/include/core/playlists/library.h b/include/core/playlists/library.h index 512dc8a3..64aaea74 100644 --- a/include/core/playlists/library.h +++ b/include/core/playlists/library.h @@ -10,7 +10,7 @@ extern struct playlist_type pl_library; /* Called to initialize library playlists. */ -void pl_library_init(struct queue_ops *); +void pl_library_init(void); /* Called to deinitialize system playlists. */ void pl_library_deinit(); diff --git a/include/core/playlists/playlist.h b/include/core/playlists/playlist.h index a85ea2cd..23d7af5e 100644 --- a/include/core/playlists/playlist.h +++ b/include/core/playlists/playlist.h @@ -3,7 +3,6 @@ */ #ifndef OCARINA_CORE_PLAYLISTS_PLAYLIST_H #define OCARINA_CORE_PLAYLISTS_PLAYLIST_H -#include #include #include @@ -54,7 +53,6 @@ struct playlist { playlist_iter pl_current; /* This playlist's current track. */ GSList *pl_sort; /* This playlist's sort order. */ gchar **pl_search; /* This playlist's search text. */ - struct queue pl_queue; /* This playlist's queue of tracks. */ const struct playlist_ops *pl_ops; /* This playlist's supported operations. */ }; diff --git a/include/core/playlists/system.h b/include/core/playlists/system.h index 01e9edbe..566c79af 100644 --- a/include/core/playlists/system.h +++ b/include/core/playlists/system.h @@ -23,7 +23,7 @@ extern struct playlist_type pl_system; /* Called to initialize system playlists. */ -void pl_system_init(struct queue_ops *); +void pl_system_init(void); /* Called to deinitialize system playlists. */ void pl_system_deinit(); diff --git a/include/core/playlists/user.h b/include/core/playlists/user.h index c1648d7e..266a1771 100644 --- a/include/core/playlists/user.h +++ b/include/core/playlists/user.h @@ -18,7 +18,7 @@ extern struct playlist_type pl_user; /* Called to initialize user playlists. */ -void pl_user_init(struct queue_ops *ops); +void pl_user_init(void); /* Called to deinitialize user playlists. */ void pl_user_deinit(); diff --git a/include/core/queue.h b/include/core/queue.h deleted file mode 100644 index bcdec092..00000000 --- a/include/core/queue.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013 (c) Anna Schumaker. - * - * Queues are lists of tracks that the user has requested to play next. - * Users of queues are expected to implement their own save and load functions, - * and to provide a filled out queue_ops structure during initialization. - */ -#ifndef OCARINA_CORE_QUEUE_H -#define OCARINA_CORE_QUEUE_H - -#include -#include - -struct queue; - - -struct queue_ops { - /* Called to tell a higher layer that a queue has been initialized. */ - void *(*qop_init)(struct queue *, void *); -}; - - -struct queue { - void *q_private; /* The queue's private data. */ - - const struct queue_ops *q_ops; /* The queue's operations vector. */ -}; - - -/* Called to initialize a queue. */ -void queue_init(struct queue *, const struct queue_ops *, void *); - -#endif /* OCARINA_CORE_QUEUE_H */ diff --git a/include/gui/playlist.h b/include/gui/playlist.h index 2321442a..8b387aec 100644 --- a/include/gui/playlist.h +++ b/include/gui/playlist.h @@ -25,9 +25,6 @@ static inline GtkMenuItem *gui_rc_add_to_other() return GTK_MENU_ITEM(gui_builder_widget("rc_add_to_other")); } -/* Playlist operations passed to core_init() */ -extern struct queue_ops playlist_ops; - /* Playlist callbacks passed to core_init() */ extern struct playlist_callbacks playlist_cb; diff --git a/tests/core/.gitignore b/tests/core/.gitignore index 7134f6b1..d5a4adb8 100644 --- a/tests/core/.gitignore +++ b/tests/core/.gitignore @@ -5,6 +5,5 @@ date idle settings database -queue playlist audio diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index fe4d274f..c24f4d3b 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -13,7 +13,6 @@ core_unit_test(Settings) core_unit_test(Database) add_subdirectory(tags/) -core_unit_test(Queue) core_unit_test(Playlist) add_subdirectory(playlists/) core_unit_test(Audio) diff --git a/tests/core/playlist.c b/tests/core/playlist.c index a87aeb9e..2243a05d 100644 --- a/tests/core/playlist.c +++ b/tests/core/playlist.c @@ -9,6 +9,11 @@ static struct playlist *cb_playlist = NULL; static struct track *cb_track = NULL; +static void test_pl_alloc(struct playlist *playlist) +{ + cb_playlist = NULL; +} + static void test_pl_removed(struct playlist *playlist, struct track *track, unsigned int n) { @@ -31,6 +36,7 @@ static struct playlist_ops test_ops = { .pl_sort = playlist_generic_sort, }; static struct playlist_callbacks test_cb = { + .pl_cb_alloc = test_pl_alloc, .pl_cb_added = test_pl_callback, .pl_cb_removed = test_pl_removed, .pl_cb_updated = test_pl_callback, @@ -43,8 +49,8 @@ static void test_null() g_assert_false(playlist_delete(NULL)); playlist_generic_free(NULL); - playlist_generic_init(NULL, NULL); - playlist_generic_init_sorted(NULL, NULL); + playlist_generic_init(NULL); + playlist_generic_init_sorted(NULL); playlist_generic_deinit(NULL); g_assert_null(playlist_lookup(PL_MAX_TYPE, "NULL")); @@ -104,7 +110,7 @@ static void test_playlist() int i; g_assert_cmpuint(playlist_size(&p), ==, 0); - playlist_generic_init(&p, NULL); + playlist_generic_init(&p); g_assert_cmpuint(playlist_size(&p), ==, 0); g_assert_cmpuint(p.pl_length, ==, 0); @@ -196,7 +202,7 @@ static void test_sorting() struct track *track; unsigned int i; - playlist_generic_init_sorted(&p, NULL); + playlist_generic_init_sorted(&p); g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 3); playlist_clear_sort(&p); g_assert_cmpuint(g_slist_length(p.pl_sort), ==, 0); @@ -280,7 +286,7 @@ static void test_next() unsigned int i; g_random_set_seed(0); - playlist_generic_init(&p, NULL); + playlist_generic_init(&p); for (i = 0; i < 13; i++) playlist_generic_add(&p, track_get(i)); @@ -374,7 +380,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL, &test_cb); + playlist_init(&test_cb); while (idle_run_task()) {}; library = library_find("tests/Music"); diff --git a/tests/core/playlists/artist.c b/tests/core/playlists/artist.c index ab3a0cce..b049f3f1 100644 --- a/tests/core/playlists/artist.c +++ b/tests/core/playlists/artist.c @@ -24,7 +24,7 @@ void test_artist() g_assert_false(playlist_select(NULL)); pl_artist_deinit(); - pl_artist_init(NULL); + pl_artist_init(); while (idle_run_task()) {}; @@ -65,7 +65,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL, NULL); + playlist_init(NULL); while (idle_run_task()) {}; /* Add tracks to the collection. */ diff --git a/tests/core/playlists/library.c b/tests/core/playlists/library.c index dfd8b8f2..c3842bcc 100644 --- a/tests/core/playlists/library.c +++ b/tests/core/playlists/library.c @@ -53,7 +53,7 @@ void test_library() pl_library_deinit(); g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music")); g_assert_null(library->li_playlist); - pl_library_init(NULL); + pl_library_init(); while (idle_run_task()) {}; playlist = library->li_playlist; @@ -115,7 +115,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL, NULL); + playlist_init(NULL); while (idle_run_task()) {}; g_test_init(&argc, &argv, NULL); diff --git a/tests/core/playlists/system.c b/tests/core/playlists/system.c index ad9b7905..5b00d97c 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -365,7 +365,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL, NULL); + playlist_init(NULL); while (idle_run_task()) {}; g_test_init(&argc, &argv, NULL); diff --git a/tests/core/playlists/user.c b/tests/core/playlists/user.c index 4cd731ce..f8d5435b 100644 --- a/tests/core/playlists/user.c +++ b/tests/core/playlists/user.c @@ -53,7 +53,7 @@ void test_user() pl_user_deinit(); g_assert_cmpuint(db->db_size, ==, 0); - pl_user_init(NULL); + pl_user_init(); while (idle_run_task()) {}; g_assert_cmpuint(db->db_size, ==, 1); @@ -79,7 +79,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL, NULL); + playlist_init(NULL); while (idle_run_task()) {}; playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); diff --git a/tests/core/queue.c b/tests/core/queue.c deleted file mode 100644 index a85440eb..00000000 --- a/tests/core/queue.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -#include -#include -#include -#include - - -unsigned int count_init = 0; - - -static void *queue_op_init(struct queue *queue, void *data) -{ - count_init++; - return GUINT_TO_POINTER(count_init); -} - - -static const struct queue_ops test_ops = { - .qop_init = queue_op_init, -}; - - -static void test_init() -{ - struct queue q; - - queue_init(&q, NULL, NULL); - g_assert_cmpuint(count_init, ==, 0); - g_assert_null(q.q_private); - - g_assert_null(q.q_ops); - - queue_init(&q, &test_ops, NULL); - g_assert_cmpuint(count_init, ==, 1); - g_assert_cmpuint(GPOINTER_TO_UINT(q.q_private), ==, 1); - - g_assert(q.q_ops == &test_ops); -} - -int main(int argc, char **argv) -{ - struct library *library; - int ret; - - idle_init_sync(); - tags_init(); - while (idle_run_task()) {} - - 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"); - track_add(library, "tests/Music/Hyrule Symphony/03 - Hyrule Field.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/04 - Hyrule Castle.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/05 - Lon Lon Ranch.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/06 - Kakariko Village.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/07 - Death Mountain.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/08 - Zora's Domain.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/09 - Gerudo Valley.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/10 - Ganondorf.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/11 - Princess Zelda.ogg"); - track_add(library, "tests/Music/Hyrule Symphony/12 - Ocarina Medley.ogg"); - track_add(library, - "tests/Music/Hyrule Symphony/13 - The Legend of Zelda Medley.ogg"); - - g_test_init(&argc, &argv, NULL); - g_test_add_func("/Core/Queue/Initialization", test_init); - ret = g_test_run(); - - tags_deinit(); - idle_deinit(); - return ret; -} diff --git a/tests/gui/artwork.c b/tests/gui/artwork.c index 06c1068f..ce5f1231 100644 --- a/tests/gui/artwork.c +++ b/tests/gui/artwork.c @@ -23,7 +23,6 @@ static struct audio_ops test_audio_ops = { }; struct core_init_data init_data = { - .playlist_ops = &playlist_ops, .audio_ops = &test_audio_ops, #ifdef CONFIG_ALBUM_ART_TEST .idle_async = true, diff --git a/tests/gui/filter.c b/tests/gui/filter.c index 9db2abb9..35c82ce8 100644 --- a/tests/gui/filter.c +++ b/tests/gui/filter.c @@ -8,13 +8,6 @@ #include #include -void *test_queue_init(struct queue *queue, void *data) - { return NULL; } - -struct queue_ops test_ops = { - .qop_init = test_queue_init, -}; - void test_on_load(struct track *track) {} void test_on_state_change(GstState state) {} void test_on_config_pause(int count) {} @@ -26,8 +19,7 @@ struct audio_ops test_audio_ops = { }; struct core_init_data init_data = { - .playlist_ops = &test_ops, - .audio_ops = &test_audio_ops, + .audio_ops = &test_audio_ops, }; void test_filter() @@ -46,8 +38,6 @@ void test_filter() entry = GTK_ENTRY(gui_filter_search()); model = GTK_TREE_MODEL(gui_filter_get()); - playlist_lookup(PL_SYSTEM, "Collection")->pl_queue.q_private = - playlist_lookup(PL_SYSTEM, "Collection"); g_assert_false(gtk_tree_model_get_iter_first(model, &iter)); gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); diff --git a/tests/gui/model.c b/tests/gui/model.c index 8c6459f3..38d2ffd7 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -23,17 +23,11 @@ void on_row_changed(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { count_update++; } -void *test_queue_init(struct queue *queue, void *data) - { return NULL; } void test_cb_alloc(struct playlist *playlist) {} void test_on_load(struct track *track) {} void test_on_state_change(GstState state) {} void test_on_config_pause(int count) {} -struct queue_ops test_ops = { - .qop_init = test_queue_init, -}; - struct playlist_callbacks test_cb = { .pl_cb_alloc = test_cb_alloc, .pl_cb_added = gui_model_add, @@ -49,7 +43,6 @@ struct audio_ops test_audio_ops = { struct core_init_data init_data = { .playlist_cb = &test_cb, - .playlist_ops = &test_ops, .audio_ops = &test_audio_ops, }; @@ -174,8 +167,6 @@ static void test_model() /* Okay, now scan a directory ... */ collection = playlist_lookup(PL_SYSTEM, "Collection"); favorites = playlist_lookup(PL_SYSTEM, "Favorites"); - collection->pl_queue.q_private = collection; - favorites->pl_queue.q_private = favorites; playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); while (idle_run_task() == true) {} g_assert_cmpuint(playlist_size(collection), ==, 13); diff --git a/tests/gui/playlist.c b/tests/gui/playlist.c index 6ad76abc..76ae5e92 100644 --- a/tests/gui/playlist.c +++ b/tests/gui/playlist.c @@ -11,9 +11,7 @@ #include #include -struct core_init_data init_data = { - .playlist_ops = &playlist_ops, -}; +struct core_init_data init_data; static void test_playlist() { diff --git a/tests/gui/playlists/library.c b/tests/gui/playlists/library.c index bd31d796..abbccac0 100644 --- a/tests/gui/playlists/library.c +++ b/tests/gui/playlists/library.c @@ -11,9 +11,7 @@ #include #include -struct core_init_data init_data = { - .playlist_ops = &playlist_ops, -}; +struct core_init_data init_data; static void test_library() { diff --git a/tests/gui/playlists/system.c b/tests/gui/playlists/system.c index 1df70787..2aaa9e39 100644 --- a/tests/gui/playlists/system.c +++ b/tests/gui/playlists/system.c @@ -23,8 +23,8 @@ static struct audio_ops test_audio_ops = { }; struct core_init_data init_data = { - .playlist_ops = &playlist_ops, - .audio_ops = &test_audio_ops, + .playlist_cb = &playlist_cb, + .audio_ops = &test_audio_ops, }; static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" }; diff --git a/tests/gui/playlists/user.c b/tests/gui/playlists/user.c index 6943aeda..fb8413ed 100644 --- a/tests/gui/playlists/user.c +++ b/tests/gui/playlists/user.c @@ -11,9 +11,7 @@ #include #include -struct core_init_data init_data = { - .playlist_ops = &playlist_ops, -}; +struct core_init_data init_data; static void test_user() {