Repository navigation
Gate the player, visualizer and source streams on the playback activity - #281
Merged
Merged
Conversation
Spec #314: on a connection without 'playback' in its activities the client MUST ignore the player and visualizer objects in stream/start, unvalidated, and discard player audio and visualization data (messaging.md "stream/start"), and MUST ignore a source start; an activation that drops 'playback' MUST end an open source stream (roles/source/v1.md "Source command semantics"). Nothing gated on 'playback'. - stream/start takes the player and visualizer sections only with 'playback'; artwork carries on, as a paused group keeps its artwork. - Player audio is discarded without 'playback', after the length check a discarded payload still owes (messaging.md "Communication"). - A source start counts only with 'playback'. - An activation that drops 'playback' ends the source stream (with client-stream/end) and any player or visualizer stream a server left running, so the stream/start a new 'playback' brings starts a stream rather than updating a stale one.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The integration guide overstates which traffic is ignored without playback, and a test comment claims sync-task behavior that the test does not verify.
2 open issues
What changed in this PR
Ties player, visualizer, and source streaming to the connection’s playback activity, while allowing artwork and other roles to continue.
Changes:
- Gates stream starts and player audio without skipping required binary-length checks.
- Ends retained playback streams when an activation drops
playback. - Adds lifecycle tests and updates listener and integration documentation.
| File | Description |
|---|---|
tests/test_source_role.cpp |
Covers source start rejection and shutdown when playback drops. |
tests/test_role_deactivation.cpp |
Tests stream gating, artwork continuity, and paired end callbacks. |
tests/test_player_role.cpp |
Covers audio discards and length checks without playback. |
src/source_role.cpp |
Applies the combined source-start eligibility check. |
src/source_role_impl.h |
Documents source-start eligibility. |
src/player_role.cpp |
Discards audio when playback eligibility fails. |
src/player_role_impl.h |
Documents audio acceptance criteria. |
src/connection_manager.cpp |
Detects playback removal during activation. |
src/client.cpp |
Ends playback streams for retained roles. |
src/client_dispatch.cpp |
Gates stream sections, source starts, and player audio. |
include/sendspin/visualizer_role.h |
Documents stream-end callbacks on playback removal. |
include/sendspin/source_role.h |
Documents source shutdown on playback removal. |
include/sendspin/player_role.h |
Documents player stream-end behavior. |
include/sendspin/client.h |
Declares the internal playback-stream shutdown helper. |
docs/internals.md |
Describes activity gating and lifecycle ordering. |
docs/integration-guide.md |
Explains playback requirements and listener behavior. |
Review effort: Max (adaptive)
Clarified behavior of playback activity and its impact on streams in the integration guide. Updated comments in the test to reflect changes in stream handling. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Summary
Spec #314 ties the player, visualizer and source streams to the
'playback'activity. On a connection without it the client MUST ignore theplayerandvisualizerobjects instream/start, leaving them unvalidated, and discard player audio and visualization data (messaging.md "stream/start"). It MUST also ignore a sourcestart, and an activation that drops'playback'MUST end an open source stream (roles/source/v1.md "Source command semantics"). Nothing in the library gated on'playback'.Change
stream/starttakes the player and visualizer sections only on a connection with'playback'(one helper,carries_playback()). Artwork is not gated: a paused group keeps its artwork stream.'playback', after the 13-byte length check that a discarded payload still owes (messaging.md "Communication"). The visualizer needs no separate gate: its stream cannot start without'playback', and its existing no-stream discard covers the rest.startcounts only with'playback'.'playback'ends, for the roles the connection keeps:client-stream/end;Without that, a server that skipped its
stream/endwould leave a starved stream, an unmatched start callback and a held high-performance hold, and its nextstream/startwould update the stale stream in place. After a normal pause this adds one player end event, which fires no callback.stream/endandstream/clearstay ungated. The internals dispatch table, the source lifecycle and the guide's role section describe the gate.Tests
'playback'ends the stream, and restoring it needs a new start; a start without'playback'is ignored; the drop cancels an opening waiting for the time sync; a drop that ends a re-handshake's quiet window sendsclient-stream/endbefore theclient/state.'playback'; a short chunk still closes without it, with a control.'playback', no player or visualizer stream starts while artwork decodes; the control starts both after a'playback'activation. Dropping'playback'ends each stream exactly once, whether or not the server ended them first.stream/startgate, the audio gate, the source gate or the drop hook, moving the discard ahead of the length check, ending the visualizer without a running stream, or dropping the player or source end each fails a test.Not covered: not built for ESP or role-disabled builds; stack budgets not re-derived (the new chain matches the role-removal path's depth).