summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-10-16 22:57:24 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-10-16 22:57:24 +0200
commitdc707a1f6d57105f9a81289ad113f1a33e9c7e79 (patch)
treebda2afb9795bcd960d2c3fc2b12d882d499d3e8f
parent739fc31d262031e8d2dd661b5f439f8628e57f64 (diff)
gtkui: fixed default cover image on resize
-rw-r--r--plugins/gtkui/coverart.c37
-rw-r--r--plugins/gtkui/coverart.h3
-rw-r--r--plugins/gtkui/plcommon.c3
3 files changed, 38 insertions, 5 deletions
diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c
index 0e08d180..98e60c57 100644
--- a/plugins/gtkui/coverart.c
+++ b/plugins/gtkui/coverart.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <assert.h>
#ifdef __linux__
#include <sys/prctl.h>
#endif
@@ -34,6 +35,9 @@
extern DB_artwork_plugin_t *coverart_plugin;
+
+GdkPixbuf *pixbuf_default;
+
#define MAX_ID 256
#define CACHE_SIZE 20
@@ -170,11 +174,6 @@ loading_thread (void *none) {
g_error_free (error);
error = NULL;
}
- const char *defpath = coverart_plugin->get_default_cover ();
- pixbuf = gdk_pixbuf_new_from_file_at_scale (defpath, queue->width, queue->width, TRUE, &error);
- if (!pixbuf) {
- fprintf (stderr, "default cover: gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", defpath, queue->width, error->message);
- }
}
if (error) {
g_error_free (error);
@@ -370,7 +369,35 @@ cover_art_free (void) {
}
}
memset (cache, 0, sizeof (cache));
+ if (pixbuf_default) {
+ g_object_unref (pixbuf_default);
+ pixbuf_default = NULL;
+ }
deadbeef->cond_free (cond);
+ cond = 0;
deadbeef->mutex_free (mutex);
+ mutex = 0;
}
+GdkPixbuf *
+cover_get_default_pixbuf (void) {
+ if (!pixbuf_default) {
+ GError *error = NULL;
+ const char *defpath = coverart_plugin->get_default_cover ();
+ pixbuf_default = gdk_pixbuf_new_from_file (defpath, &error);
+ if (!pixbuf_default) {
+ fprintf (stderr, "default cover: gdk_pixbuf_new_from_file %s failed, error: %s\n", defpath, error->message);
+ }
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ }
+ if (!pixbuf_default) {
+ pixbuf_default = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 2, 2);
+ }
+ assert (pixbuf_default);
+ }
+
+ g_object_ref (pixbuf_default);
+ return pixbuf_default;
+}
diff --git a/plugins/gtkui/coverart.h b/plugins/gtkui/coverart.h
index d3658caf..39f371cc 100644
--- a/plugins/gtkui/coverart.h
+++ b/plugins/gtkui/coverart.h
@@ -45,5 +45,8 @@ cover_art_free (void);
void
queue_cover_callback (void (*callback)(void *user_data), void *user_data);
+GdkPixbuf *
+cover_get_default_pixbuf (void);
+
#endif
diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c
index b509cbd7..750c3d75 100644
--- a/plugins/gtkui/plcommon.c
+++ b/plugins/gtkui/plcommon.c
@@ -227,6 +227,9 @@ void draw_column_data (DdbListview *listview, cairo_t *cr, DdbListviewIter it, D
h = min (height, art_h);
GdkPixbuf *pixbuf = get_cover_art_callb (deadbeef->pl_find_meta (((DB_playItem_t *)group_it), ":URI"), artist, album, real_art_width == art_width ? art_width : -1, redraw_playlist_single, listview);
+ if (!pixbuf) {
+ pixbuf = cover_get_default_pixbuf ();
+ }
if (pixbuf) {
art_width = gdk_pixbuf_get_width (pixbuf);
float art_scale = (float)real_art_width / art_width;