From 6c520d91df899a403ed3baeca02f59864fcaf150 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 27 May 2024 16:21:26 +1000 Subject: [PATCH] codal_port/modaudio: Stop streaming audio when data is exhausted. Signed-off-by: Damien George --- src/codal_port/modaudio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/codal_port/modaudio.c b/src/codal_port/modaudio.c index 33b4516..6b099e4 100644 --- a/src/codal_port/modaudio.c +++ b/src/codal_port/modaudio.c @@ -124,7 +124,13 @@ static void audio_data_fetcher(mp_sched_node_t *node) { if (audio_source_frame == NULL) { // Audio source is exhausted. - // Fill any remaining audio_output_buffer bytes with silence. + + if (audio_output_buffer_offset == 0) { + // No output data left, finish output streaming. + return; + } + + // Fill remaining audio_output_buffer bytes with silence, for the final output frame. memset(dest, 128, AUDIO_OUTPUT_BUFFER_SIZE - audio_output_buffer_offset); audio_output_buffer_offset = AUDIO_OUTPUT_BUFFER_SIZE; } else {