Index: apps/metadata/ape.c =================================================================== --- apps/metadata/ape.c (revision 27375) +++ apps/metadata/ape.c (working copy) @@ -54,11 +54,11 @@ /* Read the items in an APEV2 tag. Only looks for a tag at the end of a * file. Returns true if a tag was found and fully read, false otherwise. */ -bool read_ape_tags(int fd, struct mp3entry* id3) +bool read_ape_tags(int fd, struct mp3entry* id3, int offset) { struct apetag_header header; - if ((lseek(fd, -APETAG_HEADER_LENGTH, SEEK_END) < 0) + if ((lseek(fd, -APETAG_HEADER_LENGTH + offset, SEEK_END) < 0) || (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN) != APETAG_HEADER_LENGTH) || (memcmp(header.id, "APETAGEX", sizeof(header.id)))) @@ -75,7 +75,7 @@ unsigned int tag_remaining = header.length - APETAG_HEADER_LENGTH; int i; - if (lseek(fd, -header.length, SEEK_END) < 0) + if (lseek(fd, -header.length + offset, SEEK_END) < 0) { return false; } Index: apps/metadata/metadata_common.h =================================================================== --- apps/metadata/metadata_common.h (revision 27375) +++ apps/metadata/metadata_common.h (working copy) @@ -34,7 +34,7 @@ enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS }; -bool read_ape_tags(int fd, struct mp3entry* id3); +bool read_ape_tags(int fd, struct mp3entry* id3, int offset); long read_vorbis_tags(int fd, struct mp3entry *id3, long tag_remaining); Index: apps/metadata.c =================================================================== --- apps/metadata.c (revision 27375) +++ apps/metadata.c (working copy) @@ -286,7 +286,12 @@ { return false; } - + if (id3->id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, id3, -id3->id3v1len); + } break; #if CONFIG_CODEC == SWCODEC @@ -295,7 +300,12 @@ { return false; } - + if (id3->id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, id3, -id3->id3v1len); + } break; case AFMT_WMA: @@ -310,13 +320,13 @@ { return false; } - read_ape_tags(fd, id3); + read_ape_tags(fd, id3, 0); break; case AFMT_MPC: if (!get_musepack_metadata(fd, id3)) return false; - read_ape_tags(fd, id3); + read_ape_tags(fd, id3, 0); break; case AFMT_OGG_VORBIS: @@ -342,7 +352,7 @@ return false; } - read_ape_tags(fd, id3); /* use any apetag info we find */ + read_ape_tags(fd, id3, 0); /* use any apetag info we find */ break; case AFMT_A52: @@ -367,6 +377,12 @@ { return false; } + if (id3->id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, id3, -id3->id3v1len); + } break;