Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:openLuat/LuatOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Apr 28, 2024
2 parents 83f0975 + d9fef07 commit cfe1f7b
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions components/multimedia/luat_lib_multimedia_audio.c
Expand Up @@ -128,13 +128,13 @@ static void record_encode_amr(uint8_t *data, uint32_t len){
static void record_stop_encode_amr(void){
luat_audio_record_stop(g_s_record.multimedia_id);
luat_audio_pm_request(g_s_record.multimedia_id, LUAT_AUDIO_PM_STANDBY);
if (g_s_record.fd){
#ifdef LUAT_USE_INTER_AMR
luat_audio_inter_amr_coder_deinit(g_s_record.encoder_handler);
luat_audio_inter_amr_coder_deinit(g_s_record.encoder_handler);
#else
Encoder_Interface_exit(g_s_record.encoder_handler);
Encoder_Interface_exit(g_s_record.encoder_handler);
#endif
g_s_record.encoder_handler = NULL;
if (g_s_record.fd){
g_s_record.encoder_handler = NULL;
luat_fs_fclose(g_s_record.fd);
g_s_record.fd = NULL;
}
Expand Down Expand Up @@ -308,6 +308,43 @@ static int l_audio_record(lua_State *L){
return 1;
}

/**
录音停止
@api audio.recordStop(id)
@int id 多媒体播放通道号
@return boolean 成功返回true,否则返回false
@usage
audio.recordStop(0)
*/
static int l_audio_record_stop(lua_State *L) {
rtos_msg_t msg = {0};
msg.handler = l_multimedia_raw_handler;
if (g_s_record.is_run) {
if (g_s_record.type==LUAT_MULTIMEDIA_DATA_TYPE_AMR_NB||g_s_record.type==LUAT_MULTIMEDIA_DATA_TYPE_AMR_WB){
#ifdef LUAT_SUPPORT_AMR
record_stop_encode_amr();
#endif
}else if(g_s_record.type==LUAT_MULTIMEDIA_DATA_TYPE_PCM){
// 不需要特殊处理
}else{
LLOGE("not support %d", g_s_record.type);
return 0;
}
msg.arg1 = LUAT_MULTIMEDIA_CB_RECORD_DONE;
msg.arg2 = g_s_record.multimedia_id;
luat_msgbus_put(&msg, 1);
g_s_record.record_time_tmp = 0;
g_s_record.is_run = 0;
g_s_record.record_buffer_index = 0;
luat_rtos_task_delete(g_s_record.task_handle);
lua_pushboolean(L, 1);
return 1;
} else {
LLOGE("record is not running");
return 0;
}
}

#endif

/**
Expand Down Expand Up @@ -700,6 +737,8 @@ static const rotable_Reg_t reg_audio[] =
{ "pm", ROREG_FUNC(l_audio_pm_request)},
#ifdef LUAT_USE_RECORD
{ "record", ROREG_FUNC(l_audio_record)},
{ "recordStop", ROREG_FUNC(l_audio_record_stop)},

#endif
//@const RESUME number PM模式 工作模式
{ "RESUME", ROREG_INT(LUAT_AUDIO_PM_RESUME)},
Expand Down

0 comments on commit cfe1f7b

Please sign in to comment.