Skip to content

Replace a Sendspin next track that was already sent without a restart - #8083

Merged
marcelveldt merged 2 commits into
devfrom
feat/sendspin-replace-sent-next-track
Nov 27, 2026
Merged

marcelveldt merged 2 commits into
devfrom
feat/sendspin-replace-sent-next-track

Conversation

@maximmaxim345

@maximmaxim345 maximmaxim345 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What does this implement/fix?

When the queue changes the next track after Sendspin already sent part of it, playback no longer restarts. The server cuts its stream where the old next track starts, tells the clients to drop their audio from that point with a timestamped stream/clear, and sends the new track from there. The spec names this case for the timestamped clear.

When a crossfade into the old next track was already mixed, or a client in the group doesn't support the timestamped clear, playback restarts at the current position as before.

Core gets one small helper, fade_pending in the streams audio controller, so Sendspin can tell whether a crossfade into a later item was already mixed.

A change shortly before the next track starts still leaves a short pause while the new track's first audio arrives (0.57 s in a test with a Tidal track).

Tested with sendspin-cli 1.0.1 (sendspin-cpp v0.10.0) by changing the next track during playback.

Related issue (if applicable):

Types of changes

  • 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
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.
  • I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.

@codspeed

codspeed Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 11 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing feat/sendspin-replace-sent-next-track (ea08c3f) with dev (84e6884)2

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on dev (af5c061) during the generation of this report, so 84e6884 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@maximmaxim345

Copy link
Copy Markdown
Member Author

@Bot-MArley review

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets a Sendspin session swap the next track it already sent ahead by cutting the stream at that track's start with a timestamped stream/clear, instead of restarting playback, and bumps aiosendspin to 11.0.0 for it. The cut itself looks solid: the queued audio before the cut is kept, the fallbacks (crossfade already mixed, clients that can't cut, a stop during the cut) all go back to the old restart, and the tests cover each of them. One thing from the aiosendspin bump still needs a follow-up before this is ready.

Requested changes

  1. [PROBLEM] aiosendspin 11.0.0 drops source@v1_support (and its line_sense feature) from the spec: compliant source clients now always report signal, and a hello that still sends it is flagged as non-compliant. _supports_line_sense still reads info.source_support, so every client on the new spec, and the demo Line-In Speaker now that it no longer sends source_support, gets the "autostart unavailable" note instead of the line-in autostart setting. Please base it on the negotiated source role (or the reported signal) and update the Autostart section of the sendspin README with it.

This changes core code and requirements_all.txt, so it needs another maintainer's approval.

@maximmaxim345

Copy link
Copy Markdown
Member Author

@Bot-MArley approve

@Bot-MArley

Copy link
Copy Markdown
Collaborator

Note

This comment was posted by Bot-MArley on behalf of the Music Assistant maintainers.

@maximmaxim345 approve only works on your own server PRs into dev. On someone else's PR, approve it yourself.

@Bot-MArley

Copy link
Copy Markdown
Collaborator

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This lets a Sendspin session swap a next track it already sent ahead with a timestamped stream/clear, instead of restarting the current track. I found one thing to fix before it can merge:

  1. [CRITICAL] playback.py:1258: clear_from goes to every client without checking that it understands from_timestamp. aiosendspin documents that a client without the field drops all its audio, supports_timestamped_clear() always returns True for player@v1, and its own client ignores the field. With "Allow legacy clients" off, an older client such as an ESPHome device still plays in this mode. A "Play next" with 15 s left on the current track, after the next track was sent ahead, then silences it until the new track arrives, where before this PR it was a short restart. Please only cut when every client in the group is known to honour the timestamp, and otherwise return False so enqueue_next_media restarts.

@Bot-MArley

Copy link
Copy Markdown
Collaborator

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

@maximmaxim345 Changes in this area must be tested on real hardware before they can be merged. Have you tested this on a real Sendspin device? If so, please say what you tested. If you have a Sendspin device, the Music Assistant DEV SERVER app is an easy way to try this PR with it: stop your Music Assistant app, install the DEV app, set its server_repo option to pr-8083 and start it (see its README).

@maximmaxim345

