Commit 3ec4ec4d by aquilescanta Committed by Andrew Lewis

Make ChunkExtractor.read return a boolean instead of an int

PiperOrigin-RevId: 316172860
parent 41d4a132
...@@ -105,8 +105,10 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac ...@@ -105,8 +105,10 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
} }
@Override @Override
public int read(ExtractorInput input) throws IOException { public boolean read(ExtractorInput input) throws IOException {
return extractor.read(input, DUMMY_POSITION_HOLDER); int result = extractor.read(input, DUMMY_POSITION_HOLDER);
Assertions.checkState(result != Extractor.RESULT_SEEK);
return result == Extractor.RESULT_CONTINUE;
} }
// ExtractorOutput implementation. // ExtractorOutput implementation.
......
...@@ -19,7 +19,6 @@ import androidx.annotation.Nullable; ...@@ -19,7 +19,6 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ChunkIndex; 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.ExtractorInput;
import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.extractor.TrackOutput;
import java.io.IOException; import java.io.IOException;
...@@ -79,8 +78,9 @@ public interface ChunkExtractor { ...@@ -79,8 +78,9 @@ public interface ChunkExtractor {
* Reads from the given {@link ExtractorInput}. * Reads from the given {@link ExtractorInput}.
* *
* @param input The input to read from. * @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. * @throws IOException If an error occurred reading from or parsing the input.
*/ */
int read(ExtractorInput input) throws IOException; boolean read(ExtractorInput input) throws IOException;
} }
...@@ -24,7 +24,6 @@ import com.google.android.exoplayer2.extractor.ExtractorInput; ...@@ -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.source.chunk.ChunkExtractor.TrackOutputProvider;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
...@@ -127,11 +126,7 @@ public class ContainerMediaChunk extends BaseMediaChunk { ...@@ -127,11 +126,7 @@ public class ContainerMediaChunk extends BaseMediaChunk {
dataSource, loadDataSpec.position, dataSource.open(loadDataSpec)); dataSource, loadDataSpec.position, dataSource.open(loadDataSpec));
// Load and decode the sample data. // Load and decode the sample data.
try { try {
int result = Extractor.RESULT_CONTINUE; while (!loadCanceled && chunkExtractor.read(input)) {}
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
result = chunkExtractor.read(input);
}
Assertions.checkState(result != Extractor.RESULT_SEEK);
} finally { } finally {
nextLoadPosition = input.getPosition() - dataSpec.position; nextLoadPosition = input.getPosition() - dataSpec.position;
} }
......
...@@ -24,7 +24,6 @@ import com.google.android.exoplayer2.extractor.ExtractorInput; ...@@ -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.source.chunk.ChunkExtractor.TrackOutputProvider;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...@@ -93,11 +92,7 @@ public final class InitializationChunk extends Chunk { ...@@ -93,11 +92,7 @@ public final class InitializationChunk extends Chunk {
dataSource, loadDataSpec.position, dataSource.open(loadDataSpec)); dataSource, loadDataSpec.position, dataSource.open(loadDataSpec));
// Load and decode the initialization data. // Load and decode the initialization data.
try { try {
int result = Extractor.RESULT_CONTINUE; while (!loadCanceled && chunkExtractor.read(input)) {}
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
result = chunkExtractor.read(input);
}
Assertions.checkState(result != Extractor.RESULT_SEEK);
} finally { } finally {
nextLoadPosition = input.getPosition() - dataSpec.position; nextLoadPosition = input.getPosition() - dataSpec.position;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment