Make ChunkExtractor.read return a boolean instead of an int

PiperOrigin-RevId: 316172860
This commit is contained in:
aquilescanta 2020-06-12 22:02:34 +01:00 committed by Andrew Lewis
parent 41d4a132c4
commit 3ec4ec4dac
4 changed files with 9 additions and 17 deletions

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}