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

Commit 1f146f40 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android Git Automerger
Browse files

am a3608e7a: am 4e43a27a: Merge "MediaCodec: revalidate cached queued input...

am a3608e7a: am 4e43a27a: Merge "MediaCodec: revalidate cached queued input buffers if queue fails (2)" into lmp-dev

* commit 'a3608e7a5ea4a489830336cfb37ffefb77e89e6d':
  MediaCodec: revalidate cached queued input buffers if queue fails (2)
parents b3e68eb2 d9298cfc
Loading
Loading
Loading
Loading
+17 −5
Original line number Original line Diff line number Diff line
@@ -830,8 +830,8 @@ final public class MediaCodec {
        try {
        try {
            native_queueInputBuffer(
            native_queueInputBuffer(
                    index, offset, size, presentationTimeUs, flags);
                    index, offset, size, presentationTimeUs, flags);
        } catch (CryptoException e) {
        } catch (CryptoException | IllegalStateException e) {
            validateInputByteBuffer(mCachedInputBuffers, index);
            revalidateByteBuffer(mCachedInputBuffers, index);
            throw e;
            throw e;
        }
        }
    }
    }
@@ -955,8 +955,8 @@ final public class MediaCodec {
        try {
        try {
            native_queueSecureInputBuffer(
            native_queueSecureInputBuffer(
                    index, offset, info, presentationTimeUs, flags);
                    index, offset, info, presentationTimeUs, flags);
        } catch (CryptoException e) {
        } catch (CryptoException | IllegalStateException e) {
            validateInputByteBuffer(mCachedInputBuffers, index);
            revalidateByteBuffer(mCachedInputBuffers, index);
            throw e;
            throw e;
        }
        }
    }
    }
@@ -1280,6 +1280,18 @@ final public class MediaCodec {
        }
        }
    }
    }


    private final void revalidateByteBuffer(
            ByteBuffer[] buffers, int index) {
        synchronized(mBufferLock) {
            if (buffers != null && index >= 0 && index < buffers.length) {
                ByteBuffer buffer = buffers[index];
                if (buffer != null) {
                    buffer.setAccessible(true);
                }
            }
        }
    }

    private final void validateOutputByteBuffer(
    private final void validateOutputByteBuffer(
            ByteBuffer[] buffers, int index, BufferInfo info) {
            ByteBuffer[] buffers, int index, BufferInfo info) {
        if (buffers != null && index >= 0 && index < buffers.length) {
        if (buffers != null && index >= 0 && index < buffers.length) {