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/audio/audio_decoder.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/audio/audio_decoder.cpp') diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp index bacd5cde..7751bf37 100644 --- a/src/audio/audio_decoder.cpp +++ b/src/audio/audio_decoder.cpp @@ -26,6 +26,7 @@ #include "freertos/projdefs.h" #include "freertos/queue.h" #include "freertos/ringbuf.h" +#include "i2s_dac.hpp" #include "span.hpp" #include "audio_converter.hpp" @@ -46,7 +47,8 @@ namespace audio { static const char* kTag = "audio_dec"; -static constexpr std::size_t kCodecBufferLength = 240 * 4 * 64; +static constexpr std::size_t kCodecBufferLength = + drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2; Timer::Timer(const codecs::ICodec::OutputFormat& format) : current_seconds_(0), @@ -93,7 +95,7 @@ Decoder::Decoder(std::shared_ptr source, ESP_LOGI(kTag, "allocating codec buffer, %u KiB", kCodecBufferLength / 1024); codec_buffer_ = { reinterpret_cast(heap_caps_calloc( - kCodecBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)), + kCodecBufferLength, sizeof(sample::Sample), MALLOC_CAP_DMA)), kCodecBufferLength}; } -- cgit v1.2.3