summaryrefslogtreecommitdiff
path: root/firmware/id3.c
diff options
context:
space:
mode:
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)
379 * entry - the entry to update with the length 379 * entry - the entry to update with the length
380 * 380 *
381 * Returns: the song length in milliseconds, 381 * Returns: the song length in milliseconds,
382 * -1 means that it couldn't be calculated 382 * 0 means that it couldn't be calculated
383 */ 383 */
384static int getsonglength(int fd, struct mp3entry *entry) 384static int getsonglength(int fd, struct mp3entry *entry)
385{ 385{
@@ -408,13 +408,13 @@ static int getsonglength(int fd, struct mp3entry *entry)
408 408
409 /* Start searching after ID3v2 header */ 409 /* Start searching after ID3v2 header */
410 if(-1 == lseek(fd, entry->id3v2len, SEEK_SET)) 410 if(-1 == lseek(fd, entry->id3v2len, SEEK_SET))
411 return -1; 411 return 0;
412 412
413 /* Fill up header with first 24 bits */ 413 /* Fill up header with first 24 bits */
414 for(version = 0; version < 3; version++) { 414 for(version = 0; version < 3; version++) {
415 header <<= 8; 415 header <<= 8;
416 if(!read(fd, &tmp, 1)) 416 if(!read(fd, &tmp, 1))
417 return -1; 417 return 0;
418 header |= tmp; 418 header |= tmp;
419 } 419 }
420 420
@@ -424,13 +424,13 @@ static int getsonglength(int fd, struct mp3entry *entry)
424 do { 424 do {
425 header <<= 8; 425 header <<= 8;
426 if(!read(fd, &tmp, 1)) 426 if(!read(fd, &tmp, 1))
427 return -1; 427 return 0;
428 header |= tmp; 428 header |= tmp;
429 429
430 /* Quit if we haven't found a valid header within 128K */ 430 /* Quit if we haven't found a valid header within 128K */
431 bytecount++; 431 bytecount++;
432 if(bytecount > 0x20000) 432 if(bytecount > 0x20000)
433 return -1; 433 return 0;
434 } while(!mp3frameheader(header)); 434 } while(!mp3frameheader(header));
435 435
436 /* 436 /*
@@ -631,6 +631,11 @@ bool mp3info(struct mp3entry *entry, char *filename)
631 631
632 close(fd); 632 close(fd);
633 633
634 if(!entry->length || (entry->filesize < 8 ))
635 /* no song length or less than 8 bytes is hereby considered to be an
636 invalid mp3 and won't be played by us! */
637 return true;
638
634 return false; 639 return false;
635} 640}
636 641