Skip to content

Commit

Permalink
Fix position ramping behavior with AudioTrack speed params
Browse files Browse the repository at this point in the history
Non-realtime AudioTrack playback speed was not taken into account when
extrapolating the old mode's position, causing the position not to
advance smoothly.

This should be a no-op when not using AudioTrack playback params for
speed adjustment.

Issue: #7982
PiperOrigin-RevId: 334151163
  • Loading branch information
andrewlewis committed Sep 30, 2020
1 parent c95e43d commit 6b13640
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
([#7962](https://github.com/google/ExoPlayer/issues/7962)).
* Audio:
* Retry playback after some types of `AudioTrack` error.
* Fix the default audio sink position not advancing correctly when using
`AudioTrack`-based speed adjustment
([#7982](https://github.com/google/ExoPlayer/issues/7982)).
* Extractors:
* Add support for .mp2 boxes in the `AtomParsers`
([#7967](https://github.com/google/ExoPlayer/issues/7967)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ public long getCurrentPositionUs(boolean sourceEnded) {
if (elapsedSincePreviousModeUs < MODE_SWITCH_SMOOTHING_DURATION_US) {
// Use a ramp to smooth between the old mode and the new one to avoid introducing a sudden
// jump if the two modes disagree.
long previousModeProjectedPositionUs = previousModePositionUs + elapsedSincePreviousModeUs;
long previousModeProjectedPositionUs =
previousModePositionUs
+ Util.getMediaDurationForPlayoutDuration(
elapsedSincePreviousModeUs, audioTrackPlaybackSpeed);
// A ramp consisting of 1000 points distributed over MODE_SWITCH_SMOOTHING_DURATION_US.
long rampPoint = (elapsedSincePreviousModeUs * 1000) / MODE_SWITCH_SMOOTHING_DURATION_US;
positionUs *= rampPoint;
Expand Down

0 comments on commit 6b13640

Please sign in to comment.