From e71bc67d94599be70da6f79365e765ea02d6b698 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sun, 11 Nov 2007 21:27:18 +0000 Subject: Fix an issue that appeared in r15577, where skipping back to a track that has no audio data left, but still has its metadata and album art, would fail. The fix is to also clear the filesize member (as it should have been previously) to force a rebuffer when skipping back. To prevent the album art bitmap from flashing on the back skip, the whole track info struct is cleared when the track isn't needed anymore, i.e. after the PCM track change. Also a slightly unrelated but trivial change: only load album art if it's not already loaded. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15588 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/playback.c b/apps/playback.c index 497f250a9c..2488de7abc 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -234,6 +234,7 @@ static volatile int track_ridx = 0; /* Track being decoded (A/C-) */ static int track_widx = 0; /* Track being buffered (A) */ #define CUR_TI (&tracks[track_ridx]) /* Playing track info pointer (A/C-) */ +static struct track_info *prev_ti; /* Pointer to the previous track played */ /* Set by the audio thread when the current track information has updated * and the WPS may need to update its cached information */ @@ -2415,7 +2416,7 @@ static bool audio_load_track(int offset, bool start_play) track_id3 = bufgetid3(tracks[track_widx].id3_hid); #ifdef HAVE_ALBUMART - if (gui_sync_wps_uses_albumart()) + if (tracks[track_widx].aa_hid < 0 && gui_sync_wps_uses_albumart()) { char aa_path[MAX_PATH]; if (find_albumart(track_id3, aa_path, sizeof(aa_path))) @@ -2665,9 +2666,12 @@ static int audio_check_new_track(void) new_playlist = false; } - /* Save the old track to allow the WPS to display it */ + /* Save the old track's metadata to allow the WPS to display it */ copy_mp3entry(&prevtrack_id3, &curtrack_id3); + /* Save a pointer to the old track to allow later clearing */ + prev_ti = CUR_TI; + for (i = 0; i < ci.new_track; i++) { idx = (track_ridx + i) & MAX_TRACK_MASK; @@ -2678,7 +2682,10 @@ static int audio_check_new_track(void) /* We don't have all the audio data for that track, so clear it, but keep the metadata. */ if (tracks[idx].audio_hid >= 0 && bufclose(tracks[idx].audio_hid)) + { tracks[idx].audio_hid = -1; + tracks[idx].filesize = 0; + } } } @@ -2959,6 +2966,13 @@ static void audio_finalise_track_change(void) automatic_skip = false; } prevtrack_id3.path[0] = 0; + + if (prev_ti->audio_hid < 0) + { + /* No audio left so we clear all the track info. */ + clear_track_info(prev_ti); + } + if (track_changed_callback) track_changed_callback(&curtrack_id3); track_changed = true; -- cgit v1.2.3