Skip to content

Commit 430bcdb

Browse files
committed
port_i2s_play: fill the initial buffer via background callback
There were _possibly_ problems where this routine was being entered by direct call AND by background callback. Schedule the work here, and it will be done almost immediately, without worry about interference. I don't know if this is strictly necessary, but it doesn't hurt. Since the I2S clock is being run all the time, we have to enter the background task to fill the FIFO with zeros constantly anyway.
1 parent 12264cc commit 430bcdb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ports/esp32s2/i2s_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop) {
211211
audiosample_reset_buffer(self->sample, false, 0);
212212

213213
ESP_CALL_RAISE(i2s_set_sample_rates(self->instance, audiosample_sample_rate(sample)));
214-
i2s_fill_buffer(self);
214+
215+
background_callback_add(&self->callback, i2s_callback_fun, self);
215216
}
216217

217218
bool port_i2s_playing(i2s_t *self) {

0 commit comments

Comments
 (0)