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 69d5c4a19dbde219647ed003d1427b9c35488fb0..12bc8e543800a8a7825fd3815399487295e5ef82 100644 --- a/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h +++ b/frameworks/native/hdiadapter_new/include/sink/audio_render_sink.h @@ -118,6 +118,7 @@ private: void WriteSmartPAStatusSysEvent(int32_t status); void UpdateSinkState(bool started); void WaitForDataLinkConnected(); + void UpdateNearlinkOutputRoute(); private: static constexpr uint32_t AUDIO_CHANNELCOUNT = 2; diff --git a/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp b/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp index 0d57422a395afe528baff471cda27dbbb1a79ab6..f2b929f85340d7d662c266bc634dfbc464936ddb 100644 --- a/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp +++ b/frameworks/native/hdiadapter_new/sink/audio_render_sink.cpp @@ -486,6 +486,7 @@ int32_t AudioRenderSink::SetAudioScene(AudioScene audioScene, bool scoExcludeFla CHECK_AND_RETURN_RET_LOG(ret >= 0, ERR_OPERATION_FAILED, "select scene fail, ret: %{public}d", ret); } bool isRingingToDefaultScene = false; + bool isChangeScene = false; if (audioScene != currentAudioScene_) { if (audioScene == AUDIO_SCENE_PHONE_CALL || audioScene == AUDIO_SCENE_PHONE_CHAT) { forceSetRouteFlag_ = true; @@ -495,6 +496,7 @@ int32_t AudioRenderSink::SetAudioScene(AudioScene audioScene, bool scoExcludeFla isRingingToDefaultScene = true; } currentAudioScene_ = audioScene; + isChangeScene = true; } HdiAdapterManager &manager = HdiAdapterManager::GetInstance(); @@ -502,6 +504,11 @@ int32_t AudioRenderSink::SetAudioScene(AudioScene audioScene, bool scoExcludeFla CHECK_AND_RETURN_RET(deviceManager != nullptr, ERR_INVALID_HANDLE); deviceManager->SetAudioScene(currentAudioScene_); + if (isChangeScene && currentAudioScene_ == AUDIO_SCENE_DEFAULT && + currentActiveDevice_ == DEVICE_TYPE_NEARLINK) { + UpdateNearlinkOutputRoute(); + } + if (isRingingToDefaultScene) { AUDIO_INFO_LOG("ringing scene to default scene"); return SUCCESS; @@ -509,6 +516,14 @@ int32_t AudioRenderSink::SetAudioScene(AudioScene audioScene, bool scoExcludeFla return SUCCESS; } +void AudioRenderSink::UpdateNearlinkOutputRoute(void) +{ + AUDIO_INFO_LOG("update nearlink output route"); + std::vector outputDevices; + outputDevices.push_back(currentActiveDevice_); + DoSetOutputRoute(outputDevices); +} + int32_t AudioRenderSink::GetAudioScene(void) { return currentAudioScene_;