Increase buffer size for radio streams (#379)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 20 Jun 2022 07:38:28 +0000 (09:38 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Jun 2022 07:38:28 +0000 (09:38 +0200)
music_assistant/controllers/streams.py
music_assistant/helpers/process.py

index 7e715d17890d3af00e2bd8aca164efb6811f4b49..f076719794805dc64367d5a4b7392c1d16c3e4d5 100644 (file)
@@ -513,12 +513,12 @@ class QueueStream:
 
             sample_size = int(
                 self.pcm_sample_rate * (self.pcm_bit_depth / 8) * self.pcm_channels
-            )  # 1 second
-            buffer_size = sample_size * (self.queue.settings.crossfade_duration or 2)
+            )
+            buffer_size = sample_size * (self.queue.settings.crossfade_duration or 5)
             # force small buffer for radio to prevent too much lag at start
             if queue_track.media_type != MediaType.TRACK:
                 use_crossfade = False
-                buffer_size = sample_size
+                buffer_size = sample_size * 2
 
             self.logger.info(
                 "Start Streaming queue track: %s (%s) for queue %s",
index b368a28d8f9a9c5fd4b97e65948a2275aab04924..a556a9d7d71458c4e90b9f2ed612f6815516fa65 100644 (file)
@@ -52,7 +52,7 @@ class AsyncProcess:
                 stdin=asyncio.subprocess.PIPE if self._enable_stdin else None,
                 stdout=asyncio.subprocess.PIPE if self._enable_stdout else None,
                 stderr=asyncio.subprocess.PIPE if self._enable_stderr else None,
-                limit=self.chunk_size * 5,
+                limit=self.chunk_size * 15,
                 close_fds=True,
             )
         else:
@@ -61,7 +61,7 @@ class AsyncProcess:
                 stdin=asyncio.subprocess.PIPE if self._enable_stdin else None,
                 stdout=asyncio.subprocess.PIPE if self._enable_stdout else None,
                 stderr=asyncio.subprocess.PIPE if self._enable_stderr else None,
-                limit=self.chunk_size * 5,
+                limit=self.chunk_size * 15,
                 close_fds=True,
             )
         return self