Repository navigation
Define clock sync convergence and missing burst replies - #357
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.
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.
A player or source held its first
client/stateuntil its time filter "has converged", which the spec never defined. It now waits for acountof at least 1, since the second measurement replaces the offset instead of improving it.Bursts could also stall when a server discards requests during a re-handshake, so clients may now move on after their own timeout. I wasn't sure what timeout to choose, so I left it open for now:
server/timereply timeout? #356Clients also pick the lowest
max_errorabove 0, since the filter discards the rest.Breaking changes
Clients that pick a burst's sample with a
max_errorof 0 or less need an update, sendspin-js among them. Servers need no change.