From 5964c508cece7f48a21fce4497fe9240b7f532b4 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 13 Aug 2016 09:38:28 -0400 Subject: [PATCH] core/playlists/artists: Load each playlist with a different idle task This seems less efficient overall, since we now need to take several passes over the track database. What I've noticed is that the single-pass option creates a lot of UI notifications that makes the gui unresponsive for a large amount of time. Breaking this into smaller chunks gives us a chance to handle any user actions between loading each playlist. Fixes #71: Initalize artist playlists with more idle tasks Signed-off-by: Anna Schumaker --- CHANGELOG | 1 + core/playlists/artist.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9d471658..88315314 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.18: +- Load each artist playlist in a separate idle task - UI spacing improvements 6.4.18-rc: diff --git a/core/playlists/artist.c b/core/playlists/artist.c index f1b7d14d..54b7506b 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -28,13 +28,16 @@ static void __artist_pl_free(struct playlist *playlist) static bool __artist_pl_load(void *data) { - struct playlist *playlist; + struct playlist *playlist = (struct playlist *)data; + struct artist *artist = artist_lookup(playlist->pl_name); struct db_entry *dbe, *next; + queue_set_flag(&playlist->pl_queue, Q_ADD_FRONT); db_for_each(dbe, next, track_db_get()) { - playlist = TRACK(dbe)->tr_artist->ar_playlist; - queue_add(&playlist->pl_queue, TRACK(dbe)); + if (TRACK(dbe)->tr_artist == artist) + queue_add(&playlist->pl_queue, TRACK(dbe)); } + queue_unset_flag(&playlist->pl_queue, Q_ADD_FRONT); return true; } @@ -95,6 +98,8 @@ static bool __artist_pl_init(void *data) db_for_each(dbe, next, artist_db_get()) { playlist = __artist_pl_alloc(ARTIST(dbe)->ar_name); ARTIST(dbe)->ar_playlist = playlist; + + idle_schedule(IDLE_SYNC, __artist_pl_load, playlist); } return true; @@ -104,7 +109,6 @@ void pl_artist_init(struct queue_ops *ops) { artist_ops = ops; idle_schedule(IDLE_SYNC, __artist_pl_init, NULL); - idle_schedule(IDLE_SYNC, __artist_pl_load, NULL); } void pl_artist_deinit()