Fix issue with clearing output protocol during track changes
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 20:37:31 +0000 (21:37 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 20:37:31 +0000 (21:37 +0100)
music_assistant/controllers/players/protocol_linking.py
music_assistant/models/player.py

index cb74b0606c2aa405e0a4adf33be512e1d025c1ff..dcf86621f503be4472ce2a4514c8ef038be3d891 100644 (file)
@@ -1450,30 +1450,3 @@ class ProtocolLinkingMixin:
             parent_protocol_player.group_members,
             parent_protocol_player.synced_to,
         )
-
-        # Clear active protocol if all protocol members were removed
-        if (
-            filtered_protocol_remove
-            and not filtered_protocol_add
-            and parent_protocol_player.player_id == parent_player.active_output_protocol
-        ):
-            # Check group_members count to see if we should clear
-            members_count = len(parent_protocol_player.group_members)
-            self.logger.debug(
-                "Checking if should clear active protocol on %s: "
-                "protocol_members_count=%s, removing=%s",
-                parent_player.state.name,
-                members_count,
-                filtered_protocol_remove,
-            )
-            if members_count <= 1 and parent_player.state.playback_state == PlaybackState.IDLE:
-                parent_player.set_active_output_protocol(None)
-
-        # Clear active output protocol on removed child players
-        if filtered_protocol_remove:
-            for child_protocol_id in filtered_protocol_remove:
-                if child_protocol := self.get_player(child_protocol_id):
-                    if child_protocol.protocol_parent_id:
-                        if child_player := self.get_player(child_protocol.protocol_parent_id):
-                            if child_player.active_output_protocol == child_protocol_id:
-                                child_player.set_active_output_protocol(None)
index 72f9773a1879dbe275b8db075d672d4ddfcac5f0..ceed5b49a857315a8c3316731bf009adb5f0b8e2 100644 (file)
@@ -1010,6 +1010,7 @@ class Player(ABC):
         :param protocol_id: The protocol player_id to set as active, "native" for native playback,
             or None to clear the active protocol.
         """
+        self.mass.cancel_timer(f"set_output_protocol_{self.player_id}")
         if self.__attr_active_output_protocol == protocol_id:
             return  # No change
         if protocol_id == self.player_id:
@@ -1347,6 +1348,12 @@ class Player(ABC):
             self.mass.call_later(
                 2, self.set_active_mass_source, None, task_id=f"set_mass_source_{self.player_id}"
             )
+            self.mass.call_later(
+                2,
+                self.set_active_output_protocol,
+                None,
+                task_id=f"set_output_protocol_{self.player_id}",
+            )
 
         return get_changed_dataclass_values(
             prev_state,