From: hcj <1224667075@qq.com> Date: Wed, 26 Nov 2025 13:38:44 +0000 (+0800) Subject: VAD参数修改 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=11751bd97ec31d784770ca05692de94c18e9501c;p=mirrors%2FFD230.git VAD参数修改 --- diff --git a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c index 116174b5e..da2a6614e 100644 --- a/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c +++ b/code/sdk/middleware/services/media/hal/audio/plugins/brandy/primary/primary_sub_port_in.c @@ -104,6 +104,14 @@ static SubPortTrackInCapabilities g_caps[] = { { AUDIO_IN_COMMUNICATION, AUDIO_FORMAT_MP3, 16000, 1 }, }; +static bool isMultipleAIOpen(void) +{ + MediaHalMutexLock(g_subPortTrackInLock); + bool ret = g_subPortTrackInOpened > 1; + MediaHalMutexUnLock(g_subPortTrackInLock); + return ret; +} + static bool IsSupported(const struct PortPluginAttr *inputAttr) { for (uint32_t i = 0; i < ARRAY_SIZE(g_caps); i++) { @@ -191,7 +199,7 @@ static int32_t AIDevOpen(td_handle *aiHandle, enum AudioCategory audioCategory) MediaHalMutexUnLock(g_subPortTrackInLock); return ret; } - uapi_ai_gain gain = {}; +uapi_ai_gain gain = {}; MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_get_volume(*aiHandle, &gain)); CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_get_volume failed"); #ifdef BOARD_FD230 @@ -199,7 +207,7 @@ static int32_t AIDevOpen(td_handle *aiHandle, enum AudioCategory audioCategory) #elif defined(BORAD_N9) || defined(BORAD_W9) gain.integer = gain.integer + 10; // 前端mic灵敏度不同可通过此处调增,增加4db增益 默认gain.integer = gain.integer+4 #elif defined(LEINIAO) - gain.integer = gain.integer -15; // 前端mic灵敏度不同可通过此处调增,增加4db增益 默认gain.integer = gain.integer+4 + gain.integer = gain.integer + 8; // 前端mic灵敏度不同可通过此处调增,增加4db增益 默认gain.integer = gain.integer+4 #endif MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_set_volume(*aiHandle, &gain)); CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_set_volume failed"); @@ -320,7 +328,7 @@ static int32_t AudioSDKCloseInternal(SubPortTrackInContext *portTrackInCtx) static int32_t AudioSDKAttachInternal(td_handle aiHandle, SubPortTrackInContext *portTrackInCtx) { #ifdef AUDIO_SEA_SUPPORT - int32_t ret = AudioSDKAttach(AUDIO_MOD_AI, aiHandle, portTrackInCtx->seaHandle); + int32_t ret = AudioSDKAttach(AUDIO_MOD_AI_SEA, aiHandle, portTrackInCtx->seaHandle); CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "ai attach sea failed"); ret = AudioSDKAttach(AUDIO_MOD_SEA, portTrackInCtx->seaHandle, portTrackInCtx->aencHandle); @@ -349,7 +357,7 @@ static int32_t AudioSDKAttachInternal(td_handle aiHandle, SubPortTrackInContext SEA_DETACH_AENC: (void)AudioSDKDetach(AUDIO_MOD_SEA, portTrackInCtx->seaHandle, portTrackInCtx->aencHandle); AI_DETACH_SEA: - (void)AudioSDKDetach(AUDIO_MOD_AI, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle); + (void)AudioSDKDetach(AUDIO_MOD_AI_SEA, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle); #else AI_DETACH_AENC: (void)AudioSDKDetach(AUDIO_MOD_AI, portTrackInCtx->aiHandle, portTrackInCtx->aencHandle); @@ -403,7 +411,7 @@ static int32_t AIDetach(const SubPortTrackInContext *portTrackInCtx) CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "ai detach adp failed"); } else { #ifdef AUDIO_SEA_SUPPORT - ret = AudioSDKDetach(AUDIO_MOD_AI, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle); + ret = AudioSDKDetach(AUDIO_MOD_AI_SEA, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle); CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "ai detach sea failed"); ret = AudioSDKDetach(AUDIO_MOD_SEA, portTrackInCtx->seaHandle, portTrackInCtx->aencHandle); CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "sea detach aenc failed"); @@ -444,17 +452,19 @@ int32_t AudioPrimarySubPortInEnableTrack(AudioHandle trackHandle) { #ifdef AUDIO_SDK_SUPPORT SubPortTrackInContext *portTrackInCtx = (SubPortTrackInContext *)trackHandle; - - int32_t ret; - MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_start(portTrackInCtx->aiHandle)); - CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_start failed"); - + int32_t ret = MEDIA_HAL_OK; + if (!isMultipleAIOpen()) { + MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_start(portTrackInCtx->aiHandle)); + CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_start failed"); + } if (!portTrackInCtx->isRaw) { #ifdef AUDIO_SEA_SUPPORT - MEDIA_HAL_DOFUNC_TIME(ret = uapi_sea_start(portTrackInCtx->seaHandle)); - if (ret != MEDIA_HAL_OK) { - MEDIA_HAL_LOGI(MODULE_NAME, "uapi_sea_start failed"); - goto AI_STOP; + if (!isMultipleSeaOpen()) { + MEDIA_HAL_DOFUNC_TIME(ret = uapi_sea_start(portTrackInCtx->seaHandle)); + if (ret != MEDIA_HAL_OK) { + MEDIA_HAL_LOGI(MODULE_NAME, "uapi_sea_start failed"); + goto AI_STOP; + } } #endif MEDIA_HAL_DOFUNC_TIME(ret = uapi_aenc_start(portTrackInCtx->aencHandle)); @@ -489,13 +499,17 @@ int32_t AudioPrimarySubPortInDisableTrack(AudioHandle trackHandle) SubPortTrackInContext *portTrackInCtx = (SubPortTrackInContext *)trackHandle; int32_t ret; - MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_stop(portTrackInCtx->aiHandle)); - CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_stop failed"); + if (!isMultipleAIOpen()) { + MEDIA_HAL_DOFUNC_TIME(ret = uapi_ai_stop(portTrackInCtx->aiHandle)); + CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_ai_stop failed"); + } if (!portTrackInCtx->isRaw) { #ifdef AUDIO_SEA_SUPPORT - MEDIA_HAL_DOFUNC_TIME(ret = uapi_sea_stop(portTrackInCtx->seaHandle)); - CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_sea_stop failed"); + if (!isMultipleSeaOpen()) { + MEDIA_HAL_DOFUNC_TIME(ret = uapi_sea_stop(portTrackInCtx->seaHandle)); + CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_sea_stop failed"); + } #endif MEDIA_HAL_DOFUNC_TIME(ret = uapi_aenc_stop(portTrackInCtx->aencHandle)); CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_aenc_stop failed");