Skip to content

Commit

Permalink
codal_port/modaudio: Make audio waiting wait for audio to be silent.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Sep 9, 2024
1 parent d0080bc commit 2dcd909
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/codal_port/modaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2dcd909

Please sign in to comment.