Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 0595c776095e1fdc4d5626a0c65806893c064197 Mon Sep 17 00:00:00 2001
- From: Max Eliaser <max@maxxedout.net>
- Date: Thu, 6 Jun 2019 21:17:42 -0700
- Subject: [PATCH] Fix infinite retry loop when an album art file won't fit in
- in-memory buffer.
- The existing error code, ERR_BUFFER_FULL, signified a buffer that was
- temporarily too full. It would trigger a flush of buffered files and a reload.
- However, if the file actually exceeded the buffer size completely, the
- allocation for it would never succeed, triggering an infinite loop. The UI
- would remain responsive but no music would play.
- This commit adds a new error code, ERR_BUFFER_TOO_SMALL, which is NOT retried.
- It will be used in cases where the buffer is just too small, and no amount of
- flushing will make the file fit.
- Since there is already code to handle if an audio file won't fit in the
- buffer, behavior is only altered for image files.
- ---
- apps/buffering.c | 3 +++
- apps/buffering.h | 11 ++++++-----
- 2 files changed, 9 insertions(+), 5 deletions(-)
- diff --git a/apps/buffering.c b/apps/buffering.c
- index 9ffd35714c..6cd3b13f88 100644
- --- a/apps/buffering.c
- +++ b/apps/buffering.c
- @@ -992,6 +992,9 @@ int bufopen(const char *file, off_t offset, enum data_type type,
- /* Reserve extra space because alignment can move data forward */
- size_t padded_size = STORAGE_PAD(size - adjusted_offset);
- + if (padded_size > buffer_len && type == TYPE_BITMAP)
- + return ERR_BUFFER_TOO_SMALL;
- +
- mutex_lock(&llist_mutex);
- h = add_handle(hflags, padded_size, file, &data);
- diff --git a/apps/buffering.h b/apps/buffering.h
- index fcffcf086c..692d8fa785 100644
- --- a/apps/buffering.h
- +++ b/apps/buffering.h
- @@ -42,11 +42,12 @@ enum data_type {
- /* Error return values */
- #define ERR_HANDLE_NOT_FOUND -1
- #define ERR_BUFFER_FULL -2
- -#define ERR_INVALID_VALUE -3
- -#define ERR_FILE_ERROR -4
- -#define ERR_HANDLE_NOT_DONE -5
- -#define ERR_UNSUPPORTED_TYPE -6
- -#define ERR_WRONG_THREAD -7
- +#define ERR_BUFFER_TOO_SMALL -3
- +#define ERR_INVALID_VALUE -4
- +#define ERR_FILE_ERROR -5
- +#define ERR_HANDLE_NOT_DONE -6
- +#define ERR_UNSUPPORTED_TYPE -7
- +#define ERR_WRONG_THREAD -8
- /* Initialise the buffering subsystem */
- void buffering_init(void) INIT_ATTR;
- --
- 2.20.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement