From 53e804667a23ada2d0c06f91fef0db6d4a6a8171 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Wed, 15 Jan 2025 20:07:01 +0800 Subject: [PATCH] =?utf8?q?=E8=93=9D=E7=89=99=E8=80=B3=E6=9C=BACAT1?= =?utf8?q?=E7=94=B5=E8=AF=9D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/bt.bin | 4 +- .../nativeui/alarm/src/AlarmClockModel.cpp | 22 +-- .../bluetooth/src/BluetoothHeadsetEvent.cpp | 6 + .../phoneservice/include/PhoneServiceC.h | 2 + .../phoneservice/src/PhoneAGService.cpp | 6 +- .../phoneservice/src/PhoneService.cpp | 6 + .../service/ble_service/bleservice/bleEvent.c | 6 +- .../peripheral/slip/cat1Service/cat1_ctl.cpp | 11 ++ .../peripheral/slip/cat1Service/cat1_ctl.h | 2 + .../peripheral/utils/custom_cmd_service.c | 3 + .../voice_call_volte_sample_wrapper.cpp | 136 +++++++++++------- .../plugins/brandy/modem/modem_sub_port.c | 6 +- code/sdk/tools/pkg/bin/brandy/bt.bin | 4 +- 13 files changed, 142 insertions(+), 72 deletions(-) diff --git a/bin/bt.bin b/bin/bt.bin index 5564865ed..749411053 100644 --- a/bin/bt.bin +++ b/bin/bt.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6faa308a3591ba1d1743e2fd4ebe9334778acf2fa7fdd7eb8ac434e252ad25f -size 424848 +oid sha256:6d0298cc726fb3ff2290406bf86f52bf9e53c048bdafc71a1b43a0064bbfb708 +size 424904 diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index d884f8119..10ea14959 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -839,10 +839,10 @@ uint16 AlarmClockModel::GetSliceId() int AlarmClockModel::AlarmPlayerStat() { int32_t ret; - if(NotificationManager::GetInstance()->GetWatchCallStatus()) - { - return 0; - } + // if(NotificationManager::GetInstance()->GetWatchCallStatus()) + // { + // return 0; + // } // 设置回调函数 if (playerCtr.get() == nullptr) { @@ -963,12 +963,14 @@ int AlarmClockModel::AlarmPlayerStop(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::AlarmPlayerStop playerCtr nullptr"); return OHOS_FAILURE; } - - ret = playerCtr->Stop(); - playerCtr->Reset(); - playerCtr->Release(); - if (amIntance.DeactivateAudioInterrupt(interrupt) != 0) { - return OHOS_FAILURE; + if(playerCtr->IsPlaying()) + { + ret = playerCtr->Stop(); + playerCtr->Reset(); + playerCtr->Release(); + if (amIntance.DeactivateAudioInterrupt(interrupt) != 0) { + return OHOS_FAILURE; + } } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Reset, ret:%d", ret); return OHOS_SUCCESS; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp index 963b64400..d8f2355e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp @@ -12,6 +12,7 @@ #include "service_id_define.h" #include "graphic_service.h" #include +#include "notification_manager.h" using namespace OHOS; @@ -110,6 +111,11 @@ void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume) //根据传入的按键操作类型和值,执行相应的操作并通知媒体状态变化 void UsingPressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue) { + if(NotificationManager::GetInstance()->GetWatchCallStatus()) + { + return ; + } + bt_avrcp_tg_evt_status_param event; // printf("keyOperation = %d, keyValue = %d\n"); switch (keyOperation) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h index 25f1896ee..71a72f112 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/include/PhoneServiceC.h @@ -28,6 +28,8 @@ void cat1_audio_AudioRelease(void); int32_t PhoneAudioSetMicMuteCat1(bool isMute); +void cat1_audio_stop(void); + void cat1_connect_sco_(void); void cat1_disconn_sco_(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp index dae05df84..783c95c4e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneAGService.cpp @@ -302,6 +302,8 @@ static void sample_hfp_ag_sco_conn_state_changed_callback(const bd_addr_t *bd_ad } else { + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT_AUDIO_END, nullptr, 0); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_CAT1_AUDIO_STOP, nullptr, 0); } @@ -326,7 +328,7 @@ static void sample_hfp_ag_codec_changed_callback(const bd_addr_t *bd_addr, hfp_a } else if (codec == HFP_AG_CODEC_ID_MSBC) { - // g_hfp_codec = mSBC; + g_hfp_codec = mSBC; updata_Audio_code_hfp(1); } @@ -339,7 +341,7 @@ static void sample_hfp_ag_volume_changed_callback(const bd_addr_t *bd_addr, hfp_ sample_hfp_ag_print_addr(bd_addr); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"type: %d, volume: %u\n", type, volume); if (type == HFP_VOLUME_SPEAKER) { - sample_hfp_ag_set_spk_volume(volume); + // sample_hfp_ag_set_spk_volume(volume); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index b1a274c8b..0c90da918 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -417,6 +417,12 @@ void cat1_audio_AudioRelease(void) uapi_cat1_stop_volte_voice(); } +void cat1_audio_stop(void) +{ + uapi_stop_call(); +} + + // 同步音量 diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 76689b2a6..55d915f16 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -6193,8 +6193,6 @@ void Read_BIN_file_buf_send_bin_Data(uint8_t day,uint32_t pack_size,uint16_t id) { ble_data_type type_={0x01,id,0,1,1}; send_big_data(type_,NULL,0); - - //send_big_data(1,NULL,0,0,1,1,id,1); return; } uint8_t single_data=8; @@ -6209,8 +6207,8 @@ void Read_BIN_file_buf_send_bin_Data(uint8_t day,uint32_t pack_size,uint16_t id) int check_num=data_len%single_data; if(check_num!=0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"数据有误 %d \r\n",id); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"数据有误 %d \r\n",id); + free(data); ble_data_type type_={0x01,id,0,1,1}; send_big_data(type_,NULL,0); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.cpp index 7ed50fe52..b44d0f1a2 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.cpp @@ -98,6 +98,17 @@ int32_t uapi_cat1_start_volte_voice(void) } +int32_t uapi_stop_call(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_cat1_RequsetAudioFocus\n"); + + int32_t ret = ERRCODE_FAIL; + int32_t argc = 1; + uint8_t *argv = (uint8_t *)"stopcall"; + ret = VoiceCallVolteSample(argc, (const char **)&argv); + return ret; +} + int32_t uapi_cat1_start_SCO_volte_voice(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_cat1_start_SCO_volte_voice\n"); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.h index ee1bf385c..9ea851c9f 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ctl.h @@ -31,6 +31,8 @@ uint8_t volte_voice_state(void); int32_t uapi_cat1_start_SCO_volte_voice(void); +int32_t uapi_stop_call(void); + void uapi_cat1_remove_cat1_vote(void); void uapi_cat1_add_cat1_vote(void); void uapi_cat1_wakeup_cat1(uint8_t wakeup); diff --git a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c index 6fabab38f..c05eed6ba 100644 --- a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c @@ -331,6 +331,9 @@ static void custom_cmd_service_check_task(void const *arg) case CUSTOM_CMD_MSG_CAT_HFP_SCO_AUDIO_START: cat1_start_SCO_audio_(); break; + case CUSTOM_CMD_MSG_CAT_AUDIO_END: + cat1_audio_stop(); + break; default: 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 f9dfa40ba..e6f178a88 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 @@ -73,8 +73,16 @@ static int32_t VoiceCallSetVolume(const char **param); static int32_t VoiceCAllSeaEnable(const char **param); static int32_t VoiceCallMicMute(const char **param); static int32_t StartHFPVoiceCall(const char **param); +static int32_t NO_LOCAL_VOICE_CALL_RequsetAudioFocus(const char **param); +static int32_t ReleaseAudioFocus_HFP(const char **param); // static int32_t updata_Audio_code_hfp(const char **param); +static AudioSession g_sessionId=0; +static AudioInterrupt g_interrupt; + +static uint8_t is_stop_call=0; + + typedef struct { AudioCodecFormat code; uint32_t sampleRate; @@ -89,6 +97,12 @@ typedef struct { int32_t (*func)(const char **param); } FuncsMap; +static int32_t stopcall(const char **param) +{ + is_stop_call=1; + return 0; + +} static FuncsMap g_voiceCallVolteFuncs[] = { { "start", StartVoiceCall }, { "stop", StopVoiceCall }, @@ -96,6 +110,9 @@ static FuncsMap g_voiceCallVolteFuncs[] = { { "seaenable", VoiceCAllSeaEnable }, { "mute", VoiceCallMicMute }, { "startSCO",StartHFPVoiceCall}, + { "stopcall",stopcall} + // { "RequsetAudioFocus",NO_LOCAL_VOICE_CALL_RequsetAudioFocus}, + // { "ReleaseAudioFocus",ReleaseAudioFocus_HFP} // { "updata_Audio_code_hfp",updata_Audio_code_hfp} }; @@ -525,14 +542,14 @@ static bool RequsetAudioFocus(VoiceCallVolteContext *context) return true; } -static bool NO_LOCAL_VOICE_CALL_RequsetAudioFocus(VoiceCallVolteContext *context) +static int32_t NO_LOCAL_VOICE_CALL_RequsetAudioFocus(const char **param) { bool success; success = g_amInstance.Initialize(); if (!success) { MEDIA_ERR_LOG("audiomanager init failed"); - return false; + return -1; } AudioSession sessionId; @@ -541,28 +558,28 @@ static bool NO_LOCAL_VOICE_CALL_RequsetAudioFocus(VoiceCallVolteContext *context if (sessionId == AUDIO_SESSION_ID_NONE) { MEDIA_ERR_LOG("audio session id invalid"); - return false; + return -1; } std::shared_ptr interruptListener = - std::make_shared(context); + std::make_shared((VoiceCallVolteContext*)NULL); if (interruptListener == nullptr || interruptListener.get() == nullptr) { MEDIA_ERR_LOG("voice call volte interrupt listener is nullptr"); - return false; + return -1; } AudioInterrupt interrupt = { AUDIO_STREAM_VOICE_CALL_VOLTE, sessionId, interruptListener }; if (g_amInstance.ActivateAudioInterrupt(interrupt) == INTERRUPT_FAILED) { MEDIA_ERR_LOG("activate audio interrupt failed"); - return false; + return -1; } - context->sessionId = sessionId; - context->interrupt = interrupt; + g_sessionId = sessionId; + g_interrupt = interrupt; - return true; + return 0; } @@ -588,13 +605,15 @@ static bool ReleaseAudioFocus(VoiceCallVolteContext *context) } #endif -static bool ReleaseAudioFocus_HFP(VoiceCallVolteContext *context) +static int32_t ReleaseAudioFocus_HFP(const char **param) { - if (g_amInstance.DeactivateAudioInterrupt(context->interrupt) != 0) { + if (g_amInstance.DeactivateAudioInterrupt(g_interrupt) != 0) { MEDIA_ERR_LOG("deactivate audio interrupt failed"); - return false; + return -1; } - return true; + g_sessionId=0; + MEDIA_ERR_LOG("succ ReleaseAudioFocus_HFP"); + return 0; } @@ -603,32 +622,45 @@ static void *VoiceCallVolteThread(void *priv) { VoiceCallVolteContext *context = (VoiceCallVolteContext *)priv; - bool success = RequsetAudioFocus(context); - if (!success) { - MEDIA_ERR_LOG("requset audio focus failed"); - return nullptr; + // bool success = RequsetAudioFocus(context); + // if (!success) { + // MEDIA_ERR_LOG("requset audio focus failed"); + // return nullptr; + // } + if(g_sessionId==0) + { + NO_LOCAL_VOICE_CALL_RequsetAudioFocus(NULL); } + context->sessionId=g_sessionId; + context->sessionId=g_sessionId; + int32_t ret = RunVoiceCallVolte(context); - if (ret != 0) { - MEDIA_ERR_LOG("run voice call volte failed"); -#ifdef LOCAL_VOICE_CALL - (void)ReleaseAudioFocus(); -#else - (void)ReleaseAudioFocus(context); -#endif - return nullptr; +// if (ret != 0) { +// MEDIA_ERR_LOG("run voice call volte failed"); +// #ifdef LOCAL_VOICE_CALL +// (void)ReleaseAudioFocus(); +// #else +// (void)ReleaseAudioFocus(context); +// #endif +// return nullptr; +// } + +// #ifdef LOCAL_VOICE_CALL +// success = ReleaseAudioFocus(); +// #else +// success = ReleaseAudioFocus(context); +// #endif +// if (!success) { +// MEDIA_ERR_LOG("release audio focus failed"); +// return nullptr; +// } + if(is_stop_call) + { + ReleaseAudioFocus_HFP(NULL); + is_stop_call=0; } -#ifdef LOCAL_VOICE_CALL - success = ReleaseAudioFocus(); -#else - success = ReleaseAudioFocus(context); -#endif - if (!success) { - MEDIA_ERR_LOG("release audio focus failed"); - return nullptr; - } printf("VoiceCallVolteThread END"); return nullptr; } @@ -796,6 +828,8 @@ static int32_t RunVoiceCallVolte_NO_LOCAL_VOICE_CALL(VoiceCallVolteContext *cont MEDIA_ERR_LOG("set modem headset out device connect failed"); } + MEDIA_INFO_LOG("captureConfig.sampleRate %d",Audio_code_hfp_t.sampleRate); + g_stream_in_uplink = std::make_shared(); CapturerInputConfig captureConfig = {}; @@ -963,33 +997,37 @@ static int32_t RunVoiceCallVolte_NO_LOCAL_VOICE_CALL(VoiceCallVolteContext *cont return 0; } - - static void *VoiceCallVolteHFPThread(void *priv) { VoiceCallVolteContext *context = (VoiceCallVolteContext *)priv; - - bool success = NO_LOCAL_VOICE_CALL_RequsetAudioFocus(context); - if (!success) { - MEDIA_ERR_LOG("requset audio focus failed"); - return nullptr; + if(g_sessionId==0) + { + NO_LOCAL_VOICE_CALL_RequsetAudioFocus(NULL); } + context->sessionId=g_sessionId; + + + // bool success = NO_LOCAL_VOICE_CALL_RequsetAudioFocus(context); + // if (!success) { + // MEDIA_ERR_LOG("requset audio focus failed"); + // return nullptr; + // } int32_t ret = RunVoiceCallVolte_NO_LOCAL_VOICE_CALL(context); if (ret != 0) { MEDIA_ERR_LOG("run voice call volte failed"); - (void)ReleaseAudioFocus_HFP(context); + // (void)ReleaseAudioFocus_HFP(context); // (void)ReleaseAudioFocus(); return nullptr; } - - success = ReleaseAudioFocus_HFP(context); - // success = ReleaseAudioFocus(); - if (!success) { - MEDIA_ERR_LOG("release audio focus failed"); - return nullptr; + if(is_stop_call) + { + ReleaseAudioFocus_HFP(NULL); + is_stop_call=0; } + + printf("VoiceCallVolteHFPThread END"); return nullptr; } @@ -1017,7 +1055,7 @@ static int32_t StartHFPVoiceCall(const char **param) MediaMutexUnLock(g_voiceCallVolteContextMutex); // 3. create voice call volte thread - MediaThreadattr attr = { "VoiceCallVolteThread", 0x2000, THREAD_SCHED_INVALID, 0, false }; + MediaThreadattr attr = { "VoiceCallVolteHFPThread", 0x2000, THREAD_SCHED_INVALID, 0, false }; g_voiceCallVolteContext->taskHandle = MediaThreadCreate(VoiceCallVolteHFPThread, g_voiceCallVolteContext, &attr); if ( g_voiceCallVolteContext->taskHandle == nullptr) { MEDIA_ERR_LOG("create voice call volte thread failed"); diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c index 35efe44d6..514551873 100755 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/modem/modem_sub_port.c @@ -473,12 +473,12 @@ static int32_t AIDevClose(const SubPortTrackContext *portTrackCtx) return MEDIA_HAL_OK; } -static void GetHeadsetDownlinkAOAttr(uapi_snd_attr *sndAttr) +static void GetHeadsetDownlinkAOAttr(uapi_snd_attr *sndAttr,SubPortTrackContext *portTrackCtx) { sndAttr->port_num = MODEM_HEADSET_DOWNLINK_SOUND_PORT_NUM; sndAttr->port_attr[0].out_port = UAPI_SND_OUT_PORT_CAST0; sndAttr->bit_depth = UAPI_AUDIO_BIT_DEPTH_16; - sndAttr->sample_rate = MODEM_HEADSET_DOWNLINK_SOUND_SAMPLE_RATE; + sndAttr->sample_rate = portTrackCtx->inputAttr.sampleRate; sndAttr->channels = MODEM_HEADSET_DOWNLINK_SOUND_CHANNELS; } @@ -504,7 +504,7 @@ static int32_t AODevOpen(SubPortTrackContext *portTrackCtx) MEDIA_HAL_DOFUNC_TIME(ret = uapi_snd_open(&portTrackCtx->uplinkSoundHandle, sndId, &sndAttr)); } else { if (portTrackCtx->workScene == MODEM_HEADSET_DOWNLINK) { - GetHeadsetDownlinkAOAttr(&sndAttr); + GetHeadsetDownlinkAOAttr(&sndAttr,portTrackCtx); } else { GetBuiltinAOAttr(&sndAttr); } diff --git a/code/sdk/tools/pkg/bin/brandy/bt.bin b/code/sdk/tools/pkg/bin/brandy/bt.bin index 5564865ed..749411053 100755 --- a/code/sdk/tools/pkg/bin/brandy/bt.bin +++ b/code/sdk/tools/pkg/bin/brandy/bt.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6faa308a3591ba1d1743e2fd4ebe9334778acf2fa7fdd7eb8ac434e252ad25f -size 424848 +oid sha256:6d0298cc726fb3ff2290406bf86f52bf9e53c048bdafc71a1b43a0064bbfb708 +size 424904 -- 2.17.1