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.
This commit is contained in:
jepler 2019-08-28 16:43:55 -05:00
parent 42956a62a3
commit 0b00787b4d
1 changed files with 4 additions and 0 deletions

View File

@ -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);