From: luozheng <1732036298@qq.com> Date: Thu, 3 Jul 2025 11:12:32 +0000 (+0800) Subject: 4gAi音频打断提交,还需优化 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5118aff8dd5b2d3e6ec333839f999678f95952e5;p=mirrors%2FFD230.git 4gAi音频打断提交,还需优化 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index c28f2d14e..a164a4b47 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -749,8 +749,10 @@ namespace OHOS if (slider) { int value = slider->GetValue(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "volume:%d front", value); if (event.GetRotate() > 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "222"); value += 20; if (value > 100) { @@ -759,17 +761,14 @@ namespace OHOS } else { - value -= 10; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "111"); + value -= 20; if (value < 0) { value = 0; } } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "volume:%d", value); - if (value >= 100 || value <= 0) - { - return; - } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "volume:%d end", value); do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value)); } } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 24a9452d9..e684c3128 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -2449,9 +2449,17 @@ static void blesrvAi_send_service_task(void const *arg) { if(mail.msg_data && mail.msg_len!=0) { - if(server_handle == 200) + if(server_handle == 200 ||server_handle == 201 ) { - AIStreamWrite(mail.msg_data,mail.msg_len); + if(server_handle == 201) + { + AIStreamWrite(NULL,1); + } + else + { + AIStreamWrite(mail.msg_data,mail.msg_len); + } + } else{ if(server_handle==2) @@ -2560,7 +2568,7 @@ int send_msg_data_into_Ai_msg_queue(void *buff,uint16_t len,uint8_t type) } blesrv_mail.msg_data=0; - if(type == 200) + if(type == 200 || type == 201) { blesrv_mail.service_handle = type; diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp index 28d5ce206..66d03dc9b 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp @@ -919,10 +919,35 @@ errcode_t chat_server_init(void); errcode_t tts_server_init(void); // void tts_server_deinit(void); +uint8 tts_break =0; + +void uapi_set_tts_break(uint8_t data) +{ + tts_break=data; +} + +uint8_t uapi_get_tts_break(void) +{ + return tts_break; +} void uapi_UI_start_asr(void) { + if(bk_websocket_tts_tick!=0) + { + // uapi_tts_paly_stop(); + tts_server_deinit(); + send_msg_data_into_Ai_msg_queue((uint8_t *)"tts_recv_buf",13,201); + + tts_break=1; + tts_reconnect=1; + while (tts_break) + { + LOS_Msleep(10); + } + LOS_Msleep(50); + } asr_need_stop=0; asr_server_init(); @@ -937,12 +962,6 @@ void uapi_UI_start_asr(void) } - - if(bk_websocket_tts_tick!=0) - { - tts_server_deinit(); - tts_reconnect=1; - } } @@ -1804,7 +1823,7 @@ void bk_websocket_tts(void *data) { while (client_count) { - tts_client = init_websocket_client("ws://118.145.158.207:22080/tts/stream?audio_buffer_size=576",NULL,0); + tts_client = init_websocket_client("ws://118.145.158.207:22080/tts/stream?audio_buffer_size=1024",NULL,0); if (tts_client== NULL) { @@ -1867,6 +1886,8 @@ void bk_websocket_tts(void *data) { else if(type==WS_TEXT) { printf("bk_websocket_demo %s %d %d\n",tts_recv_buf,bk_websocket_tts_tick,(uint32_t)osKernelGetTickCount()); + + send_msg_data_into_Ai_msg_queue((uint8_t *)tts_recv_buf,len,201); bk_websocket_tts_tick=0; // tts_paly(); } diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h index daa3dfb62..a6f7717c9 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h @@ -24,7 +24,9 @@ void uapi_UI_stop_start_asr_timeout(void); void tts_server_deinit(void); +void uapi_set_tts_break(uint8_t data); +uint8_t uapi_get_tts_break(void); uint8_t get_ai_asr_service_init_flag(void); void set_ai_asr_service_init_flag(uint8_t flag); diff --git a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp index 0b82ce8c9..66058d6fd 100755 --- a/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp +++ b/code/sdk/middleware/services/media/foundation/audiomanager/frameworks/audiomanager/cpp/audio_manager.cpp @@ -45,7 +45,8 @@ bool AudioManager::SetVolume(AudioStreamType streamType, int32_t volume) CHK_NULL_RETURN(impl_, false, "impl_ is nullptr"); - if(streamType == AUDIO_STREAM_MUSIC || streamType == AUDIO_STREAM_A2DP_MUSIC || streamType == AUDIO_STREAM_NOTIFICATION_SYSTEM) + if(streamType == AUDIO_STREAM_MUSIC || streamType == AUDIO_STREAM_A2DP_MUSIC || streamType == AUDIO_STREAM_NOTIFICATION_SYSTEM + || streamType == AUDIO_STREAM_VOICE_ASSISTANT) { if(volume == 0) volume = 0; diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp index 3d585076e..d978b239d 100755 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp @@ -1372,18 +1372,54 @@ void startAudioCaptureTask(void) -int32_t AIStreamWrite(uint8_t *buf, uint32_t size) +int32_t AIStreamWrite(uint8_t *buf, uint32_t size) { int32_t ret = 0; + if(buf==NULL && size==1) + { + MEDIA_ERR_LOG("AIStreamWrite end"); + uapi_set_tts_break(0); + return -1; + } + if(uapi_get_tts_break()) + { + MEDIA_ERR_LOG("uapi_get_tts_break"); + return -1; + } + // 原有流写入逻辑 - if (g_stream_out_downink) + if (g_stream_out_downink) { + StreamWrite_retry: + uint64_t writeLen = 0; AudioRendererConfig renderConfig; - ret = g_stream_out_downink->StreamWrite(buf, size, writeLen, renderConfig); - LOS_Msleep(30); - if (ret < 0) { + if (g_stream_out_downink) + { + ret = g_stream_out_downink->StreamWrite(buf, size, writeLen, renderConfig); + MEDIA_ERR_LOG("StreamWrite writeLen %d\r\n", writeLen); + } + else + { + return -1; + } + + int sleep_time = 0; + if (sleep_time % 288) + { + sleep_time = writeLen / 288 + 1; + } + else + { + sleep_time = writeLen / 288; + } + + LOS_Msleep(sleep_time * 17); + + if (ret < 0) + { MEDIA_ERR_LOG("StreamWrite failed"); + goto StreamWrite_retry; } }