From: marcelveldt Date: Sun, 13 Oct 2019 02:12:41 +0000 (+0200) Subject: Update http_streamer.py X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=066d0c3fd4460042ba76e3d4700dfee49299570f;p=music-assistant-server.git Update http_streamer.py fix singe track --- diff --git a/music_assistant/http_streamer.py b/music_assistant/http_streamer.py index 5d9b819a..f28e24fc 100755 --- a/music_assistant/http_streamer.py +++ b/music_assistant/http_streamer.py @@ -75,12 +75,17 @@ class HTTPStreamer(): try: audio_stream = self.__get_audio_stream(player, queue_item, cancelled) async for is_last_chunk, audio_chunk in audio_stream: - await buffer.put(audio_chunk) + asyncio.run_coroutine_threadsafe( + buffer.put(audio_chunk), + self.mass.event_loop) # wait for the queue to consume the data # this prevents that the entire track is sitting in memory - # while buffer.qsize() > 1 and not cancelled.is_set(): - # await asyncio.sleep(1) - await buffer.put(b'') # EOF + while buffer.qsize() > 2 and not cancelled.is_set(): + await asyncio.sleep(1) + # indicate EOF if no more data + asyncio.run_coroutine_threadsafe( + buffer.put(b''), + self.mass.event_loop) except (asyncio.CancelledError, asyncio.TimeoutError): cancelled.set() LOGGER.info("stream_track interrupted for %s" % queue_item.name)