diff --git a/extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java b/extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java index 5ae2b6a196..1c0c450a30 100644 --- a/extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java +++ b/extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacExtractorSeekTest.java @@ -49,8 +49,7 @@ public final class FlacExtractorSeekTest { .createDataSource(); @Test - public void flacExtractorReads_seekTable_returnSeekableSeekMap() - throws IOException, InterruptedException { + public void flacExtractorReads_seekTable_returnSeekableSeekMap() throws IOException { Uri fileUri = TestUtil.buildAssetUri(TEST_FILE_SEEK_TABLE); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -61,7 +60,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_seekTable_handlesSeekToZero() throws IOException, InterruptedException { + public void seeking_seekTable_handlesSeekToZero() throws IOException { String fileName = TEST_FILE_SEEK_TABLE; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -78,7 +77,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_seekTable_handlesSeekToEoF() throws IOException, InterruptedException { + public void seeking_seekTable_handlesSeekToEoF() throws IOException { String fileName = TEST_FILE_SEEK_TABLE; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -95,7 +94,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_seekTable_handlesSeekingBackward() throws IOException, InterruptedException { + public void seeking_seekTable_handlesSeekingBackward() throws IOException { String fileName = TEST_FILE_SEEK_TABLE; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -114,7 +113,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_seekTable_handlesSeekingForward() throws IOException, InterruptedException { + public void seeking_seekTable_handlesSeekingForward() throws IOException { String fileName = TEST_FILE_SEEK_TABLE; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -133,8 +132,7 @@ public final class FlacExtractorSeekTest { } @Test - public void flacExtractorReads_binarySearch_returnSeekableSeekMap() - throws IOException, InterruptedException { + public void flacExtractorReads_binarySearch_returnSeekableSeekMap() throws IOException { Uri fileUri = TestUtil.buildAssetUri(TEST_FILE_BINARY_SEARCH); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -145,7 +143,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_binarySearch_handlesSeekToZero() throws IOException, InterruptedException { + public void seeking_binarySearch_handlesSeekToZero() throws IOException { String fileName = TEST_FILE_BINARY_SEARCH; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -162,7 +160,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_binarySearch_handlesSeekToEoF() throws IOException, InterruptedException { + public void seeking_binarySearch_handlesSeekToEoF() throws IOException { String fileName = TEST_FILE_BINARY_SEARCH; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -179,8 +177,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_binarySearch_handlesSeekingBackward() - throws IOException, InterruptedException { + public void seeking_binarySearch_handlesSeekingBackward() throws IOException { String fileName = TEST_FILE_BINARY_SEARCH; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -199,8 +196,7 @@ public final class FlacExtractorSeekTest { } @Test - public void seeking_binarySearch_handlesSeekingForward() - throws IOException, InterruptedException { + public void seeking_binarySearch_handlesSeekingForward() throws IOException { String fileName = TEST_FILE_BINARY_SEARCH; Uri fileUri = TestUtil.buildAssetUri(fileName); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -219,8 +215,7 @@ public final class FlacExtractorSeekTest { } @Test - public void flacExtractorReads_unseekable_returnUnseekableSeekMap() - throws IOException, InterruptedException { + public void flacExtractorReads_unseekable_returnUnseekableSeekMap() throws IOException { Uri fileUri = TestUtil.buildAssetUri(TEST_FILE_UNSEEKABLE); SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri); @@ -235,7 +230,7 @@ public final class FlacExtractorSeekTest { FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) - throws IOException, InterruptedException { + throws IOException { FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName); int expectedFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs); @@ -252,7 +247,7 @@ public final class FlacExtractorSeekTest { FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) - throws IOException, InterruptedException { + throws IOException { FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName); int maxFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs); @@ -276,8 +271,7 @@ public final class FlacExtractorSeekTest { assertThat(frameFound).isTrue(); } - private static FakeTrackOutput getExpectedTrackOutput(String fileName) - throws IOException, InterruptedException { + private static FakeTrackOutput getExpectedTrackOutput(String fileName) throws IOException { return TestUtil.extractAllSamplesFromFile( new FlacExtractor(), ApplicationProvider.getApplicationContext(), fileName) .trackOutputs diff --git a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java index 4053c17163..742ade214d 100644 --- a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java +++ b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java @@ -100,7 +100,7 @@ import java.nio.ByteBuffer; @Override public TimestampSearchResult searchForTimestamp(ExtractorInput input, long targetSampleIndex) - throws IOException, InterruptedException { + throws IOException { ByteBuffer outputBuffer = outputFrameHolder.byteBuffer; long searchPosition = input.getPosition(); decoderJni.reset(searchPosition); diff --git a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java index 31aacfd0df..c3eab1dfbc 100644 --- a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java +++ b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java @@ -63,7 +63,7 @@ import java.util.List; streamMetadata = decoderJni.decodeStreamMetadata(); } catch (ParserException e) { throw new FlacDecoderException("Failed to decode StreamInfo", e); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { // Never happens. throw new IllegalStateException(e); } @@ -107,7 +107,7 @@ import java.util.List; decoderJni.decodeSample(outputData); } catch (FlacDecoderJni.FlacFrameDecodeException e) { return new FlacDecoderException("Frame decoding failed", e); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { // Never happens. throw new IllegalStateException(e); } diff --git a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java index 6e8f394c19..daf4584948 100644 --- a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java +++ b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java @@ -115,7 +115,7 @@ import java.nio.ByteBuffer; * read from the source, then 0 is returned. */ @SuppressWarnings("unused") // Called from native code. - public int read(ByteBuffer target) throws IOException, InterruptedException { + public int read(ByteBuffer target) throws IOException { int byteCount = target.remaining(); if (byteBufferData != null) { byteCount = Math.min(byteCount, byteBufferData.remaining()); @@ -145,7 +145,7 @@ import java.nio.ByteBuffer; } /** Decodes and consumes the metadata from the FLAC stream. */ - public FlacStreamMetadata decodeStreamMetadata() throws IOException, InterruptedException { + public FlacStreamMetadata decodeStreamMetadata() throws IOException { FlacStreamMetadata streamMetadata = flacDecodeMetadata(nativeDecoderContext); if (streamMetadata == null) { throw new ParserException("Failed to decode stream metadata"); @@ -161,7 +161,7 @@ import java.nio.ByteBuffer; * @param retryPosition If any error happens, the input will be rewound to {@code retryPosition}. */ public void decodeSampleWithBacktrackPosition(ByteBuffer output, long retryPosition) - throws InterruptedException, IOException, FlacFrameDecodeException { + throws IOException, FlacFrameDecodeException { try { decodeSample(output); } catch (IOException e) { @@ -177,8 +177,7 @@ import java.nio.ByteBuffer; /** Decodes and consumes the next sample from the FLAC stream into the given byte buffer. */ @SuppressWarnings("ByteBufferBackingArray") - public void decodeSample(ByteBuffer output) - throws IOException, InterruptedException, FlacFrameDecodeException { + public void decodeSample(ByteBuffer output) throws IOException, FlacFrameDecodeException { output.clear(); int frameSize = output.isDirect() @@ -266,8 +265,7 @@ import java.nio.ByteBuffer; } private int readFromExtractorInput( - ExtractorInput extractorInput, byte[] tempBuffer, int offset, int length) - throws IOException, InterruptedException { + ExtractorInput extractorInput, byte[] tempBuffer, int offset, int length) throws IOException { int read = extractorInput.read(tempBuffer, offset, length); if (read == C.RESULT_END_OF_INPUT) { endOfExtractorInput = true; @@ -278,14 +276,11 @@ import java.nio.ByteBuffer; private native long flacInit(); - private native FlacStreamMetadata flacDecodeMetadata(long context) - throws IOException, InterruptedException; + private native FlacStreamMetadata flacDecodeMetadata(long context) throws IOException; - private native int flacDecodeToBuffer(long context, ByteBuffer outputBuffer) - throws IOException, InterruptedException; + private native int flacDecodeToBuffer(long context, ByteBuffer outputBuffer) throws IOException; - private native int flacDecodeToArray(long context, byte[] outputArray) - throws IOException, InterruptedException; + private native int flacDecodeToArray(long context, byte[] outputArray) throws IOException; private native long flacGetDecodePosition(long context); diff --git a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java index c800e819f9..364cf80ef8 100644 --- a/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java +++ b/extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java @@ -113,14 +113,13 @@ public final class FlacExtractor implements Extractor { } @Override - public boolean sniff(ExtractorInput input) throws IOException, InterruptedException { + public boolean sniff(ExtractorInput input) throws IOException { id3Metadata = FlacMetadataReader.peekId3Metadata(input, /* parseData= */ !id3MetadataDisabled); return FlacMetadataReader.checkAndPeekStreamMarker(input); } @Override - public int read(final ExtractorInput input, PositionHolder seekPosition) - throws IOException, InterruptedException { + public int read(final ExtractorInput input, PositionHolder seekPosition) throws IOException { if (input.getPosition() == 0 && !id3MetadataDisabled && id3Metadata == null) { id3Metadata = FlacMetadataReader.peekId3Metadata(input, /* parseData= */ true); } @@ -185,7 +184,7 @@ public final class FlacExtractor implements Extractor { @RequiresNonNull({"decoderJni", "extractorOutput", "trackOutput"}) // Requires initialized. @EnsuresNonNull({"streamMetadata", "outputFrameHolder"}) // Ensures stream metadata decoded. @SuppressWarnings({"contracts.postcondition.not.satisfied"}) - private void decodeStreamMetadata(ExtractorInput input) throws InterruptedException, IOException { + private void decodeStreamMetadata(ExtractorInput input) throws IOException { if (streamMetadataDecoded) { return; } @@ -225,7 +224,7 @@ public final class FlacExtractor implements Extractor { ParsableByteArray outputBuffer, OutputFrameHolder outputFrameHolder, TrackOutput trackOutput) - throws InterruptedException, IOException { + throws IOException { int seekResult = binarySearchSeeker.handlePendingSeek(input, seekPosition); ByteBuffer outputByteBuffer = outputFrameHolder.byteBuffer; if (seekResult == RESULT_CONTINUE && outputByteBuffer.limit() > 0) { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataReader.java b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataReader.java index a713576bf7..d3971171ea 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataReader.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataReader.java @@ -30,7 +30,6 @@ public interface DataReader { * may be less than {@code length} because the end of the input (or available data) was * reached, the method was interrupted, or the operation was aborted early for another reason. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread has been interrupted. */ - int read(byte[] target, int offset, int length) throws IOException, InterruptedException; + int read(byte[] target, int offset, int length) throws IOException; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java b/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java index 4caf07d905..e13d5edb34 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/BundledExtractorsAdapter.java @@ -51,7 +51,7 @@ import java.io.IOException; @Override public void init(DataSource dataSource, long position, long length, ExtractorOutput output) - throws IOException, InterruptedException { + throws IOException { extractorInput = new DefaultExtractorInput(dataSource, position, length); if (extractor != null) { return; @@ -109,7 +109,7 @@ import java.io.IOException; } @Override - public int read(PositionHolder positionHolder) throws IOException, InterruptedException { + public int read(PositionHolder positionHolder) throws IOException { return Assertions.checkNotNull(extractor) .read(Assertions.checkNotNull(extractorInput), positionHolder); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java index f7d26ac06c..7e7d4e4d8d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaExtractor.java @@ -35,10 +35,9 @@ import java.io.IOException; * extractor. * @throws UnrecognizedInputFormatException Thrown if the input format could not be detected. * @throws IOException Thrown if the input could not be read. - * @throws InterruptedException Thrown if the thread was interrupted. */ void init(DataSource dataSource, long position, long length, ExtractorOutput output) - throws IOException, InterruptedException; + throws IOException; /** Releases any held resources. */ void release(); @@ -71,7 +70,6 @@ import java.io.IOException; * hold the position of the required data. * @return One of the {@link Extractor}{@code .RESULT_*} values. * @throws IOException If an error occurred reading from the input. - * @throws InterruptedException If the thread was interrupted. */ - int read(PositionHolder positionHolder) throws IOException, InterruptedException; + int read(PositionHolder positionHolder) throws IOException; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java index ca19d60750..b5f1e29b8f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java @@ -51,6 +51,7 @@ import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.Util; import java.io.IOException; +import java.io.InterruptedIOException; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -950,7 +951,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } @Override - public void load() throws IOException, InterruptedException { + public void load() throws IOException { int result = Extractor.RESULT_CONTINUE; while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { try { @@ -978,7 +979,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; pendingExtractorSeek = false; } while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { - loadCondition.block(); + try { + loadCondition.block(); + } catch (InterruptedException e) { + throw new InterruptedIOException(); + } result = progressiveMediaExtractor.read(positionHolder); long currentInputPosition = progressiveMediaExtractor.getCurrentInputPosition(); if (currentInputPosition > position + continueLoadingCheckIntervalBytes) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java index 3b41119492..7fd95df34f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java @@ -177,8 +177,7 @@ import java.util.Arrays; return totalBytesWritten; } - public int sampleData(DataReader input, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + public int sampleData(DataReader input, int length, boolean allowEndOfInput) throws IOException { length = preAppend(length); int bytesAppended = input.read( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java index f4b8b6fdcd..306915e65e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java @@ -470,7 +470,7 @@ public class SampleQueue implements TrackOutput { @Override public final int sampleData(DataReader input, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + throws IOException { return sampleDataQueue.sampleData(input, length, allowEndOfInput); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java index fb93af96df..76a4665d77 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java @@ -204,7 +204,7 @@ public final class ChunkExtractorWrapper implements ExtractorOutput { @Override public int sampleData(DataReader input, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + throws IOException { return castNonNull(trackOutput).sampleData(input, length, allowEndOfInput); } 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 5fa85a33e3..1b43af2084 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 @@ -112,7 +112,7 @@ public class ContainerMediaChunk extends BaseMediaChunk { @SuppressWarnings("NonAtomicVolatileUpdate") @Override - public final void load() throws IOException, InterruptedException { + public final void load() throws IOException { if (nextLoadPosition == 0) { // Configure the output and set it as the target for the extractor wrapper. BaseMediaChunkOutput output = getOutput(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java index 4c22532506..6d97c1d92e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java @@ -77,7 +77,7 @@ public abstract class DataChunk extends Chunk { } @Override - public final void load() throws IOException, InterruptedException { + public final void load() throws IOException { try { dataSource.open(dataSpec); int limit = 0; 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 ce355de6ef..eedcad3072 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 @@ -83,7 +83,7 @@ public final class InitializationChunk extends Chunk { @SuppressWarnings("NonAtomicVolatileUpdate") @Override - public void load() throws IOException, InterruptedException { + public void load() throws IOException { if (nextLoadPosition == 0) { extractorWrapper.init( trackOutputProvider, /* startTimeUs= */ C.TIME_UNSET, /* endTimeUs= */ C.TIME_UNSET); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java index c275c8dc2e..4e91e921d2 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java @@ -91,7 +91,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk { @SuppressWarnings("NonAtomicVolatileUpdate") @Override - public void load() throws IOException, InterruptedException { + public void load() throws IOException { BaseMediaChunkOutput output = getOutput(); output.setSampleOffsetUs(0); TrackOutput trackOutput = output.track(0, trackType); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java index d9d84bdda1..4ff58b108c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java @@ -63,10 +63,8 @@ public final class Loader implements LoaderErrorThrower { * Performs the load, returning on completion or cancellation. * * @throws IOException If the input could not be loaded. - * @throws InterruptedException If the thread was interrupted. */ - void load() throws IOException, InterruptedException; - + void load() throws IOException; } /** @@ -400,12 +398,6 @@ public final class Loader implements LoaderErrorThrower { if (!released) { obtainMessage(MSG_IO_EXCEPTION, e).sendToTarget(); } - } catch (InterruptedException e) { - // The load was canceled. - Assertions.checkState(canceled); - if (!released) { - sendEmptyMessage(MSG_END_OF_SOURCE); - } } catch (Exception e) { // This should never happen, but handle it anyway. Log.e(TAG, "Unexpected exception loading stream", e); diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java index b9a1f872a6..6d440b96df 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java @@ -80,11 +80,10 @@ public final class DashUtil { * @param period The {@link Period}. * @return The loaded {@link DrmInitData}, or null if none is defined. * @throws IOException Thrown when there is an error while loading. - * @throws InterruptedException Thrown if the thread was interrupted. */ @Nullable public static DrmInitData loadDrmInitData(DataSource dataSource, Period period) - throws IOException, InterruptedException { + throws IOException { int primaryTrackType = C.TRACK_TYPE_VIDEO; Representation representation = getFirstRepresentation(period, primaryTrackType); if (representation == null) { @@ -110,12 +109,10 @@ public final class DashUtil { * @param representation The representation which initialization chunk belongs to. * @return the sample {@link Format} of the given representation. * @throws IOException Thrown when there is an error while loading. - * @throws InterruptedException Thrown if the thread was interrupted. */ @Nullable public static Format loadSampleFormat( - DataSource dataSource, int trackType, Representation representation) - throws IOException, InterruptedException { + DataSource dataSource, int trackType, Representation representation) throws IOException { ChunkExtractorWrapper extractorWrapper = loadInitializationData(dataSource, trackType, representation, false); return extractorWrapper == null @@ -134,12 +131,10 @@ public final class DashUtil { * @return The {@link ChunkIndex} of the given representation, or null if no initialization or * index data exists. * @throws IOException Thrown when there is an error while loading. - * @throws InterruptedException Thrown if the thread was interrupted. */ @Nullable public static ChunkIndex loadChunkIndex( - DataSource dataSource, int trackType, Representation representation) - throws IOException, InterruptedException { + DataSource dataSource, int trackType, Representation representation) throws IOException { ChunkExtractorWrapper extractorWrapper = loadInitializationData(dataSource, trackType, representation, true); return extractorWrapper == null ? null : (ChunkIndex) extractorWrapper.getSeekMap(); @@ -157,12 +152,11 @@ public final class DashUtil { * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no * initialization or (if requested) index data exists. * @throws IOException Thrown when there is an error while loading. - * @throws InterruptedException Thrown if the thread was interrupted. */ @Nullable private static ChunkExtractorWrapper loadInitializationData( DataSource dataSource, int trackType, Representation representation, boolean loadIndex) - throws IOException, InterruptedException { + throws IOException { RangedUri initializationUri = representation.getInitializationUri(); if (initializationUri == null) { return null; @@ -188,9 +182,12 @@ public final class DashUtil { return extractorWrapper; } - private static void loadInitializationData(DataSource dataSource, - Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri) - throws IOException, InterruptedException { + private static void loadInitializationData( + DataSource dataSource, + Representation representation, + ChunkExtractorWrapper extractorWrapper, + RangedUri requestUri) + throws IOException { DataSpec dataSpec = DashUtil.buildDataSpec(representation, requestUri); InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec, representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */, diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/PlayerEmsgHandler.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/PlayerEmsgHandler.java index 027e34e497..b6cbcf6c82 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/PlayerEmsgHandler.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/PlayerEmsgHandler.java @@ -296,7 +296,7 @@ public final class PlayerEmsgHandler implements Handler.Callback { @Override public int sampleData(DataReader input, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + throws IOException { return sampleQueue.sampleData(input, length, allowEndOfInput); } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java index c382fe5994..b5eb092dfb 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/BinarySearchSeeker.java @@ -49,10 +49,9 @@ public abstract class BinarySearchSeeker { * @param targetTimestamp The target timestamp. * @return A {@link TimestampSearchResult} that describes the result of the search. * @throws IOException If an error occurred reading from the input. - * @throws InterruptedException If the thread was interrupted. */ TimestampSearchResult searchForTimestamp(ExtractorInput input, long targetTimestamp) - throws IOException, InterruptedException; + throws IOException; /** Called when a seek operation finishes. */ default void onSeekFinished() {} @@ -169,10 +168,9 @@ public abstract class BinarySearchSeeker { * to hold the position of the required seek. * @return One of the {@code RESULT_} values defined in {@link Extractor}. * @throws IOException If an error occurred reading from the input. - * @throws InterruptedException If the thread was interrupted. */ public int handlePendingSeek(ExtractorInput input, PositionHolder seekPositionHolder) - throws InterruptedException, IOException { + throws IOException { while (true) { SeekOperationParams seekOperationParams = Assertions.checkStateNotNull(this.seekOperationParams); @@ -241,7 +239,7 @@ public abstract class BinarySearchSeeker { } protected final boolean skipInputUntilPosition(ExtractorInput input, long position) - throws IOException, InterruptedException { + throws IOException { long bytesToSkip = position - input.getPosition(); if (bytesToSkip >= 0 && bytesToSkip <= MAX_SKIP_BYTES) { input.skipFully((int) bytesToSkip); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java index c6f1129da8..4979854d4c 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java @@ -21,6 +21,7 @@ import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; import java.io.EOFException; import java.io.IOException; +import java.io.InterruptedIOException; import java.util.Arrays; /** @@ -55,7 +56,7 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public int read(byte[] target, int offset, int length) throws IOException, InterruptedException { + public int read(byte[] target, int offset, int length) throws IOException { int bytesRead = readFromPeekBuffer(target, offset, length); if (bytesRead == 0) { bytesRead = @@ -68,7 +69,7 @@ public final class DefaultExtractorInput implements ExtractorInput { @Override public boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + throws IOException { int bytesRead = readFromPeekBuffer(target, offset, length); while (bytesRead < length && bytesRead != C.RESULT_END_OF_INPUT) { bytesRead = readFromDataSource(target, offset, length, bytesRead, allowEndOfInput); @@ -78,13 +79,12 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public void readFully(byte[] target, int offset, int length) - throws IOException, InterruptedException { + public void readFully(byte[] target, int offset, int length) throws IOException { readFully(target, offset, length, false); } @Override - public int skip(int length) throws IOException, InterruptedException { + public int skip(int length) throws IOException { int bytesSkipped = skipFromPeekBuffer(length); if (bytesSkipped == 0) { bytesSkipped = @@ -95,8 +95,7 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public boolean skipFully(int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + public boolean skipFully(int length, boolean allowEndOfInput) throws IOException { int bytesSkipped = skipFromPeekBuffer(length); while (bytesSkipped < length && bytesSkipped != C.RESULT_END_OF_INPUT) { int minLength = Math.min(length, bytesSkipped + scratchSpace.length); @@ -108,12 +107,12 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public void skipFully(int length) throws IOException, InterruptedException { + public void skipFully(int length) throws IOException { skipFully(length, false); } @Override - public int peek(byte[] target, int offset, int length) throws IOException, InterruptedException { + public int peek(byte[] target, int offset, int length) throws IOException { ensureSpaceForPeek(length); int peekBufferRemainingBytes = peekBufferLength - peekBufferPosition; int bytesPeeked; @@ -139,7 +138,7 @@ public final class DefaultExtractorInput implements ExtractorInput { @Override public boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + throws IOException { if (!advancePeekPosition(length, allowEndOfInput)) { return false; } @@ -148,14 +147,12 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public void peekFully(byte[] target, int offset, int length) - throws IOException, InterruptedException { + public void peekFully(byte[] target, int offset, int length) throws IOException { peekFully(target, offset, length, false); } @Override - public boolean advancePeekPosition(int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + public boolean advancePeekPosition(int length, boolean allowEndOfInput) throws IOException { ensureSpaceForPeek(length); int bytesPeeked = peekBufferLength - peekBufferPosition; while (bytesPeeked < length) { @@ -171,7 +168,7 @@ public final class DefaultExtractorInput implements ExtractorInput { } @Override - public void advancePeekPosition(int length) throws IOException, InterruptedException { + public void advancePeekPosition(int length) throws IOException { advancePeekPosition(length, false); } @@ -271,18 +268,18 @@ public final class DefaultExtractorInput implements ExtractorInput { * @param allowEndOfInput True if encountering the end of the input having read no data is * allowed, and should result in {@link C#RESULT_END_OF_INPUT} being returned. False if it * should be considered an error, causing an {@link EOFException} to be thrown. - * @return The total number of bytes read so far, or {@link C#RESULT_END_OF_INPUT} if - * {@code allowEndOfInput} is true and the input has ended having read no bytes. + * @return The total number of bytes read so far, or {@link C#RESULT_END_OF_INPUT} if {@code + * allowEndOfInput} is true and the input has ended having read no bytes. * @throws EOFException If the end of input was encountered having partially satisfied the read * (i.e. having read at least one byte, but fewer than {@code length}), or if no bytes were * read and {@code allowEndOfInput} is false. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread is interrupted. */ - private int readFromDataSource(byte[] target, int offset, int length, int bytesAlreadyRead, - boolean allowEndOfInput) throws InterruptedException, IOException { + private int readFromDataSource( + byte[] target, int offset, int length, int bytesAlreadyRead, boolean allowEndOfInput) + throws IOException { if (Thread.interrupted()) { - throw new InterruptedException(); + throw new InterruptedIOException(); } int bytesRead = dataSource.read(target, offset + bytesAlreadyRead, length - bytesAlreadyRead); if (bytesRead == C.RESULT_END_OF_INPUT) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DummyTrackOutput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DummyTrackOutput.java index 1ebfab259a..7ef308ef46 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DummyTrackOutput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DummyTrackOutput.java @@ -43,8 +43,7 @@ public final class DummyTrackOutput implements TrackOutput { } @Override - public int sampleData(DataReader input, int length, boolean allowEndOfInput) - throws IOException, InterruptedException { + public int sampleData(DataReader input, int length, boolean allowEndOfInput) throws IOException { int bytesToSkipByReading = Math.min(readBuffer.length, length); int bytesSkipped = input.read(readBuffer, /* offset= */ 0, bytesToSkipByReading); if (bytesSkipped == C.RESULT_END_OF_INPUT) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java index a9151a1b7c..d1371d56b6 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java @@ -57,16 +57,15 @@ public interface Extractor { /** * Returns whether this extractor can extract samples from the {@link ExtractorInput}, which must * provide data from the start of the stream. - *
- * If {@code true} is returned, the {@code input}'s reading position may have been modified. + * + *
If {@code true} is returned, the {@code input}'s reading position may have been modified. * Otherwise, only its peek position may have been modified. * * @param input The {@link ExtractorInput} from which data should be peeked/read. * @return Whether this extractor can read the provided input. * @throws IOException If an error occurred reading from the input. - * @throws InterruptedException If the thread was interrupted. */ - boolean sniff(ExtractorInput input) throws IOException, InterruptedException; + boolean sniff(ExtractorInput input) throws IOException; /** * Initializes the extractor with an {@link ExtractorOutput}. Called at most once. @@ -89,20 +88,18 @@ public interface Extractor { * {@link #RESULT_SEEK} is returned. If the extractor reached the end of the data provided by the * {@link ExtractorInput}, then {@link #RESULT_END_OF_INPUT} is returned. * - *
When this method throws an {@link IOException} or an {@link InterruptedException}, - * extraction may continue by providing an {@link ExtractorInput} with an unchanged {@link - * ExtractorInput#getPosition() read position} to a subsequent call to this method. + *
When this method throws an {@link IOException}, extraction may continue by providing an + * {@link ExtractorInput} with an unchanged {@link ExtractorInput#getPosition() read position} to + * a subsequent call to this method. * * @param input The {@link ExtractorInput} from which data should be read. * @param seekPosition If {@link #RESULT_SEEK} is returned, this holder is updated to hold the * position of the required data. * @return One of the {@code RESULT_} values defined in this interface. * @throws IOException If an error occurred reading from the input. - * @throws InterruptedException If the thread was interrupted. */ @ReadResult - int read(ExtractorInput input, PositionHolder seekPosition) - throws IOException, InterruptedException; + int read(ExtractorInput input, PositionHolder seekPosition) throws IOException; /** * Notifies the extractor that a seek has occurred. diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java index 9d902b154e..6799ca6de1 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java @@ -68,8 +68,8 @@ public interface ExtractorInput extends DataReader { /** * Reads up to {@code length} bytes from the input and resets the peek position. - *
- * This method blocks until at least one byte of data can be read, the end of the input is + * + *
This method blocks until at least one byte of data can be read, the end of the input is * detected, or an exception is thrown. * * @param target A target array into which data should be written. @@ -77,9 +77,9 @@ public interface ExtractorInput extends DataReader { * @param length The maximum number of bytes to read from the input. * @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the input has ended. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread has been interrupted. */ - int read(byte[] target, int offset, int length) throws IOException, InterruptedException; + @Override + int read(byte[] target, int offset, int length) throws IOException; /** * Like {@link #read(byte[], int, int)}, but reads the requested {@code length} in full. @@ -97,10 +97,9 @@ public interface ExtractorInput extends DataReader { * (i.e. having read at least one byte, but fewer than {@code length}), or if no bytes were * read and {@code allowEndOfInput} is false. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread has been interrupted. */ boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput) - throws IOException, InterruptedException; + throws IOException; /** * Equivalent to {@link #readFully(byte[], int, int, boolean) readFully(target, offset, length, @@ -111,9 +110,8 @@ public interface ExtractorInput extends DataReader { * @param length The number of bytes to read from the input. * @throws EOFException If the end of input was encountered. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread is interrupted. */ - void readFully(byte[] target, int offset, int length) throws IOException, InterruptedException; + void readFully(byte[] target, int offset, int length) throws IOException; /** * Like {@link #read(byte[], int, int)}, except the data is skipped instead of read. @@ -121,9 +119,8 @@ public interface ExtractorInput extends DataReader { * @param length The maximum number of bytes to skip from the input. * @return The number of bytes skipped, or {@link C#RESULT_END_OF_INPUT} if the input has ended. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread has been interrupted. */ - int skip(int length) throws IOException, InterruptedException; + int skip(int length) throws IOException; /** * Like {@link #readFully(byte[], int, int, boolean)}, except the data is skipped instead of read. @@ -139,22 +136,20 @@ public interface ExtractorInput extends DataReader { * (i.e. having skipped at least one byte, but fewer than {@code length}), or if no bytes were * skipped and {@code allowEndOfInput} is false. * @throws IOException If an error occurs reading from the input. - * @throws InterruptedException If the thread has been interrupted. */ - boolean skipFully(int length, boolean allowEndOfInput) throws IOException, InterruptedException; + boolean skipFully(int length, boolean allowEndOfInput) throws IOException; /** * Like {@link #readFully(byte[], int, int)}, except the data is skipped instead of read. - *
- * Encountering the end of input is always considered an error, and will result in an - * {@link EOFException} being thrown. + * + *
Encountering the end of input is always considered an error, and will result in an {@link
+ * EOFException} being thrown.
*
* @param length The number of bytes to skip from the input.
* @throws EOFException If the end of input was encountered.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- void skipFully(int length) throws IOException, InterruptedException;
+ void skipFully(int length) throws IOException;
/**
* Peeks up to {@code length} bytes from the peek position. The current read position is left
@@ -172,9 +167,8 @@ public interface ExtractorInput extends DataReader {
* @param length The maximum number of bytes to peek from the input.
* @return The number of bytes peeked, or {@link C#RESULT_END_OF_INPUT} if the input has ended.
* @throws IOException If an error occurs peeking from the input.
- * @throws InterruptedException If the thread has been interrupted.
*/
- int peek(byte[] target, int offset, int length) throws IOException, InterruptedException;
+ int peek(byte[] target, int offset, int length) throws IOException;
/**
* Like {@link #peek(byte[], int, int)}, but peeks the requested {@code length} in full.
@@ -192,10 +186,9 @@ public interface ExtractorInput extends DataReader {
* (i.e. having peeked at least one byte, but fewer than {@code length}), or if no bytes were
* peeked and {@code allowEndOfInput} is false.
* @throws IOException If an error occurs peeking from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput)
- throws IOException, InterruptedException;
+ throws IOException;
/**
* Equivalent to {@link #peekFully(byte[], int, int, boolean) peekFully(target, offset, length,
@@ -206,9 +199,8 @@ public interface ExtractorInput extends DataReader {
* @param length The number of bytes to peek from the input.
* @throws EOFException If the end of input was encountered.
* @throws IOException If an error occurs peeking from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- void peekFully(byte[] target, int offset, int length) throws IOException, InterruptedException;
+ void peekFully(byte[] target, int offset, int length) throws IOException;
/**
* Advances the peek position by {@code length} bytes. Like {@link #peekFully(byte[], int, int,
@@ -225,10 +217,8 @@ public interface ExtractorInput extends DataReader {
* advanced by at least one byte, but fewer than {@code length}), or if the end of input was
* encountered before advancing and {@code allowEndOfInput} is false.
* @throws IOException If an error occurs advancing the peek position.
- * @throws InterruptedException If the thread is interrupted.
*/
- boolean advancePeekPosition(int length, boolean allowEndOfInput)
- throws IOException, InterruptedException;
+ boolean advancePeekPosition(int length, boolean allowEndOfInput) throws IOException;
/**
* Advances the peek position by {@code length} bytes. Like {@link #peekFully(byte[], int, int)}
@@ -237,9 +227,8 @@ public interface ExtractorInput extends DataReader {
* @param length The number of bytes to peek from the input.
* @throws EOFException If the end of input was encountered.
* @throws IOException If an error occurs peeking from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- void advancePeekPosition(int length) throws IOException, InterruptedException;
+ void advancePeekPosition(int length) throws IOException;
/**
* Resets the peek position to equal the current read position.
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorUtil.java
index 3867a0fded..5ce274b11a 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorUtil.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorUtil.java
@@ -33,10 +33,9 @@ import java.io.IOException;
* @param length The maximum number of bytes to peek from the input.
* @return The number of bytes peeked.
* @throws IOException If an error occurs peeking from the input.
- * @throws InterruptedException If the thread has been interrupted.
*/
public static int peekToLength(ExtractorInput input, byte[] target, int offset, int length)
- throws IOException, InterruptedException {
+ throws IOException {
int totalBytesPeeked = 0;
while (totalBytesPeeked < length) {
int bytesPeeked = input.peek(target, offset + totalBytesPeeked, length - totalBytesPeeked);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacFrameReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacFrameReader.java
index 798cde54a1..264c6d7b0d 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacFrameReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacFrameReader.java
@@ -93,7 +93,7 @@ public final class FlacFrameReader {
FlacStreamMetadata flacStreamMetadata,
int frameStartMarker,
SampleNumberHolder sampleNumberHolder)
- throws IOException, InterruptedException {
+ throws IOException {
long originalPeekPosition = input.getPeekPosition();
byte[] frameStartBytes = new byte[2];
@@ -132,11 +132,9 @@ public final class FlacFrameReader {
* @return The frame first sample number.
* @throws ParserException If an error occurs parsing the sample number.
* @throws IOException If peeking from the input fails.
- * @throws InterruptedException If interrupted while peeking from input.
*/
public static long getFirstSampleNumber(
- ExtractorInput input, FlacStreamMetadata flacStreamMetadata)
- throws IOException, InterruptedException {
+ ExtractorInput input, FlacStreamMetadata flacStreamMetadata) throws IOException {
input.resetPeekPosition();
input.advancePeekPosition(1);
byte[] blockingStrategyByte = new byte[1];
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacMetadataReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacMetadataReader.java
index cad8b58b92..65e65c401e 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacMetadataReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacMetadataReader.java
@@ -60,12 +60,10 @@ public final class FlacMetadataReader {
* is {@code false}.
* @throws IOException If peeking from the input fails. In this case, there is no guarantee on the
* peek position.
- * @throws InterruptedException If interrupted while peeking from input. In this case, there is no
- * guarantee on the peek position.
*/
@Nullable
public static Metadata peekId3Metadata(ExtractorInput input, boolean parseData)
- throws IOException, InterruptedException {
+ throws IOException {
@Nullable
Id3Decoder.FramePredicate id3FramePredicate = parseData ? null : Id3Decoder.NO_FRAMES_PREDICATE;
@Nullable Metadata id3Metadata = new Id3Peeker().peekId3Data(input, id3FramePredicate);
@@ -79,11 +77,8 @@ public final class FlacMetadataReader {
* @return Whether the data peeked is the FLAC stream marker.
* @throws IOException If peeking from the input fails. In this case, the peek position is left
* unchanged.
- * @throws InterruptedException If interrupted while peeking from input. In this case, the peek
- * position is left unchanged.
*/
- public static boolean checkAndPeekStreamMarker(ExtractorInput input)
- throws IOException, InterruptedException {
+ public static boolean checkAndPeekStreamMarker(ExtractorInput input) throws IOException {
ParsableByteArray scratch = new ParsableByteArray(FlacConstants.STREAM_MARKER_SIZE);
input.peekFully(scratch.data, 0, FlacConstants.STREAM_MARKER_SIZE);
return scratch.readUnsignedInt() == STREAM_MARKER;
@@ -101,12 +96,10 @@ public final class FlacMetadataReader {
* is {@code false}.
* @throws IOException If reading from the input fails. In this case, the read position is left
* unchanged and there is no guarantee on the peek position.
- * @throws InterruptedException If interrupted while reading from input. In this case, the read
- * position is left unchanged and there is no guarantee on the peek position.
*/
@Nullable
public static Metadata readId3Metadata(ExtractorInput input, boolean parseData)
- throws IOException, InterruptedException {
+ throws IOException {
input.resetPeekPosition();
long startingPeekPosition = input.getPeekPosition();
@Nullable Metadata id3Metadata = peekId3Metadata(input, parseData);
@@ -123,11 +116,8 @@ public final class FlacMetadataReader {
* position of {@code input} is advanced by {@link FlacConstants#STREAM_MARKER_SIZE} bytes.
* @throws IOException If reading from the input fails. In this case, the position is left
* unchanged.
- * @throws InterruptedException If interrupted while reading from input. In this case, the
- * position is left unchanged.
*/
- public static void readStreamMarker(ExtractorInput input)
- throws IOException, InterruptedException {
+ public static void readStreamMarker(ExtractorInput input) throws IOException {
ParsableByteArray scratch = new ParsableByteArray(FlacConstants.STREAM_MARKER_SIZE);
input.readFully(scratch.data, 0, FlacConstants.STREAM_MARKER_SIZE);
if (scratch.readUnsignedInt() != STREAM_MARKER) {
@@ -153,13 +143,9 @@ public final class FlacMetadataReader {
* start of a metadata block and there is no guarantee on the peek position.
* @throws IOException If reading from the input fails. In this case, the read position will be at
* the start of a metadata block and there is no guarantee on the peek position.
- * @throws InterruptedException If interrupted while reading from input. In this case, the read
- * position will be at the start of a metadata block and there is no guarantee on the peek
- * position.
*/
public static boolean readMetadataBlock(
- ExtractorInput input, FlacStreamMetadataHolder metadataHolder)
- throws IOException, InterruptedException {
+ ExtractorInput input, FlacStreamMetadataHolder metadataHolder) throws IOException {
input.resetPeekPosition();
ParsableBitArray scratch = new ParsableBitArray(new byte[4]);
input.peekFully(scratch.data, 0, FlacConstants.METADATA_BLOCK_HEADER_SIZE);
@@ -239,10 +225,8 @@ public final class FlacMetadataReader {
* @return The frame start marker (which must be the same for all the frames in the stream).
* @throws ParserException If an error occurs parsing the frame start marker.
* @throws IOException If peeking from the input fails.
- * @throws InterruptedException If interrupted while peeking from input.
*/
- public static int getFrameStartMarker(ExtractorInput input)
- throws IOException, InterruptedException {
+ public static int getFrameStartMarker(ExtractorInput input) throws IOException {
input.resetPeekPosition();
ParsableByteArray scratch = new ParsableByteArray(2);
input.peekFully(scratch.data, 0, 2);
@@ -258,8 +242,7 @@ public final class FlacMetadataReader {
return frameStartMarker;
}
- private static FlacStreamMetadata readStreamInfoBlock(ExtractorInput input)
- throws IOException, InterruptedException {
+ private static FlacStreamMetadata readStreamInfoBlock(ExtractorInput input) throws IOException {
byte[] scratchData = new byte[FlacConstants.STREAM_INFO_BLOCK_SIZE];
input.readFully(scratchData, 0, FlacConstants.STREAM_INFO_BLOCK_SIZE);
return new FlacStreamMetadata(
@@ -267,14 +250,14 @@ public final class FlacMetadataReader {
}
private static FlacStreamMetadata.SeekTable readSeekTableMetadataBlock(
- ExtractorInput input, int length) throws IOException, InterruptedException {
+ ExtractorInput input, int length) throws IOException {
ParsableByteArray scratch = new ParsableByteArray(length);
input.readFully(scratch.data, 0, length);
return readSeekTableMetadataBlock(scratch);
}
private static List
- * The element header (containing the element ID and content size) will already have been read.
- * Implementations are required to consume the whole remainder of the element, which is
- * {@code contentSize} bytes in length, before returning. Implementations are permitted to fail
- * (by throwing an exception) having partially consumed the data, however if they do this, they
- * must consume the remainder of the content when called again.
+ *
+ * The element header (containing the element ID and content size) will already have been read.
+ * Implementations are required to consume the whole remainder of the element, which is {@code
+ * contentSize} bytes in length, before returning. Implementations are permitted to fail (by
+ * throwing an exception) having partially consumed the data, however if they do this, they must
+ * consume the remainder of the content when called again.
*
* @param id The element ID.
* @param contentsSize The element's content size.
* @param input The {@link ExtractorInput} from which data should be read.
* @throws ParserException If a parsing error occurs.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- void binaryElement(int id, int contentsSize, ExtractorInput input)
- throws IOException, InterruptedException;
-
+ void binaryElement(int id, int contentsSize, ExtractorInput input) throws IOException;
}
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java
index c3f00a222f..fc32fba4f7 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java
@@ -50,8 +50,6 @@ import java.io.IOException;
* @return True if data can continue to be read. False if the end of the input was encountered.
* @throws ParserException If parsing fails.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- boolean read(ExtractorInput input) throws IOException, InterruptedException;
-
+ boolean read(ExtractorInput input) throws IOException;
}
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
index 6df328c4e7..6e66049d13 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
@@ -420,7 +420,7 @@ public class MatroskaExtractor implements Extractor {
}
@Override
- public final boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public final boolean sniff(ExtractorInput input) throws IOException {
return new Sniffer().sniff(input);
}
@@ -448,8 +448,7 @@ public class MatroskaExtractor implements Extractor {
}
@Override
- public final int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public final int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
haveOutputSample = false;
boolean continueReading = true;
while (continueReading && !haveOutputSample) {
@@ -1051,8 +1050,7 @@ public class MatroskaExtractor implements Extractor {
* @see EbmlProcessor#binaryElement(int, int, ExtractorInput)
*/
@CallSuper
- protected void binaryElement(int id, int contentSize, ExtractorInput input)
- throws IOException, InterruptedException {
+ protected void binaryElement(int id, int contentSize, ExtractorInput input) throws IOException {
switch (id) {
case ID_SEEK_ID:
Arrays.fill(seekEntryIdBytes.data, (byte) 0);
@@ -1231,7 +1229,7 @@ public class MatroskaExtractor implements Extractor {
protected void handleBlockAdditionalData(
Track track, int blockAdditionalId, ExtractorInput input, int contentSize)
- throws IOException, InterruptedException {
+ throws IOException {
if (blockAdditionalId == BLOCK_ADDITIONAL_ID_VP9_ITU_T_35
&& CODEC_ID_VP9.equals(track.codecId)) {
blockAdditionalData.reset(contentSize);
@@ -1282,8 +1280,7 @@ public class MatroskaExtractor implements Extractor {
* Ensures {@link #scratch} contains at least {@code requiredLength} bytes of data, reading from
* the extractor input if necessary.
*/
- private void readScratch(ExtractorInput input, int requiredLength)
- throws IOException, InterruptedException {
+ private void readScratch(ExtractorInput input, int requiredLength) throws IOException {
if (scratch.limit() >= requiredLength) {
return;
}
@@ -1303,10 +1300,8 @@ public class MatroskaExtractor implements Extractor {
* @param size The size of the sample data on the input side.
* @return The final size of the written sample.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- private int writeSampleData(ExtractorInput input, Track track, int size)
- throws IOException, InterruptedException {
+ private int writeSampleData(ExtractorInput input, Track track, int size) throws IOException {
if (CODEC_ID_SUBRIP.equals(track.codecId)) {
writeSubtitleSampleData(input, SUBRIP_PREFIX, size);
return finishWriteSampleData();
@@ -1506,7 +1501,7 @@ public class MatroskaExtractor implements Extractor {
}
private void writeSubtitleSampleData(ExtractorInput input, byte[] samplePrefix, int size)
- throws IOException, InterruptedException {
+ throws IOException {
int sizeWithPrefix = samplePrefix.length + size;
if (subtitleSample.capacity() < sizeWithPrefix) {
// Initialize subripSample to contain the required prefix and have space to hold a subtitle
@@ -1581,7 +1576,7 @@ public class MatroskaExtractor implements Extractor {
* pending {@link #sampleStrippedBytes} and any remaining data read from {@code input}.
*/
private void writeToTarget(ExtractorInput input, byte[] target, int offset, int length)
- throws IOException, InterruptedException {
+ throws IOException {
int pendingStrippedBytes = Math.min(length, sampleStrippedBytes.bytesLeft());
input.readFully(target, offset + pendingStrippedBytes, length - pendingStrippedBytes);
if (pendingStrippedBytes > 0) {
@@ -1594,7 +1589,7 @@ public class MatroskaExtractor implements Extractor {
* {@link #sampleStrippedBytes} or data read from {@code input}.
*/
private int writeToOutput(ExtractorInput input, TrackOutput output, int length)
- throws IOException, InterruptedException {
+ throws IOException {
int bytesWritten;
int strippedBytesLeft = sampleStrippedBytes.bytesLeft();
if (strippedBytesLeft > 0) {
@@ -1774,8 +1769,7 @@ public class MatroskaExtractor implements Extractor {
}
@Override
- public void binaryElement(int id, int contentsSize, ExtractorInput input)
- throws IOException, InterruptedException {
+ public void binaryElement(int id, int contentsSize, ExtractorInput input) throws IOException {
MatroskaExtractor.this.binaryElement(id, contentsSize, input);
}
}
@@ -1803,7 +1797,7 @@ public class MatroskaExtractor implements Extractor {
chunkSampleCount = 0;
}
- public void startSample(ExtractorInput input) throws IOException, InterruptedException {
+ public void startSample(ExtractorInput input) throws IOException {
if (foundSyncframe) {
return;
}
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java
index 62c9404916..d380fa47c7 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java
@@ -39,10 +39,8 @@ import java.io.IOException;
scratch = new ParsableByteArray(8);
}
- /**
- * @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput)
- */
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ /** @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput) */
+ public boolean sniff(ExtractorInput input) throws IOException {
long inputLength = input.getLength();
int bytesToSearch = (int) (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH
? SEARCH_LENGTH : inputLength);
@@ -86,10 +84,8 @@ import java.io.IOException;
return peekLength == headerStart + headerSize;
}
- /**
- * Peeks a variable-length unsigned EBML integer from the input.
- */
- private long readUint(ExtractorInput input) throws IOException, InterruptedException {
+ /** Peeks a variable-length unsigned EBML integer from the input. */
+ private long readUint(ExtractorInput input) throws IOException {
input.peekFully(scratch.data, 0, 1);
int value = scratch.data[0] & 0xFF;
if (value == 0) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java
index a94a5ec216..6b244de72d 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java
@@ -56,15 +56,15 @@ import java.io.IOException;
}
/**
- * Reads an EBML variable-length integer (varint) from an {@link ExtractorInput} such that
- * reading can be resumed later if an error occurs having read only some of it.
- *
- * If an value is successfully read, then the reader will automatically reset itself ready to
+ * Reads an EBML variable-length integer (varint) from an {@link ExtractorInput} such that reading
+ * can be resumed later if an error occurs having read only some of it.
+ *
+ * If an value is successfully read, then the reader will automatically reset itself ready to
* read another value.
- *
- * If an {@link IOException} or {@link InterruptedException} is throw, the read can be resumed
- * later by calling this method again, passing an {@link ExtractorInput} providing data starting
- * where the previous one left off.
+ *
+ * If an {@link IOException} is thrown, the read can be resumed later by calling this method
+ * again, passing an {@link ExtractorInput} providing data starting where the previous one left
+ * off.
*
* @param input The {@link ExtractorInput} from which the integer should be read.
* @param allowEndOfInput True if encountering the end of the input having read no data is
@@ -76,10 +76,13 @@ import java.io.IOException;
* and the end of the input was encountered, or {@link C#RESULT_MAX_LENGTH_EXCEEDED} if the
* length of the varint exceeded maximumAllowedLength.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- public long readUnsignedVarint(ExtractorInput input, boolean allowEndOfInput,
- boolean removeLengthMask, int maximumAllowedLength) throws IOException, InterruptedException {
+ public long readUnsignedVarint(
+ ExtractorInput input,
+ boolean allowEndOfInput,
+ boolean removeLengthMask,
+ int maximumAllowedLength)
+ throws IOException {
if (state == STATE_BEGIN_READING) {
// Read the first byte to establish the length.
if (!input.readFully(scratch, 0, 1, allowEndOfInput)) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
index 99bccdf3a0..8967e0a230 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
@@ -182,7 +182,7 @@ public final class Mp3Extractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
return synchronize(input, true);
}
@@ -213,8 +213,7 @@ public final class Mp3Extractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
assertInitialized();
int readResult = readInternal(input);
if (readResult == RESULT_END_OF_INPUT && seeker instanceof IndexSeeker) {
@@ -240,7 +239,7 @@ public final class Mp3Extractor implements Extractor {
// Internal methods.
@RequiresNonNull({"extractorOutput", "currentTrackOutput", "realTrackOutput"})
- private int readInternal(ExtractorInput input) throws IOException, InterruptedException {
+ private int readInternal(ExtractorInput input) throws IOException {
if (synchronizedHeaderData == 0) {
try {
synchronize(input, false);
@@ -273,7 +272,7 @@ public final class Mp3Extractor implements Extractor {
}
@RequiresNonNull({"currentTrackOutput", "realTrackOutput", "seeker"})
- private int readSample(ExtractorInput extractorInput) throws IOException, InterruptedException {
+ private int readSample(ExtractorInput extractorInput) throws IOException {
if (sampleBytesRemaining == 0) {
extractorInput.resetPeekPosition();
if (peekEndOfStreamOrHeader(extractorInput)) {
@@ -329,8 +328,7 @@ public final class Mp3Extractor implements Extractor {
return basisTimeUs + samplesRead * C.MICROS_PER_SECOND / synchronizedHeader.sampleRate;
}
- private boolean synchronize(ExtractorInput input, boolean sniffing)
- throws IOException, InterruptedException {
+ private boolean synchronize(ExtractorInput input, boolean sniffing) throws IOException {
int validFrameCount = 0;
int candidateSynchronizedHeaderData = 0;
int peekedId3Bytes = 0;
@@ -407,8 +405,7 @@ public final class Mp3Extractor implements Extractor {
* Returns whether the extractor input is peeking the end of the stream. If {@code false},
* populates the scratch buffer with the next four bytes.
*/
- private boolean peekEndOfStreamOrHeader(ExtractorInput extractorInput)
- throws IOException, InterruptedException {
+ private boolean peekEndOfStreamOrHeader(ExtractorInput extractorInput) throws IOException {
if (seeker != null) {
long dataEndPosition = seeker.getDataEndPosition();
if (dataEndPosition != C.POSITION_UNSET
@@ -424,7 +421,7 @@ public final class Mp3Extractor implements Extractor {
}
}
- private Seeker computeSeeker(ExtractorInput input) throws IOException, InterruptedException {
+ private Seeker computeSeeker(ExtractorInput input) throws IOException {
// Read past any seek frame and set the seeker based on metadata or a seek frame. Metadata
// takes priority as it can provide greater precision.
Seeker seekFrameSeeker = maybeReadSeekFrame(input);
@@ -471,11 +468,9 @@ public final class Mp3Extractor implements Extractor {
* @return A {@link Seeker} if seeking metadata was present and valid, or {@code null} otherwise.
* @throws IOException Thrown if there was an error reading from the stream. Not expected if the
* next two frames were already peeked during synchronization.
- * @throws InterruptedException Thrown if reading from the stream was interrupted. Not expected if
- * the next two frames were already peeked during synchronization.
*/
@Nullable
- private Seeker maybeReadSeekFrame(ExtractorInput input) throws IOException, InterruptedException {
+ private Seeker maybeReadSeekFrame(ExtractorInput input) throws IOException {
ParsableByteArray frame = new ParsableByteArray(synchronizedHeader.frameSize);
input.peekFully(frame.data, 0, synchronizedHeader.frameSize);
int xingBase = (synchronizedHeader.version & 1) != 0
@@ -509,11 +504,8 @@ public final class Mp3Extractor implements Extractor {
return seeker;
}
- /**
- * Peeks the next frame and returns a {@link ConstantBitrateSeeker} based on its bitrate.
- */
- private Seeker getConstantBitrateSeeker(ExtractorInput input)
- throws IOException, InterruptedException {
+ /** Peeks the next frame and returns a {@link ConstantBitrateSeeker} based on its bitrate. */
+ private Seeker getConstantBitrateSeeker(ExtractorInput input) throws IOException {
input.peekFully(scratch.data, 0, 4);
scratch.setPosition(0);
synchronizedHeader.setForHeaderData(scratch.readInt());
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
index e3ff8885ef..84a92cfd13 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
@@ -268,7 +268,7 @@ public class FragmentedMp4Extractor implements Extractor {
}
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
return Sniffer.sniffFragmented(input);
}
@@ -303,8 +303,7 @@ public class FragmentedMp4Extractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
while (true) {
switch (parserState) {
case STATE_READING_ATOM_HEADER:
@@ -331,7 +330,7 @@ public class FragmentedMp4Extractor implements Extractor {
atomHeaderBytesRead = 0;
}
- private boolean readAtomHeader(ExtractorInput input) throws IOException, InterruptedException {
+ private boolean readAtomHeader(ExtractorInput input) throws IOException {
if (atomHeaderBytesRead == 0) {
// Read the standard length atom header.
if (!input.readFully(atomHeader.data, 0, Atom.HEADER_SIZE, true)) {
@@ -419,7 +418,7 @@ public class FragmentedMp4Extractor implements Extractor {
return true;
}
- private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
+ private void readAtomPayload(ExtractorInput input) throws IOException {
int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
if (atomData != null) {
input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
@@ -1170,7 +1169,7 @@ public class FragmentedMp4Extractor implements Extractor {
new ChunkIndex(sizes, offsets, durationsUs, timesUs));
}
- private void readEncryptionData(ExtractorInput input) throws IOException, InterruptedException {
+ private void readEncryptionData(ExtractorInput input) throws IOException {
TrackBundle nextTrackBundle = null;
long nextDataOffset = Long.MAX_VALUE;
int trackBundlesSize = trackBundles.size();
@@ -1208,9 +1207,8 @@ public class FragmentedMp4Extractor implements Extractor {
* @return Whether a sample was read. The read sample may have been output or skipped. False
* indicates that there are no samples left to read in the current mdat.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- private boolean readSample(ExtractorInput input) throws IOException, InterruptedException {
+ private boolean readSample(ExtractorInput input) throws IOException {
if (parserState == STATE_READING_SAMPLE_START) {
if (currentTrackBundle == null) {
@Nullable TrackBundle currentTrackBundle = getNextFragmentRun(trackBundles);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
index 659b97a8a9..48c7e3e122 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
@@ -146,7 +146,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
}
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
return Sniffer.sniffUnfragmented(input);
}
@@ -176,8 +176,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
while (true) {
switch (parserState) {
case STATE_READING_ATOM_HEADER:
@@ -270,7 +269,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
atomHeaderBytesRead = 0;
}
- private boolean readAtomHeader(ExtractorInput input) throws IOException, InterruptedException {
+ private boolean readAtomHeader(ExtractorInput input) throws IOException {
if (atomHeaderBytesRead == 0) {
// Read the standard length atom header.
if (!input.readFully(atomHeader.data, 0, Atom.HEADER_SIZE, true)) {
@@ -341,7 +340,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
* restart loading at the position in {@code positionHolder}. Otherwise, the atom is read/skipped.
*/
private boolean readAtomPayload(ExtractorInput input, PositionHolder positionHolder)
- throws IOException, InterruptedException {
+ throws IOException {
long atomPayloadSize = atomSize - atomHeaderBytesRead;
long atomEndPosition = input.getPosition() + atomPayloadSize;
boolean seekRequired = false;
@@ -485,22 +484,20 @@ public final class Mp4Extractor implements Extractor, SeekMap {
/**
* Attempts to extract the next sample in the current mdat atom for the specified track.
- *
- * Returns {@link #RESULT_SEEK} if the source should be reloaded from the position in
- * {@code positionHolder}.
- *
- * Returns {@link #RESULT_END_OF_INPUT} if no samples are left. Otherwise, returns
- * {@link #RESULT_CONTINUE}.
+ *
+ * Returns {@link #RESULT_SEEK} if the source should be reloaded from the position in {@code
+ * positionHolder}.
+ *
+ * Returns {@link #RESULT_END_OF_INPUT} if no samples are left. Otherwise, returns {@link
+ * #RESULT_CONTINUE}.
*
* @param input The {@link ExtractorInput} from which to read data.
* @param positionHolder If {@link #RESULT_SEEK} is returned, this holder is updated to hold the
* position of the required data.
* @return One of the {@code RESULT_*} flags in {@link Extractor}.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread is interrupted.
*/
- private int readSample(ExtractorInput input, PositionHolder positionHolder)
- throws IOException, InterruptedException {
+ private int readSample(ExtractorInput input, PositionHolder positionHolder) throws IOException {
long inputPosition = input.getPosition();
if (sampleTrackIndex == C.INDEX_UNSET) {
sampleTrackIndex = getTrackIndexOfNextReadSample(inputPosition);
@@ -663,8 +660,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
* we can't rely on the file type though. Instead we must check the 8 bytes after the common
* header bytes ourselves.
*/
- private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input)
- throws IOException, InterruptedException {
+ private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input) throws IOException {
scratch.reset(8);
// Peek the next 8 bytes which can be either
// (iso) [1 byte version + 3 bytes flags][4 byte size of next atom]
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java
index dac74bfe2b..c661e7be07 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java
@@ -66,10 +66,8 @@ import java.io.IOException;
* @param input The extractor input from which to peek data. The peek position will be modified.
* @return Whether the input appears to be in the fragmented MP4 format.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread has been interrupted.
*/
- public static boolean sniffFragmented(ExtractorInput input)
- throws IOException, InterruptedException {
+ public static boolean sniffFragmented(ExtractorInput input) throws IOException {
return sniffInternal(input, true);
}
@@ -80,15 +78,13 @@ import java.io.IOException;
* @param input The extractor input from which to peek data. The peek position will be modified.
* @return Whether the input appears to be in the unfragmented MP4 format.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread has been interrupted.
*/
- public static boolean sniffUnfragmented(ExtractorInput input)
- throws IOException, InterruptedException {
+ public static boolean sniffUnfragmented(ExtractorInput input) throws IOException {
return sniffInternal(input, false);
}
private static boolean sniffInternal(ExtractorInput input, boolean fragmented)
- throws IOException, InterruptedException {
+ throws IOException {
long inputLength = input.getLength();
int bytesToSearch = (int) (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH
? SEARCH_LENGTH : inputLength);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java
index b9f51b78a9..456cd50397 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java
@@ -169,7 +169,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*
* @param input An {@link ExtractorInput} from which to read the encryption data.
*/
- public void fillEncryptionData(ExtractorInput input) throws IOException, InterruptedException {
+ public void fillEncryptionData(ExtractorInput input) throws IOException {
input.readFully(sampleEncryptionData.data, 0, sampleEncryptionData.limit());
sampleEncryptionData.setPosition(0);
sampleEncryptionDataNeedsFill = false;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
index ecbaaeb143..1d73a1b66a 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/DefaultOggSeeker.java
@@ -88,7 +88,7 @@ import java.io.IOException;
}
@Override
- public long read(ExtractorInput input) throws IOException, InterruptedException {
+ public long read(ExtractorInput input) throws IOException {
switch (state) {
case STATE_IDLE:
return -1;
@@ -148,9 +148,8 @@ import java.io.IOException;
* @return The byte position from which data should be provided for the next step, or {@link
* C#POSITION_UNSET} if the search has converged.
* @throws IOException If reading from the input fails.
- * @throws InterruptedException If interrupted while reading from the input.
*/
- private long getNextSeekPosition(ExtractorInput input) throws IOException, InterruptedException {
+ private long getNextSeekPosition(ExtractorInput input) throws IOException {
if (start == end) {
return C.POSITION_UNSET;
}
@@ -199,10 +198,8 @@ import java.io.IOException;
* @param input The {@link ExtractorInput} to read from.
* @throws ParserException If populating the page header fails.
* @throws IOException If reading from the input fails.
- * @throws InterruptedException If interrupted while reading from the input.
*/
- private void skipToPageOfTargetGranule(ExtractorInput input)
- throws IOException, InterruptedException {
+ private void skipToPageOfTargetGranule(ExtractorInput input) throws IOException {
pageHeader.populate(input, /* quiet= */ false);
while (pageHeader.granulePosition <= targetGranule) {
input.skipFully(pageHeader.headerSize + pageHeader.bodySize);
@@ -218,11 +215,10 @@ import java.io.IOException;
*
* @param input The {@code ExtractorInput} to skip to the next page.
* @throws IOException If peeking/reading from the input fails.
- * @throws InterruptedException If the thread is interrupted.
* @throws EOFException If the next page can't be found before the end of the input.
*/
@VisibleForTesting
- void skipToNextPage(ExtractorInput input) throws IOException, InterruptedException {
+ void skipToNextPage(ExtractorInput input) throws IOException {
if (!skipToNextPage(input, payloadEndPosition)) {
// Not found until eof.
throw new EOFException();
@@ -236,10 +232,8 @@ import java.io.IOException;
* @param limit The limit up to which the search should take place.
* @return Whether the next page was found.
* @throws IOException If peeking/reading from the input fails.
- * @throws InterruptedException If interrupted while peeking/reading from the input.
*/
- private boolean skipToNextPage(ExtractorInput input, long limit)
- throws IOException, InterruptedException {
+ private boolean skipToNextPage(ExtractorInput input, long limit) throws IOException {
limit = Math.min(limit + 3, payloadEndPosition);
byte[] buffer = new byte[2048];
int peekLength = buffer.length;
@@ -275,10 +269,9 @@ import java.io.IOException;
* @param input The {@link ExtractorInput} to read from.
* @return The total number of samples of this input.
* @throws IOException If reading from the input fails.
- * @throws InterruptedException If the thread is interrupted.
*/
@VisibleForTesting
- long readGranuleOfLastPage(ExtractorInput input) throws IOException, InterruptedException {
+ long readGranuleOfLastPage(ExtractorInput input) throws IOException {
skipToNextPage(input);
pageHeader.reset();
while ((pageHeader.type & 0x04) != 0x04 && input.getPosition() < payloadEndPosition) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java
index 47698cc285..9aaa3332ce 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java
@@ -44,7 +44,7 @@ public class OggExtractor implements Extractor {
private boolean streamReaderInitialized;
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
try {
return sniffInternal(input);
} catch (ParserException e) {
@@ -70,8 +70,7 @@ public class OggExtractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
Assertions.checkStateNotNull(output); // Asserts that init has been called.
if (streamReader == null) {
if (!sniffInternal(input)) {
@@ -89,7 +88,7 @@ public class OggExtractor implements Extractor {
}
@EnsuresNonNullIf(expression = "streamReader", result = true)
- private boolean sniffInternal(ExtractorInput input) throws IOException, InterruptedException {
+ private boolean sniffInternal(ExtractorInput input) throws IOException {
OggPageHeader header = new OggPageHeader();
if (!header.populate(input, true) || (header.type & 0x02) != 0x02) {
return false;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java
index 9c594ffde5..2ee65f0112 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java
@@ -55,9 +55,8 @@ import java.util.Arrays;
* @return {@code true} if the read was successful. The read fails if the end of the input is
* encountered without reading data.
* @throws IOException If reading from the input fails.
- * @throws InterruptedException If the thread is interrupted.
*/
- public boolean populate(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean populate(ExtractorInput input) throws IOException {
Assertions.checkState(input != null);
if (populated) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java
index c7fb3ff6a2..d96aaa4568 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java
@@ -82,10 +82,8 @@ import java.io.IOException;
* @return Whether the read was successful. The read fails if the end of the input is encountered
* without reading data.
* @throws IOException If reading data fails or the stream is invalid.
- * @throws InterruptedException If the thread is interrupted.
*/
- public boolean populate(ExtractorInput input, boolean quiet)
- throws IOException, InterruptedException {
+ public boolean populate(ExtractorInput input, boolean quiet) throws IOException {
scratch.reset();
reset();
boolean hasEnoughBytes = input.getLength() == C.LENGTH_UNSET
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggSeeker.java
index 1fa7478488..7626aa52d8 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggSeeker.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggSeeker.java
@@ -43,17 +43,15 @@ import java.io.IOException;
/**
* Reads data from the {@link ExtractorInput} to build the {@link SeekMap} or to continue a seek.
- * If more data is required or if the position of the input needs to be modified then a
+ * position from which data should be provided is returned. Else a negative value is returned. If
+ * a seek has been completed then the value returned is -(currentGranule + 2). Else it is -1.
*
* @param input The {@link ExtractorInput} to read from.
* @return A non-negative position to seek the {@link ExtractorInput} to, or -(currentGranule + 2)
* if the progressive seek has completed, or -1 otherwise.
* @throws IOException If reading from the {@link ExtractorInput} fails.
- * @throws InterruptedException If the thread is interrupted.
*/
- long read(ExtractorInput input) throws IOException, InterruptedException;
-
+ long read(ExtractorInput input) throws IOException;
}
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java
index c701339816..f28602d9b3 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java
@@ -101,11 +101,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
- /**
- * @see Extractor#read(ExtractorInput, PositionHolder)
- */
- final int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ /** @see Extractor#read(ExtractorInput, PositionHolder) */
+ final int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
switch (state) {
case STATE_READ_HEADERS:
return readHeaders(input);
@@ -121,7 +118,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
- private int readHeaders(ExtractorInput input) throws IOException, InterruptedException {
+ private int readHeaders(ExtractorInput input) throws IOException {
boolean readingHeaders = true;
while (readingHeaders) {
if (!oggPacket.populate(input)) {
@@ -166,8 +163,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
return Extractor.RESULT_CONTINUE;
}
- private int readPayload(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ private int readPayload(ExtractorInput input, PositionHolder seekPosition) throws IOException {
long position = oggSeeker.read(input);
if (position >= 0) {
seekPosition.position = position;
@@ -238,8 +234,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* @param setupData Setup data to be filled.
* @return Whether the packet contains header data.
*/
- protected abstract boolean readHeaders(ParsableByteArray packet, long position,
- SetupData setupData) throws IOException, InterruptedException;
+ protected abstract boolean readHeaders(
+ ParsableByteArray packet, long position, SetupData setupData) throws IOException;
/**
* Called on end of seeking.
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java
index c2cf2b1059..ae30231a50 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractor.java
@@ -71,15 +71,14 @@ public final class RawCcExtractor implements Extractor {
}
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
dataScratch.reset();
input.peekFully(dataScratch.data, 0, HEADER_SIZE);
return dataScratch.readInt() == HEADER_ID;
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
Assertions.checkStateNotNull(trackOutput); // Asserts that init has been called.
while (true) {
switch (parserState) {
@@ -118,7 +117,7 @@ public final class RawCcExtractor implements Extractor {
// Do nothing
}
- private boolean parseHeader(ExtractorInput input) throws IOException, InterruptedException {
+ private boolean parseHeader(ExtractorInput input) throws IOException {
dataScratch.reset();
if (input.readFully(dataScratch.data, 0, HEADER_SIZE, true)) {
if (dataScratch.readInt() != HEADER_ID) {
@@ -132,8 +131,7 @@ public final class RawCcExtractor implements Extractor {
}
}
- private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
- InterruptedException {
+ private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException {
dataScratch.reset();
if (version == 0) {
if (!input.readFully(dataScratch.data, 0, TIMESTAMP_SIZE_V0 + 1, true)) {
@@ -156,7 +154,7 @@ public final class RawCcExtractor implements Extractor {
}
@RequiresNonNull("trackOutput")
- private void parseSamples(ExtractorInput input) throws IOException, InterruptedException {
+ private void parseSamples(ExtractorInput input) throws IOException {
for (; remainingSampleCount > 0; remainingSampleCount--) {
dataScratch.reset();
input.readFully(dataScratch.data, 0, 3);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java
index b1d15b7189..f0cb8ca1f7 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java
@@ -61,7 +61,7 @@ public final class Ac3Extractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
// Skip any ID3 headers.
ParsableByteArray scratch = new ParsableByteArray(ID3_HEADER_LENGTH);
int startPosition = 0;
@@ -124,8 +124,7 @@ public final class Ac3Extractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException,
- InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
int bytesRead = input.read(sampleData.data, 0, MAX_SYNC_FRAME_SIZE);
if (bytesRead == C.RESULT_END_OF_INPUT) {
return RESULT_END_OF_INPUT;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Extractor.java
index 205d71e16e..c493d1d0bd 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Extractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Extractor.java
@@ -68,7 +68,7 @@ public final class Ac4Extractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
// Skip any ID3 headers.
ParsableByteArray scratch = new ParsableByteArray(ID3_HEADER_LENGTH);
int startPosition = 0;
@@ -132,8 +132,7 @@ public final class Ac4Extractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
int bytesRead = input.read(sampleData.data, /* offset= */ 0, /* length= */ READ_BUFFER_SIZE);
if (bytesRead == C.RESULT_END_OF_INPUT) {
return RESULT_END_OF_INPUT;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java
index e481a8458d..f870527284 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsExtractor.java
@@ -120,7 +120,7 @@ public final class AdtsExtractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
// Skip any ID3 headers.
int startPosition = peekId3Header(input);
@@ -179,8 +179,7 @@ public final class AdtsExtractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
Assertions.checkStateNotNull(extractorOutput); // Asserts that init has been called.
long inputLength = input.getLength();
@@ -212,7 +211,7 @@ public final class AdtsExtractor implements Extractor {
return RESULT_CONTINUE;
}
- private int peekId3Header(ExtractorInput input) throws IOException, InterruptedException {
+ private int peekId3Header(ExtractorInput input) throws IOException {
int firstFramePosition = 0;
while (true) {
input.peekFully(scratch.data, /* offset= */ 0, ID3_HEADER_LENGTH);
@@ -256,8 +255,7 @@ public final class AdtsExtractor implements Extractor {
hasOutputSeekMap = true;
}
- private void calculateAverageFrameSize(ExtractorInput input)
- throws IOException, InterruptedException {
+ private void calculateAverageFrameSize(ExtractorInput input) throws IOException {
if (hasCalculatedAverageFrameSize) {
return;
}
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java
index c4f53ba176..09cf9b3f00 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsBinarySearchSeeker.java
@@ -70,7 +70,7 @@ import java.io.IOException;
@Override
public TimestampSearchResult searchForTimestamp(ExtractorInput input, long targetTimestamp)
- throws IOException, InterruptedException {
+ throws IOException {
long inputPosition = input.getPosition();
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength() - inputPosition);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsDurationReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsDurationReader.java
index b0cdf7eb79..4748b832de 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsDurationReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsDurationReader.java
@@ -81,11 +81,9 @@ import java.io.IOException;
* to hold the position of the required seek.
* @return One of the {@code RESULT_} values defined in {@link Extractor}.
* @throws IOException If an error occurred reading from the input.
- * @throws InterruptedException If the thread was interrupted.
*/
public @Extractor.ReadResult int readDuration(
- ExtractorInput input, PositionHolder seekPositionHolder)
- throws IOException, InterruptedException {
+ ExtractorInput input, PositionHolder seekPositionHolder) throws IOException {
if (!isLastScrValueRead) {
return readLastScrValue(input, seekPositionHolder);
}
@@ -137,7 +135,7 @@ import java.io.IOException;
}
private int readFirstScrValue(ExtractorInput input, PositionHolder seekPositionHolder)
- throws IOException, InterruptedException {
+ throws IOException {
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength());
int searchStartPosition = 0;
if (input.getPosition() != searchStartPosition) {
@@ -173,7 +171,7 @@ import java.io.IOException;
}
private int readLastScrValue(ExtractorInput input, PositionHolder seekPositionHolder)
- throws IOException, InterruptedException {
+ throws IOException {
long inputLength = input.getLength();
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, inputLength);
long searchStartPosition = inputLength - bytesToSearch;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java
index 7dc360b6d4..96bdc22631 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java
@@ -89,7 +89,7 @@ public final class PsExtractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
byte[] scratch = new byte[14];
input.peekFully(scratch, 0, 14);
@@ -162,8 +162,7 @@ public final class PsExtractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
Assertions.checkStateNotNull(output); // Asserts init has been called.
long inputLength = input.getLength();
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java
index a627c00ba2..8a1d2b2fdf 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsBinarySearchSeeker.java
@@ -74,7 +74,7 @@ import java.io.IOException;
@Override
public TimestampSearchResult searchForTimestamp(ExtractorInput input, long targetTimestamp)
- throws IOException, InterruptedException {
+ throws IOException {
long inputPosition = input.getPosition();
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength() - inputPosition);
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java
index 804a643414..a60d3fcb82 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java
@@ -74,11 +74,9 @@ import java.io.IOException;
* @param pcrPid The PID of the packet stream within this TS stream that contains PCR values.
* @return One of the {@code RESULT_} values defined in {@link Extractor}.
* @throws IOException If an error occurred reading from the input.
- * @throws InterruptedException If the thread was interrupted.
*/
public @Extractor.ReadResult int readDuration(
- ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid)
- throws IOException, InterruptedException {
+ ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid) throws IOException {
if (pcrPid <= 0) {
return finishReadDuration(input);
}
@@ -124,7 +122,7 @@ import java.io.IOException;
}
private int readFirstPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid)
- throws IOException, InterruptedException {
+ throws IOException {
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, input.getLength());
int searchStartPosition = 0;
if (input.getPosition() != searchStartPosition) {
@@ -159,7 +157,7 @@ import java.io.IOException;
}
private int readLastPcrValue(ExtractorInput input, PositionHolder seekPositionHolder, int pcrPid)
- throws IOException, InterruptedException {
+ throws IOException {
long inputLength = input.getLength();
int bytesToSearch = (int) Math.min(TIMESTAMP_SEARCH_BYTES, inputLength);
long searchStartPosition = inputLength - bytesToSearch;
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java
index 3d0d6a18ea..5e85a80a5d 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java
@@ -190,7 +190,7 @@ public final class TsExtractor implements Extractor {
// Extractor implementation.
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
byte[] buffer = tsPacketBuffer.data;
input.peekFully(buffer, 0, TS_PACKET_SIZE * SNIFF_TS_PACKET_COUNT);
for (int startPosCandidate = 0; startPosCandidate < TS_PACKET_SIZE; startPosCandidate++) {
@@ -253,7 +253,7 @@ public final class TsExtractor implements Extractor {
@Override
public @ReadResult int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ throws IOException {
long inputLength = input.getLength();
if (tracksEnded) {
boolean canReadDuration = inputLength != C.LENGTH_UNSET && mode != MODE_HLS;
@@ -372,8 +372,7 @@ public final class TsExtractor implements Extractor {
}
}
- private boolean fillBufferWithAtLeastOnePacket(ExtractorInput input)
- throws IOException, InterruptedException {
+ private boolean fillBufferWithAtLeastOnePacket(ExtractorInput input) throws IOException {
byte[] data = tsPacketBuffer.data;
// Shift bytes to the start of the buffer if there isn't enough space left at the end.
if (BUFFER_SIZE - tsPacketBuffer.getPosition() < TS_PACKET_SIZE) {
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
index 27bf6b6fc9..5ba550047b 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
@@ -61,7 +61,7 @@ public final class WavExtractor implements Extractor {
}
@Override
- public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ public boolean sniff(ExtractorInput input) throws IOException {
return WavHeaderReader.peek(input) != null;
}
@@ -85,8 +85,7 @@ public final class WavExtractor implements Extractor {
}
@Override
- public int read(ExtractorInput input, PositionHolder seekPosition)
- throws IOException, InterruptedException {
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
assertInitialized();
if (outputWriter == null) {
WavHeader header = WavHeaderReader.peek(input);
@@ -176,10 +175,8 @@ public final class WavExtractor implements Extractor {
* @param bytesLeft The number of sample data bytes left to be read from the input.
* @return Whether the end of the sample data has been reached.
* @throws IOException If an error occurs reading from the input.
- * @throws InterruptedException If the thread has been interrupted.
*/
- boolean sampleData(ExtractorInput input, long bytesLeft)
- throws IOException, InterruptedException;
+ boolean sampleData(ExtractorInput input, long bytesLeft) throws IOException;
}
private static final class PassthroughOutputWriter implements OutputWriter {
@@ -253,8 +250,7 @@ public final class WavExtractor implements Extractor {
}
@Override
- public boolean sampleData(ExtractorInput input, long bytesLeft)
- throws IOException, InterruptedException {
+ public boolean sampleData(ExtractorInput input, long bytesLeft) throws IOException {
// Write sample data until we've reached the target sample size, or the end of the data.
boolean endOfSampleData = bytesLeft == 0;
while (!endOfSampleData && pendingOutputBytes < targetSampleSizeBytes) {
@@ -397,8 +393,7 @@ public final class WavExtractor implements Extractor {
}
@Override
- public boolean sampleData(ExtractorInput input, long bytesLeft)
- throws IOException, InterruptedException {
+ public boolean sampleData(ExtractorInput input, long bytesLeft) throws IOException {
// Calculate the number of additional frames that we need on the output side to complete a
// sample of the target size.
int targetFramesRemaining =
diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
index b2cdda7f9d..bcc229f3e9 100644
--- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
+++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavHeaderReader.java
@@ -38,12 +38,11 @@ import java.io.IOException;
* @param input Input stream to peek the WAV header from.
* @throws ParserException If the input file is an incorrect RIFF WAV.
* @throws IOException If peeking from the input fails.
- * @throws InterruptedException If interrupted while peeking from input.
* @return A new {@code WavHeader} peeked from {@code input}, or null if the input is not a
* supported WAV format.
*/
@Nullable
- public static WavHeader peek(ExtractorInput input) throws IOException, InterruptedException {
+ public static WavHeader peek(ExtractorInput input) throws IOException {
Assertions.checkNotNull(input);
// Allocate a scratch buffer large enough to store the format chunk.
@@ -108,10 +107,8 @@ import java.io.IOException;
* @return The byte positions at which the data starts (inclusive) and ends (exclusive).
* @throws ParserException If an error occurs parsing chunks.
* @throws IOException If reading from the input fails.
- * @throws InterruptedException If interrupted while reading from input.
*/
- public static Pair