From c5917658e6a0fcc77971237c80bb4e47f3e8bf9e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 14 Feb 2024 17:48:13 +1100 Subject: [PATCH] Cram one of the flac samples buffers into internal ram Can't quite fit the second... yet. Just one is a pretty reasonable speedup, though! Probably bc we're not hammering the spiram cache so hard. --- src/codecs/miniflac.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/codecs/miniflac.cpp b/src/codecs/miniflac.cpp index ace73466..74eafb3b 100644 --- a/src/codecs/miniflac.cpp +++ b/src/codecs/miniflac.cpp @@ -30,9 +30,16 @@ MiniFlacDecoder::MiniFlacDecoder() current_sample_() { miniflac_init(flac_.get(), MINIFLAC_CONTAINER_UNKNOWN); for (int i = 0; i < samples_by_channel_.size(); i++) { - // Full decoded frames too big to fit in internal ram :( + uint32_t caps; + if (i == 0) { + caps = MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL; + } else { + // FIXME: We can *almost* fit two channels into internal ram, but we're a + // few KiB shy of being able to do it safely. + caps = MALLOC_CAP_SPIRAM; + } samples_by_channel_[i] = reinterpret_cast( - heap_caps_malloc(kMaxFrameSize * sizeof(int32_t), MALLOC_CAP_SPIRAM)); + heap_caps_malloc(kMaxFrameSize * sizeof(int32_t), caps)); } }