summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2020-12-09 13:17:05 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-12-25 17:47:19 +0000
commitca09f91f647f6677fea7804930d7d1b2c876f76e (patch)
tree03f6b4e5659deb7f52b315478d8106babaf358ab /apps/playback.c
parentb5e6c30a61047e89f6cb1299a81453a80b79cc37 (diff)
downloadrockbox-ca09f91f647f6677fea7804930d7d1b2c876f76e.tar.gz
rockbox-ca09f91f647f6677fea7804930d7d1b2c876f76e.zip
Fix deadlocks when trying to buffer large album art.
Internally, buffering tries to load the entire album art file into the audio buffer, which will fail if the file is larger than the buffer. Playback.c interprets a file failing to buffer to mean that the buffer is full, so it waits for more space and tries again. This results in a deadlock since the file will never fit. Change bufopen to return a new error condition when an image file will not fit on the buffer because it is too large: ERR_BITMAP_TOO_LARGE. Note that we arbitrarily set "too large" to be within 64KB of the entire buffer size or larger, this could be adjusted if needed. Change audio_load_albumart to pass through error messages from bufopen. In playback.c, check to see why audio_load_albumart fails. If it fails because the file is too large to buffer, simply ignore the file. If it fails because the file would fit but the buffer is full, try again later. Change-Id: I66799ae26f124b495e1522fce7285332f4cf986f
Diffstat (limited to 'apps/playback.c')
-rwxr-xr-x[-rw-r--r--]apps/playback.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 31aed2abe1..5419888c27 100644..100755
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1689,7 +1689,7 @@ static bool audio_load_cuesheet(struct track_info *infop,
1689 1689
1690#ifdef HAVE_ALBUMART 1690#ifdef HAVE_ALBUMART
1691/* Load any album art for the file - returns false if the buffer is full */ 1691/* Load any album art for the file - returns false if the buffer is full */
1692static bool audio_load_albumart(struct track_info *infop, 1692static int audio_load_albumart(struct track_info *infop,
1693 struct mp3entry *track_id3) 1693 struct mp3entry *track_id3)
1694{ 1694{
1695 FOREACH_ALBUMART(i) 1695 FOREACH_ALBUMART(i)
@@ -1730,7 +1730,11 @@ static bool audio_load_albumart(struct track_info *infop,
1730 if (hid == ERR_BUFFER_FULL) 1730 if (hid == ERR_BUFFER_FULL)
1731 { 1731 {
1732 logf("buffer is full for now (%s)", __func__); 1732 logf("buffer is full for now (%s)", __func__);
1733 return false; 1733 return ERR_BUFFER_FULL;
1734 }
1735 else if (hid == ERR_BITMAP_TOO_LARGE){
1736 logf("image is too large to fit in buffer (%s)", __func__);
1737 return ERR_BITMAP_TOO_LARGE;
1734 } 1738 }
1735 else 1739 else
1736 { 1740 {
@@ -1981,7 +1985,12 @@ static int audio_finish_load_track(struct track_info *infop)
1981 1985
1982#ifdef HAVE_ALBUMART 1986#ifdef HAVE_ALBUMART
1983 /* Try to load album art for the track */ 1987 /* Try to load album art for the track */
1984 if (!audio_load_albumart(infop, track_id3)) 1988 int retval = audio_load_albumart(infop, track_id3);
1989 if (retval == ERR_BITMAP_TOO_LARGE)
1990 {
1991 /* No space for album art on buffer because the file is larger than the buffer.
1992 Ignore the file and keep buffering */
1993 } else if (retval == ERR_BUFFER_FULL)
1985 { 1994 {
1986 /* No space for album art on buffer, not an error */ 1995 /* No space for album art on buffer, not an error */
1987 filling = STATE_FULL; 1996 filling = STATE_FULL;