diff --git a/frameworks/native/audioeffect/include/audio_effect_chain.h b/frameworks/native/audioeffect/include/audio_effect_chain.h index f5a8fd498833451c8c9a103fb29fbdeb4c1d9907..eab7c11d789d831c4df9c35e0121270af8ac57e0 100644 --- a/frameworks/native/audioeffect/include/audio_effect_chain.h +++ b/frameworks/native/audioeffect/include/audio_effect_chain.h @@ -58,6 +58,7 @@ public: uint32_t GetLatency(); int32_t UpdateEffectParam(); void ResetIoBufferConfig(); + void SetSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType); private: AudioEffectConfig GetIoBufferConfig(); @@ -80,6 +81,7 @@ private: FILE *dumpFileOutput_ = nullptr; std::string dumpNameIn_ = ""; std::string dumpNameOut_ = ""; + AudioSpatialDeviceType spatialDeviceType_{ EARPHONE_TYPE_OTHERS }; #ifdef SENSOR_ENABLE std::shared_ptr headTracker_; diff --git a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h index 3de79618fcdb9a9480f93dc9612f2151072735a3..3292ce93739ba53f4aa336a83bb62c2206734a09 100644 --- a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h +++ b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h @@ -112,6 +112,7 @@ public: int32_t UpdateMultichannelConfig(const std::string &sceneType); int32_t InitAudioEffectChainDynamic(const std::string &sceneType); int32_t UpdateSpatializationState(AudioSpatializationState spatializationState); + int32_t UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType); int32_t SetHdiParam(const std::string &sceneType, const std::string &effectMode, bool enabled); int32_t SessionInfoMapAdd(const std::string &sessionID, const SessionEffectInfo &info); int32_t SessionInfoMapDelete(const std::string &sceneType, const std::string &sessionID); @@ -187,6 +188,7 @@ private: bool isCommonEffectChainExisted_ = false; bool debugArmFlag_ = false; int32_t commonEffectChainCount_ = 0; + AudioSpatialDeviceType spatialDeviceType_{ EARPHONE_TYPE_OTHERS }; #ifdef SENSOR_ENABLE std::shared_ptr headTracker_; diff --git a/frameworks/native/audioeffect/src/audio_effect_chain.cpp b/frameworks/native/audioeffect/src/audio_effect_chain.cpp index eeb3dff1c3945ca5b2c6b8101ace94e750fb8a94..177def2d1e7a8ce3f93726c996571ebfb9627b47 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace AudioStandard { -const uint32_t NUM_SET_EFFECT_PARAM = 6; +const uint32_t NUM_SET_EFFECT_PARAM = 7; const uint32_t DEFAULT_SAMPLE_RATE = 48000; const uint32_t DEFAULT_NUM_CHANNEL = STEREO; const uint64_t DEFAULT_NUM_CHANNELLAYOUT = CH_LAYOUT_STEREO; @@ -150,39 +150,41 @@ int32_t AudioEffectChain::SetEffectParamToHandle(AudioEffectHandle handle, int32 { AudioEffectTransInfo cmdInfo = {sizeof(AudioEffectConfig), &ioBufferConfig_}; AudioEffectTransInfo replyInfo = {sizeof(int32_t), &replyData}; + std::vector paramBuffer(sizeof(AudioEffectParam) + NUM_SET_EFFECT_PARAM * sizeof(int32_t)); // Set param - AudioEffectParam *effectParam = - new AudioEffectParam[sizeof(AudioEffectParam) + NUM_SET_EFFECT_PARAM * sizeof(int32_t)]; + AudioEffectParam *effectParam = reinterpret_cast(paramBuffer.data()); effectParam->status = 0; effectParam->paramSize = sizeof(int32_t); effectParam->valueSize = 0; int32_t *data = &(effectParam->data[0]); - *data++ = EFFECT_SET_PARAM; - *data++ = static_cast(currSceneType_); - *data++ = GetKeyFromValue(AUDIO_SUPPORTED_SCENE_MODES, effectMode_); + data[0] = EFFECT_SET_PARAM; + data[1] = static_cast(currSceneType_); + AUDIO_DEBUG_LOG("set ap integration scene type: %{public}d", data[1]); + data[2] = GetKeyFromValue(AUDIO_SUPPORTED_SCENE_MODES, effectMode_); // 2:effect mode index #ifdef WINDOW_MANAGER_ENABLE std::shared_ptr audioEffectRotation = AudioEffectRotation::GetInstance(); if (audioEffectRotation == nullptr) { - *data++ = 0; + data[3] = 0; // 3:rotation index } else { - *data++ = audioEffectRotation->GetRotation(); + data[3] = audioEffectRotation->GetRotation(); // 3:rotation index } #else - *data++ = 0; + data[3] = 0; // 3:rotation index #endif - AUDIO_DEBUG_LOG("set ap integration rotation: %{public}u", *(data - 1)); + AUDIO_DEBUG_LOG("set ap integration rotation: %{public}d", data[3]); // 3:rotation index std::shared_ptr audioEffectVolume = AudioEffectVolume::GetInstance(); if (audioEffectVolume == nullptr) { - *data++ = 0; + data[4] = 0; // 4:volume index } else { - *data++ = audioEffectVolume->GetApVolume(sceneType_); + data[4] = audioEffectVolume->GetApVolume(sceneType_); // 4:volume index } - AUDIO_DEBUG_LOG("set ap integration volume: %{public}u", *(data - 1)); - *data++ = extraEffectChainType_; - AUDIO_DEBUG_LOG("set scene type: %{public}d", extraEffectChainType_); + AUDIO_DEBUG_LOG("set ap integration volume: %{public}d", data[4]); // 4:volume index + data[5] = extraEffectChainType_; // 5:extra effect chain type index + AUDIO_DEBUG_LOG("set extra effect chain type: %{public}d", extraEffectChainType_); + data[6] = spatialDeviceType_; // 6:spatial device type index + AUDIO_DEBUG_LOG("set ap integration spatial device type: %{public}d", data[6]); // 6:spatial device type index cmdInfo = {sizeof(AudioEffectParam) + sizeof(int32_t) * NUM_SET_EFFECT_PARAM, effectParam}; int32_t ret = (*handle)->command(handle, EFFECT_CMD_SET_PARAM, &cmdInfo, &replyInfo); - delete[] effectParam; return ret; } @@ -397,5 +399,12 @@ void AudioEffectChain::InitEffectChain() sceneType_.c_str(), effectMode_.c_str()); } } + +void AudioEffectChain::SetSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) +{ + spatialDeviceType_ = spatialDeviceType; + + return; +} } // namespace AudioStandard } // namespace OHOS diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index 9f92cbc12fc5942727f46973d7f941a2ad481bb5..55362de0b4d5b75c9713b05ecef123806ca31041 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -91,6 +91,7 @@ AudioEffectChainManager::AudioEffectChainManager() SceneTypeToEffectChainCountBackupMap_.clear(); deviceType_ = DEVICE_TYPE_SPEAKER; deviceSink_ = DEFAULT_DEVICE_SINK; + spatialDeviceType_ = EARPHONE_TYPE_OTHERS; isInitialized_ = false; #ifdef SENSOR_ENABLE @@ -380,6 +381,7 @@ int32_t AudioEffectChainManager::SetAudioEffectChainDynamic(const std::string &s audioEffectChain->SetEffectMode(effectMode); audioEffectChain->SetExtraSceneType(extraSceneType_); + audioEffectChain->SetSpatialDeviceType(spatialDeviceType_); for (std::string effect: EffectChainToEffectsMap_[effectChain]) { AudioEffectHandle handle = nullptr; AudioEffectDescriptor descriptor; @@ -755,6 +757,32 @@ int32_t AudioEffectChainManager::UpdateSpatializationState(AudioSpatializationSt return SUCCESS; } +int32_t AudioEffectChainManager::UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) +{ + int32_t ret{ SUCCESS }; + spatialDeviceType_ = spatialDeviceType; + + effectHdiInput_[0] = HDI_UPDATE_SPATIAL_DEVICE_TYPE; + effectHdiInput_[1] = spatialDeviceType_; + AUDIO_INFO_LOG("set hdi spatialDeviceType: %{public}d", effectHdiInput_[1]); + ret = audioEffectHdiParam_->UpdateHdiState(effectHdiInput_, DEVICE_TYPE_BLUETOOTH_A2DP); + if (ret != SUCCESS) { + AUDIO_WARNING_LOG("set hdi update spatial device type failed"); + } + + std::lock_guard lock(dynamicMutex_); + for (auto& sceneType2EffectChain : SceneTypeToEffectChainMap_) { + auto audioEffectChain = sceneType2EffectChain.second; + if (audioEffectChain != nullptr) { + audioEffectChain->SetSpatialDeviceType(spatialDeviceType_); + ret = audioEffectChain->UpdateEffectParam(); + CHECK_AND_CONTINUE_LOG(ret == SUCCESS, "UpdateEffectParam failed."); + } + } + + return SUCCESS; +} + int32_t AudioEffectChainManager::ReturnEffectChannelInfo(const std::string &sceneType, uint32_t &channels, uint64_t &channelLayout) { diff --git a/interfaces/inner_api/native/audiocommon/include/audio_effect.h b/interfaces/inner_api/native/audiocommon/include/audio_effect.h index 9b5caddcf16fca03254425e261c35bc8250736a8..1f8881d0bf47d4ca0c127f1a3788ab96f580b503 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_effect.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_effect.h @@ -41,12 +41,15 @@ constexpr int32_t AUDIO_EFFECT_COUNT_PER_CHAIN_UPPER_LIMIT = 16; // max num of e constexpr int32_t HDI_EFFECT_NUM = 2; constexpr int32_t HDI_SET_PATAM = 6; + constexpr int32_t HDI_INIT = 0; constexpr int32_t HDI_BYPASS = 1; constexpr int32_t HDI_HEAD_MODE = 2; constexpr int32_t HDI_ROOM_MODE = 3; constexpr int32_t HDI_BLUETOOTH_MODE = 4; constexpr int32_t HDI_DESTROY = 5; +constexpr int32_t HDI_UPDATE_SPATIAL_DEVICE_TYPE = 6; + constexpr int32_t HDI_VOLUME = 7; constexpr int32_t HDI_ROTATION = 8; @@ -353,4 +356,4 @@ struct AudioRendererInfoForSpatialization { } // namespace AudioStandard } // namespace OHOS -#endif //AUDIO_FRAMEWORK_AUDIO_EFFECT_H \ No newline at end of file +#endif // AUDIO_FRAMEWORK_AUDIO_EFFECT_H \ No newline at end of file diff --git a/services/audio_policy/server/include/service/spatialization/audio_spatialization_service.h b/services/audio_policy/server/include/service/spatialization/audio_spatialization_service.h index cd7b13d972b792b1f625e5b982d94e9115476918..74a5435f712c7d004cca138f07ec7566dcf8d8a5 100644 --- a/services/audio_policy/server/include/service/spatialization/audio_spatialization_service.h +++ b/services/audio_policy/server/include/service/spatialization/audio_spatialization_service.h @@ -84,6 +84,7 @@ private: int32_t UpdateSpatializationStateReal(bool outputDeviceChange, std::string preDeviceAddress = ""); int32_t UpdateSpatializationState(); int32_t UpdateSpatializationSceneType(); + void UpdateSpatialDeviceType(AudioSpatialDeviceType audioSpatialDeviceType); void HandleSpatializationStateChange(bool outputDeviceChange); void WriteSpatializationStateToDb(WriteToDbOperation operation); bool IsHeadTrackingDataRequestedForCurrentDevice(); @@ -99,6 +100,7 @@ private: bool isLoadedfromDb_ = false; AudioSpatializationState spatializationStateFlag_ = {false}; AudioSpatializationSceneType spatializationSceneType_ = SPATIALIZATION_SCENE_TYPE_DEFAULT; + AudioSpatialDeviceType currSpatialDeviceType_{ EARPHONE_TYPE_OTHERS }; std::vector spatializationRendererInfoList_; std::mutex spatializationServiceMutex_; std::mutex spatializationSupportedMutex_; diff --git a/services/audio_policy/server/src/service/spatialization/audio_spatialization_service.cpp b/services/audio_policy/server/src/service/spatialization/audio_spatialization_service.cpp index 1033db2f4700fbb36448105fc7714576e9b946b3..73dcef00dbb4bde098006df6a3e190a259cedd84 100644 --- a/services/audio_policy/server/src/service/spatialization/audio_spatialization_service.cpp +++ b/services/audio_policy/server/src/service/spatialization/audio_spatialization_service.cpp @@ -222,7 +222,9 @@ bool AudioSpatializationService::IsHeadTrackingSupportedForDevice(const std::str int32_t AudioSpatializationService::UpdateSpatialDeviceState(const AudioSpatialDeviceState audioSpatialDeviceState) { - AUDIO_INFO_LOG("UpdateSpatialDeviceState Entered"); + AUDIO_INFO_LOG("UpdateSpatialDeviceState Entered, " + "isSpatializationSupported = %{public}d, isHeadTrackingSupported = %{public}d", + audioSpatialDeviceState.isSpatializationSupported, audioSpatialDeviceState.isHeadTrackingSupported); { std::lock_guard lock(spatializationSupportedMutex_); if (addressToSpatialDeviceStateMap_.count(audioSpatialDeviceState.address) > 0 && @@ -234,6 +236,13 @@ int32_t AudioSpatializationService::UpdateSpatialDeviceState(const AudioSpatialD addressToSpatialDeviceStateMap_[audioSpatialDeviceState.address] = audioSpatialDeviceState; } + AUDIO_INFO_LOG("currSpatialDeviceType_ = %{public}d, nextSpatialDeviceType_ = %{public}d", + currSpatialDeviceType_, audioSpatialDeviceState.spatialDeviceType); + if (audioSpatialDeviceState.spatialDeviceType != currSpatialDeviceType_) { + UpdateSpatialDeviceType(audioSpatialDeviceState.spatialDeviceType); + currSpatialDeviceType_ = audioSpatialDeviceState.spatialDeviceType; + } + std::lock_guard lock(spatializationServiceMutex_); if (UpdateSpatializationStateReal(false) != 0) { return ERROR; @@ -277,6 +286,24 @@ void AudioSpatializationService::UpdateCurrentDevice(const std::string macAddres } std::string preDeviceAddress = currentDeviceAddress_; currentDeviceAddress_ = macAddress; + + if (addressToSpatialDeviceStateMap_.find(currentDeviceAddress_) != addressToSpatialDeviceStateMap_.end()) { + auto nextSpatialDeviceType{ addressToSpatialDeviceStateMap_[currentDeviceAddress_].spatialDeviceType }; + AUDIO_INFO_LOG("currSpatialDeviceType_ = %{public}d, nextSpatialDeviceType_ = %{public}d", + currSpatialDeviceType_, nextSpatialDeviceType); + if (nextSpatialDeviceType != currSpatialDeviceType_) { + UpdateSpatialDeviceType(nextSpatialDeviceType); + currSpatialDeviceType_ = nextSpatialDeviceType; + } + } else { + AUDIO_INFO_LOG("currSpatialDeviceType_ = %{public}d, nextSpatialDeviceType_ = %{public}d", + currSpatialDeviceType_, EARPHONE_TYPE_NONE); + if (currSpatialDeviceType_ != EARPHONE_TYPE_NONE) { + UpdateSpatialDeviceType(EARPHONE_TYPE_NONE); + currSpatialDeviceType_ = EARPHONE_TYPE_NONE; + } + } + if (UpdateSpatializationStateReal(true, preDeviceAddress) != 0) { AUDIO_WARNING_LOG("UpdateSpatializationStateReal fail"); } @@ -383,6 +410,19 @@ int32_t AudioSpatializationService::UpdateSpatializationSceneType() return SPATIALIZATION_SERVICE_OK; } +void AudioSpatializationService::UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) +{ + const sptr gsp = GetAudioServerProxy(); + CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable: g_adProxy null"); + + std::string identity = IPCSkeleton::ResetCallingIdentity(); + int32_t ret = gsp->UpdateSpatialDeviceType(spatialDeviceType); + IPCSkeleton::SetCallingIdentity(identity); + CHECK_AND_RETURN_LOG(ret == 0, "AudioSpatializationService::UpdateSpatialDeviceType fail"); + + return; +} + void AudioSpatializationService::HandleSpatializationStateChange(bool outputDeviceChange) { AUDIO_INFO_LOG("Spatialization State callback is triggered"); diff --git a/services/audio_service/client/include/audio_manager_base.h b/services/audio_service/client/include/audio_manager_base.h index d193c4ffdc807d9cb9b9cbcca3e29e9d779258b6..d4a9d3cbbc92150e66f558a6a72918888e47c50d 100644 --- a/services/audio_service/client/include/audio_manager_base.h +++ b/services/audio_service/client/include/audio_manager_base.h @@ -359,6 +359,15 @@ public: */ virtual int32_t UpdateSpatializationState(AudioSpatializationState spatializationState) = 0; + /** + * Update spatial device type. + * + * @param spatialDeviceType identify the spatial device type. + * + * @return result of setting. 0 if success, error number else. + */ + virtual int32_t UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) = 0; + /** * Notify Stream volume changed. * @@ -467,6 +476,7 @@ private: int HandleSetWakeupSourceCallback(MessageParcel &data, MessageParcel &reply); int HandleSetCaptureSilentState(MessageParcel &data, MessageParcel &reply); int HandleUpdateSpatializationState(MessageParcel &data, MessageParcel &reply); + int HandleUpdateSpatialDeviceType(MessageParcel& data, MessageParcel& reply); int HandleOffloadSetVolume(MessageParcel &data, MessageParcel &reply); int HandleNotifyStreamVolumeChanged(MessageParcel &data, MessageParcel &reply); int HandleSetSpatializationSceneType(MessageParcel &data, MessageParcel &reply); diff --git a/services/audio_service/client/include/audio_manager_proxy.h b/services/audio_service/client/include/audio_manager_proxy.h index 47b0734ac3f23361ab32d3b40a6558efa1fc81b4..c404c7b29ef26fa0786089adf88136b5c30a0598 100644 --- a/services/audio_service/client/include/audio_manager_proxy.h +++ b/services/audio_service/client/include/audio_manager_proxy.h @@ -69,6 +69,7 @@ public: int32_t RegiestPolicyProvider(const sptr &object) override; int32_t SetCaptureSilentState(bool state) override; int32_t UpdateSpatializationState(AudioSpatializationState spatializationState) override; + int32_t UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) override; int32_t NotifyStreamVolumeChanged(AudioStreamType streamType, float volume) override; int32_t SetSpatializationSceneType(AudioSpatializationSceneType spatializationSceneType) override; int32_t ResetRouteForDisconnect(DeviceType type) override; diff --git a/services/audio_service/client/include/pulseaudio_ipc_interface_code.h b/services/audio_service/client/include/pulseaudio_ipc_interface_code.h index 94b5033f97d8eb74758d6e7d2a029ed8bfd0e9ea..f3eb2f37c572a77efd757d24abd0e5290276e2a3 100644 --- a/services/audio_service/client/include/pulseaudio_ipc_interface_code.h +++ b/services/audio_service/client/include/pulseaudio_ipc_interface_code.h @@ -51,6 +51,7 @@ namespace AudioStandard { SET_WAKEUP_CLOSE_CALLBACK, SET_CAPTURE_SILENT_STATE, UPDATE_SPATIALIZATION_STATE, + UPDATE_SPATIAL_DEVICE_TYPE, OFFLOAD_SET_VOLUME, NOTIFY_STREAM_VOLUME_CHANGED, SET_SPATIALIZATION_SCENE_TYPE, diff --git a/services/audio_service/client/src/audio_manager_proxy.cpp b/services/audio_service/client/src/audio_manager_proxy.cpp index 22c54d7eedfb136481c7b33f4083214cc498059f..a87f6b58e0bcbbcad11077b9c79e922387459b75 100644 --- a/services/audio_service/client/src/audio_manager_proxy.cpp +++ b/services/audio_service/client/src/audio_manager_proxy.cpp @@ -877,6 +877,24 @@ int32_t AudioManagerProxy::UpdateSpatializationState(AudioSpatializationState sp return reply.ReadInt32(); } +int32_t AudioManagerProxy::UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) +{ + int32_t error; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); + data.WriteInt32(spatialDeviceType); + + error = Remote()->SendRequest( + static_cast(AudioServerInterfaceCode::UPDATE_SPATIAL_DEVICE_TYPE), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "UpdateSpatialDeviceType failed, error: %{public}d", error); + + return reply.ReadInt32(); +} + int32_t AudioManagerProxy::SetSpatializationSceneType(AudioSpatializationSceneType spatializationSceneType) { int32_t error; diff --git a/services/audio_service/server/include/audio_server.h b/services/audio_service/server/include/audio_server.h index 01fb5e99db22709cea6e843d3cd77b084413187a..8afbdcab9a4132061a6903b177b4f4aae6008e99 100644 --- a/services/audio_service/server/include/audio_server.h +++ b/services/audio_service/server/include/audio_server.h @@ -122,6 +122,8 @@ public: int32_t UpdateSpatializationState(AudioSpatializationState spatializationState) override; + int32_t UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) override; + int32_t NotifyStreamVolumeChanged(AudioStreamType streamType, float volume) override; int32_t SetSpatializationSceneType(AudioSpatializationSceneType spatializationSceneType) override; diff --git a/services/audio_service/server/src/audio_manager_stub.cpp b/services/audio_service/server/src/audio_manager_stub.cpp index 54a93c25842a405778341fe32e497477b8dc4e0b..0ee8e6455b520a97f14de272159afba7cf6a37b9 100644 --- a/services/audio_service/server/src/audio_manager_stub.cpp +++ b/services/audio_service/server/src/audio_manager_stub.cpp @@ -60,6 +60,7 @@ const char *g_audioServerCodeStrs[] = { "SET_WAKEUP_CLOSE_CALLBACK", "SET_CAPTURE_SILENT_STATE", "UPDATE_SPATIALIZATION_STATE", + "UPDATE_SPATIAL_DEVICE_TYPE", "OFFLOAD_SET_VOLUME", "NOTIFY_STREAM_VOLUME_CHANGED", "SET_SPATIALIZATION_SCENE_TYPE", @@ -561,6 +562,14 @@ int AudioManagerStub::HandleUpdateSpatializationState(MessageParcel &data, Messa return AUDIO_OK; } +int AudioManagerStub::HandleUpdateSpatialDeviceType(MessageParcel& data, MessageParcel& reply) +{ + AudioSpatialDeviceType spatialDeviceType = static_cast(data.ReadInt32()); + int32_t ret = UpdateSpatialDeviceType(spatialDeviceType); + reply.WriteInt32(ret); + return AUDIO_OK; +} + int AudioManagerStub::HandleOffloadSetVolume(MessageParcel &data, MessageParcel &reply) { const float volume = data.ReadFloat(); @@ -747,6 +756,8 @@ int AudioManagerStub::HandleSecondPartCode(uint32_t code, MessageParcel &data, M return HandleSetCaptureSilentState(data, reply); case static_cast(AudioServerInterfaceCode::UPDATE_SPATIALIZATION_STATE): return HandleUpdateSpatializationState(data, reply); + case static_cast(AudioServerInterfaceCode::UPDATE_SPATIAL_DEVICE_TYPE): + return HandleUpdateSpatialDeviceType(data, reply); case static_cast(AudioServerInterfaceCode::OFFLOAD_SET_VOLUME): return HandleOffloadSetVolume(data, reply); default: diff --git a/services/audio_service/server/src/audio_server.cpp b/services/audio_service/server/src/audio_server.cpp index d21b0c67145ca82bee9b38f976f4b6dc255125ca..d4386400c468d2b9658aae274d86ffc3fd063def 100644 --- a/services/audio_service/server/src/audio_server.cpp +++ b/services/audio_service/server/src/audio_server.cpp @@ -1924,6 +1924,17 @@ int32_t AudioServer::UpdateSpatializationState(AudioSpatializationState spatiali return audioEffectChainManager->UpdateSpatializationState(spatializationState); } +int32_t AudioServer::UpdateSpatialDeviceType(AudioSpatialDeviceType spatialDeviceType) +{ + int32_t callingUid = IPCSkeleton::GetCallingUid(); + CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifyIsAudio(), ERR_NOT_SUPPORTED, "refused for %{public}d", callingUid); + + AudioEffectChainManager *audioEffectChainManager = AudioEffectChainManager::GetInstance(); + CHECK_AND_RETURN_RET_LOG(audioEffectChainManager != nullptr, ERROR, "audioEffectChainManager is nullptr"); + + return audioEffectChainManager->UpdateSpatialDeviceType(spatialDeviceType); +} + int32_t AudioServer::NotifyStreamVolumeChanged(AudioStreamType streamType, float volume) { int32_t callingUid = IPCSkeleton::GetCallingUid();