完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
主芯片: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: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 |
|
相关推荐
1个回答
|
|
针对您的问题,我为您提供以下几个解决方案:
1. **优化音频处理流程**:检查您的代码,看看是否有不必要的内存分配或未释放的内存。确保在使用完资源后,及时释放它们。 2. **使用内存池**:ESP32-C3的内存有限,可以考虑使用内存池来管理内存分配。这样可以减少内存碎片,提高内存使用效率。 3. **减少音频文件大小**:如果可能的话,尝试减小音频文件的大小。例如,降低音频文件的比特率或使用更高效的编码格式。 4. **限制同时播放的音频数量**:如果可能的话,限制同时播放的音频数量,以减少内存消耗。 5. **使用外部存储**:如果音频文件较大,可以考虑使用外部存储(如SD卡)来存储音频文件,以减少RAM的使用。 6. **升级硬件**:如果以上方法都无法解决问题,您可以考虑升级到具有更大RAM的ESP32型号,如ESP32-S3。 7. **优化ESP-ADF**:检查ESP-ADF的配置和设置,看看是否有优化空间。例如,您可以调整音频处理模块的参数,以减少内存消耗。 8. **使用动态内存分配**:在某些情况下,使用动态内存分配可能会比静态分配更有效。但是,请注意,这可能会增加代码的复杂性。 9. **调试和分析**:使用ESP-IDF的调试工具,如gdb,来分析内存使用情况。这可以帮助您找到内存泄漏或不必要的内存分配。 |
|
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
437浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-21 20:11 , Processed in 0.822674 second(s), Total 83, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号