Chore: limit cache filling a bit more
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 10 Mar 2025 15:11:06 +0000 (16:11 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 10 Mar 2025 15:11:06 +0000 (16:11 +0100)
to keep cpu to a minimum on super fast connections, rate limit the cache fill a bit more

music_assistant/helpers/audio.py

index 8bce0578b79d7eb6e11141e0a1a87351333afa91..185642d3f64391a26d4e0d05f5d4a378fafd5e67 100644 (file)
@@ -157,8 +157,10 @@ class StreamCache:
             audio_input=audio_source,
             input_format=self.streamdetails.audio_format,
             output_format=self.streamdetails.audio_format,
-            extra_input_args=extra_input_args,
             chunk_size=64000,
+            # apply readrate limiting to avoid buffering too much data too fast
+            # so we only allow reading into the cache max 5 times the normal speed
+            extra_input_args=["-readrate", "5", *extra_input_args],
         ):
             async with self._lock:
                 self._data += chunk