Skip to content

Commit

Permalink
Don't use MediaCodec.setOutputSurface on Nexus 7 with qcom decoder
Browse files Browse the repository at this point in the history
Issue: #3236

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167581198
  • Loading branch information
ojw28 authored and Oliver Woodman committed Sep 8, 2017
1 parent 2853bf8 commit d187d29
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {

private Format[] streamFormats;
private CodecMaxValues codecMaxValues;
private boolean codecNeedsSetOutputSurfaceWorkaround;

private Surface surface;
private Surface dummySurface;
Expand Down Expand Up @@ -354,7 +355,8 @@ private void setSurface(Surface surface) throws ExoPlaybackException {
int state = getState();
if (state == STATE_ENABLED || state == STATE_STARTED) {
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);
} else {
releaseCodec();
Expand Down Expand Up @@ -425,6 +427,7 @@ protected void releaseCodec() {
protected void onCodecInitialized(String name, long initializedTimestampMs,
long initializationDurationMs) {
eventDispatcher.decoderInitialized(name, initializedTimestampMs, initializationDurationMs);
codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(name);
}

@Override
Expand Down Expand Up @@ -963,6 +966,18 @@ private static boolean deviceNeedsAutoFrcWorkaround() {
return Util.SDK_INT <= 22 && "foster".equals(Util.DEVICE) && "NVIDIA".equals(Util.MANUFACTURER);
}

/**
* 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
* two {@link Format}s.
Expand Down

0 comments on commit d187d29

Please sign in to comment.