Skip to content

Commit 6253f11

Browse files
committed
samd: audio_dma_stop: Clear out audio_dma_state[]
As identified in #1908, when both AudioOut and PDMIn are used, hard locks can occur. Because audio_dma_stop didn't clear audio_dma_state[], a future call to audio_dma_load_next_block could occur using a DMA object which belongs to PDMIn. I believe that this Closes: #1908 though perhaps it is still not the full story. Testing performed: Loaded a sketch similar to the one on #1908 that tends to reproduce the bug within ~30s. Ran for >300s without hard lock. HOWEVER, while my cpx is no longer hard locking, it occasionally (<1 / 200s) announces Code done running. Waiting for reload. (and does so), even though my main loop is surrounded by a 'while True:' condition, so there are still gremlins nearby.
1 parent 47a0b7c commit 6253f11

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ports/atmel-samd/audio_dma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ void audio_dma_stop(audio_dma_t* dma) {
261261
dma_disable_channel(dma->dma_channel);
262262
disable_event_channel(dma->event_channel);
263263
MP_STATE_PORT(playing_audio)[dma->dma_channel] = NULL;
264+
audio_dma_state[dma->dma_channel] = NULL;
264265

265266
dma->dma_channel = AUDIO_DMA_CHANNEL_COUNT;
266267
}

0 commit comments

Comments
 (0)