diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-01 23:31:43 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-01 23:31:43 +0000 |
commit | 54e6eb3bdaea5a904d77a50866cb400857427c08 (patch) | |
tree | b4fcb445f7e005cf50db9bdb36bcb5cb6fbddb76 /apps/buffering.c | |
parent | 60d420938372477226184fb9012de7f6b4ea2d83 (diff) | |
download | rockbox-54e6eb3bdaea5a904d77a50866cb400857427c08.tar.gz rockbox-54e6eb3bdaea5a904d77a50866cb400857427c08.zip |
Search for, and load, JPEG album art files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20837 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index a4d425fb1d..66bd22f12d 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include "metadata.h" | 53 | #include "metadata.h" |
54 | #ifdef HAVE_ALBUMART | 54 | #ifdef HAVE_ALBUMART |
55 | #include "albumart.h" | 55 | #include "albumart.h" |
56 | #include "jpeg_load.h" | ||
56 | #endif | 57 | #endif |
57 | 58 | ||
58 | #define GUARD_BUFSIZE (32*1024) | 59 | #define GUARD_BUFSIZE (32*1024) |
@@ -830,9 +831,10 @@ static bool fill_buffer(void) | |||
830 | /* Given a file descriptor to a bitmap file, write the bitmap data to the | 831 | /* Given a file descriptor to a bitmap file, write the bitmap data to the |
831 | buffer, with a struct bitmap and the actual data immediately following. | 832 | buffer, with a struct bitmap and the actual data immediately following. |
832 | Return value is the total size (struct + data). */ | 833 | Return value is the total size (struct + data). */ |
833 | static int load_bitmap(int fd) | 834 | static int load_image(int fd, const char *path) |
834 | { | 835 | { |
835 | int rc; | 836 | int rc; |
837 | int pathlen = strlen(path); | ||
836 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; | 838 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; |
837 | /* FIXME: alignment may be needed for the data buffer. */ | 839 | /* FIXME: alignment may be needed for the data buffer. */ |
838 | bmp->data = &buffer[buf_widx + sizeof(struct bitmap)]; | 840 | bmp->data = &buffer[buf_widx + sizeof(struct bitmap)]; |
@@ -846,8 +848,12 @@ static int load_bitmap(int fd) | |||
846 | 848 | ||
847 | get_albumart_size(bmp); | 849 | get_albumart_size(bmp); |
848 | 850 | ||
849 | rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| | 851 | if (strcmp(path + pathlen - 4, ".bmp")) |
850 | FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); | 852 | rc = read_jpeg_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| |
853 | FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); | ||
854 | else | ||
855 | rc = read_bmp_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER| | ||
856 | FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL); | ||
851 | return rc + (rc > 0 ? sizeof(struct bitmap) : 0); | 857 | return rc + (rc > 0 ? sizeof(struct bitmap) : 0); |
852 | } | 858 | } |
853 | #endif | 859 | #endif |
@@ -942,7 +948,7 @@ int bufopen(const char *file, size_t offset, enum data_type type) | |||
942 | /* Bitmap file: we load the data instead of the file */ | 948 | /* Bitmap file: we load the data instead of the file */ |
943 | int rc; | 949 | int rc; |
944 | mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */ | 950 | mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */ |
945 | rc = load_bitmap(fd); | 951 | rc = load_image(fd, file); |
946 | mutex_unlock(&llist_mutex); | 952 | mutex_unlock(&llist_mutex); |
947 | if (rc <= 0) | 953 | if (rc <= 0) |
948 | { | 954 | { |