Repository navigation
Resync the clock after reconnecting to the server - #201
Merged
Merged
Conversation
After an auto-reconnect the client kept the previous connection's clock offset and drift and reported itself synchronized, so playback after a server restart was scheduled against a stale clock.
There was a problem hiding this comment.
🟡 Changes recommended
The recorrection monitor can interpret the unsynchronized filter’s reset offset as drift and interrupt buffered playback.
1 open issue
What changed in this PR
This PR resets the SDK’s clock synchronization when a new connection opens, preventing playback from using a stale server-clock offset after reconnecting.
Changes:
- Reset the time filter on connection open while preserving it during a connection drop.
- Add a regression test verifying the filter remains synchronized after a drop and resets when the replacement socket opens.
| File | Description |
|---|---|
tests/unit/core.test.ts |
Tests time-filter preservation during a drop and reset on reconnect. |
src/core/core.ts |
Resets the time filter before starting the new connection’s transport. |
Review effort: Balanced
After a reconnect reset the filter, the recorrection check measured the scheduled audio against an unsynchronized offset, saw a large drift and cut the buffered audio while new audio could not be scheduled yet.
1 of 9 tasks
maximmaxim345
added a commit
that referenced
this pull request
Oct 27, 2026
…205) # What does this implement/fix? The player reported `available: true` before its clock was synchronized, so servers sent audio it couldn't schedule yet. A short clip like an announcement that arrived before the first time sync was never played. `client/state` now reports `available: false` until the first time sync completes, then sends an update with `available: true`. I kept one rule for every set of roles, so a controller only client also reports `available: false` until then. Servers that follow the spec keep a client that opens with `available: false` in its group while it syncs. Music Assistant 2.10.0 to 2.10.6 moves it to its own group instead, which aiosendspin 10.0.0 fixed. After a reconnect the clock filter stays synchronized from the previous connection, so the player can still report available before the new connection's first sync. #201 will fix that. **Related issue or spec PR (if applicable):** - Closes #182 - #181 ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the matching label, and the release notes use it to sort this change. --> - [x] Bugfix (non-breaking change which fixes an issue): `bugfix` - [ ] New feature (non-breaking change which adds functionality): `new-feature` - [ ] Enhancement to an existing feature: `enhancement` - [ ] Breaking change (changes the public API or the protocol in a way that is not backwards compatible): `breaking-change` - [ ] Refactor (no behavior change): `refactor` - [ ] Documentation only: `documentation` - [ ] Maintenance / chore: `maintenance` - [ ] CI / workflow change: `ci` - [ ] Dependencies bump: `dependencies`
This was referenced Nov 5, 2026
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.

What does this implement/fix?
After a reconnect, the player kept the previous connection's clock offset and reported itself as synchronized. After a server restart, this scheduled playback against the old server clock until the time filter slowly caught up.
The time filter now resets whenever a new connection opens, and still persists across a re-handshake as the spec requires. Until the first clock sync on the new connection, the player reports itself as not available and skips sync correction.
Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies