From 22633d66a22e4fd16625d1da6219d72c22f80dcd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Aug 2002 07:58:18 +0000 Subject: Check the return code from each call to mp3info(), as it might return true to indicate a bad mp3 file. TODO: when having a dir full of zero-byte mp3 files and pressing play on one using the simulator, this'll go crazy. TO CHECK: I haven't checked how the live target code behaves on this. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1922 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 71 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'firmware') diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 0117102e57..2e3080f47d 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -606,7 +606,11 @@ static void add_track_to_tag_list(char *filename) { /* grab id3 tag of new file and remember where in memory it starts */ - mp3info(&(t->id3), filename); + if(mp3info(&(t->id3), filename)) + { + DEBUGF("Bad mp3\n"); + return; + } t->mempos = mp3buf_write; t->id3.elapsed = 0; if(!append_tag(t)) @@ -1220,14 +1224,23 @@ bool mpeg_has_changed_track(void) void mpeg_play(int offset) { #ifdef SIMULATOR - char* trackname = playlist_next( 0, NULL ); - if ( trackname ) { - mp3info(&taginfo, trackname); - taginfo.offset = offset; - set_elapsed(&taginfo); - playing = true; - } - (void)offset; + char* trackname; + int steps=0; + + do { + trackname = playlist_next( steps, NULL ); + if ( trackname ) { + if(mp3info(&taginfo, trackname)) { + /* bad mp3, move on */ + steps++; + continue; + } + taginfo.offset = offset; + set_elapsed(&taginfo); + playing = true; + break; + } + } while(1); #else queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset); #endif @@ -1267,10 +1280,19 @@ void mpeg_next(void) #ifndef SIMULATOR queue_post(&mpeg_queue, MPEG_NEXT, NULL); #else - char* file = playlist_next(1,NULL); - mp3info(&taginfo, file); - current_track_counter++; - playing = true; + char* file; + int steps = 1; + + do { + file = playlist_next(steps, NULL); + if(mp3info(&taginfo, file)) { + steps++; + continue; + } + current_track_counter++; + playing = true; + break; + } while(1); #endif } @@ -1279,10 +1301,19 @@ void mpeg_prev(void) #ifndef SIMULATOR queue_post(&mpeg_queue, MPEG_PREV, NULL); #else - char* file = playlist_next(-1,NULL); - mp3info(&taginfo, file); - current_track_counter++; - playing = true; + char* file; + int steps = -1; + + do { + file = playlist_next(steps, NULL); + if(mp3info(&taginfo, file)) { + steps--; + continue; + } + current_track_counter++; + playing = true; + break; + } while(1); #endif } @@ -1638,3 +1669,9 @@ void mpeg_init(int volume, int bass, int treble, int balance, int loudness, int memset(id3tags, sizeof(id3tags), 0); memset(_id3tags, sizeof(id3tags), 0); } + +/* ----------------------------------------------------------------- + * local variables: + * eval: (load-file "rockbox-mode.el") + * end: + */ -- cgit v1.2.3