music-assistant-server

Branch:dev-lidarr-plugin

Commit Details

Crossfades no longer shrink to a few seconds on slower sources (#6128)

# What does this implement/fix?

With smart fades on, crossfades were often barely audible and on shorter
tracks
disappeared entirely. Reported on a Sonos sync group playing Spotify.

A fade may only hold back audio the player is already ahead by, and that
lead was
measured from scratch on every track. A source delivering just above
playback pace
(librespot runs at ~1.09x) can only bank a few percent of a track's
length, so every
boundary started from nothing. Measured on real hardware: 8.4s on
Spotify where the
same speakers give 44.5s from a local file. Under ~103s of track the
window falls below
the 3-second floor and there is no fade and no log line at all.

The lead a track earns is now carried into the next one, in both the
single-item and the
flow stream, so it grows through the queue. Measured on a Sonos sync
group with the
source paced at Spotify's 1.09x: the window went 8.4s, 36.7s, 44.5s as
the lead grew
0 -> 14.0s -> 45.0s, instead of resetting to nothing every track.

**Related issue (if applicable):**

- reported directly

## Types of changes

- [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`
- [ ] 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

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `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.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.
Forgejo

Author

Marcel van der Veldt<[email protected]>
August 31, 2026 at 02:14 PM UTC

Committer

Marvin Schenkel<[email protected]>
September 4, 2026 at 07:55 AM UTC
781additions
174deletions
2files changed

Parent commits

Changes

2 files
+781-174

Changed Files (2)

music_assistant/controllers/streams/
tests/controllers/streams/
music_assistant/controllers/streams/audio.py
+324-174
tests/controllers/streams/test_realtime_sources.py
+457