{ 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++) {
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
#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");
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);
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);
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");
{
#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));
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");