Skip to content

Commit

Permalink
update:调整codec初始化位置,不应在volte初始化,应该和audio绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed Jan 22, 2024
1 parent 1a70ac9 commit 54307b0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
20 changes: 5 additions & 15 deletions components/cc/luat_lib_cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,11 @@ static void luat_volte_task(void *param){
luat_i2s_setup(&i2s_conf);
luat_cc.i2s_conf = luat_i2s_get_config(audio_conf->codec_conf.i2s_id);

int ret = audio_conf->codec_conf.codec_opts->init(&audio_conf->codec_conf,LUAT_CODEC_MODE_SLAVE);
if (ret){
LLOGE("no codec %s",audio_conf->codec_conf.codec_opts->name);
luat_rtos_task_delete(luat_cc.task_handle);
return;
}else{
LLOGD("find codec %s",audio_conf->codec_conf.codec_opts->name);

audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_RATE,16000);
audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_BITS,16);
audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_FORMAT,LUAT_CODEC_FORMAT_I2S);

// // audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_MODE_STANDBY,LUAT_CODEC_MODE_ALL);
audio_conf->codec_conf.codec_opts->stop(&audio_conf->codec_conf);
}
audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_RATE,16000);
audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_BITS,16);

audio_conf->codec_conf.codec_opts->stop(&audio_conf->codec_conf);

while (1){
luat_rtos_event_recv(luat_cc.task_handle, 0, &event, NULL, LUAT_WAIT_FOREVER);
switch(event.id)
Expand Down
4 changes: 2 additions & 2 deletions components/multimedia/luat_lib_multimedia_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ static int l_audio_set_output_bus(lua_State *L) {
}
lua_pop(L, 1);
}
luat_audio_set_bus_type(id,tp);
return 0;
lua_pushboolean(L, !luat_audio_set_bus_type(id,tp));
return 1;
}

LUAT_WEAK void luat_audio_set_debug(uint8_t on_off)
Expand Down
11 changes: 9 additions & 2 deletions components/multimedia/luat_multimedia_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,22 @@ LUAT_WEAK uint8_t luat_audio_mic_vol(uint8_t multimedia_id, uint16_t vol){
return -1;
}

LUAT_WEAK void luat_audio_set_bus_type(uint8_t multimedia_id,uint8_t bus_type){
LUAT_WEAK int luat_audio_set_bus_type(uint8_t multimedia_id,uint8_t bus_type){
luat_audio_conf_t* audio_conf = luat_audio_get_config(multimedia_id);
if (audio_conf){
if (bus_type == MULTIMEDIA_AUDIO_BUS_I2S){
audio_conf->bus_type = MULTIMEDIA_AUDIO_BUS_I2S;
audio_conf->codec_conf.codec_opts->init(&audio_conf->codec_conf,LUAT_CODEC_MODE_SLAVE);
if (audio_conf->codec_conf.codec_opts->init(&audio_conf->codec_conf,LUAT_CODEC_MODE_SLAVE)){
LLOGE("no codec %s",audio_conf->codec_conf.codec_opts->name);
return -1;
}else{
LLOGD("find codec %s",audio_conf->codec_conf.codec_opts->name);
}
audio_conf->codec_conf.codec_opts->control(&audio_conf->codec_conf,LUAT_CODEC_SET_FORMAT,LUAT_CODEC_FORMAT_I2S);
return 0;
}
}
return -1;
}


Expand Down
4 changes: 2 additions & 2 deletions demo/cc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ sys.taskInit(function()

audio.setBus(multimedia_id, audio.BUS_I2S,{chip = "es8311",i2cid = i2c_id , i2sid = i2s_id}) --通道0的硬件输出通道设置为I2S
audio.config(multimedia_id, 25, 0, 3, 100, 255, 0, 100)
cc.init(multimedia_id)

audio.vol(multimedia_id, voice_vol)
audio.micVol(multimedia_id, mic_vol)

cc.init(multimedia_id)

sys.waitUntil("CC_READY")
sys.wait(100)
--cc.dial(0,"114") --拨打电话
Expand Down
2 changes: 1 addition & 1 deletion luat/include/luat_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ uint8_t luat_audio_mic_vol(uint8_t multimedia_id, uint16_t vol);
*
* @param bus_type 见MULTIMEDIA_AUDIO_BUS,目前只有0=DAC 1=I2S 2=SOFT_DAC
*/
void luat_audio_set_bus_type(uint8_t multimedia_id,uint8_t bus_type);
int luat_audio_set_bus_type(uint8_t multimedia_id,uint8_t bus_type);

luat_audio_conf_t *luat_audio_get_config(uint8_t multimedia_id);

Expand Down

0 comments on commit 54307b0

Please sign in to comment.