Copy link
Copy Markdown
Member Author

This is intentional.
A server has no way yet to tell whether a client handles from_timestamp, so the cut only runs with "Allow legacy clients" turned off. The setting is on by default, and with it on Sendspin plays in flow mode and never sends from_timestamp.
Turning it off is an advanced option for clients that follow the current Sendspin spec, as the docs for the setting say, and since Sendspin/spec#336 the spec expects every player to keep the audio before from_timestamp.
That limits the breakage to people who turn it off to try the latest features. An older client there gets the fallback the spec PR describes: it goes silent until the cut, then plays the new track.

Tested with "Allow legacy clients" off on an ESPHome speaker with sendspin-cpp 0.10.0: "Play next" 8 s before the end of a track kept the rest of that track, then played the new one.

Docs for the setting:

@Bot-MArley

Copy link
Copy Markdown
Collaborator

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345, that context helps. If the cut only runs with "Allow legacy clients" off, where the spec expects players to keep the audio before from_timestamp, the impact is limited to people who opted in, and your ESPHome test covers the hardware question.

I can't take a confirmed critical off the list from a reply, though, so that point stays open for you to decide in the review. Since a client that ignores the field goes silent in that mode, the setting's docs should say so.

@maximmaxim345
maximmaxim345 force-pushed the feat/sendspin-replace-sent-next-track branch 2 times, most recently from 4c9be36 to 2ca002c Compare November 24, 2026 16:23
Base automatically changed from feat/sendspin-track-by-track to dev November 24, 2026 17:28
@maximmaxim345
maximmaxim345 force-pushed the feat/sendspin-replace-sent-next-track branch from 2ca002c to ea08c3f Compare November 24, 2026 17:28
@maximmaxim345

Copy link
Copy Markdown
Member Author

@Bot-MArley approve

@github-actions

Copy link
Copy Markdown
Contributor

🔒 Dependency Security Report

📦 Modified Dependencies

music_assistant/providers/sendspin/manifest.json

Added:

Removed:

Unchanged dependencies

The following dependencies were added or modified:

diff --git a/requirements_all.txt b/requirements_all.txt
index 4d326223d..e1f56f186 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -13,7 +13,7 @@ aiohttp-socks==0.12.0
 aiojellyfin==0.14.1
 aiolibdatachannel @ git+https://github.com/music-assistant/aiolibdatachannel@feat/certpem-testdrive
 aiomusiccast==0.15.0
-aiosendspin[server]==10.3.0
+aiosendspin[server]==11.0.0
 aioslimproto==3.6.8
 aiosonos==0.5.0
 aiosqlite==0.22.1

New/modified packages to review:

  • aiosendspin[server]==11.0.0

Automated Security Checks

  • ✅ Vulnerability Scan: Passed - No known vulnerabilities
  • ✅ Trusted Sources: All packages have verified source repositories
  • ✅ Typosquatting Check: No suspicious package names detected
  • ✅ License Compatibility: All licenses are OSI-approved and compatible
  • ✅ Supply Chain Risk: Passed - packages appear mature and maintained

Manual Review

Maintainer approval required:

  • I have reviewed the changes above and approve these dependency updates

To approve: Comment /approve-dependencies or manually add the dependencies-reviewed label.


🔍 Vulnerability Scan Results

No known vulnerabilities found

Name Skip Reason
aiolibdatachannel Dependency not found on PyPI and could not be audited: aiolibdatachannel (2026.5.23.dev4+g950e7f0)
music-assistant-frontend Dependency not found on PyPI and could not be audited: music-assistant-frontend (2.17.380)
torch Dependency not found on PyPI and could not be audited: torch (2.13.0+cpu)
torchaudio Dependency not found on PyPI and could not be audited: torchaudio (2.11.0+cpu)
yappi Dependency not found on PyPI and could not be audited: yappi (1.7.7)

✅ No known vulnerabilities found

@Bot-MArley

Copy link
Copy Markdown
Collaborator

Note

This comment was posted by Bot-MArley on behalf of the Music Assistant maintainers.

