|
发表于 2023-9-15 10:15:46
|
显示全部楼层
首先确认开始录音和关闭录音消息:MSG_RECODE_START,
开始录音如果要加提示音,需要在提示音播放完成之后再发录音开始消息,如下
- void my_du_play(void)
- {
- int msg[2], err;
- void *pfs = 0;
- void *pfile = 0;
- dec_obj *obj = 0;
- decoder_init();
- err = vfs_mount(&pfs, (void *)NULL, (void *)NULL);
- if (err) {
- log_info("vfs_mount err : 0x%x\n", err);
- }
- err = vfs_openbypath(pfs, &pfile, "/dir_tone/du.f1a");
- if (err) {
- log_info("fs_openbypath err : 0x%x\n", err);
- vfs_fs_close(&pfs);
- }
- obj = decoder_io(pfile, BIT_F1A1 | BIT_A, NULL, 0);
- if (NULL == obj) {
- log_info("fs_openbypath err : 0x%x\n", err);
- vfs_file_close(&pfile);
- vfs_fs_close(&pfs);
- }
- while (1) {
- err = get_msg(2, &msg[0]);
- 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, NO_WAIT);
- vfs_file_close(&pfile);
- vfs_fs_close(&pfs);
- goto __tone_over_deal;
- break;
- case MSG_500MS:
- wdt_clear();
- break;
- }
- }
- __tone_over_deal:
- post_msg(1, MSG_RECODE_START);
- //log_info("-----tone played over!!!\n");
- }
复制代码
结束录音的提示音要在录音结束之后发播放:
- case MSG_RECODE_START:
- if (ENC_ING == record_obj.enc_status) {
- /* 结束录音并播放录音 */
- encode_stop(&record_obj);
- post_msg(1, MY_TONE_PLAY_2);
- //post_msg(1, MSG_PP); //cyc
- } else {
- /* 开始录音 */
- decoder_stop(p_dec_obj, NEED_WAIT);
- encode_file_fs_close(&record_obj);
- encode_start(&record_obj);
- log_info("dev:%d fs_name:%s\n", record_obj.dev_index, record_obj.fs_name);
- }
- break;
复制代码 |
|