From 0754f10883350bc7e375ed655ba6f3d5bd02ff82 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 13 Sep 2016 11:10:34 -0400 Subject: [PATCH] core/playlist: Remove playlist_update() This was only used by system playlists to keep the unplayed, most played, and least played playlist up to date. We can handle this internally through the playlist_played() handler. Signed-off-by: Anna Schumaker --- core/playlist.c | 5 ----- core/playlists/artist.c | 5 ----- core/playlists/library.c | 17 +++++++---------- core/playlists/system.c | 1 - core/playlists/user.c | 5 ----- include/core/playlist.h | 4 ---- include/core/playlists/library.h | 3 +++ include/core/playlists/type.h | 3 --- tests/core/playlists/library.c | 4 ++-- tests/core/playlists/user.c | 1 - 10 files changed, 12 insertions(+), 36 deletions(-) diff --git a/core/playlist.c b/core/playlist.c index 220b5aa2..7aa84b39 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -180,11 +180,6 @@ bool playlist_remove(struct playlist *playlist, struct track *track) return ret; } -void playlist_update(enum playlist_type_t type, const gchar *name) -{ - playlist_types[type]->pl_update(name); -} - bool playlist_has(struct playlist *playlist, struct track *track) { if (!playlist || !track) diff --git a/core/playlists/artist.c b/core/playlists/artist.c index 40b28a6b..8ab8b83b 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -122,17 +122,12 @@ static void pl_artist_played(struct track *track) queue_updated(&playlist->pl_queue, track); } -static void pl_artist_update(const gchar *name) -{ -} - struct playlist_type pl_artist = { .pl_save = pl_artist_save, .pl_lookup = pl_artist_lookup, .pl_get = pl_artist_get, .pl_played = pl_artist_played, - .pl_update = pl_artist_update, }; diff --git a/core/playlists/library.c b/core/playlists/library.c index 45475737..e66161a8 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -253,13 +253,6 @@ static void pl_library_played(struct track *track) queue_updated(&playlist->pl_queue, track); } -static void pl_library_update(const gchar *name) -{ - struct playlist *playlist = __lib_pl_lookup(name); - if (playlist) - idle_schedule(IDLE_SYNC, __lib_pl_update, playlist); -} - struct playlist_type pl_library = { .pl_save = pl_library_save, @@ -267,7 +260,6 @@ struct playlist_type pl_library = { .pl_get = pl_library_get, .pl_new = pl_library_new, .pl_played = pl_library_played, - .pl_update = pl_library_update, }; @@ -282,8 +274,8 @@ void pl_library_init(struct queue_ops *ops) playlist = __lib_pl_alloc(LIBRARY(dbe)); LIBRARY(dbe)->li_playlist = playlist; - idle_schedule(IDLE_SYNC, __lib_pl_add, playlist); - pl_library_update(playlist->pl_name); + idle_schedule(IDLE_SYNC, __lib_pl_add, playlist); + idle_schedule(IDLE_SYNC, __lib_pl_update, playlist); } idle_schedule(IDLE_SYNC, __lib_pl_load, NULL); @@ -301,3 +293,8 @@ void pl_library_deinit() __lib_pl_free(playlist); } } + +void pl_library_update(struct playlist *playlist) +{ + idle_schedule(IDLE_SYNC, __lib_pl_update, playlist); +} diff --git a/core/playlists/system.c b/core/playlists/system.c index 936079ce..0ba5e78d 100644 --- a/core/playlists/system.c +++ b/core/playlists/system.c @@ -512,7 +512,6 @@ struct playlist_type pl_system = { .pl_lookup = pl_system_lookup, .pl_get = pl_system_get, .pl_played = pl_system_played, - .pl_update = pl_system_update, }; diff --git a/core/playlists/user.c b/core/playlists/user.c index 817fcede..aaabe43c 100644 --- a/core/playlists/user.c +++ b/core/playlists/user.c @@ -131,10 +131,6 @@ static void pl_user_played(struct track *track) } } -static void pl_user_update(const gchar *name) -{ -} - struct playlist_type pl_user = { .pl_save = pl_user_save, @@ -142,7 +138,6 @@ struct playlist_type pl_user = { .pl_get = pl_user_get, .pl_new = pl_user_new, .pl_played = pl_user_played, - .pl_update = pl_user_update, }; diff --git a/include/core/playlist.h b/include/core/playlist.h index 7829a10a..9fe9edf0 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -59,10 +59,6 @@ bool playlist_add(struct playlist *, struct track *); /* Called to remove a track from a playlist. */ bool playlist_remove(struct playlist *, struct track *); -/* Called to update tracks on a playlist. */ -void playlist_update(enum playlist_type_t, const gchar *); - - /* Called to check if a specific track is in the playlist. */ bool playlist_has(struct playlist *, struct track *); diff --git a/include/core/playlists/library.h b/include/core/playlists/library.h index c9091533..4ab239e0 100644 --- a/include/core/playlists/library.h +++ b/include/core/playlists/library.h @@ -16,4 +16,7 @@ void pl_library_init(struct queue_ops *); /* Called to deinitialize system playlists. */ void pl_library_deinit(); +/* Called to update a library path. */ +void pl_library_update(struct playlist *); + #endif /* OCARINA_CORE_PLAYLISTS_LIBRARY_H */ diff --git a/include/core/playlists/type.h b/include/core/playlists/type.h index bf2a4897..368ea4d4 100644 --- a/include/core/playlists/type.h +++ b/include/core/playlists/type.h @@ -76,9 +76,6 @@ struct playlist_type { /* Called to notify that a track has been played. */ void (*pl_played)(struct track *); - - /* Called to update a playlist. */ - void (*pl_update)(const gchar *); }; diff --git a/tests/core/playlists/library.c b/tests/core/playlists/library.c index 1f3b6136..59d4e14b 100644 --- a/tests/core/playlists/library.c +++ b/tests/core/playlists/library.c @@ -84,14 +84,14 @@ void test_library() g_assert_cmpuint(g_slist_length(playlist->pl_queue.q_sort), ==, 1); g_rename("tests/Music/Hyrule Symphony/", "tests/Hyrule Symphony/"); - playlist_update(PL_LIBRARY, "tests/Music"); + pl_library_update(playlist); while (idle_run_task()) {} g_assert_cmpuint(db_actual_size(track_db_get()), ==, 48); g_assert_cmpuint(track_db_get()->db_size, ==, 35); g_assert_cmpuint(playlist_size(playlist), ==, 35); g_rename("tests/Hyrule Symphony", "tests/Music/Hyrule Symphony/"); - playlist_update(PL_LIBRARY, "tests/Music"); + pl_library_update(playlist); while (idle_run_task()) {} g_assert_cmpuint(db_actual_size(track_db_get()), ==, 61); g_assert_cmpuint(track_db_get()->db_size, ==, 48); diff --git a/tests/core/playlists/user.c b/tests/core/playlists/user.c index 883412bf..2df6cc52 100644 --- a/tests/core/playlists/user.c +++ b/tests/core/playlists/user.c @@ -49,7 +49,6 @@ void test_user() g_assert_cmpuint(playlist_size(playlist), ==, 1); playlist_played(track_get(0)); - playlist_update(PL_USER, "Test Playlist"); pl_user_deinit(); g_assert_cmpuint(db->db_size, ==, 0); pl_user_init(NULL);