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.
This commit is contained in:
Jeff Epler 2021-01-08 08:49:25 -06:00
parent 12264cca34
commit 430bcdb59d
1 changed files with 2 additions and 1 deletions

View File

@ -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) {