Skip to content

Commit

Permalink
sync tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 24, 2024
1 parent f2c6500 commit 7211fae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion music_assistant/server/controllers/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,10 @@ async def cmd_sync_many(self, target_player: str, child_player_ids: list[str]) -
async with self._player_throttlers[target_player]:
try:
await player_provider.cmd_sync_many(target_player, final_player_ids)
finally:
except Exception:
# restore sync state if the command failed
parent_player.group_childs = prev_group_childs
raise

@api_command("players/cmd/unsync_many")
async def cmd_unsync_many(self, player_ids: list[str]) -> None:
Expand Down
5 changes: 4 additions & 1 deletion music_assistant/server/providers/player_group/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ async def _sync_syncgroup(self, group_player: Player) -> None:
if sync_leader.player_id == member.player_id:
# skip sync leader
continue
if member.synced_to == sync_leader.player_id:
if (
member.synced_to == sync_leader.player_id
and member.player_id in sync_leader.group_childs
):
# already synced
continue
members_to_sync.append(member.player_id)
Expand Down
3 changes: 2 additions & 1 deletion music_assistant/server/providers/slimproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ async def cmd_unsync(self, player_id: str) -> None:
player = self.mass.players.get(player_id, raise_unavailable=True)
if player.synced_to:
group_leader = self.mass.players.get(player.synced_to, raise_unavailable=True)
group_leader.group_childs.remove(player_id)
if player_id in group_leader.group_childs:
group_leader.group_childs.remove(player_id)
player.synced_to = None
if slimclient := self.slimproto.get_player(player_id):
await slimclient.stop()
Expand Down

0 comments on commit 7211fae

Please sign in to comment.