Handle buffer overrun in AudioOutputI2S

Status
Not open for further replies.

Archie3d

New member
Hi, I am using Teensy 4.0 board for audio synthesis with i2s output.
Currently the AudioOutputI2S::isr() triggers audio stream update every other half-buffer
When audio stream takes long to process the the isr() does not detect the buffer overrun, which causes audio data to be out of sync with DMA double buffering, which in its turn results in irreparable audio distortion.

What would be the right way to detect buffer overrun and handle it graciously? My current solution is to add a pending flag to AudioStream which is set on update_all class and cleared on software_isr() return. AudioOutputI2S::isr() can then check this flag and bail out without swapping half-buffers.
 
Status
Not open for further replies.
Back
Top