MediaCodeVideoRenderer: flush video sink before codec

When seeking, we must first flush the video sink so it stops
using any SurfaceTextures before flushing MediaCodec.

#minor-release

PiperOrigin-RevId: 570015998
(cherry picked from commit 144bd72236)
This commit is contained in:
christosts 2023-10-02 04:00:45 -07:00 committed by oceanjules
parent 1c7b426ccb
commit ecfddb9aeb

View file

@ -655,10 +655,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer implements Video
@Override
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
super.onPositionReset(positionUs, joining);
// Flush the video sink first to ensure it stops reading textures that will be owned by
// MediaCodec once the codec is flushed.
if (videoSink != null) {
videoSink.flush();
}
super.onPositionReset(positionUs, joining);
if (videoSinkProvider.isInitialized()) {
videoSinkProvider.setStreamOffsetUs(getOutputStreamOffsetUs());