From bb91724b941e6366711515a544b09385fbb6fc3d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 16 Oct 2023 16:15:48 +1100 Subject: Codec memory tweaks - Ensure mad and ogg structs are allocated internally - Free old codec before making a new one --- lib/ogg/include/ogg/os_types.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/ogg') diff --git a/lib/ogg/include/ogg/os_types.h b/lib/ogg/include/ogg/os_types.h index e655a1d6..9d2da360 100644 --- a/lib/ogg/include/ogg/os_types.h +++ b/lib/ogg/include/ogg/os_types.h @@ -16,11 +16,16 @@ #ifndef _OS_TYPES_H #define _OS_TYPES_H +#include "esp_heap_caps.h" + +#define OGG_MALLOC_CAPS_1 (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) +#define OGG_MALLOC_CAPS_2 (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT) + /* make it easy on the folks that want to compile the libs with a different malloc than stdlib */ -#define _ogg_malloc malloc -#define _ogg_calloc calloc -#define _ogg_realloc realloc +#define _ogg_malloc(x) heap_caps_malloc_prefer(x, OGG_MALLOC_CAPS_1, OGG_MALLOC_CAPS_2) +#define _ogg_calloc(x, y) heap_caps_calloc_prefer(x, y, OGG_MALLOC_CAPS_1, OGG_MALLOC_CAPS_2) +#define _ogg_realloc(x, y) heap_caps_realloc_prefer(x, y, OGG_MALLOC_CAPS_1, OGG_MALLOC_CAPS_2) #define _ogg_free free #if defined(_WIN32) -- cgit v1.2.3