Always call onProcessedStreamChanged for first stream for effects

Before this CL:
- MediaCodecVideoRenderer.onProcessedStreamChanged was called for the
  first stream in CompositionPlayer.
- MediaCodecVideoRenderer.onProcessedStreamChanged was NOT called for
  the first stream in ExoPlayer.setVideoEffects.

This discrepancy was adding some complexity to the code, making it less robust.

PiperOrigin-RevId: 735439320
This commit is contained in:
kimvde 2025-03-10 10:56:45 -07:00 committed by Copybara-Service
parent e8842b939c
commit ce59680d0f
2 changed files with 4 additions and 9 deletions

View File

@ -935,6 +935,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
if (wakeupListener != null) {
videoSink.setWakeupListener(wakeupListener);
}
experimentalEnableProcessedStreamChangedAtStart();
} else {
videoFrameReleaseControl.setClock(getClock());
int firstFrameReleaseInstruction =
@ -962,13 +963,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
MediaSource.MediaPeriodId mediaPeriodId)
throws ExoPlaybackException {
super.onStreamChanged(formats, startPositionUs, offsetUs, mediaPeriodId);
if (this.startPositionUs == C.TIME_UNSET) {
this.startPositionUs = startPositionUs;
if (videoSink != null) {
videoSink.setStreamStartPositionUs(getOutputStreamStartPositionUs());
videoSink.setBufferTimestampAdjustmentUs(getBufferTimestampAdjustmentUs());
}
}
updatePeriodDurationUs(mediaPeriodId);
}
@ -992,7 +986,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
// MediaCodec once the codec is flushed.
videoSink.flush(/* resetPosition= */ true);
}
pendingVideoSinkInputStreamChange = true;
}
super.onPositionReset(positionUs, joining);
if (videoSink == null) {
@ -1869,6 +1862,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
// Signaling end of the previous stream.
videoSink.signalEndOfCurrentInputStream();
videoSink.setStreamStartPositionUs(getOutputStreamStartPositionUs());
if (this.startPositionUs == C.TIME_UNSET) {
this.startPositionUs = getOutputStreamStartPositionUs();
}
videoSink.setBufferTimestampAdjustmentUs(getBufferTimestampAdjustmentUs());
} else {
videoFrameReleaseControl.onStreamChanged(RELEASE_FIRST_FRAME_WHEN_PREVIOUS_STREAM_PROCESSED);

View File

@ -329,7 +329,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
this.bufferingVideoSink = bufferingVideoSink;
this.requestToneMapping = requestToneMapping;
this.pendingEffects = ImmutableList.of();
experimentalEnableProcessedStreamChangedAtStart();
}
@Override