portTrackCtx->common.GetVolume = AudioBluetoothSubPortTrackGetVolume;
portTrackCtx->common.Invoke = AudioBluetoothSubPortInvoke;
portTrackCtx->common.RegCallback = AudioBluetoothSubPortTrackRegCallback;
- portTrackCtx->isRaw = IsRawFormat(inputAttr->audioFormat);
+ portTrackCtx->isRaw = false;
portTrackCtx->subPortCtx = portCtx;
portTrackCtx->isHandlePublicResource = true;
MEDIA_HAL_LOGD(MODULE_NAME, "success");
#ifdef MINI_MEMORY_SUPPORT
MediaHalMutexLock(portTrackCtx->subPortCtx->a2dpTrackMutex);
int32_t ret = SetPause(portTrackCtx->trackId, true);
- if (ret != MEDIA_HAL_OK) {\r
- MEDIA_HAL_LOGE(MODULE_NAME, " pause track failed");\r
- MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);\r
- return MEDIA_HAL_ERR;\r
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, " pause track failed");
+ MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);
+ return MEDIA_HAL_ERR;
}
portTrackCtx->isHandlePublicResource = IsNeedHandlePublicResource();
// pick up bluetooth voice call when bluetooth music playback
MediaHalMutexLock(portTrackCtx->subPortCtx->a2dpTrackMutex);
portTrackCtx->isHandlePublicResource = IsNeedHandlePublicResource();
int32_t ret = SetPause(portTrackCtx->trackId, false);
- if (ret != MEDIA_HAL_OK) {\r
- MEDIA_HAL_LOGE(MODULE_NAME, " resume track failed");\r
- MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);\r
- return MEDIA_HAL_ERR;\r
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, " resume track failed");
+ MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);
+ return MEDIA_HAL_ERR;
}
// 该判断放在设置状态后面的原因:两路混音场景,第一路恢复播放,需要重新搭建通路,
// 第二路恢复播放,不需要搭建通路,如果判断放在前面,就会直接返回,不会设置状态,
// 因此,当前代码逻辑简单理解,先设置状态,再判断是否搭建通路
ret = AudioSDKOpenInternal(portTrackCtx);
- if (ret != MEDIA_HAL_OK) {\r
- MEDIA_HAL_LOGE(MODULE_NAME, "audio open failed");\r
- MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);\r
- return ret;\r
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, "audio open failed");
+ MediaHalMutexUnLock(portTrackCtx->subPortCtx->a2dpTrackMutex);
+ return ret;
}
ret = AudioSDKAttachInternal(portTrackCtx);
int32_t trackCount = -1;
MediaHalMutexLock(portCtx->a2dpTrackMutex);
int32_t trackId = SubPortGetFreeTrack(&trackCount);
- if (trackId == INVALID_ID) {\r
- MediaHalMutexUnLock(portCtx->a2dpTrackMutex);\r
- return MEDIA_HAL_INVALID_PARAM;\r
+ if (trackId == INVALID_ID) {
+ MediaHalMutexUnLock(portCtx->a2dpTrackMutex);
+ return MEDIA_HAL_INVALID_PARAM;
}
int32_t ret = MEDIA_HAL_ERR;
SubPortTrackContext *portTrackCtx = (SubPortTrackContext *)malloc(sizeof(SubPortTrackContext));
portCtx->portTrack[trackId] = portTrackCtx;
*trackHandle = &portTrackCtx->common;
/* A2dp sink 和 sco 不占用蓝牙资源和aenc,所以这里默认就是暂停的状态 */
- if (portTrackCtx->workScene == BLUETOOTH_IN_A2DP_NORMAL ||\r
+ if (portTrackCtx->workScene == BLUETOOTH_IN_A2DP_NORMAL ||
portTrackCtx->workScene == BLUETOOTH_SCO) {
- SetPause(trackId, true);\r
+ SetPause(trackId, true);
}
MediaHalMutexUnLock(portCtx->a2dpTrackMutex);
return MEDIA_HAL_OK;
/* attr context */
bool isRaw;
struct PortPluginAttr inputAttr;
- } SubPortTrackInContext;
+} SubPortTrackInContext;
typedef struct {
#ifdef AUDIO_SDK_SUPPORT
portTrackInCtx->common.SetVolume = AudioPrimarySubPortInSetVolume;
portTrackInCtx->common.GetVolume = AudioPrimarySubPortInGetVolume;
portTrackInCtx->common.Invoke = AudioPrimarySubPortInInvoke;
- MEDIA_HAL_LOGD(MODULE_NAME, "success");
+ MEDIA_HAL_LOGD(MODULE_NAME, "success");
return MEDIA_HAL_OK;
}
aencAttr.param.interleaved = true;
if (inputAttrTemp.type == AUDIO_IN_MEDIA) {
aencAttr.frame_mode_output = TD_TRUE;
- }
+ }
aencAttr.param.channels = inputAttrTemp.channelCount;
aencAttr.param.bit_depth = inputAttrTemp.bitWidth;
aencAttr.param.sample_rate = inputAttrTemp.sampleRate;
static int32_t EstablishPipeline(td_handle aiHandle, SubPortTrackInContext *portTrackInCtx)
{
int32_t ret;
- portTrackInCtx->isRaw = IsRawFormat(portTrackInCtx->inputAttr.audioFormat);
+ portTrackInCtx->isRaw = IsRawFormat(portTrackInCtx->inputAttr);
if (portTrackInCtx->isRaw) {
ret = AudioSDKAdpOpen(&portTrackInCtx->outputAdpHandle);
CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "output adp open failed");
+#ifdef AUDIO_SEA_SUPPORT
+ ret = AudioSDKSeaOpen(&portTrackInCtx->seaHandle, portTrackInCtx->inputAttr);
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, "sea open failed");
+ goto ADP_CLOSE;
+ }
+ ret = AudioSDKAttach(AUDIO_MOD_AI_SEA, aiHandle, portTrackInCtx->seaHandle);
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, "ai attach sea failed!");
+ goto SEA_CLOSE;
+ }
+ ret = AudioSDKAttach(AUDIO_MOD_SEA, portTrackInCtx->seaHandle, portTrackInCtx->outputAdpHandle);
+ if (ret != MEDIA_HAL_OK) {
+ MEDIA_HAL_LOGE(MODULE_NAME, "sea attach aenc failed");
+ goto AI_DETACH_SEA;
+ }
+#else
ret = AudioSDKAttach(AUDIO_MOD_AI, aiHandle, portTrackInCtx->outputAdpHandle);
if (ret != MEDIA_HAL_OK) {
MEDIA_HAL_LOGE(MODULE_NAME, "ai attach adp failed");
goto ADP_CLOSE;
}
+#endif
} else {
ret = AudioSDKOpenInternal(portTrackInCtx);
CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "AudioSDKOpenInternal failed");
AUDIO_SDK_CLOSE:
(void)AudioSDKCloseInternal(portTrackInCtx);
+#ifdef AUDIO_SEA_SUPPORT
+ if (portTrackInCtx->isRaw) {
+AI_DETACH_SEA:
+ (void)AudioSDKDetach(AUDIO_MOD_AI_SEA, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle);
+SEA_CLOSE:
+ AudioSDKSeaClose(portTrackInCtx->seaHandle);
+#endif
+ }
ADP_CLOSE:
(void)AudioSDKAdpClose(portTrackInCtx->outputAdpHandle);
return ret;
{
#ifdef AUDIO_SDK_SUPPORT
int32_t ret;
-
if (portTrackInCtx->isRaw) {
+#ifdef AUDIO_SEA_SUPPORT
+ 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->outputAdpHandle);
+ CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "sea detach outputAdpHandle failed");
+ ret = AudioSDKSeaClose(portTrackInCtx->seaHandle);
+ CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "sea close failed");
+#else
ret = AudioSDKDetach(AUDIO_MOD_AI, portTrackInCtx->aiHandle, portTrackInCtx->outputAdpHandle);
CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "ai detach adp failed");
+#endif
} else {
#ifdef AUDIO_SEA_SUPPORT
ret = AudioSDKDetach(AUDIO_MOD_AI_SEA, portTrackInCtx->aiHandle, portTrackInCtx->seaHandle);
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
if (!isMultipleSeaOpen()) {
MEDIA_HAL_DOFUNC_TIME(ret = uapi_sea_start(portTrackInCtx->seaHandle));
}
}
#endif
+ if (!portTrackInCtx->isRaw) {
MEDIA_HAL_DOFUNC_TIME(ret = uapi_aenc_start(portTrackInCtx->aencHandle));
if (ret != MEDIA_HAL_OK) {
MEDIA_HAL_LOGI(MODULE_NAME, "uapi_aenc_start failed");
{
#ifdef AUDIO_SDK_SUPPORT
SubPortTrackInContext *portTrackInCtx = (SubPortTrackInContext *)trackHandle;
-
int32_t ret;
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
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
+ if (!portTrackInCtx->isRaw) {
MEDIA_HAL_DOFUNC_TIME(ret = uapi_aenc_stop(portTrackInCtx->aencHandle));
CHK_FAILED_RETURN(ret, MEDIA_HAL_OK, ret, "uapi_aenc_stop failed");
}
MEDIA_HAL_LOGE(MODULE_NAME, "input buffer too small, actual: %llu vs except: %u",
requestBytes, audioStream.size);
return MEDIA_HAL_INVALID_PARAM;
- }
-
+ }
+
if (requestBytes > SIZE_MAX) {
MEDIA_HAL_LOGE(MODULE_NAME, "input buffer size overflow");
return MEDIA_HAL_INVALID_PARAM;
}
-
+
if (memcpy_s(buffer, (size_t)requestBytes, audioStream.data, audioStream.size) != EOK) {
MEDIA_HAL_LOGE(MODULE_NAME, "memcpy_s failed");
return MEDIA_HAL_ERR;
*replyBytes = audioStream.size;
ret = CheckParam(portTrackInCtx, buffer, requestBytes, audioStream);
if (ret != MEDIA_HAL_OK) {
- MEDIA_HAL_LOGE(MODULE_NAME, "param is invalid");
+ MEDIA_HAL_LOGE(MODULE_NAME, "param is invalid");
(void)uapi_adp_release_stream(portTrackInCtx->outputAdpHandle, &audioStream);
return ret;
}
-
+
ret = uapi_adp_release_stream(portTrackInCtx->outputAdpHandle, &audioStream);
if (ret != MEDIA_HAL_OK) {
MEDIA_HAL_LOGE(MODULE_NAME, "release stream failed: 0x%x", ret);
int32_t AudioPrimarySubPortInDestroyTrack(AudioHandle portHandle, AudioHandle trackHandle)
{
#ifdef AUDIO_SDK_SUPPORT
- SubPortTrackInContext *portTrackInCtx = (SubPortTrackInContext *)trackHandle;
+ SubPortInContext *portInCtx = (SubPortInContext *)portHandle;
+ SubPortTrackInContext *portTrackInCtx = (SubPortTrackInContext *)trackHandle;
int32_t ret = AIDetach(portTrackInCtx);
CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "AIDetach failed");
- ret = AIDevClose(portTrackInCtx->aiHandle);
+ ret = AIDevClose(portInCtx->aiHandle);
CHK_FAILED_NO_RETURN(ret, MEDIA_HAL_OK, "AIDevClose failed");
free(portTrackInCtx);