ESP32-C3播放http音频文件消耗RAM空间

lorry333
Posts: 3
Joined: Thu Jun 01, 2023 5:56 am

ESP32-C3播放http音频文件消耗RAM空间

Postby lorry333 » Thu Jun 01, 2023 6:11 am

主芯片:ESP32-C3-WROOM-02模组

问题描述:
在ESP-ADF下的play_http_mp3例程项目基础上修改:从mqtt服务接收要播放的音频地址,传入audio_element_set_uri(),运行并通过esp_get_free_heap_size()发现每获取并播放一次会消耗约200Byte的RAM空间,播放次数多了就会因空间不足播放失败。

请教各位大神,有没有遇到同样情况的?该怎么解决呢?

附:
下发两次播放音频的相关log【关注start free_heap_size值】:

begin paly audio
start free_heap_size = 110788
I (47617) HTTP_MP3_EXAMPLE: [2.0] Create audio pipeline for playback
I (47627) HTTP_MP3_EXAMPLE: [2.1] Create http stream to read data
I (47627) HTTP_MP3_EXAMPLE: [2.2] Create i2s stream to write data to codec chip
W (47637) I2S: APLL not supported on current chip, use I2S_CLK_D2CLK as default clock source
I (47657) HTTP_MP3_EXAMPLE: [2.3] Create mp3 decoder to decode mp3 file
I (47657) HTTP_MP3_EXAMPLE: [2.4] Register all elements to audio pipeline
I (47657) HTTP_MP3_EXAMPLE: [2.5] Link it together http_stream-->mp3_decoder-->i2s_stream-->[codec_chip]
I (47667) HTTP_MP3_EXAMPLE: [2.6] Set up uri (http as http_stream, mp3 as mp3 decoder, and default output is i2s)
I (47687) HTTP_MP3_EXAMPLE: [ 4 ] Set up event listener
I (47687) HTTP_MP3_EXAMPLE: [4.1] Listening event from all elements of pipeline
I (47697) HTTP_MP3_EXAMPLE: [ 5 ] Start audio_pipeline
I (49257) HTTP_MP3_EXAMPLE: [ * ] Receive music info from mp3 decoder, sample_rates=8000, bits=16, ch=2
W (49287) I2S: APLL not supported on current chip, use I2S_CLK_D2CLK as default clock source
W (49337) HTTP_STREAM: No more data,errno:0, total_bytes:20304, rlen = 0
W (52927) HTTP_MP3_EXAMPLE: [ * ] Stop event received
I (52927) HTTP_MP3_EXAMPLE: [ 6 ] Stop audio_pipeline
E (52927) AUDIO_ELEMENT: [http] Element already stopped
E (52927) AUDIO_ELEMENT: [mp3] Element already stopped
E (52937) AUDIO_ELEMENT: [i2s] Element already stopped
W (52937) AUDIO_PIPELINE: There are no listener registered
W (52947) AUDIO_ELEMENT: [http] Element has not create when AUDIO_ELEMENT_TERMINATE
W (52957) AUDIO_ELEMENT: [i2s] Element has not create when AUDIO_ELEMENT_TERMINATE
W (52967) AUDIO_ELEMENT: [mp3] Element has not create when AUDIO_ELEMENT_TERMINATE
over free_heap_size = 94592
W (53017) wifi:<ba-add>idx:0 (ifx:0, 58:c7:ac:81:4c:b1), tid:0, ssn:992, winSize:64
begin paly audio
start free_heap_size = 110548
I (91537) HTTP_MP3_EXAMPLE: [2.0] Create audio pipeline for playback
I (91537) HTTP_MP3_EXAMPLE: [2.1] Create http stream to read data
I (91547) HTTP_MP3_EXAMPLE: [2.2] Create i2s stream to write data to codec chip
W (91557) I2S: APLL not supported on current chip, use I2S_CLK_D2CLK as default clock source
I (91567) HTTP_MP3_EXAMPLE: [2.3] Create mp3 decoder to decode mp3 file
I (91567) HTTP_MP3_EXAMPLE: [2.4] Register all elements to audio pipeline
I (91577) HTTP_MP3_EXAMPLE: [2.5] Link it together http_stream-->mp3_decoder-->i2s_stream-->[codec_chip]
I (91587) HTTP_MP3_EXAMPLE: [2.6] Set up uri (http as http_stream, mp3 as mp3 decoder, and default output is i2s)
I (91597) HTTP_MP3_EXAMPLE: [ 4 ] Set up event listener
I (91607) HTTP_MP3_EXAMPLE: [4.1] Listening event from all elements of pipeline
I (91617) HTTP_MP3_EXAMPLE: [ 5 ] Start audio_pipeline
I (91717) HTTP_MP3_EXAMPLE: [ * ] Receive music info from mp3 decoder, sample_rates=8000, bits=16, ch=2
W (91747) I2S: APLL not supported on current chip, use I2S_CLK_D2CLK as default clock source
W (91807) HTTP_STREAM: No more data,errno:0, total_bytes:20304, rlen = 0
W (95387) HTTP_MP3_EXAMPLE: [ * ] Stop event received
I (95387) HTTP_MP3_EXAMPLE: [ 6 ] Stop audio_pipeline
E (95387) AUDIO_ELEMENT: [http] Element already stopped
E (95387) AUDIO_ELEMENT: [mp3] Element already stopped
E (95397) AUDIO_ELEMENT: [i2s] Element already stopped
W (95407) AUDIO_PIPELINE: There are no listener registered
W (95407) AUDIO_ELEMENT: [http] Element has not create when AUDIO_ELEMENT_TERMINATE
W (95417) AUDIO_ELEMENT: [i2s] Element has not create when AUDIO_ELEMENT_TERMINATE
W (95427) AUDIO_ELEMENT: [mp3] Element has not create when AUDIO_ELEMENT_TERMINATE
over free_heap_size = 94116

lorry333
Posts: 3
Joined: Thu Jun 01, 2023 5:56 am

Re: ESP32-C3播放http音频文件消耗RAM空间

Postby lorry333 » Wed Jun 07, 2023 7:58 am

现在发现播放完一段音频后要间隔一段时间,约1min,再播放时查看RAM空间基本会保持不变。
难道不支持连续播放音频吗?

Who is online

Users browsing this forum: No registered users and 32 guests