diff --git a/CHANGELOG b/CHANGELOG index 21ba80ee..19d42066 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.16: +- Reduce time spent polling for album art - Split album art code into a new file - Fix PKGBUILD dependencies diff --git a/gui/artwork.c b/gui/artwork.c index 9b8ed67e..7fd92952 100644 --- a/gui/artwork.c +++ b/gui/artwork.c @@ -6,6 +6,7 @@ #include static struct album *__artwork_cur_album = NULL; +static unsigned int __artwork_timeo_id = 0; static GdkPixbuf *__artwork_get_pixbuf(struct track *track) { @@ -24,14 +25,14 @@ static GdkPixbuf *__artwork_get_pixbuf(struct track *track) return pix; } -void gui_artwork_set_cover(void) +static bool __artwork_set_pixbuf(void) { GtkImage *cover = GTK_IMAGE(gui_builder_widget("o_cover")); struct track *track = audio_cur_track(); GdkPixbuf *pix; if (!track || track->tr_album == __artwork_cur_album) - return; + return true; pix = __artwork_get_pixbuf(track); if (pix) { @@ -42,6 +43,22 @@ void gui_artwork_set_cover(void) gtk_widget_set_sensitive(GTK_WIDGET(cover), pix != NULL); __artwork_cur_album = pix ? track->tr_album : NULL; + return (pix != NULL); +} + +static gboolean __artwork_timeout(gpointer data) +{ + if (__artwork_set_pixbuf()) { + __artwork_timeo_id = 0; + return G_SOURCE_REMOVE; + } + return G_SOURCE_CONTINUE; +} + +void gui_artwork_set_cover(void) +{ + if (!__artwork_set_pixbuf() && __artwork_timeo_id == 0) + __artwork_timeo_id = g_timeout_add(2000, __artwork_timeout, NULL); } void __artwork_select_cover(GtkButton *button) diff --git a/gui/audio.c b/gui/audio.c index f0a01f5b..126ca662 100644 --- a/gui/audio.c +++ b/gui/audio.c @@ -95,9 +95,6 @@ static int __audio_timeout(gpointer data) gtk_adjustment_set_upper(progress, audio_duration() / GST_SECOND); gtk_adjustment_set_value(progress, audio_position() / GST_SECOND); __audio_set_time_label("o_position", audio_position() / GST_SECOND); - - gui_artwork_set_cover(); - return G_SOURCE_CONTINUE; }