diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameReleaseControl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameReleaseControl.java index bb012d6a2a..921018d7ab 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameReleaseControl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameReleaseControl.java @@ -31,7 +31,6 @@ import androidx.media3.common.util.Clock; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import androidx.media3.exoplayer.ExoPlaybackException; -import androidx.media3.exoplayer.Renderer; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -110,7 +109,7 @@ public final class VideoFrameReleaseControl { /** Signals that a frame should be ignored. */ public static final int FRAME_RELEASE_IGNORE = 4; - /** Signals that a frame should not be released and the renderer should try again later. */ + /** Signals that a frame should not be released and the caller should try again later. */ public static final int FRAME_RELEASE_TRY_AGAIN_LATER = 5; /** Per {@link FrameReleaseAction} metadata. */ @@ -217,7 +216,7 @@ public final class VideoFrameReleaseControl { * @param frameTimingEvaluator The {@link FrameTimingEvaluator} that will assist in {@linkplain * #getFrameReleaseAction(long, long, long, long, boolean, FrameReleaseInfo) frame release * actions}. - * @param allowedJoiningTimeMs The maximum duration in milliseconds for which the renderer can + * @param allowedJoiningTimeMs The maximum duration in milliseconds for which the caller can * attempt to seamlessly join an ongoing playback. */ public VideoFrameReleaseControl( @@ -256,14 +255,14 @@ public final class VideoFrameReleaseControl { } } - /** Called when the renderer is started. */ + /** Called when rendering starts. */ public void onStarted() { started = true; lastReleaseRealtimeUs = msToUs(clock.elapsedRealtime()); frameReleaseHelper.onStarted(); } - /** Called when the renderer is stopped. */ + /** Called when rendering stops. */ public void onStopped() { started = false; joiningDeadlineMs = C.TIME_UNSET; @@ -311,14 +310,11 @@ public final class VideoFrameReleaseControl { /** * Whether the release control is ready to start playback. * - *

The renderer should be {@linkplain Renderer#isReady() ready} if and only if the release - * control is ready. - * - * @param rendererOtherwiseReady Whether the renderer is ready except for the release control. + * @param otherwiseReady Whether the caller is ready except for the release control. * @return Whether the release control is ready. */ - public boolean isReady(boolean rendererOtherwiseReady) { - if (rendererOtherwiseReady && firstFrameState == C.FIRST_FRAME_RENDERED) { + public boolean isReady(boolean otherwiseReady) { + if (otherwiseReady && firstFrameState == C.FIRST_FRAME_RENDERED) { // Ready. If we were joining then we've now joined, so clear the joining deadline. joiningDeadlineMs = C.TIME_UNSET; return true; @@ -351,7 +347,7 @@ public final class VideoFrameReleaseControl { } /** - * Returns a {@link FrameReleaseAction} for a video frame which instructs a renderer what to do + * Returns a {@link FrameReleaseAction} for a video frame which instructs the caller what to do * with the frame. * * @param presentationTimeUs The presentation time of the video frame, in microseconds. @@ -363,7 +359,7 @@ public final class VideoFrameReleaseControl { * @param frameReleaseInfo A {@link FrameReleaseInfo} that will be filled with detailed data only * if the method returns {@link #FRAME_RELEASE_IMMEDIATELY} or {@link * #FRAME_RELEASE_SCHEDULED}. - * @return A {@link FrameReleaseAction} that should instruct the renderer whether to release the + * @return A {@link FrameReleaseAction} that should instruct the caller whether to release the * frame or not. */ public @FrameReleaseAction int getFrameReleaseAction( @@ -435,7 +431,7 @@ public final class VideoFrameReleaseControl { frameReleaseHelper.setChangeFrameRateStrategy(changeFrameRateStrategy); } - /** Sets the playback speed. Called when the renderer playback speed changes. */ + /** Sets the playback speed. */ public void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed) { checkArgument(speed > 0); if (speed == playbackSpeed) { @@ -462,9 +458,8 @@ public final class VideoFrameReleaseControl { */ private long calculateEarlyTimeUs( long positionUs, long elapsedRealtimeUs, long framePresentationTimeUs) { - // Calculate how early we are. In other words, the realtime duration that needs to elapse whilst - // the renderer is started before the frame should be rendered. A negative value means that - // we're already late. + // Calculate how early we are. In other words, calculate the realtime duration that needs to + // elapse before the frame should be rendered. A negative value means that we're already late. // Note: Use of double rather than float is intentional for accuracy in the calculations below. long earlyUs = (long) ((framePresentationTimeUs - positionUs) / (double) playbackSpeed); if (started) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameRenderControl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameRenderControl.java index 71e4db915a..4f10dff7ed 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameRenderControl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/VideoFrameRenderControl.java @@ -102,7 +102,7 @@ import androidx.media3.exoplayer.ExoPlaybackException; lastPresentationTimeUs = C.TIME_UNSET; } - /** Flushes the renderer. */ + /** Flushes the render control. */ public void flush() { presentationTimestampsUs.clear(); latestInputPresentationTimeUs = C.TIME_UNSET; diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/video/VideoFrameReleaseControlTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/video/VideoFrameReleaseControlTest.java index 5cbdc347e4..969f14f3c2 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/video/VideoFrameReleaseControlTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/video/VideoFrameReleaseControlTest.java @@ -33,8 +33,8 @@ public class VideoFrameReleaseControlTest { public void isReady_onNewInstance_returnsFalse() { VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isFalse(); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isFalse(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse(); } @Test @@ -42,7 +42,7 @@ public class VideoFrameReleaseControlTest { VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); assertThat(videoFrameReleaseControl.onFrameReleasedIsFirstFrame()).isTrue(); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isTrue(); } @Test @@ -54,7 +54,7 @@ public class VideoFrameReleaseControlTest { videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue(); } @Test @@ -66,7 +66,7 @@ public class VideoFrameReleaseControlTest { videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue(); } @Test @@ -77,11 +77,11 @@ public class VideoFrameReleaseControlTest { videoFrameReleaseControl.setClock(clock); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue(); clock.advanceTime(/* timeDiffMs= */ 101); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse(); } @Test @@ -92,11 +92,11 @@ public class VideoFrameReleaseControlTest { videoFrameReleaseControl.setClock(clock); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue(); clock.advanceTime(/* timeDiffMs= */ 101); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse(); } @Test @@ -125,10 +125,10 @@ public class VideoFrameReleaseControlTest { VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); videoFrameReleaseControl.onFrameReleasedIsFirstFrame(); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isTrue(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isTrue(); videoFrameReleaseControl.reset(); - assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isFalse(); + assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isFalse(); } @Test