|
发表于 2023-8-19 17:42:42
|
显示全部楼层
原厂demo是没有独立的提示音播放函数的,所以需要重新写,具体如下:
- void my_tone_play(char* path)
- {
- int msg[2], err;
- void *pfs = 0;
- void *pfile = 0;
- dec_obj *obj = 0;
- decoder_init();
- err = fs_mount(&pfs, (void *)NULL, (void *)NULL);
- if (err) {
- log_info("fs_mount err : 0x%x\n", err);
- }
- err = fs_openbypath(pfs, &pfile, path);
- if (err) {
- log_info("fs_openbypath err : 0x%x\n", err);
- fs_fs_close(&pfs);
- }
- obj = decoder_io(pfile, BIT_F1A1, NULL, 0);
- if (NULL == obj) {
- log_info("fs_openbypath err : 0x%x\n", err);
- fs_fs_close(&pfs);
- fs_file_close(&pfile);
- }
- while (1) {
- err = get_msg(2, &msg[0]);
- bsp_loop();
- if (MSG_NO_ERROR != err) {
- msg[0] = NO_MSG;
- log_info("get msg err 0x%x\n", err);
- }
- switch (msg[0]) {
- case MSG_F1A1_FILE_END:
- case MSG_MP3_FILE_END:
- case MSG_WAV_FILE_END:
- decoder_stop(obj, NEED_WAIT, 0);
- goto __tone_over_deal;
- break;
- case MSG_500MS:
- printf("-----tone is playing!!!\n");
- wdt_clear();
- break;
- }
- }
- __tone_over_deal:
- printf("-----tone played over!!!\n");
- }
复制代码
参数path为要播放的文件的地址 |
|