summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2021-01-08 08:49:25 -0600
committerJeff Epler <jepler@gmail.com>2021-01-08 08:49:25 -0600
commit430bcdb59d47fc89c7788aeb300027bcf4e00bf2 (patch)
treeb4845acb9cf255816bac88960ff02efba8401954 /ports
parent12264cca34179c2e3bafad49145c9af3f827fa0f (diff)
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.
Diffstat (limited to 'ports')
-rw-r--r--ports/esp32s2/i2s_common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ports/esp32s2/i2s_common.c b/ports/esp32s2/i2s_common.c
index a948ee0f5..552fe7424 100644
--- a/ports/esp32s2/i2s_common.c
+++ b/ports/esp32s2/i2s_common.c
@@ -211,7 +211,8 @@ void port_i2s_play(i2s_t *self, mp_obj_t sample, bool loop) {
audiosample_reset_buffer(self->sample, false, 0);
ESP_CALL_RAISE(i2s_set_sample_rates(self->instance, audiosample_sample_rate(sample)));
- i2s_fill_buffer(self);
+
+ background_callback_add(&self->callback, i2s_callback_fun, self);
}
bool port_i2s_playing(i2s_t *self) {