From: Marcel van der Veldt Date: Sun, 7 Aug 2022 22:04:47 +0000 (+0200) Subject: Fix: Qobuz stream disconnects abruptly (#448) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=d9b052e9be84c8fbaf630ba83a2ce7eaf552c3e5;p=music-assistant-server.git Fix: Qobuz stream disconnects abruptly (#448) Fix: Qobuz stream disconnect abrubt Extend buffer size Shorten expiry Log the amount of time the we were buffering the stream --- diff --git a/music_assistant/controllers/streams.py b/music_assistant/controllers/streams.py index 655fadb1..98d73286 100644 --- a/music_assistant/controllers/streams.py +++ b/music_assistant/controllers/streams.py @@ -119,7 +119,7 @@ class StreamsController: http_site = web.TCPSite(runner, host=None, port=self._port) await http_site.start() - async def on_shutdown_event(*event: MassEvent): + async def on_shutdown_event(event: MassEvent): """Handle shutdown event.""" await http_site.stop() await runner.cleanup() @@ -668,6 +668,7 @@ class QueueStream: bytes_written = 0 chunk_num = 0 # handle incoming audio chunks + track_time_start = time() async for chunk in get_media_stream( self.mass, streamdetails, @@ -739,20 +740,24 @@ class QueueStream: self.total_seconds_streamed - self.queue.player.elapsed_time or 0 ) seconds_in_buffer = len(buffer) / self.sample_size_per_second + process_time = round(time() - track_time_start, 2) # log warning if received seconds are a lot less than expected if (stream_duration - chunk_num) > 20: self.logger.warning( - "Unexpected number of chunks received for track %s: %s/%s", + "Unexpected number of chunks received for track %s: %s/%s - process_time: %s", queue_track.uri, chunk_num, stream_duration, + process_time, ) self.logger.debug( - "end of track reached - chunk_num: %s - crossfade_buffer: %s - stream_duration: %s - player_buffer: %s", + "end of track reached - chunk_num: %s - crossfade_buffer: %s - " + "stream_duration: %s - player_buffer: %s - process_time: %s", chunk_num, seconds_in_buffer, stream_duration, player_buffered, + process_time, ) if buffer: diff --git a/music_assistant/helpers/process.py b/music_assistant/helpers/process.py index 997aafaa..c0ccf54e 100644 --- a/music_assistant/helpers/process.py +++ b/music_assistant/helpers/process.py @@ -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=32 * 1024 * 1024, + limit=64 * 1024 * 1024, 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=32 * 1024 * 102, + limit=64 * 1024 * 102, close_fds=True, ) return self diff --git a/music_assistant/helpers/resources/silence.mp3 b/music_assistant/helpers/resources/silence.mp3 index 24f4d721..38febc1b 100644 Binary files a/music_assistant/helpers/resources/silence.mp3 and b/music_assistant/helpers/resources/silence.mp3 differ diff --git a/music_assistant/music_providers/qobuz/qobuz.py b/music_assistant/music_providers/qobuz/qobuz.py index 55a22443..099a748b 100644 --- a/music_assistant/music_providers/qobuz/qobuz.py +++ b/music_assistant/music_providers/qobuz/qobuz.py @@ -361,7 +361,7 @@ class QobuzProvider(MusicProvider): sample_rate=int(streamdata["sampling_rate"] * 1000), bit_depth=streamdata["bit_depth"], data=streamdata, # we need these details for reporting playback - expires=time.time() + 1800, # not sure about the real allowed value + expires=time.time() + 600, # not sure about the real allowed value direct=streamdata["url"], callback=self._report_playback_stopped, )