/
/
# What does this implement/fix? Skipping to the next track, while Spotify plays through Spotify's own playback engine, started the new track with up to half a second of the track you had just skipped away from. Music Assistant reads the engine's audio through a capture pipe. When it asks the engine to jump, the engine confirms within about ten milliseconds — but the audio it had already produced is still travelling through that pipe, so the tail of the old track ended up at the head of the new one. Music Assistant now measures how much audio is still in flight at the moment of the jump and drops exactly that much, so the new track starts on its own first note. Changes: - Measure the audio still held between the capture sink and the reader when the engine confirms a skip, and drop that, instead of trusting the confirmation to arrive before the audio does. The amount is measured per skip because it varies (383–627 ms across a test run), so no fixed value fits. - Free a track's leftover audio once its stream is gone, so what a skip abandons stops counting against the session's buffer limit for the rest of the session. - Tests for both, driving a real pipe so the measurement itself is exercised. **Related issue (if applicable):** - none; found while testing #5918 ## 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` - [x] 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.