Use VideoSink directly in MCVR where possible

PiperOrigin-RevId: 630030889
This commit is contained in:
kimvde 2024-05-02 05:21:46 -07:00 committed by Copybara-Service
parent 0893275841
commit d059e97b28

View File

@ -647,11 +647,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
@Override @Override
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException { protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
// When this renderer doesn't own the VideoSinkProvider, it's possible that the VideoSink is // When this renderer doesn't own the VideoSink, it's possible that the VideoSink is already
// already initialized by another renderer, before this renderer is enabled. // initialized by another renderer, before this renderer is enabled.
// Flush the video sink first to ensure it stops reading textures that will be owned by // Flush the video sink first to ensure it stops reading textures that will be owned by
// MediaCodec once the codec is flushed. // MediaCodec once the codec is flushed.
videoSinkProvider.getSink().flush(); videoSink.flush();
super.onPositionReset(positionUs, joining); super.onPositionReset(positionUs, joining);
videoFrameReleaseControl.reset(); videoFrameReleaseControl.reset();
if (joining) { if (joining) {
@ -1451,9 +1451,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
super.onProcessedStreamChange(); super.onProcessedStreamChange();
videoFrameReleaseControl.onProcessedStreamChange(); videoFrameReleaseControl.onProcessedStreamChange();
maybeSetupTunnelingForFirstFrame(); maybeSetupTunnelingForFirstFrame();
// If the renderer does not own the VideoSinkProvider, it's possible the VideoSink is null when videoSink.setStreamOffsetUs(getOutputStreamOffsetUs());
// this method is invoked, that is when transitioning from another renderer.
videoSinkProvider.getSink().setStreamOffsetUs(getOutputStreamOffsetUs());
} }
/** /**