Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bb8df2b authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Remove InterruptedException from MediaParser" into rvc-dev am:...

Merge "Merge "Remove InterruptedException from MediaParser" into rvc-dev am: 315b8782 am: e8a71156" into rvc-d1-dev-plus-aosp
parents dffd1369 af553356
Loading
Loading
Loading
Loading
+27 −24
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.google.android.exoplayer2.video.ColorInfo;

import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.HashMap;
@@ -119,7 +120,7 @@ import java.util.Map;
 *
 *     @Override
 *     public void onSampleData(int trackIndex, @NonNull InputReader inputReader)
 *         throws IOException, InterruptedException {
 *         throws IOException {
 *       int numberOfBytesToRead = (int) inputReader.getLength();
 *       if (videoTrackIndex != trackIndex) {
 *         // Discard contents.
@@ -310,8 +311,7 @@ public final class MediaParser {
         *     of the input has been reached.
         * @throws java.io.IOException If an error occurs reading from the source.
         */
        int read(@NonNull byte[] buffer, int offset, int readLength)
                throws IOException, InterruptedException;
        int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException;

        /** Returns the current read position (byte offset) in the stream. */
        long getPosition();
@@ -373,11 +373,8 @@ public final class MediaParser {
         * @param trackIndex The index of the track to which the sample data corresponds.
         * @param inputReader The {@link InputReader} from which to read the data.
         * @throws IOException If an exception occurs while reading from {@code inputReader}.
         * @throws InterruptedException If an interruption occurs while reading from {@code
         *     inputReader}.
         */
        void onSampleData(int trackIndex, @NonNull InputReader inputReader)
                throws IOException, InterruptedException;
        void onSampleData(int trackIndex, @NonNull InputReader inputReader) throws IOException;

        /**
         * Called once all the data of a sample has been passed to {@link #onSampleData}.
@@ -717,8 +714,7 @@ public final class MediaParser {
     * @throws UnrecognizedInputFormatException If the format cannot be recognized by any of the
     *     underlying parser implementations.
     */
    public boolean advance(@NonNull SeekableInputReader seekableInputReader)
            throws IOException, InterruptedException {
    public boolean advance(@NonNull SeekableInputReader seekableInputReader) throws IOException {
        if (mExtractorInput == null) {
            // TODO: For efficiency, the same implementation should be used, by providing a
            // clearBuffers() method, or similar.
@@ -748,8 +744,10 @@ public final class MediaParser {
                        }
                    } catch (EOFException e) {
                        // Do nothing.
                    } catch (IOException | InterruptedException e) {
                        throw new IllegalStateException(e);
                    } catch (InterruptedException e) {
                        // TODO: Remove this exception replacement once we update the ExoPlayer
                        // version.
                        throw new InterruptedIOException();
                    } finally {
                        mExtractorInput.resetPeekPosition();
                    }
@@ -767,7 +765,13 @@ public final class MediaParser {
        }

        mPositionHolder.position = seekableInputReader.getPosition();
        int result = mExtractor.read(mExtractorInput, mPositionHolder);
        int result = 0;
        try {
            result = mExtractor.read(mExtractorInput, mPositionHolder);
        } catch (InterruptedException e) {
            // TODO: Remove this exception replacement once we update the ExoPlayer version.
            throw new InterruptedIOException();
        }
        if (result == Extractor.RESULT_END_OF_INPUT) {
            return false;
        }
@@ -853,13 +857,7 @@ public final class MediaParser {

        @Override
        public int read(byte[] buffer, int offset, int readLength) throws IOException {
            // TODO: Reevaluate interruption in Input.
            try {
            return mInputReader.read(buffer, offset, readLength);
            } catch (InterruptedException e) {
                // TODO: Remove.
                throw new RuntimeException();
            }
        }

        @Override
@@ -926,7 +924,7 @@ public final class MediaParser {

        @Override
        public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput)
                throws IOException, InterruptedException {
                throws IOException {
            mScratchExtractorInputAdapter.setExtractorInput(input, length);
            long positionBeforeReading = mScratchExtractorInputAdapter.getPosition();
            mOutputConsumer.onSampleData(mTrackIndex, mScratchExtractorInputAdapter);
@@ -938,7 +936,7 @@ public final class MediaParser {
            mScratchParsableByteArrayAdapter.resetWithByteArray(data, length);
            try {
                mOutputConsumer.onSampleData(mTrackIndex, mScratchParsableByteArrayAdapter);
            } catch (IOException | InterruptedException e) {
            } catch (IOException e) {
                // Unexpected.
                throw new RuntimeException(e);
            }
@@ -967,9 +965,14 @@ public final class MediaParser {
        // Input implementation.

        @Override
        public int read(byte[] buffer, int offset, int readLength)
                throws IOException, InterruptedException {
            int readBytes = mExtractorInput.read(buffer, offset, readLength);
        public int read(byte[] buffer, int offset, int readLength) throws IOException {
            int readBytes = 0;
            try {
                readBytes = mExtractorInput.read(buffer, offset, readLength);
            } catch (InterruptedException e) {
                // TODO: Remove this exception replacement once we update the ExoPlayer version.
                throw new InterruptedIOException();
            }
            mCurrentPosition += readBytes;
            return readBytes;
        }
+3 −3
Original line number Diff line number Diff line
@@ -26403,7 +26403,7 @@ package android.media {
  }
  public final class MediaParser {
    method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException, java.lang.InterruptedException;
    method public boolean advance(@NonNull android.media.MediaParser.SeekableInputReader) throws java.io.IOException;
    method @NonNull public static android.media.MediaParser create(@NonNull android.media.MediaParser.OutputConsumer, @NonNull java.lang.String...);
    method @NonNull public static android.media.MediaParser createByName(@NonNull String, @NonNull android.media.MediaParser.OutputConsumer);
    method @Nullable public String getParserName();
@@ -26435,12 +26435,12 @@ package android.media {
  public static interface MediaParser.InputReader {
    method public long getLength();
    method public long getPosition();
    method public int read(@NonNull byte[], int, int) throws java.io.IOException, java.lang.InterruptedException;
    method public int read(@NonNull byte[], int, int) throws java.io.IOException;
  }
  public static interface MediaParser.OutputConsumer {
    method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo);
    method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException, java.lang.InterruptedException;
    method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException;
    method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap);
    method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData);
    method public void onTracksFound(int);