From 56e5d1a0a1f87f24635207f70c42b5efc3fe35ab Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 9 Oct 2002 13:47:38 +0000 Subject: Better handling of bad playlists, and when all tracks fit in memory git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2550 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'firmware') diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 104b6c5011..f149814dac 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -57,6 +57,7 @@ extern void bitswap(unsigned char *data, int length); extern char* playlist_peek(int steps); extern int playlist_next(int steps); +extern int playlist_amount(void); extern void update_file_pos( int id, int pos ); static char *units[] = @@ -709,6 +710,7 @@ static int add_track_to_tag_list(char *filename) /* If next_track is true, opens the next track, if false, opens prev track */ static int new_file(int steps) { + int max_steps = playlist_amount(); int start = num_tracks_in_memory() - 1; if (start < 0) @@ -727,6 +729,10 @@ static int new_file(int steps) if(mpeg_file < 0) { DEBUGF("Couldn't open file: %s\n",trackname); steps++; + + /* Bail out if no file could be opened */ + if(steps > max_steps) + return -1; } else { -- cgit v1.2.3