/
/
# What does this implement/fix? Follow-up hardening on #5784. When a player switches between being a speaker output of another player and being a player of its own, the switch was detected by comparing the player's current type against the type in its last calculated state. That state is recalculated all the time (any volume change, group change or the periodic refresh), and a recalculation adopts the new type. If one landed between the provider setting the new type and announcing it, the switch was no longer visible and the player silently ended up without a queue again - the exact problem #5784 fixed. The switch is now read off the queue the player owns instead: a speaker output never owns one, every other player always does. That is the same thing the switch has to repair, so it cannot be missed and it also heals a switch that was somehow missed earlier. - Detect the role switch from the player's queue rather than from its last state update. - Pass the direction of the switch into the link cleanup so it no longer depends on the state either. - Split the protocol link cleanup into its two halves, so the caller picks the one it needs. - Added tests covering a state update landing before the re-registration, in both directions. **Related issue (if applicable):** - n/a ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives the label from the ticked box and applies it automatically; the release-notes generator uses that same label to slot this change into the next release notes. --> - [ ] 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.