1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Daniel Stenberg 2002-08-22 07:59:31 +00:00
parent 22633d66a2
commit ae3952ec90

View file

@ -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;
}