diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-08-28 11:43:49 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-08-28 11:43:49 +0000 |
commit | 606b0f545dadb245ae262cc1daaa4b301cc9a595 (patch) | |
tree | 6e59cf35a547c76bd8d42cd33d7a5e70b1ea4c15 /firmware/mpeg.c | |
parent | e8b856e45473bbd0b99e48e6890726d87f1d27ac (diff) |
More error handling, handles empty MP3 files now
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2030 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 5969dca577..1f24ea7425 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -615,7 +615,7 @@ void IMIA1(void) TSR1 &= ~0x01; } -static void add_track_to_tag_list(char *filename) +static int add_track_to_tag_list(char *filename) { struct id3tag *t = NULL; int i; @@ -631,7 +631,7 @@ static void add_track_to_tag_list(char *filename) if(mp3info(&(t->id3), filename)) { DEBUGF("Bad mp3\n"); - return; + return -1; } t->mempos = mp3buf_write; t->id3.elapsed = 0; @@ -646,6 +646,7 @@ static void add_track_to_tag_list(char *filename) { DEBUGF("No memory available for id3 tag"); } + return 0; } /* If next_track is true, opens the next track, if false, opens prev track */ @@ -672,13 +673,22 @@ static int new_file(int steps) index = playlist_next(steps); - add_track_to_tag_list(trackname); - /* skip past id3v2 tag (to an even byte) */ - lseek(mpeg_file, - id3tags[new_tag_idx]->id3.id3v2len & ~1, - SEEK_SET); - id3tags[new_tag_idx]->id3.index = index; - id3tags[new_tag_idx]->id3.offset = 0; + if(add_track_to_tag_list(trackname)) + { + /* Bad mp3 file */ + steps++; + close(mpeg_file); + mpeg_file = -1; + } + else + { + /* skip past id3v2 tag (to an even byte) */ + lseek(mpeg_file, + id3tags[new_tag_idx]->id3.id3v2len & ~1, + SEEK_SET); + id3tags[new_tag_idx]->id3.index = index; + id3tags[new_tag_idx]->id3.offset = 0; + } } } while ( mpeg_file < 0 ); |