diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ad682a22d2..c9b409d0db 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -19,6 +19,8 @@ * Add support for composition-level audio effects. * Track Selection: * Extractors: + * Fix issue where padding was not skipped when reading odd-sized chunks + from WAV files ([#1117](https://github.com/androidx/media/pull/1117)). * Audio: * Allow renderer recovery by disabling offload if audio track fails to initialize in offload mode. diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/wav/WavHeaderReader.java b/libraries/extractor/src/main/java/androidx/media3/extractor/wav/WavHeaderReader.java index 7ecd28483a..4db508135f 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/wav/WavHeaderReader.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/wav/WavHeaderReader.java @@ -172,8 +172,9 @@ import java.io.IOException; while (chunkHeader.id != chunkId) { Log.w(TAG, "Ignoring unknown WAV chunk: " + chunkHeader.id); long bytesToSkip = ChunkHeader.SIZE_IN_BYTES + chunkHeader.size; - // To align RIFF chunks to certain boundaries the RIFF specification includes a JUNK chunk. - // Its contents are to be skipped when reading. + // According to the RIFF specification, if a chunk's body size is odd, it's followed by a + // padding byte of value 0. This ensures each chunk occupies an even number of bytes in the + // file. The padding byte isn't included in the size field. if (chunkHeader.size % 2 != 0) { bytesToSkip++; // padding present if size is odd, skip it. }