diff --git a/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h b/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h index 97cd5afb53a5a2d0e76578b97f5481aeb36dd9c5..d7b0cbe6f40dc12d4b4e0fed0e2af338acd9d0d7 100644 --- a/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h +++ b/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h @@ -173,6 +173,7 @@ private: DeviceType currentActiveDevice_ = DEVICE_TYPE_NONE; AudioScene currentAudioScene_ = AUDIO_SCENE_INVALID; int32_t currentDevicesSize_ = 0; + bool forceSetRouteFlag_ = false; int32_t paStatus_ = 0; std::string address_ = ""; AdapterType sinkType_ = ADAPTER_TYPE_PRIMARY; diff --git a/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp b/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp index 89c973e8d2ab4690d5620e421e1707e5cbec6c27..235bdbf4c2d745337bf1e55975c3f39331833fd0 100644 --- a/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp +++ b/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp @@ -457,6 +457,9 @@ int32_t AudioRenderSink::SetAudioScene(AudioScene audioScene, std::vectorSelectScene(audioRender_, &sceneDesc); CHECK_AND_RETURN_RET_LOG(ret >= 0, ERR_OPERATION_FAILED, "select scene fail, ret: %{public}d", ret); currentAudioScene_ = audioScene; + if (currentAudioScene_ == AUDIO_SCENE_PHONE_CALL || currentAudioScene_ == AUDIO_SCENE_PHONE_CHAT) { + forceSetRouteFlag_ = true; + } } int32_t ret = UpdateActiveDevice(activeDevices); if (ret != SUCCESS) { @@ -475,10 +478,11 @@ int32_t AudioRenderSink::UpdateActiveDevice(std::vector &outputDevic CHECK_AND_RETURN_RET_LOG(!outputDevices.empty() && outputDevices.size() <= AUDIO_CONCURRENT_ACTIVE_DEVICES_LIMIT, ERR_INVALID_PARAM, "invalid device"); if (currentActiveDevice_ == outputDevices[0] && outputDevices.size() == - static_cast(currentDevicesSize_)) { + static_cast(currentDevicesSize_) && !forceSetRouteFlag_) { AUDIO_INFO_LOG("output device not change, device: %{public}d", outputDevices[0]); return SUCCESS; } + forceSetRouteFlag_ = false; currentActiveDevice_ = outputDevices[0]; currentDevicesSize_ = static_cast(outputDevices.size()); SetAudioRouteInfoForEnhanceChain();