diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java index 0e2eae27d2..83a6da844f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java @@ -105,8 +105,10 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac } @Override - public int read(ExtractorInput input) throws IOException { - return extractor.read(input, DUMMY_POSITION_HOLDER); + public boolean read(ExtractorInput input) throws IOException { + int result = extractor.read(input, DUMMY_POSITION_HOLDER); + Assertions.checkState(result != Extractor.RESULT_SEEK); + return result == Extractor.RESULT_CONTINUE; } // ExtractorOutput implementation. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java index e0ae50bd86..215e965ca0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java @@ -19,7 +19,6 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.extractor.ChunkIndex; -import com.google.android.exoplayer2.extractor.Extractor; import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.TrackOutput; import java.io.IOException; @@ -79,8 +78,9 @@ public interface ChunkExtractor { * Reads from the given {@link ExtractorInput}. * * @param input The input to read from. - * @return One of the {@link Extractor}{@code .RESULT_*} values. + * @return Whether there is any data left to extract. Returns false if the end of input has been + * reached. * @throws IOException If an error occurred reading from or parsing the input. */ - int read(ExtractorInput input) throws IOException; + boolean read(ExtractorInput input) throws IOException; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ContainerMediaChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ContainerMediaChunk.java index 57e5687337..b8938deac4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ContainerMediaChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ContainerMediaChunk.java @@ -24,7 +24,6 @@ import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.source.chunk.ChunkExtractor.TrackOutputProvider; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; -import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; import java.io.IOException; @@ -127,11 +126,7 @@ public class ContainerMediaChunk extends BaseMediaChunk { dataSource, loadDataSpec.position, dataSource.open(loadDataSpec)); // Load and decode the sample data. try { - int result = Extractor.RESULT_CONTINUE; - while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { - result = chunkExtractor.read(input); - } - Assertions.checkState(result != Extractor.RESULT_SEEK); + while (!loadCanceled && chunkExtractor.read(input)) {} } finally { nextLoadPosition = input.getPosition() - dataSpec.position; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java index fb33e940f2..944b25395a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java @@ -24,7 +24,6 @@ import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.source.chunk.ChunkExtractor.TrackOutputProvider; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; -import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @@ -93,11 +92,7 @@ public final class InitializationChunk extends Chunk { dataSource, loadDataSpec.position, dataSource.open(loadDataSpec)); // Load and decode the initialization data. try { - int result = Extractor.RESULT_CONTINUE; - while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { - result = chunkExtractor.read(input); - } - Assertions.checkState(result != Extractor.RESULT_SEEK); + while (!loadCanceled && chunkExtractor.read(input)) {} } finally { nextLoadPosition = input.getPosition() - dataSpec.position; }