esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

Memory alloc failed with algorithm-stream (AUD-3700)

Open quickshat opened this issue 3 years ago • 5 comments

Hi,

i've been trying to run the pipeline_a2dp_sink_with_hfp example. The basic example is working on the MSC2.2 LyraT board.

EDIT: IDF 4.4 - ADF Current Release

Additional specifications require an algo-stream with AEC on the encoder pipeline, which i added according to the demo applications from this repo.

I've also tested this setup with external PSRAM enabled / disabled. In both cases there's plenty of heap left to allocate. Right before the call of the pipeline_run, there's something around 10kB heap available (already without PSRAM).

The audio-element tasks are created and as soon as the init-step for the algo-element begins to execute, some random allocation fail aborts the application.

The pipeline looks like this:

I2S-Reader (44100-2) --> Resample Filter (16000-1) --> AlgoStream --> Raw

Algo-stream uses default type-1 config with 16000Hz and single channel.

The code executes without any issues, as long the algo-stream element isn't linked - even init and register don't cause a core dump.

Last debug print always is: AUDIO_ELEMENT: [algo] AEL_MSG_CMD_RESUME,state:1

Did you have some ideas what might cause this problem ?

quickshat avatar Mar 14 '22 18:03 quickshat

Hi @quickshat

I recommend you to use module with psram( ESP32-WROVER ), I see that you only have 10k of ram left, it should not be enough for AlgoStream + bt application.

HengYongChao avatar Mar 18 '22 08:03 HengYongChao

Hi @HengYongChao ,

i enabled PSRAM but it makes no difference. Are any specific options necessary to make the PSRAM work correctly ?

quickshat avatar Mar 18 '22 11:03 quickshat

In the meantime the Algo-Stream component does not cause crashes anymore but makes the microphone pipeline unusable. The Algo stream runs on a different core than the bluetooth hfp client and as soon as a voice call is active, the following output gets thrown: BT_BTM: SCO xmit Q overflow, pkt dropped

I've tried to modify any performance values of the algo task, but no change at all. When increasing the resamplers out_buffer size, i am able to delay the issue but no prevent. Also no sound is transmitted. Seems like it won't pass the algo stream.

quickshat avatar Mar 21 '22 15:03 quickshat

Hi @quickshat

  1. Are you working on using algorithm stream to process HFP data for Bluetooth?

BT_BTM: SCO xmit Q overflow, pkt dropped

  1. This print is a reminder that the Bluetooth data packet is lost. Could it be that the system load is not balanced so that the Bluetooth cannot receive the packet? You may need to check your system's cpu load

  2. Algorithm flow has different processing algorithms, NS, AGC, AEC, please note that their usage conditions are different. You can refer to the routine algorithm. Pipeline like : ** hfp stream ---> filter ---> algorithm ---> i2s_stream ---> [speaker] **

  3. And your current problem is no longer a memory malloc problem, If so please open a new issue describing your problem.

HengYongChao avatar Mar 25 '22 08:03 HengYongChao

@quickshat So appreciate any progress from your issue.

jason-mao avatar Aug 08 '22 13:08 jason-mao

This topic has become inactive so I'm going to close the issue. Please reopen this if you have any questions or need any further assistance.

jason-mao avatar Sep 05 '23 07:09 jason-mao