summaryrefslogtreecommitdiffstats
path: root/firmware/id3.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-22 07:59:31 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-22 07:59:31 +0000
commitae3952ec90ba7d86ea046b0553cc5e4c1d626b65 (patch)
treecc7632bfd58446a1ec99a349bdeccf472ea99645 /firmware/id3.c
parent22633d66a22e4fd16625d1da6219d72c22f80dcd (diff)
downloadrockbox-ae3952ec90ba7d86ea046b0553cc5e4c1d626b65.tar.gz
rockbox-ae3952ec90ba7d86ea046b0553cc5e4c1d626b65.zip
make mp3info() better return true on bad mp3 files, also make
getsonglength() return 0 if the length is unknown git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1923 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/id3.c')
-rw-r--r--firmware/id3.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index b373c9b77c..d97e7b7986 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -379,7 +379,7 @@ static bool mp3frameheader(unsigned long head)
* entry - the entry to update with the length
*
* Returns: the song length in milliseconds,
- * -1 means that it couldn't be calculated
+ * 0 means that it couldn't be calculated
*/
static int getsonglength(int fd, struct mp3entry *entry)
{
@@ -408,13 +408,13 @@ static int getsonglength(int fd, struct mp3entry *entry)
/* Start searching after ID3v2 header */
if(-1 == lseek(fd, entry->id3v2len, SEEK_SET))
- return -1;
+ return 0;
/* Fill up header with first 24 bits */
for(version = 0; version < 3; version++) {
header <<= 8;
if(!read(fd, &tmp, 1))
- return -1;
+ return 0;
header |= tmp;
}
@@ -424,13 +424,13 @@ static int getsonglength(int fd, struct mp3entry *entry)
do {
header <<= 8;
if(!read(fd, &tmp, 1))
- return -1;
+ return 0;
header |= tmp;
/* Quit if we haven't found a valid header within 128K */
bytecount++;
if(bytecount > 0x20000)
- return -1;
+ return 0;
} while(!mp3frameheader(header));
/*
@@ -631,6 +631,11 @@ bool mp3info(struct mp3entry *entry, char *filename)
close(fd);
+ if(!entry->length || (entry->filesize < 8 ))
+ /* no song length or less than 8 bytes is hereby considered to be an
+ invalid mp3 and won't be played by us! */
+ return true;
+
return false;
}