Skip to content

Add support to advertise player timing capabilities - #116

Merged
maximmaxim345 merged 4 commits into
mainfrom
fix/client-state-buffer-fields
Jun 3, 2026
Merged

maximmaxim345 merged 4 commits into
mainfrom
fix/client-state-buffer-fields

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

Servers need each player's required_lead_time_ms and min_buffer_ms to compute per-player send-ahead since Sendspin/spec#69 got merged.
The SDK now makes both of them configurable via SendspinCoreConfig (default 250ms each, matches Music Assistants internal default).
Both can also be updated during runtime with setRequiredLeadTimeMs / setMinBufferMs, matching the spec which allows clients to update these at any time.

The sample player gains inputs for both values, and the README documents the config options and runtime setters.

The spec marks both as always required for players; without them a server
cannot compute per-player send-ahead. Default to 250ms each, configurable
via SendspinCoreConfig and updatable at runtime via setRequiredLeadTimeMs /
setMinBufferMs.

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.

Pull request overview

Adds support for advertising per-player buffer timing requirements (required_lead_time_ms, min_buffer_ms) to the Sendspin server via client/state, with new SDK configuration knobs and runtime setters, plus updates to the sample player UI and documentation.

Changes:

  • Extend client/state payload and protocol handler to report required_lead_time_ms and min_buffer_ms (with defaults).
  • Add runtime setters on SendspinCore/SendspinPlayer to update these values.
  • Update README and sample player UI to configure and adjust buffer timing.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Adds new timing fields to ClientState and new config options to SendspinCoreConfig.
src/index.ts Adds SendspinPlayer runtime setters for timing fields.
src/core/protocol-handler.ts Stores timing values, adds setters, and includes values in client/state.
src/core/core.ts Forwards new config fields into the protocol handler and exposes core-level setters.
README.md Documents new config options and runtime setters.
public/app.js Adds sample UI persistence and runtime application of timing parameters.
index.html Adds inputs/buttons to control the new timing parameters in the sample UI.
Comments suppressed due to low confidence (1)

public/app.js:618

  • The sample player passes requiredLeadTimeMs/minBufferMs into the SendspinPlayer constructor, but those values are currently not forwarded into SendspinCore (so they won't be reported to the server unless runtime setters are invoked). As a workaround (and to keep the sample behavior aligned with the README), apply the runtime setters after connecting.
    player = new SendspinPlayer({
      playerId: getPlayerId(),
      baseUrl: serverUrl,
      clientName: "Sendspin Sample Player",
      syncDelay: sanitizedSyncDelay,
      requiredLeadTimeMs,
      minBufferMs,
      correctionMode: savedCorrectionMode,
      correctionThresholds,
      reconnect: {
        onReconnecting: (attempt) =>
          showToast(`Reconnecting (attempt ${attempt})`, "info"),
        onReconnected: () => showToast("Reconnected", "success"),
        onExhausted: () => showToast("Reconnect failed", "error"),
      },
      onStateChange,
    });

    await player.connect();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/protocol-handler.ts Resolved
Comment thread src/core/protocol-handler.ts Resolved
Comment thread src/index.ts Resolved
SendspinPlayer dropped requiredLeadTimeMs/minBufferMs at construction, so
the documented options never reached client/state. Forward them and reject
non-finite or negative values in the setters and constructor.
@maximmaxim345
maximmaxim345 merged commit 400fe58 into main Jun 3, 2026
2 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/client-state-buffer-fields branch June 3, 2026 14:37
maximmaxim345 added a commit that referenced this pull request Jun 4, 2026
…st a real aiosendspin server. (#93)

Adds a vitest test suite covering the SDK and an end-to-end run against
a real aiosendspin server. No changes to `src/`.

## Unit tests (13 files, `tests/unit/`)

clock-source, codec-support, core, decoder, decoder-codecs,
output-latency-tracker, protocol-handler, recorrection-monitor,
scheduler, state-manager, time-filter, time-sync-manager,
websocket-manager.

## E2E (1 file, `tests/e2e/`)

`sendspin-core.e2e.test.ts` drives a real aiosendspin Python server
through a line-based stdin/stdout control protocol implemented by
`tests/helpers/sendspin-server.py`. The Node side spawns and controls
the subprocess via `tests/helpers/aiosendspin-server.ts`.

## Stats

234 tests across 14 files. `yarn test` ~32s locally.

## Bugs already caught and fixed

Added a couple more tests which were able to flag bugs in this library.
Each of them was already fixed in a separate PR before this one so all
tests pass:

- #116
- #117
- #118
- #119
- #121
- #122

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Maxim Raznatovski <[email protected]>
@maximmaxim345 maximmaxim345 added new-feature Adds new functionality and removed new-feature Adds new functionality labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature Adds new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants