Workaround for slow starting radio streams
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Nov 2025 01:13:06 +0000 (02:13 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Nov 2025 01:13:06 +0000 (02:13 +0100)
music_assistant/controllers/streams.py

index fb339d0887b33f7114549136c7100314c190a96b..91a266b0ff28b3d0d4a315f2112bb1bee6a8914a 100644 (file)
@@ -1304,6 +1304,15 @@ class StreamsController(CoreController):
                 filter_params=filter_params,
             )
 
+        if (
+            streamdetails.media_type == MediaType.RADIO
+            and streamdetails.volume_normalization_mode == VolumeNormalizationMode.DYNAMIC
+        ):
+            # prepend 3 seconds of silence to give loudnorm filter time to adjust
+            # fixes https://github.com/music-assistant/support/issues/4028#issuecomment-3478449178
+            silence = b"\0" * int(pcm_format.sample_rate * (pcm_format.bit_depth / 8) * 2) * 3
+            yield silence
+
         first_chunk_received = False
         fade_in_buffer = b""
         bytes_received = 0