summaryrefslogtreecommitdiff
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-10-16 19:14:41 +0000
committerThomas Martitz <kugel@rockbox.org>2009-10-16 19:14:41 +0000
commite9c10189e93fe53cff74ae8fa15d19b1c522d5e4 (patch)
treee3c39a41ff160194dfd9ce617893e0367a6fdcc8 /apps/buffering.c
parenta72ffe7bb533302dbf4e6c7c4f1e4bd4078d3ed6 (diff)
Rework albumart buffering internally to allow for mutliple albumart sizes.
Playback now has a few albumart slots. Anything (most importantly: skins) can obtain such a slot. The slot has fields for the size which is passed to bufopen then to image_load to buffer the albumart with the proper size. Currently there's 1 slot. We can increase it for remotes if we want. Custom statusbar will increase it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23209 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 08590c9fdf..e66e95d66d 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -54,6 +54,7 @@
#ifdef HAVE_ALBUMART
#include "albumart.h"
#include "jpeg_load.h"
+#include "bmp.h"
#endif
#define GUARD_BUFSIZE (32*1024)
@@ -843,10 +844,13 @@ static bool fill_buffer(void)
/* Given a file descriptor to a bitmap file, write the bitmap data to the
buffer, with a struct bitmap and the actual data immediately following.
Return value is the total size (struct + data). */
-static int load_image(int fd, const char *path)
+static int load_image(int fd, const char *path, struct dim *dim)
{
int rc;
struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx];
+
+ /* get the desired image size */
+ bmp->width = dim->width, bmp->height = dim->height;
/* FIXME: alignment may be needed for the data buffer. */
bmp->data = &buffer[buf_widx + sizeof(struct bitmap)];
#ifndef HAVE_JPEG
@@ -859,8 +863,6 @@ static int load_image(int fd, const char *path)
int free = (int)MIN(buffer_len - BUF_USED, buffer_len - buf_widx)
- sizeof(struct bitmap);
- get_albumart_size(bmp);
-
#ifdef HAVE_JPEG
int pathlen = strlen(path);
if (strcmp(path + pathlen - 4, ".bmp"))
@@ -897,11 +899,19 @@ management functions for all the actual handle management work.
filename: name of the file to open
offset: offset at which to start buffering the file, useful when the first
(offset-1) bytes of the file aren't needed.
+ type: one of the data types supported (audio, image, cuesheet, others
+ user_data: user data passed possibly passed in subcalls specific to a
+ data_type (only used for image (albumart) buffering so far )
return value: <0 if the file cannot be opened, or one file already
queued to be opened, otherwise the handle for the file in the buffer
*/
-int bufopen(const char *file, size_t offset, enum data_type type)
+int bufopen(const char *file, size_t offset, enum data_type type,
+ void *user_data)
{
+#ifndef HAVE_ALBUMART
+ /* currently only used for aa loading */
+ (void)user_data;
+#endif
if (type == TYPE_ID3)
{
/* ID3 case: allocate space, init the handle and return. */
@@ -967,7 +977,7 @@ int bufopen(const char *file, size_t offset, enum data_type type)
/* Bitmap file: we load the data instead of the file */
int rc;
mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields */
- rc = load_image(fd, file);
+ rc = load_image(fd, file, (struct dim*)user_data);
mutex_unlock(&llist_mod_mutex);
if (rc <= 0)
{