From a430c5b117d45b9b0edeb25fdedfd89f4cc07660 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 28 Aug 2016 09:46:16 -0400 Subject: [PATCH] core/playlists/artist: Add artist playlists as artists are added Scanning new library paths should also add artist playlists, otherwise they won't show up until Ocarina is restarted. Fixes #79: Artist playlists not updated when tracks are added Signed-off-by: Anna Schumaker --- core/playlists/artist.c | 13 +++++++++++++ core/playlists/library.c | 3 ++- include/core/playlists/artist.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/playlists/artist.c b/core/playlists/artist.c index 54b7506b..ca5ec4a9 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -123,3 +123,16 @@ void pl_artist_deinit() __artist_pl_free(playlist); } } + +void pl_artist_new_track(struct track *track) +{ + struct artist *artist = track->tr_artist; + struct playlist *playlist = (struct playlist *)artist->ar_playlist; + + if (!playlist) { + playlist = __artist_pl_alloc(artist->ar_name); + artist->ar_playlist = playlist; + } + + queue_add(&playlist->pl_queue, track); +} diff --git a/core/playlists/library.c b/core/playlists/library.c index 65eb1a3e..f6dd0593 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -2,7 +2,7 @@ * Copyright 2016 (c) Anna Schumaker. */ #include -#include +#include #include #include #include @@ -84,6 +84,7 @@ static void __lib_pl_read_path(struct scan_data *scan, const gchar *name) if (track) { queue_add(&playlist->pl_queue, track); pl_system_new_track(track); + pl_artist_new_track(track); } } } diff --git a/include/core/playlists/artist.h b/include/core/playlists/artist.h index 6bd73399..afa02f32 100644 --- a/include/core/playlists/artist.h +++ b/include/core/playlists/artist.h @@ -15,4 +15,7 @@ void pl_artist_init(struct queue_ops *ops); /* Called to deinitialize library playlists. */ void pl_artist_deinit(); +/* Called to tell system playlists about a new track. */ +void pl_artist_new_track(struct track *); + #endif /* OCARINA_CORE_PLAYLISTS_ARTIST_H */