Commit 720f0012 by olly Committed by Oliver Woodman

AudioTrackPositionTracker: Prevent negative timestamps

Issue: #7456
PiperOrigin-RevId: 314408767
parent 5b06d894
......@@ -195,8 +195,9 @@
* Fix "Not allowed to start service" `IllegalStateException` in
`DownloadService`
([#7306](https://github.com/google/ExoPlayer/issues/7306)).
* Ads:
* Fix `AdsMediaSource` child `MediaSource`s not being released.
* Fix issue in `AudioTrackPositionTracker` that could cause negative positions
to be reported at the start of playback and immediately after seeking
([#7456](https://github.com/google/ExoPlayer/issues/7456).
* DASH:
* Merge trick play adaptation sets (i.e., adaptation sets marked with
`http://dashif.org/guidelines/trickmode`) into the same `TrackGroup` as
......@@ -242,6 +243,7 @@
([#5444](https://github.com/google/ExoPlayer/issues/5444),
[#5966](https://github.com/google/ExoPlayer/issues/5966),
[#7002](https://github.com/google/ExoPlayer/issues/7002)).
* Fix `AdsMediaSource` child `MediaSource`s not being released.
* Cronet extension: Default to using the Cronet implementation in Google Play
Services rather than Cronet Embedded. This allows Cronet to be used with a
negligible increase in application size, compared to approximately 8MB when
......
......@@ -206,6 +206,7 @@ import java.lang.reflect.Method;
hasData = false;
stopTimestampUs = C.TIME_UNSET;
forceResetWorkaroundTimeMs = C.TIME_UNSET;
lastLatencySampleTimeUs = 0;
latencyUs = 0;
}
......@@ -239,7 +240,7 @@ import java.lang.reflect.Method;
positionUs = systemTimeUs + smoothedPlayheadOffsetUs;
}
if (!sourceEnded) {
positionUs -= latencyUs;
positionUs = Math.max(0, positionUs - latencyUs);
}
return positionUs;
}
......@@ -353,7 +354,7 @@ import java.lang.reflect.Method;
}
/**
* Resets the position tracker. Should be called when the audio track previous passed to {@link
* Resets the position tracker. Should be called when the audio track previously passed to {@link
* #setAudioTrack(AudioTrack, int, int, int)} is no longer in use.
*/
public void reset() {
......
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