Skip to content

Stop players from snapping on small sync errors - #359

Merged
kahrendt merged 1 commit into
fix/player-steady-statefrom
fix/prefer-soft-correction
Nov 11, 2026
Merged

kahrendt merged 1 commit into
fix/player-steady-statefrom
fix/prefer-soft-correction

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

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 N up 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.

@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.

LGTM

@kahrendt
kahrendt merged commit 9d2f15e into main Nov 11, 2026
1 check passed
@kahrendt
kahrendt deleted the fix/prefer-soft-correction branch November 11, 2026 12:27
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