Skip to content

Commit a99eba3

Browse files
authored
Merge pull request #4809 from DavePutz/issue_4266
Fix for Issue #4266 - second PWMAudioOut interferes with the first one
2 parents 934a14b + 8761e4b commit a99eba3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ports/raspberrypi/audio_dma.c

Lines changed: 2 additions & 1 deletion
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) {
@@ -368,7 +370,6 @@ bool audio_dma_get_playing(audio_dma_t *dma) {
368370
}
369371
if (!dma_channel_is_busy(dma->channel[0]) &&
370372
!dma_channel_is_busy(dma->channel[1])) {
371-
audio_dma_stop(dma);
372373
return false;
373374
}
374375

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s
102102
}
103103

104104
audio_dma_init(&self->dma);
105+
self->pacing_timer = NUM_DMA_TIMERS;
105106

106107
self->quiescent_value = quiescent_value;
107108
}
@@ -126,6 +127,7 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self
126127
}
127128

128129
void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) {
130+
129131
if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) {
130132
common_hal_audiopwmio_pwmaudioout_stop(self);
131133
}
@@ -135,8 +137,8 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self,
135137
for (size_t i = 0; i < NUM_DMA_TIMERS; i++) {
136138
if (dma_hw->timer[i] == 0) {
137139
pacing_timer = i;
140+
break;
138141
}
139-
break;
140142
}
141143
if (pacing_timer == NUM_DMA_TIMERS) {
142144
mp_raise_RuntimeError(translate("No DMA pacing timer found"));

0 commit comments

Comments
 (0)