diff options
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 20 |
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 @@ | |||
54 | #ifdef HAVE_ALBUMART | 54 | #ifdef HAVE_ALBUMART |
55 | #include "albumart.h" | 55 | #include "albumart.h" |
56 | #include "jpeg_load.h" | 56 | #include "jpeg_load.h" |
57 | #include "bmp.h" | ||
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | #define GUARD_BUFSIZE (32*1024) | 60 | #define GUARD_BUFSIZE (32*1024) |
@@ -843,10 +844,13 @@ static bool fill_buffer(void) | |||
843 | /* Given a file descriptor to a bitmap file, write the bitmap data to the | 844 | /* Given a file descriptor to a bitmap file, write the bitmap data to the |
844 | buffer, with a struct bitmap and the actual data immediately following. | 845 | buffer, with a struct bitmap and the actual data immediately following. |
845 | Return value is the total size (struct + data). */ | 846 | Return value is the total size (struct + data). */ |
846 | static int load_image(int fd, const char *path) | 847 | static int load_image(int fd, const char *path, struct dim *dim) |
847 | { | 848 | { |
848 | int rc; | 849 | int rc; |
849 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; | 850 | struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx]; |
851 | |||
852 | /* get the desired image size */ | ||
853 | bmp->width = dim->width, bmp->height = dim->height; | ||
850 | /* FIXME: alignment may be needed for the data buffer. */ | 854 | /* FIXME: alignment may be needed for the data buffer. */ |
851 | bmp->data = &buffer[buf_widx + sizeof(struct bitmap)]; | 855 | bmp->data = &buffer[buf_widx + sizeof(struct bitmap)]; |
852 | #ifndef HAVE_JPEG | 856 | #ifndef HAVE_JPEG |
@@ -859,8 +863,6 @@ static int load_image(int fd, const char *path) | |||
859 | int free = (int)MIN(buffer_len - BUF_USED, buffer_len - buf_widx) | 863 | int free = (int)MIN(buffer_len - BUF_USED, buffer_len - buf_widx) |
860 | - sizeof(struct bitmap); | 864 | - sizeof(struct bitmap); |
861 | 865 | ||
862 | get_albumart_size(bmp); | ||
863 | |||
864 | #ifdef HAVE_JPEG | 866 | #ifdef HAVE_JPEG |
865 | int pathlen = strlen(path); | 867 | int pathlen = strlen(path); |
866 | if (strcmp(path + pathlen - 4, ".bmp")) | 868 | if (strcmp(path + pathlen - 4, ".bmp")) |
@@ -897,11 +899,19 @@ management functions for all the actual handle management work. | |||
897 | filename: name of the file to open | 899 | filename: name of the file to open |
898 | offset: offset at which to start buffering the file, useful when the first | 900 | offset: offset at which to start buffering the file, useful when the first |
899 | (offset-1) bytes of the file aren't needed. | 901 | (offset-1) bytes of the file aren't needed. |
902 | type: one of the data types supported (audio, image, cuesheet, others | ||
903 | user_data: user data passed possibly passed in subcalls specific to a | ||
904 | data_type (only used for image (albumart) buffering so far ) | ||
900 | return value: <0 if the file cannot be opened, or one file already | 905 | return value: <0 if the file cannot be opened, or one file already |
901 | queued to be opened, otherwise the handle for the file in the buffer | 906 | queued to be opened, otherwise the handle for the file in the buffer |
902 | */ | 907 | */ |
903 | int bufopen(const char *file, size_t offset, enum data_type type) | 908 | int bufopen(const char *file, size_t offset, enum data_type type, |
909 | void *user_data) | ||
904 | { | 910 | { |
911 | #ifndef HAVE_ALBUMART | ||
912 | /* currently only used for aa loading */ | ||
913 | (void)user_data; | ||
914 | #endif | ||
905 | if (type == TYPE_ID3) | 915 | if (type == TYPE_ID3) |
906 | { | 916 | { |
907 | /* ID3 case: allocate space, init the handle and return. */ | 917 | /* 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) | |||
967 | /* Bitmap file: we load the data instead of the file */ | 977 | /* Bitmap file: we load the data instead of the file */ |
968 | int rc; | 978 | int rc; |
969 | mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields */ | 979 | mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields */ |
970 | rc = load_image(fd, file); | 980 | rc = load_image(fd, file, (struct dim*)user_data); |
971 | mutex_unlock(&llist_mod_mutex); | 981 | mutex_unlock(&llist_mod_mutex); |
972 | if (rc <= 0) | 982 | if (rc <= 0) |
973 | { | 983 | { |