Commit 6e751c35 by ibaker Committed by Oliver Woodman

Enable nullness checking for DefaultMediaClock

PiperOrigin-RevId: 322542289
parent 0efec5f6
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.MediaClock; import com.google.android.exoplayer2.util.MediaClock;
import com.google.android.exoplayer2.util.StandaloneMediaClock; import com.google.android.exoplayer2.util.StandaloneMediaClock;
...@@ -133,7 +134,9 @@ import com.google.android.exoplayer2.util.StandaloneMediaClock; ...@@ -133,7 +134,9 @@ import com.google.android.exoplayer2.util.StandaloneMediaClock;
@Override @Override
public long getPositionUs() { public long getPositionUs() {
return isUsingStandaloneClock ? standaloneClock.getPositionUs() : rendererClock.getPositionUs(); return isUsingStandaloneClock
? standaloneClock.getPositionUs()
: Assertions.checkNotNull(rendererClock).getPositionUs();
} }
@Override @Override
...@@ -160,6 +163,9 @@ import com.google.android.exoplayer2.util.StandaloneMediaClock; ...@@ -160,6 +163,9 @@ import com.google.android.exoplayer2.util.StandaloneMediaClock;
} }
return; return;
} }
// We are either already using the renderer clock or switching from the standalone to the
// renderer clock, so it must be non-null.
MediaClock rendererClock = Assertions.checkNotNull(this.rendererClock);
long rendererClockPositionUs = rendererClock.getPositionUs(); long rendererClockPositionUs = rendererClock.getPositionUs();
if (isUsingStandaloneClock) { if (isUsingStandaloneClock) {
// Ensure enabling the renderer clock doesn't jump backwards in time. // Ensure enabling the renderer clock doesn't jump backwards in time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment