audio_player在MicroPython下无法运行

sawyer
Posts: 1
Joined: Sat Oct 02, 2021 2:12 pm

audio_player在MicroPython下无法运行

Postby sawyer » Sat Oct 02, 2021 2:21 pm

我们参考 IDF/ADF/MicroPython_ADF 的说明将它们进行了整合,Python 的 REPL 工作基本正常,ADF下的play_mp3_control 在脱离MicroPython的环境下单独编译、运行也正常。
但在MicroPython中,通过MicroPython_ADF下的 audio_player 模块播放mp3失败。
IDF/ADF/MicroPython均为主线最新代码。

测试的命令为:
#sdcard
import machine, os
sd = machine.SDCard(slot=1)
os.mount(sd, "/sdcard")
# Add libs in sdcard to sys.path
import sys
sys.path.append('/sdcard')
#Audio
from audio import player, recorder

def cb(state):
print(state)

p = player(cb)
p.get_state()
p.play("file://sdcard/music-16b-2c-8000hz.mp3")

在执行到最后一步的时候出错,Log为:

I (29784) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3
E (29784) gpio: gpio_install_isr_service(460): GPIO isr service already installed
I (29804) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (29804) ES8388_DRIVER: init,out:02, in:00
I (29814) AUDIO_HAL: Codec mode is 3, Ctrl:1
I (29814) ESP_AUDIO_TASK: media_ctrl_task running...,0x3fb03548

----------------------------- ESP Audio Platform -----------------------------
| |
| ESP_AUDIO-v1.7.0-9-g84df87e-037bef3-09be8fe |
| Compile date: Jul 20 2021-13:51:36 |
------------------------------------------------------------------------------
I (29854) ESP_AUDIO_CTRL: Func:media_ctrl_create, Line:350, MEM Total:1235103 Bytes, Inter:270899 Bytes, Dram:231251 Bytes

I (29864) MP3_DECODER: MP3 init
I (29874) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (29874) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (29924) I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (29924) LYRAT_V4_3: I2S0, MCLK output by GPIO0
>>> p.get_state()
{'media_src': 0, 'err_msg': 0, 'status': 0}
I (31104) ESP_AUDIO_CTRL: Enter play procedure, src:0
I (31104) ESP_AUDIO_CTRL: Play procedure, URL is ok, src:0
I (31104) ESP_AUDIO_CTRL: Request_CMD_Queue CMD:0, Available:5, que:0x3ffbd824
I (31114) ESP_AUDIO_TASK: It's a decoder
I (31114) ESP_AUDIO_TASK: 1.CUR IN:[IN_file],CODEC:[DEC_mp3],RESAMPLE:[48000],OUT:[OUT_iis],rate:0,ch:0,pos:0
I (31124) ESP_AUDIO_TASK: 2.Handles,IN:0x3fb03768,CODEC:0x3fb03eb8,FILTER:0x3fb044b0,OUT:0x3fb04324
I (31134) ESP_AUDIO_TASK: 2.2 Update all pipeline
I (31144) ESP_AUDIO_TASK: 2.3 Linked new pipeline
I (31144) AUDIO_PIPELINE: link el->rb, el:0x3fb03768, tag:IN_file, rb:0x3fb04828
I (31154) AUDIO_PIPELINE: link el->rb, el:0x3fb03eb8, tag:DEC_mp3, rb:0x3fb07068
I (31164) AUDIO_PIPELINE: link el->rb, el:0x3fb044b0, tag:Audio_forge, rb:0x3fb090a8
I (31174) ESP_AUDIO_TASK: 3. Previous starting...
I (31174) AUDIO_ELEMENT: [IN_file-0x3fb03768] Element task created
I (31184) AUDIO_ELEMENT: [IN_file] AEL_MSG_CMD_RESUME,state:1
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x400dfaf0 PS : 0x00060230 A0 : 0x800e00e4 A1 : 0x3ffcf810
0x400dfaf0: gc_alloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/gc.c:460

