Skip to content

Commit

Permalink
AudioTrackPositionTracker: Prevent negative timestamps
Browse files Browse the repository at this point in the history
Issue: #7456
PiperOrigin-RevId: 314408767
  • Loading branch information
ojw28 committed Jun 2, 2020
1 parent 5b06d89 commit 720f001
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void setAudioTrack(
hasData = false;
stopTimestampUs = C.TIME_UNSET;
forceResetWorkaroundTimeMs = C.TIME_UNSET;
lastLatencySampleTimeUs = 0;
latencyUs = 0;
}

Expand Down Expand Up @@ -239,7 +240,7 @@ public long getCurrentPositionUs(boolean sourceEnded) {
positionUs = systemTimeUs + smoothedPlayheadOffsetUs;
}
if (!sourceEnded) {
positionUs -= latencyUs;
positionUs = Math.max(0, positionUs - latencyUs);
}
return positionUs;
}
Expand Down Expand Up @@ -353,7 +354,7 @@ public boolean pause() {
}

/**
* 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() {
Expand Down

0 comments on commit 720f001

Please sign in to comment.