Hi,
I want to read the mp3 file from sd card, decode it and output throuhg built-in DAC, but it occured an error(MAD_ERROR_LOSTSYNC ).
following is my code that calling funcion:
static void play_mp3_file(void vparameter)
{
web_radio_t radio_conf = vparameter;
char mp3_data[1024];//[4096];
player_t *player_config = radio_conf->player_config;
int ret;
int i;
ESP_LOGI(TAG,"play_mp3_file task\r\n");
FILE* f = fopen("/sdcard/ghsy.mp3","r");
if (f == NULL) {
ESP_LOGI(TAG,"Failed to open file for reading.\r\n");
vTaskDelete(NULL);
}
Hi, I want to read the mp3 file from sd card, decode it and output throuhg built-in DAC, but it occured an error(MAD_ERROR_LOSTSYNC ). following is my code that calling funcion: static void play_mp3_file(void vparameter) { web_radio_t radio_conf = vparameter;
ESP_LOGI(TAG,"play_mp3_file task\r\n"); FILE* f = fopen("/sdcard/ghsy.mp3","r"); if (f == NULL) { ESP_LOGI(TAG,"Failed to open file for reading.\r\n"); vTaskDelete(NULL); }
player_config->command = CMD_START; player_config->buffer_pref = BUF_PREF_FAST;//BUF_PREF_SAFE;//
ESP_LOGI(TAG,"play_mp3_file read data succ\r\n"); while( audio_stream_consumer(mp3_data, sizeof(mp3_data), player_config) != 0) { vTaskDelay(500/ portTICK_PERIOD_MS); ESP_LOGI(TAG,"play_mp3_file vTaskDelay ing\r\n"); } vTaskDelay(3000/ portTICK_PERIOD_MS); } fclose(f); printf("delete play_mp3_file_task.\r\n"); vTaskDelete(NULL); }
void web_radio_start(web_radio_t *config) { // start reader task //xTaskCreatePinnedToCore(&http_get_task, "http_get_task", 2560, config, 20, //NULL, 0); ESP_LOGI(TAG,"web_radio_start\r\n");
xTaskCreate(&play_mp3_file, "play_mp3_file", 4096+4096, config, 5, NULL);
}
and the debug log is:
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:5648 ho 0 tail 12 room 4 load:0x40078000,len:0 load:0x40078000,len:13912 entry 0x40078fd8 [0;32mI (30) boot: ESP-IDF v3.1-dev-463-g77eae33 2nd stage bootloader[0m [0;32mI (30) boot: compile time 16:47:34[0m [0;32mI (30) boot: Enabling RNG early entropy source...[0m [0;32mI (36) boot: SPI Speed : 40MHz[0m [0;32mI (40) boot: SPI Mode : DIO[0m [0;32mI (44) boot: SPI Flash Size : 4MB[0m [0;32mI (48) boot: Partition Table:[0m [0;32mI (52) boot: ## Label Usage Type ST Offset Length[0m [0;32mI (59) boot: 0 nvs WiFi data 01 02 00009000 00006000[0m [0;32mI (67) boot: 1 phy_init RF data 01 01 0000f000 00001000[0m [0;32mI (74) boot: 2 factory factory app 00 00 00010000 00200000[0m [0;32mI (82) boot: End of partition table[0m [0;32mI (86) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x48468 (296040) map[0m [0;32mI (197) esp_image: segment 1: paddr=0x00058490 vaddr=0x3ffb0000 size=0x041a0 ( 16800) load[0m [0;32mI (204) esp_image: segment 2: paddr=0x0005c638 vaddr=0x40080000 size=0x00400 ( 1024) load[0m [0;32mI (205) esp_image: segment 3: paddr=0x0005ca40 vaddr=0x40080400 size=0x035d0 ( 13776) load[0m [0;32mI (219) esp_image: segment 4: paddr=0x00060018 vaddr=0x400d0018 size=0x67cb8 (425144) map[0m [0;32mI (369) esp_image: segment 5: paddr=0x000c7cd8 vaddr=0x400839d0 size=0x07e94 ( 32404) load[0m [0;32mI (383) esp_image: segment 6: paddr=0x000cfb74 vaddr=0x400c0000 size=0x00000 ( 0) load[0m [0;32mI (391) boot: Loaded app from partition at offset 0x10000[0m [0;32mI (391) boot: Disabling RNG early entropy source...[0m [0;32mI (393) cpu_start: Pro cpu up.[0m [0;32mI (396) cpu_start: Starting app cpu, entry point is 0x400812a8[0m [0;32mI (0) cpu_start: App cpu up.[0m [0;32mI (407) heap_init: Initializing. RAM available for dynamic allocation:[0m [0;32mI (413) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m [0;32mI (419) heap_init: At 3FFBE3A8 len 00021C58 (135 KiB): DRAM[0m [0;32mI (426) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m [0;32mI (432) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m [0;32mI (438) heap_init: At 4008B864 len 0001479C (81 KiB): IRAM[0m [0;32mI (445) cpu_start: Pro cpu start user code[0m [0;32mI (127) cpu_start: Starting scheduler on PRO CPU.[0m [0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m [0;32mI (129) main: starting app_main()[0m [0;32mI (129) main: RAM left: 253568[0m [0;32mI (159) main: hardware initialized[0m [0;32mI (159) main: Initializing SD card[0m [0;32mI (159) main: Using SPI peripheral[0m [0;32mI (169) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m Name: SD16G Type: SDHC/SDXC Speed: default speed Size: 14832MB CSD: ver=1, sector_size=512, capacity=30375936 read_bl_len=9 SCR: sd_spec=2, bus_width=5 [0;32mI (289) playlist: Tracks:[0m SomaFM / Illinois Street Lounge - http://ice1.somafm.com/illstreet-128-mp3 SomaFM / Secret Agent - http://ice1.somafm.com/secretagent-128-mp3 SomaFM / Left Coast 70s - http://ice1.somafm.com/seventies-128-mp3 SomaFM / Boot Liquor - http://ice1.somafm.com/bootliquor-128-mp3 [0;32mI (309) renderer: init I2S mode 2, port 0, 16 bit, 44100 Hz[0m [0;32mI (319) I2S: queue free spaces: 1[0m [0;32mI (319) I2S: DMA Malloc info, datalen=blocksize=256, dma_buf_count=32[0m [0;32mI (329) I2S: PLL_D2: Req RATE: 44100, real rate: 2777.000, BITS: 16, CLKM: 30, BCK: 60, MCLK: 30.234, SCLK: 88864.000000, diva: 64, divb: 14[0m [0;32mI (339) web_radio: web_radio_start
[0m [0;32mI (349) main: RAM left 205480[0m [0;32mI (349) web_radio: play_mp3_file task
[0m [0;32mI (359) web_radio: play_mp3_file read data succ
[0m [0;32mI (3359) web_radio: play_mp3_file read data succ
[0m [0;32mI (6359) web_radio: play_mp3_file read data succ
[0m [0;32mI (9359) web_radio: play_mp3_file read data succ
[0m [0;32mI (12359) web_radio: play_mp3_file read data succ
[0m [0;32mI (15359) web_radio: play_mp3_file read data succ
[0m [0;32mI (18359) web_radio: play_mp3_file read data succ
[0m [0;32mI (21359) web_radio: play_mp3_file read data succ
[0m [0;32mI (24359) web_radio: play_mp3_file read data succ
[0m [0;32mI (27359) web_radio: play_mp3_file read data succ
[0m [0;32mI (30359) web_radio: play_mp3_file read data succ
[0m [0;32mI (33359) web_radio: play_mp3_file read data succ
[0m [0;32mI (36359) web_radio: play_mp3_file read data succ
[0m [0;32mI (39359) web_radio: play_mp3_file read data succ
[0m [0;32mI (42359) web_radio: play_mp3_file read data succ
[0m [0;32mI (45359) web_radio: play_mp3_file read data succ
[0m [0;32mI (48359) web_radio: play_mp3_file read data succ
[0m [0;32mI (51359) web_radio: play_mp3_file read data succ
[0m [0;32mI (54359) web_radio: play_mp3_file read data succ
[0m [0;32mI (57359) web_radio: play_mp3_file read data succ
[0m [0;32mI (60359) web_radio: play_mp3_file read data succ
[0m [0;32mI (63359) web_radio: play_mp3_file read data succ
[0m [0;32mI (66359) web_radio: play_mp3_file read data succ
[0m [0;32mI (69359) web_radio: play_mp3_file read data succ
[0m [0;32mI (72359) web_radio: play_mp3_file read data succ
[0m [0;32mI (75359) web_radio: play_mp3_file read data succ
[0m [0;32mI (78359) web_radio: play_mp3_file read data succ
[0m [0;32mI (81359) web_radio: play_mp3_file read data succ
[0m [0;32mI (84359) web_radio: play_mp3_file read data succ
[0m [0;32mI (84359) audio_player: RAM left 209848[0m [0;32mI (84359) audio_player: created decoder task: mp3_decoder_task[0m [0;32mI (84359) mad_decoder: decoder start[0m [0;31mE (84369) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84369) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84379) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84389) mad_decoder: dec err 0x0102 (reserved header layer value)[0m [0;31mE (84389) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84399) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84409) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84409) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84419) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84429) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84429) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84439) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84439) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84449) mad_decoder: dec err 0x0101 (lost synchronization)[0m [0;31mE (84459) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84459) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84469) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84469) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84479) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84489) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84489) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84499) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84499) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84509) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84519) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84519) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84529) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84539) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84539) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84549) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84549) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84559) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84569) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84569) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84579) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84579) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84589) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84599) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84599) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84609) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84609) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84619) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84629) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84629) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84639) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84639) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84649) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84659) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84659) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84669) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84679) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84679) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84689) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84689) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84699) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84709) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84709) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84719) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84719) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84729) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84739) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84739) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84749) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84749) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84759) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84769) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84769) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84779) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84779) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84789) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84799) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84799) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84809) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84809) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84819) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84829) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84829) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84839) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84849) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84849) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84859) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84859) mad_decoder: Buffer underflow, need 2881 bytes.[0m [0;31mE (84869) mad_decoder: Buffer underflow, need 2881 bytes.[0m
Is there any hint or solution for solving this problem? thank you in advance.