From d80ec5f301573400752ce171a6d380ad18178b40 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 3 Nov 2025 01:07:54 +0100 Subject: [PATCH] Fix stop on stream end in AirPlay provider --- music_assistant/helpers/process.py | 1 + music_assistant/providers/airplay/stream_session.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/music_assistant/helpers/process.py b/music_assistant/helpers/process.py index 394fe4ad..bbbb49cd 100644 --- a/music_assistant/helpers/process.py +++ b/music_assistant/helpers/process.py @@ -170,6 +170,7 @@ class AsyncProcess: try: if self.proc.stdin.can_write_eof(): self.proc.stdin.write_eof() + await self.proc.stdin.drain() except ( AttributeError, AssertionError, diff --git a/music_assistant/providers/airplay/stream_session.py b/music_assistant/providers/airplay/stream_session.py index 76604877..5ebb9c2f 100644 --- a/music_assistant/providers/airplay/stream_session.py +++ b/music_assistant/providers/airplay/stream_session.py @@ -136,10 +136,11 @@ class AirPlayStreamSession: assert airplay_player.stream.session == self async with self._lock: self.sync_clients.remove(airplay_player) - await airplay_player.stream.stop() if ffmpeg := self._player_ffmpeg.pop(airplay_player.player_id, None): + await ffmpeg.write_eof() await ffmpeg.close() del ffmpeg + await airplay_player.stream.stop() airplay_player.stream = None # If this was the last client, stop the session if not self.sync_clients: @@ -372,6 +373,8 @@ class AirPlayStreamSession: if ffmpeg := self._player_ffmpeg.pop(airplay_player.player_id, None): await ffmpeg.write_eof() await ffmpeg.close() + if airplay_player.stream: + await airplay_player.stream.stop() async def _send_metadata(self, progress: int | None, metadata: PlayerMedia | None) -> None: """Send metadata to all players.""" -- 2.34.1