From 23ddfaa80a3564b7720dc2eab9b83109163c62d6 Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 10 Sep 2019 17:42:15 +0100 Subject: [PATCH] Add fLaC prefix to FLAC initialization data The fLaC prefix is included in the initialization data output from the MKV extractor, so this is highly likely ot be the right thing to do. Issue: #6397 PiperOrigin-RevId: 268244365 --- RELEASENOTES.md | 3 ++- .../android/exoplayer2/extractor/mp4/AtomParsers.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d50686f298..e701a89d6c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -14,7 +14,8 @@ * Add `HttpDataSource.getResponseCode` to provide the status code associated with the most recent HTTP response. * Fix initialization data handling for FLAC in MP4 - ([#6396](https://github.com/google/ExoPlayer/issues/6396)). + ([#6396](https://github.com/google/ExoPlayer/issues/6396), + [#6397](https://github.com/google/ExoPlayer/issues/6397)). * Fix audio selection issue where languages are compared by bit rate ([#6335](https://github.com/google/ExoPlayer/issues/6335)). * Fix decoder selection for E-AC3 JOC streams diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java index 0ffbdf0f80..c4e6ef17c4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java @@ -1148,7 +1148,16 @@ import java.util.List; System.arraycopy(opusMagic, 0, initializationData, 0, opusMagic.length); parent.setPosition(childPosition + Atom.HEADER_SIZE); parent.readBytes(initializationData, opusMagic.length, childAtomBodySize); - } else if (childAtomType == Atom.TYPE_dfLa || childAtomType == Atom.TYPE_alac) { + } else if (childAtomType == Atom.TYPE_dfLa) { + int childAtomBodySize = childAtomSize - Atom.FULL_HEADER_SIZE; + initializationData = new byte[4 + childAtomBodySize]; + initializationData[0] = 0x66; // f + initializationData[1] = 0x4C; // L + initializationData[2] = 0x61; // a + initializationData[3] = 0x43; // C + parent.setPosition(childPosition + Atom.FULL_HEADER_SIZE); + parent.readBytes(initializationData, /* offset= */ 4, childAtomBodySize); + } else if (childAtomType == Atom.TYPE_alac) { int childAtomBodySize = childAtomSize - Atom.FULL_HEADER_SIZE; initializationData = new byte[childAtomBodySize]; parent.setPosition(childPosition + Atom.FULL_HEADER_SIZE);