Repository navigation
Stop players from snapping on small sync errors - #359
Merged
Merged
Conversation
maximmaxim345
added a commit
to Sendspin/sendspin-rs
that referenced
this pull request
Nov 12, 2026
Clock sync and playback correction now follow the spec's time filter and the player role's correction limits. - The time filter matches the spec's algorithm and parameters. Time sync runs in reply-driven bursts of 8 messages and feeds only the reply with the lowest `max_error` above 0. - Sync corrections stay under the spec's 0.5% speed cap (up to 4% before, audible as pitch) and start at 0.3 ms of error instead of 3 ms. Each correction speeds up as needed to finish within 10 seconds, and only errors the cap can't fix in time (above 36 ms, 20 ms before) move the audio straight to its scheduled position. Small corrections start at most 5 seconds after playback starts, instead of waiting for the clock estimate to settle, which took 20 seconds on a slow connection, and errors too large to correct in time after that wait jump right away. - Playback starts at the exact frame that is due instead of up to one audio callback late. Large sync errors now move the audio back to its scheduled position. Before, only the tracked position moved, and the audio stayed off. `CorrectionPlanner::with_max_speed_correction` is removed, since the speed cap is now fixed. Related: - Sendspin/spec#303 - Sendspin/spec#298 - Sendspin/spec#357 - Sendspin/spec#358 - Sendspin/spec#359 Tested in Music Assistant on a Mac behind a proxy simulating Wi-Fi jitter with stalls and one-way delay, and a 3G-like connection with 120 ms round trips. On Wi-Fi, playback started 1 second after connecting with the clock estimate 32 ms off, the player corrected that smoothly to within 0.1 ms 18 seconds after connecting, and the error then stayed within 0.5 ms. On 3G, playback started 4 seconds after connecting, and the player followed clock estimate moves of up to 8 ms without jumps or dropouts. Both sounded in sync.
55 of 58 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Outside steady state, a player may resynchronize in one shot, and a time filter update that moves the error past ±1 ms ends steady state. So a player could snap after every such update, with a click or a short dropout each time, and still comply, and the suggested correction strategy did exactly that for any error above 1 ms.
Players now SHOULD soft-correct any error the 0.5% speed cap can bring back within ±1 ms in 10 seconds, which covers errors up to about 50 ms. The suggested strategy raises
Nup to the cap for these errors and only snaps above that.sendspin-js snaps errors above 30 ms, so it doesn't follow this yet for errors between 30 and 50 ms.