From 5d99f58d60c877a29ea7cdf6645299f3c8347e26 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 25 Aug 2024 20:15:40 +0200 Subject: [PATCH] Enforce default HTTP profile for slimproto players --- music_assistant/common/models/config_entries.py | 7 +++++++ music_assistant/server/controllers/streams.py | 8 ++++---- music_assistant/server/providers/slimproto/__init__.py | 2 ++ music_assistant/server/providers/ugp/__init__.py | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/music_assistant/common/models/config_entries.py b/music_assistant/common/models/config_entries.py index 46f0a4a5a..fa42c0e2b 100644 --- a/music_assistant/common/models/config_entries.py +++ b/music_assistant/common/models/config_entries.py @@ -610,6 +610,13 @@ class CoreConfig(Config): "'chunked transfer encoding', works just fine. \n\n", ) +CONF_ENTRY_HTTP_PROFILE_DEFAULT_2 = ConfigEntry.from_dict( + {**CONF_ENTRY_HTTP_PROFILE.to_dict(), "default_value": "no_content_length"} +) +CONF_ENTRY_HTTP_PROFILE_FORCED_2 = ConfigEntry.from_dict( + {**CONF_ENTRY_HTTP_PROFILE.to_dict(), "default_value": "no_content_length", "hidden": True} +) + def create_sample_rates_config_entry( max_sample_rate: int, diff --git a/music_assistant/server/controllers/streams.py b/music_assistant/server/controllers/streams.py index 70416197e..5322bc2cd 100644 --- a/music_assistant/server/controllers/streams.py +++ b/music_assistant/server/controllers/streams.py @@ -266,8 +266,8 @@ async def serve_queue_item_stream(self, request: web.Request) -> web.Response: default_sample_rate=queue_item.streamdetails.audio_format.sample_rate, default_bit_depth=queue_item.streamdetails.audio_format.bit_depth, ) - http_profile: str = self.mass.config.get_raw_player_config_value( - queue_id, CONF_HTTP_PROFILE, "chunked" + http_profile: str = await self.mass.config.get_player_config_value( + queue_id, CONF_HTTP_PROFILE ) # prepare request, add some DLNA/UPNP compatible headers headers = { @@ -356,8 +356,8 @@ async def serve_queue_flow_stream(self, request: web.Request) -> web.Response: icy_meta_interval = 16384 # prepare request, add some DLNA/UPNP compatible headers - http_profile: str = self.mass.config.get_raw_player_config_value( - queue_id, CONF_HTTP_PROFILE, "chunked" + http_profile: str = await self.mass.config.get_player_config_value( + queue_id, CONF_HTTP_PROFILE ) # prepare request, add some DLNA/UPNP compatible headers headers = { diff --git a/music_assistant/server/providers/slimproto/__init__.py b/music_assistant/server/providers/slimproto/__init__.py index 992b9033c..cf333a4d5 100644 --- a/music_assistant/server/providers/slimproto/__init__.py +++ b/music_assistant/server/providers/slimproto/__init__.py @@ -28,6 +28,7 @@ CONF_ENTRY_EQ_BASS, CONF_ENTRY_EQ_MID, CONF_ENTRY_EQ_TREBLE, + CONF_ENTRY_HTTP_PROFILE_FORCED_2, CONF_ENTRY_OUTPUT_CHANNELS, CONF_ENTRY_SYNC_ADJUST, ConfigEntry, @@ -317,6 +318,7 @@ async def get_player_config_entries(self, player_id: str) -> tuple[ConfigEntry]: CONF_ENTRY_SYNC_ADJUST, CONF_ENTRY_DISPLAY, CONF_ENTRY_VISUALIZATION, + CONF_ENTRY_HTTP_PROFILE_FORCED_2, create_sample_rates_config_entry(int(slimclient.max_sample_rate), 24, 48000, 24), ) ) diff --git a/music_assistant/server/providers/ugp/__init__.py b/music_assistant/server/providers/ugp/__init__.py index e4ca5febc..b32ee34f9 100644 --- a/music_assistant/server/providers/ugp/__init__.py +++ b/music_assistant/server/providers/ugp/__init__.py @@ -371,8 +371,8 @@ async def _serve_ugp_stream(self, request: web.Request) -> web.Response: bit_depth=stream.audio_format.bit_depth, ) - http_profile: str = self.mass.config.get_raw_player_config_value( - child_player_id, CONF_HTTP_PROFILE, "chunked" + http_profile: str = await self.mass.config.get_player_config_value( + child_player_id, CONF_HTTP_PROFILE ) headers = { **DEFAULT_STREAM_HEADERS,