From acfb0ba9f985b37c5f1f8c71cf1c03edfb5ea7e5 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 8 Mar 2025 00:55:24 +0100 Subject: [PATCH] Fix: prevent high cpu when filling cache yield to eventloop to allow headroom for other tasks to be executed --- music_assistant/helpers/audio.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/music_assistant/helpers/audio.py b/music_assistant/helpers/audio.py index a6aea760..d71b4fdd 100644 --- a/music_assistant/helpers/audio.py +++ b/music_assistant/helpers/audio.py @@ -116,6 +116,7 @@ class StreamCache: else: yield chunk del chunk + await asyncio.sleep(0) # yield to eventloop finally: self._subscribers -= 1 if self._subscribers == 0: @@ -157,10 +158,12 @@ class StreamCache: input_format=self.streamdetails.audio_format, output_format=self.streamdetails.audio_format, extra_input_args=extra_input_args, + chunk_size=64000, ): async with self._lock: self._data += chunk del chunk + await asyncio.sleep(0) # yield to eventloop if not self._first_part_received.is_set(): self._first_part_received.set() self.logger.debug( -- 2.34.1