put opus' allocations into internal ram

it's a pretty chonky codec, but this seems like the best way to tame its
performance.
custom
jacqueline 1 year ago
parent 18345a1c2c
commit c1b03c151e
  1. 2
      lib/opusfile/CMakeLists.txt
  2. 17
      lib/opusfile/include/custom_support.h
  3. 2
      src/audio/audio_fsm.cpp

@ -17,4 +17,6 @@ set(OPUS_BUILD_TESTING OFF)
set(OPUS_BUILD_SHARED_LIBS OFF) set(OPUS_BUILD_SHARED_LIBS OFF)
add_subdirectory($ENV{PROJ_PATH}/lib/opus ${CMAKE_CURRENT_BINARY_DIR}/opus) add_subdirectory($ENV{PROJ_PATH}/lib/opus ${CMAKE_CURRENT_BINARY_DIR}/opus)
target_compile_definitions(opus PRIVATE CUSTOM_SUPPORT)
target_include_directories(opus PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${COMPONENT_LIB} PUBLIC opus) target_link_libraries(${COMPONENT_LIB} PUBLIC opus)

@ -0,0 +1,17 @@
#pragma once
#include "esp_heap_caps.h"
#include "opus_defines.h"
#define OVERRIDE_OPUS_ALLOC
#define OVERRIDE_OPUS_FREE
static OPUS_INLINE void *opus_alloc (size_t size)
{
return heap_caps_malloc(size, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
}
static OPUS_INLINE void opus_free (void *ptr)
{
heap_caps_free(ptr);
}

@ -162,7 +162,7 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) {
sServices = ev.services; sServices = ev.services;
constexpr size_t kDrainBufferSize = constexpr size_t kDrainBufferSize =
drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2 * 8; drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 8;
ESP_LOGI(kTag, "allocating drain buffer, size %u KiB", ESP_LOGI(kTag, "allocating drain buffer, size %u KiB",
kDrainBufferSize / 1024); kDrainBufferSize / 1024);
StreamBufferHandle_t stream = xStreamBufferCreateWithCaps( StreamBufferHandle_t stream = xStreamBufferCreateWithCaps(

Loading…
Cancel
Save