mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
68 lines
2 KiB
Java
68 lines
2 KiB
Java
|
package com.google.android.exoplayer2.util;
|
||
|
|
||
|
import com.google.android.exoplayer2.PlaybackParameters;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class StandaloneMediaClock implements MediaClock {
|
||
|
private long baseElapsedMs;
|
||
|
private long baseUs;
|
||
|
private final Clock clock;
|
||
|
private PlaybackParameters playbackParameters = PlaybackParameters.DEFAULT;
|
||
|
private boolean started;
|
||
|
|
||
|
@Override // com.google.android.exoplayer2.util.MediaClock
|
||
|
public PlaybackParameters getPlaybackParameters() {
|
||
|
return this.playbackParameters;
|
||
|
}
|
||
|
|
||
|
public StandaloneMediaClock(Clock clock) {
|
||
|
this.clock = clock;
|
||
|
}
|
||
|
|
||
|
public void start() {
|
||
|
if (this.started) {
|
||
|
return;
|
||
|
}
|
||
|
this.baseElapsedMs = this.clock.elapsedRealtime();
|
||
|
this.started = true;
|
||
|
}
|
||
|
|
||
|
public void stop() {
|
||
|
if (this.started) {
|
||
|
resetPosition(getPositionUs());
|
||
|
this.started = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void resetPosition(long j) {
|
||
|
this.baseUs = j;
|
||
|
if (this.started) {
|
||
|
this.baseElapsedMs = this.clock.elapsedRealtime();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.exoplayer2.util.MediaClock
|
||
|
public long getPositionUs() {
|
||
|
long mediaTimeUsForPlayoutTimeMs;
|
||
|
long j = this.baseUs;
|
||
|
if (!this.started) {
|
||
|
return j;
|
||
|
}
|
||
|
long elapsedRealtime = this.clock.elapsedRealtime() - this.baseElapsedMs;
|
||
|
if (this.playbackParameters.speed == 1.0f) {
|
||
|
mediaTimeUsForPlayoutTimeMs = Util.msToUs(elapsedRealtime);
|
||
|
} else {
|
||
|
mediaTimeUsForPlayoutTimeMs = this.playbackParameters.getMediaTimeUsForPlayoutTimeMs(elapsedRealtime);
|
||
|
}
|
||
|
return j + mediaTimeUsForPlayoutTimeMs;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.exoplayer2.util.MediaClock
|
||
|
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
|
||
|
if (this.started) {
|
||
|
resetPosition(getPositionUs());
|
||
|
}
|
||
|
this.playbackParameters = playbackParameters;
|
||
|
}
|
||
|
}
|