Do not flush c2.mtk decoders when outputting to a videoSink

Flushing a c2.mtk decoder that outputs to a SurfaceTexture often
fails and leaves the SurfaceTexture's BufferQueue in an unrecoverable
state. Release the codec instead.

PiperOrigin-RevId: 751006875
This commit is contained in:
dancho 2025-04-24 08:37:32 -07:00 committed by Copybara-Service
parent 2e20d35c3d
commit 910b6ab884

View File

@ -2473,6 +2473,22 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
}
}
@Override
protected boolean flushOrReleaseCodec() {
MediaCodecInfo codecInfo = getCodecInfo();
if (videoSink != null
&& codecInfo != null
&& (codecInfo.name.equals("c2.mtk.avc.decoder")
|| codecInfo.name.equals("c2.mtk.hevc.decoder"))) {
// Flushing a c2.mtk decoder that outputs to a SurfaceTexture often fails and leaves
// the SurfaceTexture's BufferQueue in an unrecoverable state. Release the codec instead.
// See b/362904942 for more details.
releaseCodec();
return true;
}
return super.flushOrReleaseCodec();
}
/**
* Returns whether the device is known to do post processing by default that isn't compatible with
* ExoPlayer.