Index: apps/metadata/mp4.c =================================================================== --- apps/metadata/mp4.c (revision 29188) +++ apps/metadata/mp4.c (working copy) @@ -300,8 +300,7 @@ /* Skip 13 bits from above, plus 3 bits, then read 11 bits */ else if ((length >= 4) && (((bits >> 5) & 0x7ff) == 0x2b7)) { - /* extensionAudioObjectType */ - DEBUGF("MP4: extensionAudioType\n"); + /* We found an extensionAudioObjectType */ type = bits & 0x1f; /* Object type - 5 bits*/ bits = get_long_be(&buf[4]); @@ -679,32 +678,32 @@ case MP4_alac: { uint32_t frequency; - - id3->codectype = (type == MP4_mp4a) ? AFMT_MP4_AAC : AFMT_MP4_ALAC; + uint32_t subsize; + uint32_t subtype; + + /* Read a sample rate, just in case the following alac or esds + * metadata cannot be parsed. */ lseek(fd, 22, SEEK_CUR); read_uint32be(fd, &frequency); size -= 26; id3->frequency = frequency; + /* Move to next mp4 atom which is the alac or esds atom. */ + lseek(fd, 2, SEEK_CUR); + read_mp4_atom(fd, &subsize, &subtype, size); + size -= 10; + if (type == MP4_mp4a) { - uint32_t subsize; - uint32_t subtype; bool sbr_used; - - /* Get frequency from the decoder info tag, if possible. */ - lseek(fd, 2, SEEK_CUR); - /* The esds atom is a part of the mp4a atom, so ignore - * the returned size (it's already accounted for). - */ - read_mp4_atom(fd, &subsize, &subtype, size); - size -= 10; + id3->codectype = AFMT_MP4_AAC; if (subtype == MP4_esds) { sbr_used = read_mp4_esds(fd, id3, &size); if (sbr_used) { +// id3->codectype = AFMT_MP4_AAC_HE; if (SBR_upsampling_used) DEBUGF("MP4: AAC-HE, SBR upsampling\n"); else @@ -712,6 +711,17 @@ } } } + else + { + if (subtype == MP4_alac) + { + lseek(fd, 24, SEEK_CUR); + read_uint32be(fd, &frequency); + size -= 28; + id3->frequency = frequency; + } + id3->codectype = AFMT_MP4_ALAC; + } } break;