Index: apps/metadata/ape.c =================================================================== --- apps/metadata/ape.c (revision 13664) +++ apps/metadata/ape.c (working copy) @@ -51,11 +51,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)))) { @@ -71,7 +71,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 13664) +++ apps/metadata/metadata_common.h (working copy) @@ -29,7 +29,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); bool read_vorbis_tags(int fd, struct mp3entry *id3, long tag_remaining); Index: apps/metadata.c =================================================================== --- apps/metadata.c (revision 13664) +++ apps/metadata.c (working copy) @@ -121,7 +121,12 @@ { return false; } - + if (track->id3.id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, &track->id3, -track->id3.id3v1len); + } break; #if CONFIG_CODEC == SWCODEC @@ -130,7 +135,12 @@ { return false; } - + if (track->id3.id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, &track->id3, -track->id3.id3v1len); + } break; case AFMT_APE: @@ -138,13 +148,13 @@ { return false; } - read_ape_tags(fd, &(track->id3)); + read_ape_tags(fd, &track->id3, 0); break; case AFMT_MPC: if (!get_musepack_metadata(fd, &(track->id3))) return false; - read_ape_tags(fd, &(track->id3)); + read_ape_tags(fd, &(track->id3), 0); break; case AFMT_OGG_VORBIS: @@ -226,7 +236,7 @@ track->id3.bitrate = filesize (fd) / (track->id3.length / 8); } - read_ape_tags(fd, &track->id3); /* use any apetag info we find */ + read_ape_tags(fd, &track->id3, 0); /* use any apetag info we find */ break; case AFMT_A52: @@ -343,6 +353,12 @@ { return false; } + if (track->id3.id3version <= ID3_VER_1_1) + { + /* An id3v1 tag may hide an APEv2 tag... */ + /* use any apetag info we find */ + read_ape_tags(fd, &track->id3, -track->id3.id3v1len); + } break;