Skip to content

Define steady state for player sync - #358

Merged
kahrendt merged 3 commits into
mainfrom
fix/player-steady-state
Nov 11, 2026
Merged

kahrendt merged 3 commits into
mainfrom
fix/player-steady-state

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

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-js can 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.

@kahrendt kahrendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good clarifications, thanks

@kahrendt
kahrendt merged commit d781002 into main Nov 11, 2026
1 check passed
@kahrendt
kahrendt deleted the fix/player-steady-state branch November 11, 2026 12:26
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants