diff --git a/services/audio_policy/server/domain/pipe/src/audio_capturer_session.cpp b/services/audio_policy/server/domain/pipe/src/audio_capturer_session.cpp index eb0b9e0ba17478392cf9e5e47c39f6f41c5f2ed7..08413337a5eac56d7114d203dec81de5188729d6 100644 --- a/services/audio_policy/server/domain/pipe/src/audio_capturer_session.cpp +++ b/services/audio_policy/server/domain/pipe/src/audio_capturer_session.cpp @@ -233,7 +233,7 @@ bool AudioCapturerSession::HandleIndependentInputpipe(const std::vector> &pipeList, uint32_t sessionId, AudioStreamDescriptor &runningSessionInfo, bool &hasSession) { @@ -317,41 +317,15 @@ int32_t AudioCapturerSession::ReloadCaptureSessionSoftLink() { std::lock_guard lock(onCapturerSessionChangedMutex_); hearingAidReloadFlag_ = false; - bool hasSession = false; - auto pipes = AudioPipeManager::GetPipeManager()->GetPipeList(); - if (pipes.empty()) { - AUDIO_ERR_LOG("pipes invalid"); - return ERR_INVALID_OPERATION; - } + + const std::vector> pipes = AudioPipeManager::GetPipeManager()->GetPipeList(); + CHECK_AND_RETURN_RET_LOG(!pipes.empty(), ERR_INVALID_OPERATION, "pipes invalid"); + AudioStreamDescriptor targetStream; - for (auto pipe : pipes) { - if (pipe == nullptr || pipe->streamDescriptors_.empty()) { - AUDIO_WARNING_LOG("pipe invalid"); - continue; - } - if (pipe->pipeRole_ == AudioPipeRole::PIPE_ROLE_OUTPUT || (pipe->routeFlag_ & AUDIO_INPUT_FLAG_FAST) != 0) { - AUDIO_INFO_LOG("ignore pipe for pipeRole_: %{public}d, routeFlag_: %{public}d", - pipe->pipeRole_, pipe->routeFlag_); - continue; - } - for (auto streamDescriptor : pipe->streamDescriptors_) { - if (streamDescriptor == nullptr || - sessionWithNormalSourceType_.find(streamDescriptor->sessionId_) == - sessionWithNormalSourceType_.end()) { - AUDIO_WARNING_LOG("streamDescriptor invalid"); - continue; - } - SourceType higherSourceType = sessionWithNormalSourceType_[streamDescriptor->sessionId_].sourceType; - if (streamDescriptor->streamStatus_ != AudioStreamStatus::STREAM_STATUS_STARTED || - specialSourceTypeSet_.count(higherSourceType) != 0) { - continue; - } - if (IsHigherPrioritySourceType(higherSourceType, targetStream.capturerInfo_.sourceType)) { - hasSession = true; - streamDescriptor->CopyToStruct(targetStream); - } - } - } + + const int32_t softLinkSessionId = 0; + bool hasSession = false; + hasSession = HandleNormalInputPipes(pipes, softLinkSessionId, targetStream, hasSession); CHECK_AND_RETURN_RET_LOG(hasSession, SUCCESS, "no need to reload session"); AUDIO_INFO_LOG("start reload session: %{public}u", targetStream.sessionId_); @@ -365,7 +339,7 @@ int32_t AudioCapturerSession::ReloadCaptureSession(uint32_t sessionId, SessionOp { AUDIO_INFO_LOG("prepare reload session: %{public}u with operation: %{public}d", sessionId, operation); std::lock_guard lock(onCapturerSessionChangedMutex_); - CHECK_AND_RETURN_RET_LOG(!hearingAidReloadFlag_, SUCCESS, "no need to reload session"); + CHECK_AND_RETURN_RET_LOG(!hearingAidReloadFlag_, SUCCESS, "no need to reload session for hearingAid"); uint32_t targetSessionId = sessionId; AudioStreamDescriptor runningSessionInfo = {}; bool needReload = false;