Skip to content

Report the player as available only after its clock is synchronized - #205

Merged
maximmaxim345 merged 1 commit into
mainfrom
fix/available-after-clock-sync
Oct 27, 2026
Merged

maximmaxim345 merged 1 commit into
mainfrom
fix/available-after-clock-sync

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

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):

Types of changes

  • 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

Servers sent audio before the player could schedule it, so a short
clip that arrived before the first time sync was never played.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The scoped availability change and callback wiring are consistent, with regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR delays the SDK’s availability report until its clock is synchronized, allowing servers to hold audio until the player can schedule it. Reconnect resynchronization remains deferred to #201.

Changes:

  • Report availability from clock synchronization state for all role combinations.
  • Send a state update when the clock first becomes synchronized.
  • Add availability transition coverage and update time-sync test setup.
File Description
tests/​unit/​time-sync-manager.test.ts Supplies the new synchronization callback in test setup.
tests/​unit/​protocol-handler.test.ts Tests initial unavailability, synchronized availability, and controller-only behavior.
src/​core/​time-sync-manager.ts Invokes a callback on the first synchronization transition.
src/​core/​protocol-handler.ts Reports synchronization-based availability and sends the transition update.

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit c69469a into main Oct 27, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/available-after-clock-sync branch October 27, 2026 14:23
maximmaxim345 added a commit that referenced this pull request Oct 29, 2026
# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

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):**

- #205

## 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Player reports available: true before its clock is synchronized

2 participants