Skip to content

Let a source decline a start - #334

Merged
kahrendt merged 1 commit into
mainfrom
feat/source-decline-start
Oct 28, 2026
Merged

kahrendt merged 1 commit into
mainfrom
feat/source-decline-start

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

A source had no clear way to refuse a server's start, for example when the user turned sharing off or muted a microphone. It could only skip opening the stream, which left the server waiting without an answer.

A source may now decline by sending client-stream/end without opening a stream, so no new message is needed. The server already waits for client-stream/end before treating a stream as closed, so one that arrives with no stream open can only be a decline. The existing rule for a start that crosses a client-stream/end covers a newer start sent before the decline arrived.

Limitations

  • A decline carries no reason, so the server can't tell the user why.
  • A source that doesn't want to stream for a while still has to decline each start. The only way to block all starts is available: false, which takes the whole client offline. I think that's an ok compromise, since reporting signal: absent already keeps the server from starting it automatically, so only starts the user asks for need a decline.

Breaking changes

  • Servers: must treat a client-stream/end that arrives with no open input stream as a decline. A server that treated it as an error could close the connection on an updated client.

  • Clients: none, since declining is optional.

  • I accept the Contributor License Agreement for this contribution.

kahrendt pushed a commit that referenced this pull request Oct 28, 2026
<!-- Describe the change and why it is needed. -->

`signal` was optional and only described line sensing, so a server could
not offer automatic playback for sources without it and had to explain
to users why the option was missing.

Every source now reports `signal`. `present` means the source has input
audio to offer, set from a user action like a button or a sharing
toggle, from detecting audio on its input, or both. Only a source fed
through an audio-only connection, like an analog line-in, should detect
it from the audio, so a microphone never has to listen all the time.
This removes the `line_sense` flag and with it the client's
`source@v1_support` object.

The server now reacts to changes of `signal`, so a turntable that keeps
playing after the user stopped its stream does not restart it. The first
`signal` after activation, or after the client becomes available again,
counts as a change.

## Implementation guide

A follow-up to the implementation guide will cover:
- Suggested threshold, hold time and algorithm for detecting audio on a
line-in
- How each kind of source decides `signal` (Bluetooth receivers, desktop
apps, HDMI and S/PDIF inputs, microphones)
- How a momentary button maps to `signal`, and what the device shows
while it waits for the server

These stay out of the spec, since good values depend on the hardware, no
compliance test can check them, and implementations should be able to
improve on them without a spec change.

## Limitations

- A server can't tell a source that can't detect audio apart from one
with nothing playing, since both report `absent`.
- `signal` can't stop the server from starting a source. Declining a
`start` is handled separately in #334.

## Breaking changes

- Clients: must always send `signal` in the source state, and must no
longer send `source@v1_support` in `client/hello`.
- Servers: must not require `source@v1_support` from clients. A server
that still requires it won't activate the source role for updated
clients.
- Servers: should treat `signal` changes as start and stop hints, not
the current value.

- [x] I accept the [Contributor License
Agreement](../blob/main/CONTRIBUTOR-LICENSE-AGREEMENT.md) for this
contribution.

@kahrendt kahrendt 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.

Thanks

@kahrendt
kahrendt merged commit 7f2f0e1 into main Oct 28, 2026
1 check passed
@kahrendt
kahrendt deleted the feat/source-decline-start branch October 28, 2026 11:12
maximmaxim345 added a commit to Sendspin/aiosendspin that referenced this pull request Nov 16, 2026
# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

Source clients that follow the updated spec no longer send
`source@v1_support`, but the server still required it. A strict server
rejected them and a lenient one never activated their source role, so
their `signal` never reached the application.

The server now activates the role without it and reports every `signal`
change through `SourceSignalChangedEvent`, including the first one after
the client becomes available again. An older client's
`source@v1_support` still parses, so its `line_sense` keeps working, but
it's flagged as noncompliant, like a source state without `signal`. A
strict server therefore rejects source clients built on older
aiosendspin releases.

A `client-stream/end` with no input stream open now counts as a declined
start, so it no longer authorizes a later `client-stream/start`.

**Related issue or spec PR (if applicable):**

- Sendspin/spec#335
- Sendspin/spec#334

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the
matching label, and the release notes use it to sort this change.
-->

- [x] Bugfix (non-breaking change which fixes an issue): `bugfix`
- [ ] New feature (non-breaking change which adds functionality):
`new-feature`
- [ ] Enhancement to an existing feature: `enhancement`
- [ ] Breaking change (changes the public API or the protocol in a way
that is not backwards compatible): `breaking-change`
- [ ] Refactor (no behavior change): `refactor`
- [ ] Documentation only: `documentation`
- [ ] Maintenance / chore: `maintenance`
- [ ] CI / workflow change: `ci`
- [ ] Dependencies bump: `dependencies`
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