From 8608f9367fc29e498f42f5249aa248dd2044d567 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 26 Sep 2023 17:23:34 +1000 Subject: Tune buffer sizes and locations for I2S --- src/drivers/include/i2s_dac.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/drivers/include') diff --git a/src/drivers/include/i2s_dac.hpp b/src/drivers/include/i2s_dac.hpp index 6bc5b6a4..b61f7989 100644 --- a/src/drivers/include/i2s_dac.hpp +++ b/src/drivers/include/i2s_dac.hpp @@ -18,7 +18,6 @@ #include "esp_err.h" #include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" -#include "freertos/ringbuf.h" #include "freertos/stream_buffer.h" #include "result.hpp" #include "span.hpp" @@ -28,6 +27,13 @@ namespace drivers { +// DMA max buffer size for I2S is 4092. We normalise to 2-channel, 16 bit +// audio, which gives us a max of 4092 / 2 / 2 (16 bits) frames. This in turn +// means that at 48kHz, we have about 21ms of budget to fill each buffer. +// We base this off of the maximum DMA size in order to minimise the amount of +// work the CPU has to do to service the DMA callbacks. +constexpr size_t kI2SBufferLengthFrames = 1023; + /** * Interface for a DAC that receives PCM samples over I2S. */ -- cgit v1.2.3