music-assistant-server
Branch:dev-lidarr-plugin
Commit Details
Keep a stop from cutting off playback that already restarted (#6082)
# What does this implement/fix? Stopping a queue cleared every audio buffer on it, without checking which playback session those buffers belonged to. The rest of the stop already checks: the session itself and the audio processing are only released when the session that was stopped is still the current one. The buffer cleanup was not. So when playback restarts before a stop finishes, the new session survives the stop but its audio does not, and the track that just started loses the audio it was filling. That needs the playback lock to give up on a wedged holder first, so it takes a stop that hangs for thirty seconds on an unresponsive speaker. Every audio buffer now records the session that asked for it, and a stop releases only its own. A buffer with no session recorded is still released, because a stop must never leave a producer running. Follow-up to a review comment on #6077, which deliberately left this out of scope. - Audio buffers are claimed by the playback session that asks for them, recorded on the stream details when the buffer is attached - A queue stop releases only the buffers it claimed; a clear or a replace still releases all of them, since it is discarding the items anyway - Reusing a buffer that is already warm claims it for the session reusing it - Buffers are detached before being released, so one attached while the old one is still being torn down is not dropped - A stop that had no session of its own now tears nothing down, instead of reading "no session" as "release everything" - A stop cancels a prewarm that is still running, so it can no longer attach its audio after the stop has finished and leave the queue holding a provider's stream Needs music-assistant-models 1.1.205, which is already on `dev` via #6086. **Related issue (if applicable):** - Companion PR: music-assistant/models#387 - Follow-up to #6077 ## Types of changes - [x] Maintenance / chore — `maintenance` ## 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. - [x] 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.
Author
Marcel van der Veldt<[email protected]>
August 28, 2026 at 09:35 PM UTC
Committer
Marcel van der Veldt<[email protected]>
August 29, 2026 at 12:28 AM UTC
208additions
6deletions
10files changed
Parent commits
Changes
10 files
+208-6
Changed Files (10)
music_assistant/controllers/player_queues/
music_assistant/controllers/streams/
tests/controllers/player_queues/
tests/controllers/streams/
music_assistant/controllers/player_queues/README.md
music_assistant/controllers/player_queues/base.py
music_assistant/controllers/player_queues/controller.py
+4
music_assistant/controllers/player_queues/stream_feeder.py
+8-4
music_assistant/controllers/streams/audio.py
tests/controllers/player_queues/test_queue_audio_cleanup.py
tests/controllers/player_queues/test_stop_teardown.py
+41-2
tests/controllers/player_queues/test_stream_feeder.py
tests/controllers/streams/test_audio_buffer.py
tests/controllers/streams/test_buffer_session_stamp.py
+155