diff --git a/core/core.c b/core/core.c index ed0ea0f0..8d533027 100644 --- a/core/core.c +++ b/core/core.c @@ -1,10 +1,8 @@ /* * Copyright 2014 (c) Anna Schumaker. */ -#include #include #include -#include #include #include @@ -18,13 +16,14 @@ static bool core_defragment(void *data) return true; } -void core_init(int *argc, char ***argv, struct core_init_data *init) +void core_init(int *argc, char ***argv, struct playlist_callbacks *playlist_cb, + struct audio_callbacks *audio_cb, enum idle_sync_t idle_sync) { - idle_init(init->idle_sync); + idle_init(idle_sync); settings_init(); tags_init(); - playlist_init(init->playlist_cb); - audio_init(argc, argv, init->audio_cb); + playlist_init(playlist_cb); + audio_init(argc, argv, audio_cb); idle_schedule(IDLE_SYNC, core_defragment, NULL); } diff --git a/gui/ocarina.c b/gui/ocarina.c index 09bac98a..6e70501e 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -32,12 +32,7 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina"; const static gchar *OCARINA_APP = "org.gtk.ocarina-debug"; #endif -static struct core_init_data init_data = { - .playlist_cb = &playlist_cb, - .audio_cb = &audio_cb, - .idle_sync = IDLE_ASYNC, -}; - +static enum idle_sync_t idle_sync = IDLE_ASYNC; static int startup_argc; static char **startup_argv; @@ -61,7 +56,7 @@ static int __ocarina_local_options(GApplication *application, GVariantDict *options, gpointer data) { if (g_variant_dict_contains(options, "sync")) - init_data.idle_sync = IDLE_SYNC; + idle_sync = IDLE_SYNC; if (!g_variant_dict_contains(options, "version")) return -1; g_printf("Ocarina %s\n", get_version()); @@ -103,7 +98,7 @@ static void __ocarina_startup(GApplication *application, gpointer data) gchar *icon = find_file_path("ocarina.png"); gui_builder_init(ui); - core_init(&startup_argc, &startup_argv, &init_data); + core_init(&startup_argc, &startup_argv, &playlist_cb, &audio_cb, idle_sync); gui_window_init(icon); gui_model_init(); gui_filter_init(); diff --git a/include/core/core.h b/include/core/core.h index f99d4b7c..1f69d670 100644 --- a/include/core/core.h +++ b/include/core/core.h @@ -3,18 +3,14 @@ */ #ifndef OCARINA_CORE_CORE_H #define OCARINA_CORE_CORE_H +#include +#include #include #include -struct core_init_data { - struct playlist_callbacks *playlist_cb; - struct audio_callbacks *audio_cb; - enum idle_sync_t idle_sync; -}; - - /* Called to initialize all core Ocarina components. */ -void core_init(int *, char ***, struct core_init_data *); +void core_init(int *, char ***, struct playlist_callbacks *, + struct audio_callbacks *, enum idle_sync_t); /* Called to deinitialize all core Ocarina componentns. */ void core_deinit(); diff --git a/include/core/playlist.h b/include/core/playlist.h index 52f74744..09e6eb1a 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -8,6 +8,7 @@ #ifndef OCARINA_CORE_PLAYLIST_H #define OCARINA_CORE_PLAYLIST_H #include +#include #include #include #include diff --git a/tests/core/audio.c b/tests/core/audio.c index e120003e..fcc76e3f 100644 --- a/tests/core/audio.c +++ b/tests/core/audio.c @@ -47,10 +47,6 @@ static struct audio_callbacks test_audio_cb = { .audio_cb_config_pause = test_config_pause, }; -static struct core_init_data test_init_data = { - .audio_cb = &test_audio_cb, -}; - static void test_init() { @@ -59,7 +55,7 @@ static void test_init() g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_NULL); g_assert_null(audio_next()); - core_init(NULL, NULL, &test_init_data); + core_init(NULL, NULL, NULL, &test_audio_cb, IDLE_SYNC); g_assert_false(audio_load(NULL)); g_assert_null(audio_next()); diff --git a/tests/gui/artwork.c b/tests/gui/artwork.c index 1ab1d022..02de67d0 100644 --- a/tests/gui/artwork.c +++ b/tests/gui/artwork.c @@ -22,14 +22,12 @@ static struct audio_callbacks test_audio_cb = { .audio_cb_config_pause = test_config_pause, }; -struct core_init_data init_data = { - .audio_cb = &test_audio_cb, #ifdef CONFIG_ALBUM_ART_TEST - .idle_sync = IDLE_ASYNC, +enum idle_sync_t test_sync = IDLE_ASYNC; #else /* CONFIG_ALBUM_ART_TEST */ - .idle_sync = IDLE_SYNC, +enum idle_sync_t test_sync = IDLE_SYNC; #endif /* CONFIG_ALBUM_ART_TEST */ -}; + static void test_artwork(void) { @@ -77,7 +75,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, NULL, &test_audio_cb, test_sync); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/audio.c b/tests/gui/audio.c index 990d07e9..bbbeb88d 100644 --- a/tests/gui/audio.c +++ b/tests/gui/audio.c @@ -16,10 +16,6 @@ #include #include -struct core_init_data init_data = { - .audio_cb = &audio_cb, -}; - static void test_audio_init() { g_assert_cmpstr(gtk_label_get_text(gui_album_tag()), ==, " "); @@ -123,7 +119,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, NULL, &audio_cb, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/filter.c b/tests/gui/filter.c index 833aa59b..f9e2a081 100644 --- a/tests/gui/filter.c +++ b/tests/gui/filter.c @@ -8,8 +8,6 @@ #include #include -static struct core_init_data init_data; - void test_filter() { struct track *track; @@ -79,7 +77,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_window_init("share/ocarina/ocarina.png"); gui_model_init(); diff --git a/tests/gui/idle.c b/tests/gui/idle.c index 08220def..24ddd7e3 100644 --- a/tests/gui/idle.c +++ b/tests/gui/idle.c @@ -8,7 +8,6 @@ static const unsigned int N = 100; static unsigned int cur = -1; -struct core_init_data init_data; static bool inc_cur(void *data) { @@ -45,7 +44,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_test_init(); while (idle_run_task()) {} diff --git a/tests/gui/model.c b/tests/gui/model.c index d2c67a90..b31cb2e8 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -32,10 +32,6 @@ struct playlist_callbacks test_cb = { .pl_cb_updated = gui_model_update, }; -struct core_init_data init_data = { - .playlist_cb = &test_cb, -}; - static void test_init() { GuiModel *model = gui_model_get(); @@ -271,7 +267,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, &test_cb, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); while (idle_run_task()) {}; diff --git a/tests/gui/playlist.c b/tests/gui/playlist.c index 76ae5e92..d4194cd5 100644 --- a/tests/gui/playlist.c +++ b/tests/gui/playlist.c @@ -11,8 +11,6 @@ #include #include -struct core_init_data init_data; - static void test_playlist() { GtkTreeIter iter, child; @@ -59,7 +57,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/playlists/artist.c b/tests/gui/playlists/artist.c index 021cdf3b..9f6bcacf 100644 --- a/tests/gui/playlists/artist.c +++ b/tests/gui/playlists/artist.c @@ -11,10 +11,6 @@ #include #include -struct core_init_data init_data = { - .playlist_cb = &playlist_cb, -}; - static void test_artist() { GtkTreeModel *model = gui_sidebar_model(); @@ -46,7 +42,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, &playlist_cb, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/playlists/library.c b/tests/gui/playlists/library.c index abbccac0..a9b94350 100644 --- a/tests/gui/playlists/library.c +++ b/tests/gui/playlists/library.c @@ -11,8 +11,6 @@ #include #include -struct core_init_data init_data; - static void test_library() { GtkTreeModel *model = gui_sidebar_model(); @@ -58,7 +56,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/playlists/system.c b/tests/gui/playlists/system.c index e16de074..802e7186 100644 --- a/tests/gui/playlists/system.c +++ b/tests/gui/playlists/system.c @@ -22,11 +22,6 @@ static struct audio_callbacks test_audio_cb = { .audio_cb_config_pause = test_config_pause, }; -struct core_init_data init_data = { - .playlist_cb = &playlist_cb, - .audio_cb = &test_audio_cb, -}; - static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" }; static const gchar *playlists[2] = {"Favorites", "Hidden" }; static const gchar *dynamic[3] = {"Most Played", "Least Played", "Unplayed" }; @@ -102,7 +97,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, &playlist_cb, &test_audio_cb, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/playlists/user.c b/tests/gui/playlists/user.c index fb8413ed..7e512db4 100644 --- a/tests/gui/playlists/user.c +++ b/tests/gui/playlists/user.c @@ -11,8 +11,6 @@ #include #include -struct core_init_data init_data; - static void test_user() { GtkTreeModel *model = gui_sidebar_model(); @@ -70,7 +68,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/sidebar.c b/tests/gui/sidebar.c index 23947038..ef8ba50d 100644 --- a/tests/gui/sidebar.c +++ b/tests/gui/sidebar.c @@ -16,7 +16,6 @@ const gchar *test_pl_names[8] = { "Collection", "", "Dynamic", "", "Library" }; const gchar *test_dyn_names[3] = { "Least Played", "Most Played", "Unplayed" }; -struct core_init_data init_data; static void test_sidebar() { @@ -231,7 +230,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, &argv, &init_data); + core_init(&argc, &argv, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init(); diff --git a/tests/gui/treeview.c b/tests/gui/treeview.c index 352d7054..66d57ab0 100644 --- a/tests/gui/treeview.c +++ b/tests/gui/treeview.c @@ -25,8 +25,6 @@ const gchar *GUI_COL_SETTINGS[GUI_MODEL_N_COLUMNS] = { [GUI_MODEL_FONT] = "gui.queue.font", }; -static struct core_init_data init_data; - void test_treeview_init() { GtkTreePath *path; @@ -221,7 +219,7 @@ int main(int argc, char **argv) int ret; gtk_init(&argc, NULL); - core_init(&argc, NULL, &init_data); + core_init(&argc, NULL, NULL, NULL, IDLE_SYNC); gui_builder_init("share/ocarina/ocarina.ui"); gui_model_init(); gui_filter_init();