diff --git a/core/core.c b/core/core.c index 8f813c7c..5a621c5c 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); + playlist_init(init->playlist_ops, 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 c982fa54..143f3efd 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -33,8 +33,9 @@ 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) +void playlist_init(struct queue_ops *ops, struct playlist_callbacks *cb) { + playlist_generic_set_callbacks(cb); pl_system_init(ops); pl_artist_init(ops); pl_user_init(ops); diff --git a/core/playlists/generic.c b/core/playlists/generic.c index 8acae980..9647201e 100644 --- a/core/playlists/generic.c +++ b/core/playlists/generic.c @@ -4,10 +4,14 @@ #include #include +static struct playlist_callbacks *callbacks = NULL; + + +void playlist_generic_set_callbacks(struct playlist_callbacks *cb) +{ + callbacks = cb; +} -/* - * Generic playlist operations. - */ void playlist_generic_init(struct playlist *playlist, unsigned int flags, struct queue_ops *ops) { diff --git a/gui/ocarina.c b/gui/ocarina.c index c1a714fd..be494256 100644 --- a/gui/ocarina.c +++ b/gui/ocarina.c @@ -32,8 +32,9 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina-debug"; #endif struct core_init_data init_data = { - &playlist_ops, - &audio_ops, + .playlist_cb = &playlist_cb, + .playlist_ops = &playlist_ops, + .audio_ops = &audio_ops, }; static int startup_argc; diff --git a/gui/playlist.c b/gui/playlist.c index 34ec4a8c..ced41d70 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -75,6 +75,9 @@ struct queue_ops playlist_ops = { .qop_updated = __gui_playlist_updated, }; +struct playlist_callbacks playlist_cb = { +}; + static void __gui_playlist_add_selected_to(struct playlist *playlist) { diff --git a/include/core/core.h b/include/core/core.h index 803037cf..3f2dd021 100644 --- a/include/core/core.h +++ b/include/core/core.h @@ -7,6 +7,7 @@ struct core_init_data { + struct playlist_callbacks *playlist_cb; struct queue_ops *playlist_ops; struct audio_ops *audio_ops; #ifdef CONFIG_TESTING diff --git a/include/core/playlist.h b/include/core/playlist.h index 3bb062a8..a8e1b412 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 *); +void playlist_init(struct queue_ops *, struct playlist_callbacks *); /* Called to deinitialize the playlist manager. */ void playlist_deinit(); diff --git a/include/core/playlists/generic.h b/include/core/playlists/generic.h index 739dade8..cf5b08ae 100644 --- a/include/core/playlists/generic.h +++ b/include/core/playlists/generic.h @@ -5,6 +5,13 @@ #define OCARINA_CORE_PLAYLISTS_GENERIC_H #include +struct playlist_callbacks { +}; + + +/* Called to set playlist callbacks. */ +void playlist_generic_set_callbacks(struct playlist_callbacks *); + /* Generic playlist init function. */ void playlist_generic_init(struct playlist *, unsigned int, struct queue_ops *); diff --git a/include/gui/playlist.h b/include/gui/playlist.h index 6cf1c4aa..2321442a 100644 --- a/include/gui/playlist.h +++ b/include/gui/playlist.h @@ -28,5 +28,7 @@ static inline GtkMenuItem *gui_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; #endif /* OCARINA_GUI_PLAYLIST_H */ diff --git a/tests/core/playlist.c b/tests/core/playlist.c index bd1bb984..e6ac647f 100644 --- a/tests/core/playlist.c +++ b/tests/core/playlist.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL); + playlist_init(NULL, NULL); while (idle_run_task()) {}; library = library_find("tests/Music"); diff --git a/tests/core/playlists/artist.c b/tests/core/playlists/artist.c index ce39f60b..c5e9f759 100644 --- a/tests/core/playlists/artist.c +++ b/tests/core/playlists/artist.c @@ -63,7 +63,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL); + playlist_init(NULL, 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 59d4e14b..3c5a51e8 100644 --- a/tests/core/playlists/library.c +++ b/tests/core/playlists/library.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL); + playlist_init(NULL, 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 46e01760..bc8f0a68 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -362,7 +362,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL); + playlist_init(NULL, 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 2df6cc52..63574608 100644 --- a/tests/core/playlists/user.c +++ b/tests/core/playlists/user.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) idle_init_sync(); settings_init(); tags_init(); - playlist_init(NULL); + playlist_init(NULL, NULL); while (idle_run_task()) {}; playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");