Skip to content

Commit 6d2c48e

Browse files
Fix MA hanging on announcement failure (music-assistant#3293)
Fix MA hanging on announcement failure.
1 parent f6c15e0 commit 6d2c48e

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

music_assistant/controllers/streams/streams_controller.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,14 +1309,22 @@ async def get_announcement_stream(
13091309

13101310
async def fetch_announcement() -> None:
13111311
fmt = announcement_url.rsplit(".")[-1]
1312-
async for chunk in get_ffmpeg_stream(
1313-
audio_input=announcement_url,
1314-
input_format=AudioFormat(content_type=ContentType.try_parse(fmt)),
1315-
output_format=pcm_format,
1316-
chunk_size=get_chunksize(pcm_format, 1),
1317-
):
1318-
await announcement_data.put(chunk)
1319-
await announcement_data.put(None) # signal end of stream
1312+
try:
1313+
async for chunk in get_ffmpeg_stream(
1314+
audio_input=announcement_url,
1315+
input_format=AudioFormat(content_type=ContentType.try_parse(fmt)),
1316+
output_format=pcm_format,
1317+
chunk_size=get_chunksize(pcm_format, 1),
1318+
):
1319+
await announcement_data.put(chunk)
1320+
except AudioError as err:
1321+
self.logger.warning(
1322+
"Failed to fetch announcement audio from %s: %s",
1323+
announcement_url,
1324+
err,
1325+
)
1326+
finally:
1327+
await announcement_data.put(None) # always signal end of stream
13201328

13211329
self.mass.create_task(fetch_announcement())
13221330

0 commit comments

Comments
 (0)