From 0b00787b4dae66c865f81f4e543297b6cb1c1125 Mon Sep 17 00:00:00 2001 From: jepler Date: Wed, 28 Aug 2019 16:43:55 -0500 Subject: [PATCH] samd: AudioOut: ensure stopped before deinit .. otherwise, a sequence like >>> a = audioio.AudioOut(board.A0) >>> a.play(sample, loop=True) >>> a.deinit() would potentially leave related DMA channel(s) active. --- ports/atmel-samd/common-hal/audioio/AudioOut.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 90f1aa41f6..bb7e76414f 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -312,6 +312,10 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) { return; } + if (common_hal_audioio_audioout_get_playing(self)) { + common_hal_audioio_audioout_stop(self); + } + // Ramp the DAC down. ramp_value(self->quiescent_value, 0);