From 35352221b284123997c414ae17e2879a70617bce Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 1 May 2009 08:01:40 +0000 Subject: [PATCH] * Don't bother checking embedded art if the last hash matches, and it was invalid. --- albumart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/albumart.c b/albumart.c index 545e2e2..f69b545 100644 --- a/albumart.c +++ b/albumart.c @@ -102,6 +102,7 @@ check_embedded_art(const char * path, const char * image_data, int image_size) size_t nwritten; static char last_path[PATH_MAX]; static unsigned int last_hash = 0; + static int last_success = 0; unsigned int hash; if( !image_data || !image_size || !path ) @@ -113,6 +114,8 @@ check_embedded_art(const char * path, const char * image_data, int image_size) hash = DJBHash(image_data, image_size); if( hash == last_hash ) { + if( !last_success ) + return NULL; asprintf(&art_path, DB_PATH "/art_cache%s", path); if( link(last_path, art_path) == 0 ) { @@ -133,10 +136,14 @@ check_embedded_art(const char * path, const char * image_data, int image_size) art_path = NULL; } } + last_hash = hash; imsrc = image_new_from_jpeg(NULL, 0, image_data, image_size); if( !imsrc ) + { + last_success = 0; return NULL; + } width = imsrc->width; height = imsrc->height; @@ -174,10 +181,11 @@ end_art: if( !art_path ) { DPRINTF(E_WARN, L_METADATA, "Invalid embedded album art in %s\n", basename((char *)path)); + last_success = 0; return NULL; } DPRINTF(E_DEBUG, L_METADATA, "Found new embedded album art in %s\n", basename((char *)path)); - last_hash = hash; + last_success = 1; strcpy(last_path, art_path); return(art_path);