diff --git a/core/playlist.c b/core/playlist.c index ae82067c..ff7568bf 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -61,6 +61,11 @@ bool playlist_remove(enum playlist_t plist, struct track *track) return pl_system.pl_remove_track(playlist_names[plist], track); } +void playlist_update(enum playlist_t plist) +{ + pl_system.pl_update(playlist_names[plist]); +} + bool playlist_has(enum playlist_t plist, struct track *track) { struct queue *queue = pl_system.pl_get_queue(playlist_names[plist]); diff --git a/core/playlists/system.c b/core/playlists/system.c index c0393aae..c327b328 100644 --- a/core/playlists/system.c +++ b/core/playlists/system.c @@ -79,11 +79,17 @@ static bool pl_system_remove_track(const gchar *name, struct track *track) return true; } +static void pl_system_update(const gchar *name) +{ + return; +} + struct playlist_type pl_system = { .pl_get_queue = pl_system_get_queue, .pl_add_track = pl_system_add_track, .pl_remove_track = pl_system_remove_track, + .pl_update = pl_system_update, }; diff --git a/include/core/playlist.h b/include/core/playlist.h index 53a0325a..dad4d4d4 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -33,6 +33,9 @@ bool playlist_add(enum playlist_t, struct track *); /* Called to remove a track from a playlist. */ bool playlist_remove(enum playlist_t, struct track *); +/* Called to update tracks on a playlist. */ +void playlist_update(enum playlist_t); + /* Called to check if a specific track is in the playlist. */ bool playlist_has(enum playlist_t, struct track *); diff --git a/include/core/playlists/type.h b/include/core/playlists/type.h index a47b74d7..f4498657 100644 --- a/include/core/playlists/type.h +++ b/include/core/playlists/type.h @@ -18,6 +18,9 @@ struct playlist_type { /* Called to remove a track from the playlist. */ bool (*pl_remove_track)(const gchar *, struct track *); + + /* Called to update a playlist. */ + void (*pl_update)(const gchar *); }; diff --git a/tests/core/playlists/system.c b/tests/core/playlists/system.c index 186bfe72..d19781d3 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -27,6 +27,12 @@ test_equal(pl_system.pl_remove_track(name, track_get(1)), (bool)false); \ __test_playlist_state(queue, 0, false, false) +#define __test_playlist_update(name, queue, ex_size, ex_track0, ex_track1) \ + pl_system.pl_update(name); \ + while (idle_run_task()) {}; \ + __test_playlist_state(queue, ex_size, ex_track0, ex_track1) + + #define __test_playlist_reinit(queue, ex_size, ex_track0, ex_track1) \ pl_system_deinit(); \ pl_system_init(NULL); \ @@ -70,6 +76,7 @@ static void test_favorites() __test_playlist_add("Favorites", queue); __test_playlist_reinit(queue, 2, true, true); + __test_playlist_update("Favorites", queue, 2, true, true); __test_playlist_remove("Favorites", queue); } @@ -82,6 +89,7 @@ static void test_hidden() __test_playlist_add("Hidden", queue); __test_playlist_reinit(queue, 2, true, true); + __test_playlist_update("Hidden", queue, 2, true, true); __test_playlist_remove("Hidden", queue); pl_system_deinit();