Skip to content

Gate the player, visualizer and source streams on the playback activity - #281

Merged
kahrendt merged 2 commits into
mainfrom
playback-activity-gating
Nov 19, 2026
Merged

kahrendt merged 2 commits into
mainfrom
playback-activity-gating

Conversation

@kahrendt

Copy link
Copy Markdown
Contributor

Summary

Spec #314 ties the player, visualizer and source streams to the 'playback' activity. On a connection without it the client MUST ignore the player and visualizer objects in stream/start, leaving them unvalidated, and discard player audio and visualization data (messaging.md "stream/start"). It MUST also ignore a source start, 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/start takes 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.
  • Player audio is discarded without '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.
  • A source start counts only with 'playback'.
  • An activation that drops 'playback' ends, for the roles the connection keeps:
    • the source stream, sending client-stream/end;
    • any player or visualizer stream a server left running.
      Without that, a server that skipped its stream/end would leave a starved stream, an unmatched start callback and a held high-performance hold, and its next stream/start would update the stale stream in place. After a normal pause this adds one player end event, which fires no callback.
  • stream/end and stream/clear stay ungated. The internals dispatch table, the source lifecycle and the guide's role section describe the gate.

Tests

  • Source command table: dropping '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 sends client-stream/end before the client/state.
  • Player rows: audio discarded without 'playback'; a short chunk still closes without it, with a control.
  • Loopback: with no '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.
  • Mutants: removing either stream/start gate, 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).

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.
@kahrendt
kahrendt marked this pull request as ready for review November 19, 2026 15:32
@kahrendt
kahrendt requested an adaptive review from Copilot November 19, 2026 15:32

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

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)

Comment thread docs/integration-guide.md Resolved
Comment thread tests/test_role_deactivation.cpp Resolved
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>
@kahrendt
kahrendt merged commit a10289a into main Nov 19, 2026
16 checks passed
@kahrendt
kahrendt deleted the playback-activity-gating branch November 19, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants