Skip to content

Commit 71590f2

Browse files
authored
Free audio buffer on audio_i2s_set_enabled(false) (#58)
1 parent 4a2bd29 commit 71590f2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/rp2_common/pico_audio_i2s/audio_i2s.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ void audio_i2s_set_enabled(bool enabled) {
367367

368368
if (enabled) {
369369
audio_start_dma_transfer();
370+
} else {
371+
// if there was a buffer in flight, it will not be freed by DMA IRQ, let's do it manually
372+
if (shared_state.playing_buffer) {
373+
give_audio_buffer(audio_i2s_consumer, shared_state.playing_buffer);
374+
shared_state.playing_buffer = NULL;
375+
}
370376
}
371377

372378
pio_sm_set_enabled(audio_pio, shared_state.pio_sm, enabled);

0 commit comments

Comments
 (0)