Chore: speedup AirPlay stop
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 18 Feb 2025 21:14:44 +0000 (22:14 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 18 Feb 2025 21:14:44 +0000 (22:14 +0100)
music_assistant/providers/airplay/player.py
music_assistant/providers/airplay/raop.py

index ee09e1ef704f595bb7e9962473618ad230981cfd..d13f7d72041bb39311ec45a8ed9dd6e574319ee6 100644 (file)
@@ -33,13 +33,12 @@ class AirPlayPlayer:
 
     async def cmd_stop(self, update_state: bool = True) -> None:
         """Send STOP command to player."""
-        async with self._lock:
-            if self.raop_stream:
-                # forward stop to the entire stream session
-                await self.raop_stream.session.stop()
-            if update_state and (mass_player := self.mass.players.get(self.player_id)):
-                mass_player.state = PlayerState.IDLE
-                self.mass.players.update(mass_player.player_id)
+        if self.raop_stream:
+            # forward stop to the entire stream session
+            await self.raop_stream.session.stop()
+        if update_state and (mass_player := self.mass.players.get(self.player_id)):
+            mass_player.state = PlayerState.IDLE
+            self.mass.players.update(mass_player.player_id)
 
     async def cmd_play(self) -> None:
         """Send PLAY (unpause) command to player."""
index 7c67a8c6f26a59ba911c9f555dd230b2c9a83dbf..a0183eb609a712eaa8defe8eafef9be47f33799f 100644 (file)
@@ -140,9 +140,8 @@ class RaopStreamSession:
             return
         assert airplay_player.raop_stream
         assert airplay_player.raop_stream.session == self
-        async with self._lock:
-            self._sync_clients.remove(airplay_player)
-            await airplay_player.raop_stream.stop()
+        self._sync_clients.remove(airplay_player)
+        await airplay_player.raop_stream.stop()
         airplay_player.raop_stream = None
 
     async def add_client(self, airplay_player: AirPlayPlayer) -> None:
@@ -296,7 +295,7 @@ class RaopStream:
             await self.send_cli_command("ACTION=STOP")
         self._stopped = True
         with suppress(asyncio.TimeoutError):
-            await self._cliraop_proc.wait_with_timeout(5)
+            await self._cliraop_proc.wait_with_timeout(2)
         if self._stderr_reader_task and not self._stderr_reader_task.done():
             self._stderr_reader_task.cancel()
         if self._cliraop_proc.proc and not self._cliraop_proc.closed: