Skip to content

Pin sendspin-cpp v0.10.0 and open the sink in each write's format - #122

Merged
chrisuthe merged 5 commits into
mainfrom
chrisuthe/task/re-pin-sendspin-cpp-to-v0-10-0-and-configure-the
Nov 19, 2026
Merged

chrisuthe merged 5 commits into
mainfrom
chrisuthe/task/re-pin-sendspin-cpp-to-v0-10-0-and-configure-the

Conversation

@chrisuthe

@chrisuthe chrisuthe commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Pin sendspin-cpp to the v0.10.0 tag (was 78b13d5e, 17 commits behind), move off every API it deprecates, and open the sink in the format each write carries.

Changes

  • Pin: SENDSPIN_GIT_TAG defaults to v0.10.0; configure logs against sendspin-cpp v0.10.0.
  • Deprecated APIs: load_blob/save_blob -> read_blob/write_blob, record_slot_key() -> RecordSlotKey, get_current_stream_params() -> stream_info(), on_audio_write() -> on_audio_output(). Builds under -DSENDSPIN_CLI_WERROR=ON with no deprecation warnings. The persistence provider moves out of main.cpp into src/persistence_provider.* so it can be tested.
  • Per-write format: upstream's integration guide now says to configure the output from the writes, not from on_stream_start(), and to play out the old format's audio before reopening. The sync thread never calls configure(). A write in a new format records the request and returns 0 at once (the library retries after a 1 ms back-off), so the sync thread never blocks past timeout_ms. On each tick, the main loop's PlayerListener::poll() reopens the sink once everything written has been reported played and the last reported finish time has passed. If a sink never reports, it reopens anyway after 5 s. Every backend keeps its existing threading contract: configure() still runs only on the main loop. A fresh stream still opens the sink at on_stream_start() from stream_info() (depth rounded to the container), which saves the first write's latency.
  • Refused formats: writes in a format the device refused still go to the sink, as before, so its write() keeps discarding, reporting and retrying the open. The next different format retries configure(). Frames a timed-out play-out abandons are reported played when the sink reopens.
  • docs/ROADMAP.md: names v0.10.0 as the pin. The upstream gaps and --interface (still no bind address; accept_inbound_connections is new) were re-checked against it.

Compatibility

Nothing breaks for CLI users. Flags, config keys, the control-socket protocol, exit codes and the state-file format are unchanged. A test reads a state file written in the old format through the new provider. status still reports the format actually open.

Visible but not breaking. From v0.10.0 itself:

  • --name, --product-name and --manufacturer over 64 bytes of UTF-8 are cut at a character boundary, with a warning. The CLI imposed no limit before.
  • Time-sync bursts run at most 10 s apart (internal timing; no flag is affected).
  • A stream/start in a format the player didn't advertise is refused and ends the stream. Stop hooks fire as for any stream end.
  • A server/activate that drops the playback activity ends the running stream (stop hooks fire).
  • A non-UUID-safe group_id is reported hashed. The CLI does not surface group_id anywhere.
  • --buffer-ms (max 2000) and --output-delay (max 5000) already sit inside the library's new limits.

From this change:

  • An in-place format change now plays the old format's buffered audio out before the device reopens. Before, the device was reconfigured from the main loop while the old audio was still being written.
  • Log lines: Stream started without complete parameters is gone, Stream updated: <rate> / <ch> / <bits> is new, and the refused-format line at stream end now reads Stream ended: N bytes discarded, because '<sink>' refused their format.

No Usage Breaking or Requires-Upstream label: no exposed control surface moves, and nothing waits on the library.

Testing

  • New PlayerListener tests cover: the first write configures; a format change waits for play-out; the 5 s fallback; a refused format still reaches the sink and the next format retries; a write in the open format cancels a stale switch; a finish time from an ended stream doesn't hold up the next stream; a stream end forgets the format.
  • New CliPersistenceProvider tests cover: missing key, a buffer that is too small, a short blob, reading a blob an older build wrote, and the on-disk format.
  • ctest: all 623 pass from a short working directory. From this worktree's long build/ path, two control-socket tests fail because the socket path exceeds sun_path. That failure predates this change; those files are untouched.

The sync thread asks for a new format and returns 0; the main loop reopens the
sink once the old format's audio has played out, so configure() keeps running
only on the main loop for every backend.
@chrisuthe
chrisuthe marked this pull request as ready for review November 19, 2026 17:58
@chrisuthe
chrisuthe requested an adaptive review from Copilot November 19, 2026 17:58

Copilot AI 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.

🟡 Changes recommended

Critical callback-ordering and counter-reset races can reopen the device while audio is still playing and misattribute old playback progress to a new output.

6 open issues
What changed in this PR

Updates the CLI’s sendspin-cpp integration to v0.10.0 and makes sink configuration follow each audio write’s format, with reconfiguration kept on the main loop.

Changes:

  • Pins v0.10.0 and replaces deprecated player and persistence APIs.
  • Adds playback-drain handling for format changes and virtual playback reporting for refused formats.
  • Extracts the persistence provider and adds playback and state-file compatibility tests.
File Description
tests/​state_store_test.cpp Migrates pairing-slot test keys to RecordSlotKey.
tests/​player_listener_test.cpp Tests format changes, drain timing, refusal, and stream resets.
tests/​persistence_provider_test.cpp Tests blob operations and legacy state-file compatibility.
src/​state_store.cpp Uses the replacement pairing-slot key API.
src/​player_listener.h Declares format handoff and playback-progress state.
src/​player_listener.cpp Implements per-write format handling and deferred sink reopening.
src/​persistence_provider.h Declares the extracted persistence adapter.
src/​persistence_provider.cpp Implements span-based blob reads and writes through StateStore.
src/​main.cpp Integrates the extracted provider and listener polling.
docs/​ROADMAP.md Updates the dependency pin and upstream-gap notes.
CMakeLists.txt Pins v0.10.0 and registers the provider implementation and tests.

Review effort: Max (adaptive)

Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
A refused write still reaches the sink, whose write() retries a failed open.
The finish time is published before the frame count, counters reset only once
configure() or clear() has closed the old stream, frames a timed-out play-out
abandoned are reported played, and a write in the open format cancels a stale
switch.
…eopen

Writes now wait out a reopen instead of reaching the device mid-configure, a
cancelled switch no longer shortens the next one's play-out wait, refused frames
the sink dropped are reported at the next open, and a fresh stream's open never
reports the last stream's counts.

Copilot AI 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.

Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
Comment thread src/player_listener.cpp Resolved
@chrisuthe
chrisuthe merged commit 603e439 into main Nov 19, 2026
20 of 21 checks passed
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