Always reconfigure video sink for video after image

Before this CL, the video sink was not reconfigured for the second video
in a sequence with video-image-video. For example, the stream offset
and listener were not set for the second video.

PiperOrigin-RevId: 628065991
This commit is contained in:
kimvde 2024-04-25 07:16:26 -07:00 committed by Copybara-Service
parent 0e3b05c67d
commit 00ce572a4f

View File

@ -1068,8 +1068,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
ownsVideoSinkProvider && hasEffects && !hasInitializedPlayback; ownsVideoSinkProvider && hasEffects && !hasInitializedPlayback;
// We always use the video sink if the video sink provider is passed to the renderer. // We always use the video sink if the video sink provider is passed to the renderer.
boolean useVideoSink = enableEffectsForOwnSinkProvider || !ownsVideoSinkProvider; boolean useVideoSink = enableEffectsForOwnSinkProvider || !ownsVideoSinkProvider;
if (useVideoSink && videoSink == null) { if (useVideoSink) {
try {
videoSinkProvider.setStreamOffsetUs(getOutputStreamOffsetUs()); videoSinkProvider.setStreamOffsetUs(getOutputStreamOffsetUs());
videoSink = videoSinkProvider.getSink(); videoSink = videoSinkProvider.getSink();
if (!videoSink.isInitialized()) { if (!videoSink.isInitialized()) {
@ -1122,12 +1121,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
videoSinkProvider.setOutputSurfaceInfo(displaySurface, outputResolution); videoSinkProvider.setOutputSurfaceInfo(displaySurface, outputResolution);
} }
} }
} catch (Exception e) {
// Set videoSink back to null so that, if the try block fails and the renderer retries the
// codec initialization, the try block is re-executed.
videoSink = null;
throw e;
}
} }
hasInitializedPlayback = true; hasInitializedPlayback = true;
} }