@maximmaxim345 Noted for ea08c3f: I'll approve it in a few minutes if my review of this commit is clean, and review it first if I haven't. Dependency changes and new providers still need a maintainer's approval. To have it merged, say @Bot-MArley merge. After a new push, ask again.

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! This rebase onto dev changes no code: all four commits match the ones reviewed at bc7671d. I went through the full diff again. The cut keeps the audio before the replaced item, and every fallback still goes back to the old restart: an item already faded into, a fade into a later item, clients that can't cut, and a stop during the cut. The line-in autostart now follows the negotiated source role. fade_pending only adds a read-only check to core, and the schema versions don't change. The one open point is the earlier one below, which needs a maintainer's decision.

Requested changes

  1. [CRITICAL] Still open from the earlier review: playback.py:1258 sends the timestamped stream/clear without knowing that every client honours from_timestamp. This only happens with "Allow legacy clients" off, and a maintainer decides whether to accept it.

I can't approve this one yet: the open point above has to be settled first, and the aiosendspin bump in manifest.json and requirements_all.txt is a dependency change, which needs another maintainer's approval even on request.

OzGav added a commit to music-assistant/music-assistant.io that referenced this pull request Nov 26, 2026
…art (#1291)

<!--
Thanks for contributing. The checklist below is short but the build
enforces most
of it, so ticking it off saves a round trip.

Full guide:
https://github.com/music-assistant/music-assistant.io/blob/beta/CONTRIBUTING.md
-->

## What does this change?

<!-- A sentence or two. Link the server pull request if there is one.
-->

Every Sendspin device with an audio input now reports whether a signal
is present, so the Automatically play line-in on setting and the setup
step that asks for it are offered for all of them. The note for devices
without signal detection is gone.

Server change:
- music-assistant/server#8083

Requires #1283, which moves this text to the Sendspin page.

## Checklist

- [x] Correct branch: `main` if this fixes something already on the live
site, `beta` if it adds anything new
- [ ] Any new page has a sidebar entry in `astro.config.mjs`, except
music sources and player providers

### Only if you are adding a music source or a player provider

<!-- Plugins, metadata providers and audio analysis providers do not
need these. -->

- [ ] File named after the source or provider, since the menu is sorted
by filename
- [ ] Icon added to `public/assets/icons/`, and it is visible against a
white background
- [ ] Entry added to `src/data/music-sources.ts` or
`src/data/players.ts`, with categories

---

Once this is open, scroll down to the checks and wait for **Deploy
Preview**. If it is green,
click the link to see your change on the site. If it is red, click
`Details`, read the error at
the bottom of the log and push a fix to the same branch. There is no
need to open a new pull
request.
@maximmaxim345
maximmaxim345 force-pushed the feat/sendspin-replace-sent-next-track branch from ea08c3f to e64c18c Compare November 26, 2026 16:09

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @maximmaxim345! After the rebase onto dev, this PR lets a Sendspin session swap a next track it already sent ahead with a timestamped stream/clear, instead of restarting the current track. It falls back to the old restart when a crossfade into the old next track was already mixed or a client can't do the cut.

I went through the whole diff again and didn't find anything that needs to change before merge. The new tests run the real playback loop, and the earlier point about the dependency bump no longer applies, since the aiosendspin bump is now on dev.

One optional thing: a short comment at the clear_from call that it's only reached with "Allow legacy clients" off would help the next reader.

It changes core code in streams/audio.py and the Sendspin provider, so I don't approve it on my own. If you're a server admin, comment @Bot-MArley approve for this head and I will.

@marcelveldt

Copy link
Copy Markdown
Member

lab gate --all on #8084 cbe4b8edc, which includes this PR: green, 17/17 incl. sendspin — run 20261127-140600-cfc3

@marcelveldt marcelveldt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @maximmaxim345!

@marcelveldt
marcelveldt added this pull request to the merge queue Nov 27, 2026
Merged via the queue into dev with commit 1d6f81c Nov 27, 2026
26 checks passed
@marcelveldt
marcelveldt deleted the feat/sendspin-replace-sent-next-track branch November 27, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-reviewed Indication that any added or modified/updated dependencies on a PR have been reviewed enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants