Commit d187d294 by olly Committed by Oliver Woodman

Don't use MediaCodec.setOutputSurface on Nexus 7 with qcom decoder

Issue: #3236

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167581198
parent 2853bf85
...@@ -77,6 +77,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -77,6 +77,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private Format[] streamFormats; private Format[] streamFormats;
private CodecMaxValues codecMaxValues; private CodecMaxValues codecMaxValues;
private boolean codecNeedsSetOutputSurfaceWorkaround;
private Surface surface; private Surface surface;
private Surface dummySurface; private Surface dummySurface;
...@@ -354,7 +355,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -354,7 +355,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
int state = getState(); int state = getState();
if (state == STATE_ENABLED || state == STATE_STARTED) { if (state == STATE_ENABLED || state == STATE_STARTED) {
MediaCodec codec = getCodec(); MediaCodec codec = getCodec();
if (Util.SDK_INT >= 23 && codec != null && surface != null) { if (Util.SDK_INT >= 23 && codec != null && surface != null
&& !codecNeedsSetOutputSurfaceWorkaround) {
setOutputSurfaceV23(codec, surface); setOutputSurfaceV23(codec, surface);
} else { } else {
releaseCodec(); releaseCodec();
...@@ -425,6 +427,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -425,6 +427,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
protected void onCodecInitialized(String name, long initializedTimestampMs, protected void onCodecInitialized(String name, long initializedTimestampMs,
long initializationDurationMs) { long initializationDurationMs) {
eventDispatcher.decoderInitialized(name, initializedTimestampMs, initializationDurationMs); eventDispatcher.decoderInitialized(name, initializedTimestampMs, initializationDurationMs);
codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(name);
} }
@Override @Override
...@@ -964,6 +967,18 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -964,6 +967,18 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
} }
/** /**
* Returns whether the device is known to implement {@link MediaCodec#setOutputSurface(Surface)}
* incorrectly.
* <p>
* If true is returned then we fall back to releasing and re-instantiating the codec instead.
*/
private static boolean codecNeedsSetOutputSurfaceWorkaround(String name) {
// Work around https://github.com/google/ExoPlayer/issues/3236
return ("deb".equals(Util.DEVICE) || "flo".equals(Util.DEVICE))
&& "OMX.qcom.video.decoder.avc".equals(name);
}
/**
* Returns whether a codec with suitable {@link CodecMaxValues} will support adaptation between * Returns whether a codec with suitable {@link CodecMaxValues} will support adaptation between
* two {@link Format}s. * two {@link Format}s.
* *
......
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 sign in to comment