Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve position estimate when transitioning to another checkpoint
When transitioning to the next media position parameter checkpoint we estimate the position because the audio processor chain no longer provides access to the actual playout duration. The estimate using the declared speed and the last checkpoint may have drifted over time, so we currently estimate relative to the next checkpoint, which is closer and presumably provides a better estimate. However, this assumes that these checkpoint are perfectly aligned without any position jumps. The current approach has two issues: - The next checkpoint may include a position jump by design, e.g. if it was set for a new item in the playlist and the duration of the current item wasn't perfectly accurate. - The sudden switch between two estimation methods may cause a jump in the output position, which is visible when we add new media position checkpoints to the queue, not when we actually reach the playback position of the checkpoint. We can fix both issues by taking a slightly different approach: - Continuously monitor the estimate using the current checkpoint. If it starts drifting, we can adjust it directly. This way the estimate is always aligned with the actual position. - The change above means we can safely switch to using the estimate based on the previous checkpoint. This way we don't have to make assumptions about the next checkpoint and any position jumps will only happen when we actually reach this checkpoint (which is more what a user expects to see, e.g. at a playlist item transition). Issue: #1698 PiperOrigin-RevId: 690979859 (cherry picked from commit 7c0cffd)
- Loading branch information