try to fix weird sonos issues with
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 13 Dec 2025 01:52:44 +0000 (02:52 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 13 Dec 2025 01:52:44 +0000 (02:52 +0100)
music_assistant/controllers/streams/streams_controller.py
music_assistant/providers/sonos/player.py

index bd3dadf42bfe8fed7c37e4fd870e16999e61aca6..a25ccf71cad2dbbc3cae931ed9f395d0ddc8973f 100644 (file)
@@ -517,25 +517,13 @@ class StreamsController(CoreController):
         # this final ffmpeg process in the chain will convert the raw, lossless PCM audio into
         # the desired output format for the player including any player specific filter params
         # such as channels mixing, DSP, resampling and, only if needed, encoding to lossy formats
-
-        # readrate filter input args to control buffering
-        # we need to slowly feed the music to avoid the player stopping and later
-        # restarting (or completely failing) the audio stream by keeping the buffer short.
-        # this is reported to be an issue especially with Chromecast players.
-        # see for example: https://github.com/music-assistant/support/issues/3717
-        user_agent = request.headers.get("User-Agent", "")
         if queue_item.media_type == MediaType.RADIO:
             # keep very short buffer for radio streams
             # to keep them (more or less) realtime and prevent time outs
             read_rate_input_args = ["-readrate", "1.0", "-readrate_initial_burst", "2"]
-        elif "Network_Module" in user_agent or "transferMode.dlna.org" in request.headers:
-            # and ofcourse we have an exception of the exception. Where most players actually NEED
-            # the readrate filter to avoid disconnecting, some other players (DLNA/MusicCast)
-            # actually fail when the filter is used. So we disable it completely for those players.
-            read_rate_input_args = None  # disable readrate for DLNA players
         else:
-            # allow buffer ahead of 10 seconds and read 1.5x faster than realtime
-            read_rate_input_args = ["-readrate", "1.5", "-readrate_initial_burst", "10"]
+            # just allow the player to buffer whatever it wants for single item streams
+            read_rate_input_args = None
 
         first_chunk_received = False
         bytes_sent = 0
@@ -674,8 +662,8 @@ class StreamsController(CoreController):
             # restarting (or completely failing) the audio stream by keeping the buffer short.
             # this is reported to be an issue especially with Chromecast players.
             # see for example: https://github.com/music-assistant/support/issues/3717
-            # allow buffer ahead of 8 seconds and read slightly faster than realtime
-            extra_input_args=["-readrate", "1.01", "-readrate_initial_burst", "8"],
+            # allow buffer ahead of 6 seconds and read rest in realtime
+            extra_input_args=["-readrate", "1.0", "-readrate_initial_burst", "6"],
             chunk_size=icy_meta_interval if enable_icy else get_chunksize(output_format),
         ):
             try:
index 5a539f8cb0826a971ed405d850193977cb826dcb..b0611266b9397071af91b467fb20fb5fe00b7b56 100644 (file)
@@ -63,6 +63,7 @@ SUPPORTED_FEATURES = {
     PlayerFeature.SELECT_SOURCE,
     PlayerFeature.SET_MEMBERS,
     PlayerFeature.GAPLESS_PLAYBACK,
+    PlayerFeature.GAPLESS_DIFFERENT_SAMPLERATE,
 }