From 196f5f7917f1f9885ac1dee8d05b0f7ee8cca5f5 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 22 Jan 2018 02:29:22 -0800 Subject: [PATCH] Include P8 in setOutputSurfaceWorkaround Also disable use of dummy surface for devices that require the workaround. It's only useful in the case that we can use setOutputSurfaceWorkaround, so if it's disabled the dummy surface has no purpose (it actually makes things worse by consuming past the key-frame prior to the current position, which doesn't happen if you have no surface at all). Issue: #3724 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182750068 --- RELEASENOTES.md | 2 ++ .../video/MediaCodecVideoRenderer.java | 29 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d60dc147d8..745590f9a6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -73,6 +73,8 @@ * IMA extension: Add support for playing non-Extractor content MediaSources in the IMA demo app ([#3676](https://github.com/google/ExoPlayer/issues/3676)). * `EventLogger` moved from the demo app into the core library. +* Fix ANR issue on Huawei P8 Lite + ([#3724](https://github.com/google/ExoPlayer/issues/3724)). ### 2.6.1 ### diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java index 6900823ebe..895e290a75 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java @@ -352,7 +352,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { surface = dummySurface; } else { MediaCodecInfo codecInfo = getCodecInfo(); - if (codecInfo != null && shouldUseDummySurface(codecInfo.secure)) { + if (codecInfo != null && shouldUseDummySurface(codecInfo)) { dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure); surface = dummySurface; } @@ -395,7 +395,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { @Override protected boolean shouldInitCodec(MediaCodecInfo codecInfo) { - return surface != null || shouldUseDummySurface(codecInfo.secure); + return surface != null || shouldUseDummySurface(codecInfo); } @Override @@ -405,7 +405,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { MediaFormat mediaFormat = getMediaFormat(format, codecMaxValues, deviceNeedsAutoFrcWorkaround, tunnelingAudioSessionId); if (surface == null) { - Assertions.checkState(shouldUseDummySurface(codecInfo.secure)); + Assertions.checkState(shouldUseDummySurface(codecInfo)); if (dummySurface == null) { dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure); } @@ -750,9 +750,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { maybeNotifyRenderedFirstFrame(); } - private boolean shouldUseDummySurface(boolean codecIsSecure) { - return Util.SDK_INT >= 23 && !tunneling - && (!codecIsSecure || DummySurface.isSecureSupported(context)); + private boolean shouldUseDummySurface(MediaCodecInfo codecInfo) { + return Util.SDK_INT >= 23 + && !tunneling + && !codecNeedsSetOutputSurfaceWorkaround(codecInfo.name) + && (!codecInfo.secure || DummySurface.isSecureSupported(context)); } private void setJoiningDeadlineMs() { @@ -1068,13 +1070,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { */ private static boolean codecNeedsSetOutputSurfaceWorkaround(String name) { // Work around https://github.com/google/ExoPlayer/issues/3236, - // https://github.com/google/ExoPlayer/issues/3355 and - // https://github.com/google/ExoPlayer/issues/3439. + // https://github.com/google/ExoPlayer/issues/3355, + // https://github.com/google/ExoPlayer/issues/3439 and + // https://github.com/google/ExoPlayer/issues/3724. return (("deb".equals(Util.DEVICE) || "flo".equals(Util.DEVICE)) - && "OMX.qcom.video.decoder.avc".equals(name)) - || (("tcl_eu".equals(Util.DEVICE) || "SVP-DTV15".equals(Util.DEVICE) - || "BRAVIA_ATV2".equals(Util.DEVICE)) - && "OMX.MTK.VIDEO.DECODER.AVC".equals(name)); + && "OMX.qcom.video.decoder.avc".equals(name)) + || (("tcl_eu".equals(Util.DEVICE) + || "SVP-DTV15".equals(Util.DEVICE) + || "BRAVIA_ATV2".equals(Util.DEVICE)) + && "OMX.MTK.VIDEO.DECODER.AVC".equals(name)) + || ("OMX.k3.video.decoder.avc".equals(name) && "ALE-L21".equals(Util.MODEL)); } /**