From a67cd1dec69242f144e6ce8646de3091921b65e8 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 7 Feb 2024 10:25:09 +1100 Subject: [PATCH] Ensure the resampler is allocated in internal ram It's quite small! --- lib/speexdsp/libspeexdsp/config.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/speexdsp/libspeexdsp/config.h b/lib/speexdsp/libspeexdsp/config.h index 060002b4..19095a04 100644 --- a/lib/speexdsp/libspeexdsp/config.h +++ b/lib/speexdsp/libspeexdsp/config.h @@ -4,6 +4,8 @@ #pragma once +#include "esp_heap_caps.h" + #define FIXED_POINT #define EXPORT #define STDC_HEADERS @@ -11,3 +13,19 @@ #define DISABLE_ENCODER #define DISABLE_FLOAT_API + +#define OVERRIDE_SPEEX_ALLOC +#define OVERRIDE_SPEEX_REALLOC +#define OVERRIDE_SPEEX_FREE + +static inline void* speex_alloc(int size) { + return heap_caps_calloc(size, 1, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); +} + +static inline void* speex_realloc(void* ptr, int size) { + return heap_caps_realloc(ptr, size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); +} + +static inline void speex_free(void* ptr) { + heap_caps_free(ptr); +}