diff options
-rw-r--r-- | apps/buffering.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 4176f27d22..fd386fd29f 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -884,31 +884,40 @@ int bufopen(const char *file, size_t offset, enum data_type type) | |||
884 | } | 884 | } |
885 | 885 | ||
886 | strncpy(h->path, file, MAX_PATH); | 886 | strncpy(h->path, file, MAX_PATH); |
887 | h->filerem = size - offset; | ||
888 | h->offset = offset; | 887 | h->offset = offset; |
889 | h->ridx = buf_widx; | 888 | h->ridx = buf_widx; |
890 | h->widx = buf_widx; | ||
891 | h->data = buf_widx; | 889 | h->data = buf_widx; |
892 | h->available = 0; | ||
893 | h->type = type; | 890 | h->type = type; |
894 | 891 | ||
895 | #ifdef HAVE_ALBUMART | 892 | #ifdef HAVE_ALBUMART |
896 | if (type == TYPE_BITMAP) { | 893 | if (type == TYPE_BITMAP) |
894 | { | ||
897 | /* Bitmap file: we load the data instead of the file */ | 895 | /* Bitmap file: we load the data instead of the file */ |
896 | int rc; | ||
898 | mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */ | 897 | mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */ |
899 | size = load_bitmap(fd); | 898 | rc = load_bitmap(fd); |
900 | if (size <= 0) | 899 | if (rc <= 0) |
900 | { | ||
901 | rm_handle(h); | ||
902 | close(fd); | ||
903 | mutex_unlock(&llist_mutex); | ||
901 | return ERR_FILE_ERROR; | 904 | return ERR_FILE_ERROR; |
902 | 905 | } | |
903 | h->filerem = 0; | 906 | h->filerem = 0; |
904 | h->available = size; | 907 | h->filesize = rc; |
905 | h->widx = buf_widx + size; /* safe because the data doesn't wrap */ | 908 | h->available = rc; |
906 | buf_widx += size; /* safe too */ | 909 | h->widx = buf_widx + rc; /* safe because the data doesn't wrap */ |
910 | buf_widx += rc; /* safe too */ | ||
907 | mutex_unlock(&llist_mutex); | 911 | mutex_unlock(&llist_mutex); |
908 | } | 912 | } |
913 | else | ||
909 | #endif | 914 | #endif |
910 | 915 | { | |
911 | h->filesize = size; | 916 | h->filerem = size - offset; |
917 | h->filesize = size; | ||
918 | h->available = 0; | ||
919 | h->widx = buf_widx; | ||
920 | } | ||
912 | 921 | ||
913 | if (type == TYPE_CUESHEET) { | 922 | if (type == TYPE_CUESHEET) { |
914 | h->fd = fd; | 923 | h->fd = fd; |