Skip to content

Commit 3b56528

Browse files
committed
codal_port/modaudio: Lock scheduler when starting audio pipeline.
Otherwise audio_data_fetcher may be called while it's running, if the CODAL just finished playing another sound and schedules audio_data_fetcher. See issue #47. Signed-off-by: Damien George <[email protected]>
1 parent d723177 commit 3b56528

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/codal_port/modaudio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,11 @@ void microbit_audio_play_source(mp_obj_t src, mp_obj_t pin_select, bool wait, ui
189189
}
190190

191191
// Get the iterator and start the audio running.
192+
// The scheduler must be locked because audio_data_fetcher() can also be called from the scheduler.
192193
audio_source_iter = mp_getiter(src, NULL);
194+
mp_sched_lock();
193195
audio_data_fetcher();
196+
mp_sched_unlock();
194197

195198
if (wait) {
196199
// Wait the audio to exhaust the iterator.

0 commit comments

Comments
 (0)