Skip to content

Fix double sendspin bridges for devices with both Airplay and Cast#3854

Merged
MarvinSchenkel merged 10 commits into
devfrom
fix_double_sendspin_bridges
May 16, 2026
Merged

Fix double sendspin bridges for devices with both Airplay and Cast#3854
MarvinSchenkel merged 10 commits into
devfrom
fix_double_sendspin_bridges

Conversation

@MarvinSchenkel
Copy link
Copy Markdown
Contributor

@MarvinSchenkel MarvinSchenkel commented May 8, 2026

This PR makes the bridge evaluation idempotent for devices that both have Airplay and Cast protocols:

  • Airplay is always preferred
  • Chromecast bridges now subscribe to player and provider events to evaluate whether the cast bridge is still needed

So MA can now:

  • Tear down the cast bridge and add an Airplay one when Airplay is detected (and vice versa). This also fixes the race condition where Cast registered before Airplay and left an orphaned (2nd grayed out) sendspin protocol on the universal player
  • Auto clean up orphaned sendspin bridges.

This PR also surfaced the KeyError: 'player_id' bug which turned out to be a missing guard in the save_protocol_parent_id function.

Copilot AI review requested due to automatic review settings May 8, 2026 09:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make Sendspin bridge creation/removal for Chromecast devices idempotent when a device supports both Chromecast and AirPlay, with AirPlay preferred and automatic cleanup of redundant/orphaned bridges/config.

Changes:

  • Add an idempotent evaluate_bridge path for Chromecast Sendspin bridges, including event-driven re-evaluation when relevant players/providers change.
  • Prefer AirPlay bridges over Cast bridges when both are present under the same universal/parent player (and AirPlay is available).
  • Add cleanup logic during universal-player restore to remove orphaned protocol player configs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
music_assistant/providers/universal_player/provider.py Adds cleanup for invalid/orphaned linked protocol player configs during universal-player restore.
music_assistant/providers/chromecast/sendspin_bridge.py Introduces _should_have_bridge + evaluate_bridge, adds event subscriptions, and improves bridge removal cleanup.
music_assistant/providers/chromecast/provider.py Switches bridge setup on discovery from setup_bridge to the new evaluate_bridge reconciliation flow.

Comment thread music_assistant/providers/universal_player/provider.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread music_assistant/providers/chromecast/sendspin_bridge.py
Comment thread music_assistant/providers/universal_player/provider.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread music_assistant/providers/chromecast/sendspin_bridge.py Outdated
Comment thread music_assistant/providers/chromecast/sendspin_bridge.py
@MarvinSchenkel MarvinSchenkel marked this pull request as draft May 8, 2026 13:45
MarvinSchenkel and others added 4 commits May 12, 2026 14:59
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MarvinSchenkel MarvinSchenkel marked this pull request as ready for review May 12, 2026 13:41
Copilot AI review requested due to automatic review settings May 12, 2026 13:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread music_assistant/providers/chromecast/sendspin_bridge.py
Comment thread music_assistant/providers/chromecast/sendspin_bridge.py
Copilot AI review requested due to automatic review settings May 12, 2026 15:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/providers/chromecast/sendspin_bridge.py
@marcelveldt
Copy link
Copy Markdown
Member

I think for now this is fine to add like this but if we plan to add more bridges, we should have a generic bridge helper logic in the sendspin provider that can make the decisions per protocol

@MarvinSchenkel MarvinSchenkel merged commit 85b49a5 into dev May 16, 2026
14 checks passed
@MarvinSchenkel MarvinSchenkel deleted the fix_double_sendspin_bridges branch May 16, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants