AudioTrackPositionTracker: Prevent negative timestamps

Issue: #7456
PiperOrigin-RevId: 314408767
This commit is contained in:
olly 2020-06-02 22:48:15 +01:00 committed by Oliver Woodman
parent 79acadcc89
commit fb011e66a6
2 changed files with 7 additions and 4 deletions

View File

@ -11,8 +11,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
@ -58,6 +59,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

View File

@ -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() {