Support seeking when playing back a composition

PiperOrigin-RevId: 628382976
This commit is contained in:
claincly 2024-04-26 06:04:24 -07:00 committed by Copybara-Service
parent 5666678d8a
commit 4be30bb308

View File

@ -645,11 +645,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
// already 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.
if (videoSink != null) { videoSinkProvider.getSink().flush();
videoSink.flush();
}
super.onPositionReset(positionUs, joining); super.onPositionReset(positionUs, joining);
videoFrameReleaseControl.reset(); videoFrameReleaseControl.reset();
if (joining) { if (joining) {
@ -1471,9 +1471,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
super.onProcessedStreamChange(); super.onProcessedStreamChange();
videoFrameReleaseControl.onProcessedStreamChange(); videoFrameReleaseControl.onProcessedStreamChange();
maybeSetupTunnelingForFirstFrame(); maybeSetupTunnelingForFirstFrame();
if (videoSink != null) { // 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());
} }
/** /**