Repository navigation
Define steady state for player sync - #358
Merged
Merged
Conversation
kahrendt
approved these changes
Nov 11, 2026
kahrendt
left a comment
Contributor
There was a problem hiding this comment.
Good clarifications, thanks
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.
The ±1 ms accuracy floor and the inaudible-corrections rule only apply in steady state, but the spec never said when steady state starts, so a player could stay out of it indefinitely. Steady state now starts 10 seconds after the last disturbance.
I also dropped both "MUST be rare" rules, since "rare" had no number to test against, and in steady state the speed cap and the ±1 ms floor already bound one-shot corrections.
One thing I'm not fully sure about yet is the 10 seconds. It leaves room to soft-correct up to 50 ms at the 0.5% speed cap, while still catching players that sit on a noticeable error. I still need to try whether
sendspin-jscan hold it, but I also don't think we should hold back other clients' sync quality because of Chromium's inconsistent audio clock.Breaking changes
Players that take longer than 10 seconds after a disturbance to bring the error back within ±1 ms need an update. sendspin-js soft-corrects errors below 30 ms, so an error between about 18 and 30 ms takes over 10 seconds to fix. Servers need no change.