Commit 6b13640e by andrewlewis Committed by Andrew Lewis

Fix position ramping behavior with AudioTrack speed params

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
parent c95e43d9
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
([#7962](https://github.com/google/ExoPlayer/issues/7962)). ([#7962](https://github.com/google/ExoPlayer/issues/7962)).
* Audio: * Audio:
* Retry playback after some types of `AudioTrack` error. * 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: * Extractors:
* Add support for .mp2 boxes in the `AtomParsers` * Add support for .mp2 boxes in the `AtomParsers`
([#7967](https://github.com/google/ExoPlayer/issues/7967)). ([#7967](https://github.com/google/ExoPlayer/issues/7967)).
......
...@@ -289,7 +289,10 @@ import java.lang.reflect.Method; ...@@ -289,7 +289,10 @@ import java.lang.reflect.Method;
if (elapsedSincePreviousModeUs < MODE_SWITCH_SMOOTHING_DURATION_US) { 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 // Use a ramp to smooth between the old mode and the new one to avoid introducing a sudden
// jump if the two modes disagree. // 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. // A ramp consisting of 1000 points distributed over MODE_SWITCH_SMOOTHING_DURATION_US.
long rampPoint = (elapsedSincePreviousModeUs * 1000) / MODE_SWITCH_SMOOTHING_DURATION_US; long rampPoint = (elapsedSincePreviousModeUs * 1000) / MODE_SWITCH_SMOOTHING_DURATION_US;
positionUs *= rampPoint; positionUs *= rampPoint;
......
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