Description
Hello, I started developping on the Pico -- which is a breeze thanks to this core :) I am particularly interested in audio application at the moment, connecting the Pico with an I2S DAC.
Upon debugging why my calls to I2S.write()
were blocking despite checking with I2S.availableForWrite()
beforehand, I found out that I needed to check for I2S.availableForWrite() > 16
before writing a sample otherwise the call would block. This is linked to AudioRingBuffer.write()
implementation, 16 being the default size for bufferWords
.
Now I am not familiar enough with PIO FIFO or DMA to know if a whole buffer needs to be "locked" when it is accessed to, or if AudioRingBuffer.write()
need to be patched. In the former case, maybe you could document (e.g. in the i2s.rst file) that one needs to check against bufferWords size to ensure that the call to write()
will not block? And/or create a dedicated method to know either if the call will block, or the number of samples availbles before blocking? E.g. differenciate I2S.available()
from I2S.avaiableForWrite()
, which are the same at the moment? Note that the same confusion could arrise with AudioRingBuffer.available()
if someone wants to use it directly.