Commit e048085a authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Speculative MC fix: Don't call getInputBuffers() after an error.

See bugs for more detail; this only helps M+ where we're using
the callback API now and can get the true error status earlier
than we could before.

This also adds a log message when onError is called so that we
can debug these more easily in the field.

BUG=873094, 610523
TEST=none

Change-Id: I3fbae95e872fe430f7dd0ddc70b01552492bd64a
Reviewed-on: https://chromium-review.googlesource.com/1176168Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583442}
parent 2c54ca33
...@@ -214,6 +214,8 @@ class MediaCodecBridge { ...@@ -214,6 +214,8 @@ class MediaCodecBridge {
@Override @Override
public void onError(MediaCodec codec, MediaCodec.CodecException e) { public void onError(MediaCodec codec, MediaCodec.CodecException e) {
// TODO(dalecurtis): We may want to drop transient errors here.
Log.e(TAG, "MediaCodec.onError: " + e.getDiagnosticInfo());
mMediaCodecBridge.onError(e); mMediaCodecBridge.onError(e);
} }
...@@ -287,7 +289,6 @@ class MediaCodecBridge { ...@@ -287,7 +289,6 @@ class MediaCodecBridge {
} }
public synchronized void onError(MediaCodec.CodecException e) { public synchronized void onError(MediaCodec.CodecException e) {
// TODO(dalecurtis): We may want to drop transient errors here.
mPendingError = true; mPendingError = true;
mPendingInputBuffers.clear(); mPendingInputBuffers.clear();
mPendingOutputBuffers.clear(); mPendingOutputBuffers.clear();
...@@ -478,6 +479,15 @@ class MediaCodecBridge { ...@@ -478,6 +479,15 @@ class MediaCodecBridge {
@CalledByNative @CalledByNative
private ByteBuffer getInputBuffer(int index) { private ByteBuffer getInputBuffer(int index) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
if (mUseAsyncApi) {
synchronized (this) {
// Prior to Android N, some versions of MediaCodec will
// crash internally if we call getInputBuffer() after an
// error has occurred. See https://crbug.com/610523 and
// https://crbug.com/873094.
if (mPendingError) return null;
}
}
try { try {
return mMediaCodec.getInputBuffer(index); return mMediaCodec.getInputBuffer(index);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment