- automatically choose malloc strategy in dependence of enabled/disabled SPIRAM

Signed-off-by: Karl Osterseher <karli_o@gmx.at>
This commit is contained in:
Karl Osterseher
2022-12-13 20:14:00 +01:00
Unverified
parent 677556d2bb
commit 0579684ace
4 changed files with 254 additions and 251 deletions

View File

@@ -850,7 +850,7 @@ int32_t allocate_pcm_chunk_memory(pcm_chunk_message_t **pcmChunk,
return -2;
}
#if CONFIG_USE_PSRAM
#if CONFIG_SPIRAM && CONFIG_SPIRAM_BOOT_INIT
(*pcmChunk)->fragment->payload =
(char *)heap_caps_malloc(bytes, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
if ((*pcmChunk)->fragment->payload == NULL) {
@@ -864,6 +864,21 @@ int32_t allocate_pcm_chunk_memory(pcm_chunk_message_t **pcmChunk,
(*pcmChunk)->fragment->nextFragment = NULL;
(*pcmChunk)->fragment->size = bytes;
ret = 0;
}
#elif CONFIG_SPIRAM
(*pcmChunk)->fragment->payload = (char *)malloc(bytes);
if ((*pcmChunk)->fragment->payload == NULL) {
// size_t largestFreeBlock, freeMem;
// ESP_LOGE (TAG, "Failed to allocate memory for pcm chunk fragment
// payload"); free_pcm_chunk (pcmChunk);
// freeMem = heap_caps_get_free_size (MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
ret = -2;
} else {
(*pcmChunk)->fragment->nextFragment = NULL;
(*pcmChunk)->fragment->size = bytes;
ret = 0;
}
#else