Repository navigation
Conversation
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.
Contributor
There was a problem hiding this comment.
🟡 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
Publish frame count and finish time as a coherent progress update · New Quiesce old reports and reset all progress before changing formats · New Cancel stale format requests when matching-format writes resume · New Preserve backend recovery after transient configuration failures · New Retire discarded frames before reopening the output · New Reset the refused-format playhead when a stream ends · New
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)
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.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Stale drain deadlines, uncounted refused-write frames, and skipped draining after sink recovery can cause dropped audio and incorrect synchronization.
3 open issues
6 resolved since last review
Quiesce old reports and reset all progress before changing formats Publish frame count and finish time as a coherent progress update Reset the refused-format playhead when a stream ends Retire discarded frames before reopening the output Preserve backend recovery after transient configuration failures Cancel stale format requests when matching-format writes resume
Review effort: Max (adaptive)
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.


Pin sendspin-cpp to the
v0.10.0tag (was78b13d5e, 17 commits behind), move off every API it deprecates, and open the sink in the format each write carries.Changes
SENDSPIN_GIT_TAGdefaults tov0.10.0; configure logsagainst sendspin-cpp v0.10.0.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=ONwith no deprecation warnings. The persistence provider moves out ofmain.cppintosrc/persistence_provider.*so it can be tested.on_stream_start(), and to play out the old format's audio before reopening. The sync thread never callsconfigure(). 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 pasttimeout_ms. On each tick, the main loop'sPlayerListener::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 aton_stream_start()fromstream_info()(depth rounded to the container), which saves the first write's latency.write()keeps discarding, reporting and retrying the open. The next different format retriesconfigure(). 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_connectionsis 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.
statusstill reports the format actually open.Visible but not breaking. From v0.10.0 itself:
--name,--product-nameand--manufacturerover 64 bytes of UTF-8 are cut at a character boundary, with a warning. The CLI imposed no limit before.stream/startin a format the player didn't advertise is refused and ends the stream. Stop hooks fire as for any stream end.server/activatethat drops theplaybackactivity ends the running stream (stop hooks fire).group_idis reported hashed. The CLI does not surfacegroup_idanywhere.--buffer-ms(max 2000) and--output-delay(max 5000) already sit inside the library's new limits.From this change:
Stream started without complete parametersis gone,Stream updated: <rate> / <ch> / <bits>is new, and the refused-format line at stream end now readsStream ended: N bytes discarded, because '<sink>' refused their format.No
Usage BreakingorRequires-Upstreamlabel: no exposed control surface moves, and nothing waits on the library.Testing
PlayerListenertests 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.CliPersistenceProvidertests 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 longbuild/path, two control-socket tests fail because the socket path exceedssun_path. That failure predates this change; those files are untouched.