From 4c957c4caa7115e99bb84454b3b660f0019e0d30 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 9 Sep 2024 13:26:53 +1000 Subject: [PATCH] codal_port/modaudio: Make audio waiting wait for audio to be silent. Signed-off-by: Damien George --- src/codal_port/modaudio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/codal_port/modaudio.c b/src/codal_port/modaudio.c index e22cf37..99af69f 100644 --- a/src/codal_port/modaudio.c +++ b/src/codal_port/modaudio.c @@ -301,7 +301,7 @@ void microbit_audio_play_source(mp_obj_t src, mp_obj_t pin_select, bool wait, ui if (wait) { // Wait the audio to exhaust the iterator. - while (audio_is_running()) { + while (microbit_audio_is_playing()) { mp_handle_pending(true); microbit_hal_idle(); } @@ -333,7 +333,9 @@ static mp_obj_t play(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar MP_DEFINE_CONST_FUN_OBJ_KW(microbit_audio_play_obj, 0, play); bool microbit_audio_is_playing(void) { - return audio_is_running() || microbit_hal_audio_is_expression_active(); + return audio_is_running() + || microbit_hal_audio_is_playing() + || microbit_hal_audio_is_expression_active(); } mp_obj_t is_playing(void) {