diff options
Diffstat (limited to 'firmware/id3.c')
-rw-r--r-- | firmware/id3.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index 70add41b6b..03c37c027e 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -798,13 +798,12 @@ static int getsonglength(int fd, struct mp3entry *entry) | |||
798 | * Checks all relevant information (such as ID3v1 tag, ID3v2 tag, length etc) | 798 | * Checks all relevant information (such as ID3v1 tag, ID3v2 tag, length etc) |
799 | * about an MP3 file and updates it's entry accordingly. | 799 | * about an MP3 file and updates it's entry accordingly. |
800 | * | 800 | * |
801 | * Arguments: entry - the entry to check and update with the new information | ||
802 | * | ||
803 | * Returns: void | ||
804 | */ | 801 | */ |
805 | bool mp3info(struct mp3entry *entry, char *filename) | 802 | bool mp3info(struct mp3entry *entry, char *filename, bool v1first) |
806 | { | 803 | { |
807 | int fd; | 804 | int fd; |
805 | int v1found = false; | ||
806 | |||
808 | fd = open(filename, O_RDONLY); | 807 | fd = open(filename, O_RDONLY); |
809 | if(-1 == fd) | 808 | if(-1 == fd) |
810 | return true; | 809 | return true; |
@@ -819,7 +818,10 @@ bool mp3info(struct mp3entry *entry, char *filename) | |||
819 | entry->tracknum = 0; | 818 | entry->tracknum = 0; |
820 | entry->genre = 0xff; | 819 | entry->genre = 0xff; |
821 | 820 | ||
822 | if (entry->id3v2len) | 821 | if(v1first) |
822 | v1found = setid3v1title(fd, entry); | ||
823 | |||
824 | if (!v1found && entry->id3v2len) | ||
823 | setid3v2title(fd, entry); | 825 | setid3v2title(fd, entry); |
824 | entry->length = getsonglength(fd, entry); | 826 | entry->length = getsonglength(fd, entry); |
825 | 827 | ||
@@ -827,10 +829,10 @@ bool mp3info(struct mp3entry *entry, char *filename) | |||
827 | the true size of the MP3 stream */ | 829 | the true size of the MP3 stream */ |
828 | entry->filesize -= entry->first_frame_offset; | 830 | entry->filesize -= entry->first_frame_offset; |
829 | 831 | ||
830 | /* only seek to end of file if no id3v2 tags were found */ | 832 | /* only seek to end of file if no id3v2 tags were found, |
831 | if (!entry->id3v2len) { | 833 | and we already haven't looked for a v1 tag */ |
832 | if(!entry->title) | 834 | if (!v1first && !entry->id3v2len) { |
833 | setid3v1title(fd, entry); | 835 | setid3v1title(fd, entry); |
834 | } | 836 | } |
835 | 837 | ||
836 | close(fd); | 838 | close(fd); |
@@ -860,7 +862,7 @@ int main(int argc, char **argv) | |||
860 | for(i=1; i<argc; i++) { | 862 | for(i=1; i<argc; i++) { |
861 | struct mp3entry mp3; | 863 | struct mp3entry mp3; |
862 | mp3.album = "Bogus"; | 864 | mp3.album = "Bogus"; |
863 | if(mp3info(&mp3, argv[i])) { | 865 | if(mp3info(&mp3, argv[i], false)) { |
864 | printf("Failed to get %s\n", argv[i]); | 866 | printf("Failed to get %s\n", argv[i]); |
865 | return 0; | 867 | return 0; |
866 | } | 868 | } |