Skip to content

Commit 760e8c7

Browse files
committed
Changes to correct repeat playing on a channel
1 parent 24e641a commit 760e8c7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ports/raspberrypi/audio_dma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ bool audio_dma_get_paused(audio_dma_t *dma) {
352352
void audio_dma_init(audio_dma_t *dma) {
353353
dma->first_buffer = NULL;
354354
dma->second_buffer = NULL;
355+
dma->channel[0] = NUM_DMA_CHANNELS;
356+
dma->channel[1] = NUM_DMA_CHANNELS;
355357
}
356358

357359
void audio_dma_deinit(audio_dma_t *dma) {

ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self
127127

128128
void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) {
129129

130+
if (self->dma.channel[0] < NUM_DMA_CHANNELS) {
131+
if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) {
132+
common_hal_audiopwmio_pwmaudioout_stop(self);
133+
}
134+
}
135+
130136
// TODO: Share pacing timers based on frequency.
131137
size_t pacing_timer = NUM_DMA_TIMERS;
132138
for (size_t i = 0; i < NUM_DMA_TIMERS; i++) {

0 commit comments

Comments
 (0)