A2 : 0x0000001f A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x000000fe A7 : 0x00000001 A8 : 0x800dfaf0 A9 : 0x3ffcf7f0
A10 : 0x00000000 A11 : 0x00060c23 A12 : 0x00060c20 A13 : 0x00060c23
A14 : 0x000000fe A15 : 0x00000001 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4008cea5 LEND : 0x4008ceb5 LCOUNT : 0xfffffff8
0x4008cea5: strlen at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:84

0x4008ceb5: strlen at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:96


Backtrace:0x400dfaed:0x3ffcf810 0x400e00e1:0x3ffcf830 0x400e545d:0x3ffcf850 0x400e58cf:0x3ffcf870 0x4012fa8e:0x3ffcf890 0x40171146:0x3ffcf950 0x40171693:0x3ffcf980 0x401717a6:0x3ffcf9a0 0x4017265d:0x3ffcf9d0 0x401718ac:0x3ffcfa10
0x400dfaed: gc_alloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/gc.c:460

0x400e00e1: m_malloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/malloc.c:86

0x400e545d: mp_obj_new_str_copy at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2029

0x400e58cf: mp_obj_new_str at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2095
(inlined by) mp_obj_new_str at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2088

0x4012fa8e: _vfs_open at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/micropython_adf/mod/vfs_stream.c:120

0x40171146: audio_element_process_init at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:175

0x40171693: audio_element_on_cmd_resume at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:279

0x401717a6: audio_element_on_cmd at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:320 (discriminator 13)

0x4017265d: audio_event_iface_waiting_cmd_msg at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_event_iface.c:247

0x401718ac: audio_element_task at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:473


根据Log查看 gc.c:460 行为:
459 // check if GC is locked
460 if (MP_STATE_THREAD(gc_lock_depth) > 0) {
461 return NULL;
462 }

因为中间的 esp-adf-libs 部分贵司只提供了库文件,并未公开源码,因此不是很明确此处为什么会出错及该如何解决,还望给出建议

ESP_HengYC
Posts: 184
Joined: Fri Dec 15, 2017 2:45 am

Re: audio_player在MicroPython下无法运行

Postby ESP_HengYC » Wed Dec 01, 2021 8:12 am

sawyer wrote:
Sat Oct 02, 2021 2:21 pm
我们参考 IDF/ADF/MicroPython_ADF 的说明将它们进行了整合,Python 的 REPL 工作基本正常,ADF下的play_mp3_control 在脱离MicroPython的环境下单独编译、运行也正常。
但在MicroPython中,通过MicroPython_ADF下的 audio_player 模块播放mp3失败。
IDF/ADF/MicroPython均为主线最新代码。

测试的命令为:
#sdcard
import machine, os
sd = machine.SDCard(slot=1)
os.mount(sd, "/sdcard")
# Add libs in sdcard to sys.path
import sys
sys.path.append('/sdcard')
#Audio
from audio import player, recorder

def cb(state):
print(state)

p = player(cb)
p.get_state()
p.play("file://sdcard/music-16b-2c-8000hz.mp3")

在执行到最后一步的时候出错,Log为:

I (29784) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3
E (29784) gpio: gpio_install_isr_service(460): GPIO isr service already installed
I (29804) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (29804) ES8388_DRIVER: init,out:02, in:00
I (29814) AUDIO_HAL: Codec mode is 3, Ctrl:1
I (29814) ESP_AUDIO_TASK: media_ctrl_task running...,0x3fb03548

----------------------------- ESP Audio Platform -----------------------------
| |
| ESP_AUDIO-v1.7.0-9-g84df87e-037bef3-09be8fe |
| Compile date: Jul 20 2021-13:51:36 |
------------------------------------------------------------------------------
I (29854) ESP_AUDIO_CTRL: Func:media_ctrl_create, Line:350, MEM Total:1235103 Bytes, Inter:270899 Bytes, Dram:231251 Bytes

I (29864) MP3_DECODER: MP3 init
I (29874) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (29874) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (29924) I2S: APLL: Req RATE: 48000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (29924) LYRAT_V4_3: I2S0, MCLK output by GPIO0
>>> p.get_state()
{'media_src': 0, 'err_msg': 0, 'status': 0}
I (31104) ESP_AUDIO_CTRL: Enter play procedure, src:0
I (31104) ESP_AUDIO_CTRL: Play procedure, URL is ok, src:0
I (31104) ESP_AUDIO_CTRL: Request_CMD_Queue CMD:0, Available:5, que:0x3ffbd824
I (31114) ESP_AUDIO_TASK: It's a decoder
I (31114) ESP_AUDIO_TASK: 1.CUR IN:[IN_file],CODEC:[DEC_mp3],RESAMPLE:[48000],OUT:[OUT_iis],rate:0,ch:0,pos:0
I (31124) ESP_AUDIO_TASK: 2.Handles,IN:0x3fb03768,CODEC:0x3fb03eb8,FILTER:0x3fb044b0,OUT:0x3fb04324
I (31134) ESP_AUDIO_TASK: 2.2 Update all pipeline
I (31144) ESP_AUDIO_TASK: 2.3 Linked new pipeline
I (31144) AUDIO_PIPELINE: link el->rb, el:0x3fb03768, tag:IN_file, rb:0x3fb04828
I (31154) AUDIO_PIPELINE: link el->rb, el:0x3fb03eb8, tag:DEC_mp3, rb:0x3fb07068
I (31164) AUDIO_PIPELINE: link el->rb, el:0x3fb044b0, tag:Audio_forge, rb:0x3fb090a8
I (31174) ESP_AUDIO_TASK: 3. Previous starting...
I (31174) AUDIO_ELEMENT: [IN_file-0x3fb03768] Element task created
I (31184) AUDIO_ELEMENT: [IN_file] AEL_MSG_CMD_RESUME,state:1
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x400dfaf0 PS : 0x00060230 A0 : 0x800e00e4 A1 : 0x3ffcf810
0x400dfaf0: gc_alloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/gc.c:460

A2 : 0x0000001f A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x000000fe A7 : 0x00000001 A8 : 0x800dfaf0 A9 : 0x3ffcf7f0
A10 : 0x00000000 A11 : 0x00060c23 A12 : 0x00060c20 A13 : 0x00060c23
A14 : 0x000000fe A15 : 0x00000001 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4008cea5 LEND : 0x4008ceb5 LCOUNT : 0xfffffff8
0x4008cea5: strlen at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:84

0x4008ceb5: strlen at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:96


Backtrace:0x400dfaed:0x3ffcf810 0x400e00e1:0x3ffcf830 0x400e545d:0x3ffcf850 0x400e58cf:0x3ffcf870 0x4012fa8e:0x3ffcf890 0x40171146:0x3ffcf950 0x40171693:0x3ffcf980 0x401717a6:0x3ffcf9a0 0x4017265d:0x3ffcf9d0 0x401718ac:0x3ffcfa10
0x400dfaed: gc_alloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/gc.c:460

0x400e00e1: m_malloc at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/malloc.c:86

0x400e545d: mp_obj_new_str_copy at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2029

0x400e58cf: mp_obj_new_str at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2095
(inlined by) mp_obj_new_str at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/lv_micropython/py/objstr.c:2088

0x4012fa8e: _vfs_open at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/micropython_adf/mod/vfs_stream.c:120

0x40171146: audio_element_process_init at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:175

0x40171693: audio_element_on_cmd_resume at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:279

0x401717a6: audio_element_on_cmd at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:320 (discriminator 13)

0x4017265d: audio_event_iface_waiting_cmd_msg at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_event_iface.c:247

0x401718ac: audio_element_task at /Volumes/Linux/Projects/Esp32Proj/adf_integration/yangtze/components/esp-adf/components/audio_pipeline/audio_element.c:473


根据Log查看 gc.c:460 行为:
459 // check if GC is locked
460 if (MP_STATE_THREAD(gc_lock_depth) > 0) {
461 return NULL;
462 }

因为中间的 esp-adf-libs 部分贵司只提供了库文件,并未公开源码,因此不是很明确此处为什么会出错及该如何解决,还望给出建议


谢谢你的报告, MicroPython 的代码可能需要在提交的 commit id 下面完整的跑,我们尽快适配到最新的代码上。

Who is online

Users browsing this forum: No registered users and 21 guests