From 685aeb5d7d5c0f5c2c33a5c951e51237611dd999 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Mon, 15 Nov 2004 00:34:19 +0000 Subject: Handle invalid playlist entries properly in new_file(). This fixes bug report #1060759 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5410 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 2ad708d6d7..e801f9c845 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -839,7 +839,18 @@ static int add_track_to_tag_list(const char *filename) static int new_file(int steps) { int max_steps = playlist_amount(); - int start = num_tracks_in_memory() - 1; + int start = 0; + int i; + + /* Find out how many steps to advance. Each loaded tag has a "steps" member + that tells us how many playlist entries it had to skip to get to + a valid one. We add those together to find out where to start. */ + i = tag_read_idx; + while(i != tag_write_idx) + { + start += id3tags[i]->id3.index; + i = (i+1) & MAX_ID3_TAGS_MASK; + } if (start < 0) start = 0; -- cgit v1.2.3