From efaa2961eee9d314facea69a9ffbd09e922cdf1e Mon Sep 17 00:00:00 2001 From: kimvde Date: Wed, 7 Oct 2020 20:59:12 +0100 Subject: [PATCH] Read until the track formats are available in TestUtil.extractSeekMap() Otherwise, some extractor tests are seeking without making sure that the extractor has retrieved the formats. This is needed for PR Issue: #7378. PiperOrigin-RevId: 335934326 --- .../google/android/exoplayer2/testutil/TestUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java index f2ead0485f..7107c0b8a4 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java @@ -297,7 +297,8 @@ public class TestUtil { /** * Reads from the given input using the given {@link Extractor}, until it can produce the {@link - * SeekMap} and all of the tracks have been identified, or until the extractor encounters EOF. + * SeekMap} and all of the track formats have been identified, or until the extractor encounters + * EOF. * * @param extractor The {@link Extractor} to extractor from input. * @param output The {@link FakeTrackOutput} to store the extracted {@link SeekMap} and track. @@ -316,11 +317,18 @@ public class TestUtil { int readResult = Extractor.RESULT_CONTINUE; while (true) { try { - // Keep reading until we can get the seek map + // Keep reading until we get the seek map and the track information. while (readResult == Extractor.RESULT_CONTINUE && (output.seekMap == null || !output.tracksEnded)) { readResult = extractor.read(input, positionHolder); } + for (int i = 0; i < output.trackOutputs.size(); i++) { + int trackId = output.trackOutputs.keyAt(i); + while (readResult == Extractor.RESULT_CONTINUE + && output.trackOutputs.get(trackId).lastFormat == null) { + readResult = extractor.read(input, positionHolder); + } + } } finally { Util.closeQuietly(dataSource); }