Fix wrong output timestamp in seeking

Set `VideoSink`'s offset during seeking in `MCVR.onPositionReset()`

This one is necessary in some cases, where `onProcessedStreamChange()` is not
invoked during a seek. For example, when seeking when playback has ended.

PiperOrigin-RevId: 630056723
This commit is contained in:
claincly 2024-05-02 07:27:06 -07:00 committed by Copybara-Service
parent d059e97b28
commit 2e3c3eb678

View File

@ -652,6 +652,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
// Flush the video sink first to ensure it stops reading textures that will be owned by
// MediaCodec once the codec is flushed.
videoSink.flush();
videoSink.setStreamOffsetUs(getOutputStreamOffsetUs());
super.onPositionReset(positionUs, joining);
videoFrameReleaseControl.reset();
if (joining) {
@ -1098,7 +1099,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
// Pass a direct executor since the callback handling involves posting on the app looper
// again, so there's no need to do two hops.
directExecutor());
videoSink.setStreamOffsetUs(getOutputStreamOffsetUs());
}
hasInitializedPlayback = true;
}