From 075bb99742965df104866267c45f4fde26bc7fd1 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Tue, 8 Mar 2011 19:18:43 +0100 Subject: [PATCH] Introduce artwork_get_item_filename() --- src/artwork.c | 38 +++++++++++++++++++++++++------------- src/artwork.h | 3 +++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/artwork.c b/src/artwork.c index eb7b32ba..419f370a 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -471,6 +471,8 @@ artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *e int format_ok; int ret; + DPRINTF(E_DBG, L_ART, "Artwork request parameters: max w = %d, max h = %d\n", max_w, max_h); + ret = av_open_input_file(&src_ctx, filename, NULL, 0, NULL); if (ret < 0) { @@ -684,33 +686,43 @@ artwork_get_dir_image(char *path, int isdir, int max_w, int max_h, int format, s int -artwork_get_item(int id, int max_w, int max_h, int format, struct evbuffer *evbuf) +artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf) { - char *filename; int ret; - DPRINTF(E_DBG, L_ART, "Artwork request for item %d, max w = %d, max h = %d\n", id, max_w, max_h); - - filename = db_file_path_byid(id); - if (!filename) - return -1; - /* FUTURE: look at embedded artwork */ /* Look for basename(filename).{png,jpg} */ ret = artwork_get_own_image(filename, max_w, max_h, format, evbuf); if (ret > 0) - goto out; + return ret; /* Look for basedir(filename)/{artwork,cover}.{png,jpg} */ ret = artwork_get_dir_image(filename, 0, max_w, max_h, format, evbuf); if (ret > 0) - goto out; + return ret; - DPRINTF(E_DBG, L_ART, "No artwork found for item id %d\n", id); + return -1; +} + +int +artwork_get_item(int id, int max_w, int max_h, int format, struct evbuffer *evbuf) +{ + char *filename; + int ret; + + DPRINTF(E_DBG, L_ART, "Artwork request for item %d\n", id); + + filename = db_file_path_byid(id); + if (!filename) + return -1; + + ret = artwork_get_item_filename(filename, max_w, max_h, format, evbuf); + if (ret < 0) + DPRINTF(E_DBG, L_ART, "No artwork found for item id %d\n", id); - out: free(filename); + return ret; } @@ -723,7 +735,7 @@ artwork_get_group(int id, int max_w, int max_h, int format, struct evbuffer *evb int got_art; int ret; - DPRINTF(E_DBG, L_ART, "Artwork request for group %d, max w = %d, max h = %d\n", id, max_w, max_h); + DPRINTF(E_DBG, L_ART, "Artwork request for group %d\n", id); /* Try directory artwork first */ memset(&qp, 0, sizeof(struct query_params)); diff --git a/src/artwork.h b/src/artwork.h index 8db0b90b..ccfc26b2 100644 --- a/src/artwork.h +++ b/src/artwork.h @@ -9,6 +9,9 @@ #define ART_FMT_JPEG 2 +int +artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf); + int artwork_get_item(int id, int max_w, int max_h, int format, struct evbuffer *evbuf);