From 3595d4b339b37256da301d649e7a40534c744ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Wed, 5 Feb 2025 16:17:03 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../include/audio_effect_chain_manager.h | 6 ++ .../audioeffect/libaudio_effect.versionscript | 1 + .../src/audio_effect_chain_manager.cpp | 61 +++++++++++++++---- .../src/audio_enhance_chain_manager.cpp | 8 ++- .../service/service/audio_server_proxy.h | 1 + .../src/service/audio_policy_service.cpp | 1 + .../manager/volume_data_maintainer.cpp | 1 + .../service/service/audio_server_proxy.cpp | 9 +++ .../client/include/audio_manager_base.h | 3 + .../client/include/audio_manager_proxy.h | 1 + .../include/pulseaudio_ipc_interface_code.h | 1 + .../client/src/audio_manager_proxy.cpp | 11 ++++ .../server/include/audio_server.h | 2 + .../server/src/audio_manager_stub.cpp | 9 +++ .../server/src/audio_server_effect.cpp | 8 +++ 15 files changed, 107 insertions(+), 16 deletions(-) diff --git a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h index 00d96946b5..598f29b861 100644 --- a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h +++ b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h @@ -112,6 +112,9 @@ public: void InitAudioEffectChainManager(std::vector &effectChains, const EffectChainManagerParam &effectChainManagerParam, std::vector> &effectLibraryList); + void ConstructEffectChainMgrMaps(std::vector &effectChains, + const EffectChainManagerParam &effectChainManagerParam, + std::vector> &effectLibraryList); bool CheckAndAddSessionID(const std::string &sessionID); int32_t CreateAudioEffectChainDynamic(const std::string &sceneType); bool CheckAndRemoveSessionID(const std::string &sessionID); @@ -150,6 +153,7 @@ public: int32_t InitEffectBuffer(const std::string &sessionID); int32_t QueryEffectChannelInfo(const std::string &sceneType, uint32_t &channels, uint64_t &channelLayout); int32_t QueryHdiSupportedChannelInfo(uint32_t &channels, uint64_t &channelLayout); + void LoadEffectProperties(); private: int32_t SetAudioEffectChainDynamic(const std::string &sceneType, const std::string &effectMode); void UpdateSensorState(); @@ -207,6 +211,7 @@ private: std::set sceneTypeToSpecialEffectSet_; std::vector priorSceneList_; std::unordered_map effectPropertyMap_; + std::unordered_map defaultPropertyMap_; std::vector> sceneTypeCountList_; DeviceType deviceType_ = DEVICE_TYPE_SPEAKER; std::string deviceSink_ = DEFAULT_DEVICE_SINK; @@ -230,6 +235,7 @@ private: int32_t maxEffectChainCount_ = 1; uint32_t maxSessionID_ = 0; AudioSpatialDeviceType spatialDeviceType_{ EARPHONE_TYPE_OTHERS }; + bool hasLoadedEffectProperties_ = false; #ifdef SENSOR_ENABLE std::shared_ptr headTracker_; diff --git a/frameworks/native/audioeffect/libaudio_effect.versionscript b/frameworks/native/audioeffect/libaudio_effect.versionscript index 48fed5a7af..1f74ea8f0d 100644 --- a/frameworks/native/audioeffect/libaudio_effect.versionscript +++ b/frameworks/native/audioeffect/libaudio_effect.versionscript @@ -76,6 +76,7 @@ *EnhanceChainManagerSendInitCommand*; *InitEffectBuffer*; *EffectChainManagerQueryHdiSupportedChannelLayout*; + *LoadEffectProperties*; local: *; }; diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index a36ef729bf..f3d2c6ecd8 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -21,9 +21,16 @@ #include "audio_errors.h" #include "audio_effect_log.h" #include "securec.h" +#include "system_ability_definition.h" +#include "audio_setting_provider.h" namespace OHOS { namespace AudioStandard { +namespace { +const std::unordered_map AUDIO_PERSISTENCE_EFFECT_KEY { + {"voip_down", "settings.sound_ai_voip_down_selection"}, +}; +} static int32_t CheckValidEffectLibEntry(const std::shared_ptr &libEntry, const std::string &effect, const std::string &libName) { @@ -81,7 +88,7 @@ AudioEffectChainManager::AudioEffectChainManager() deviceSink_ = DEFAULT_DEVICE_SINK; spatialDeviceType_ = EARPHONE_TYPE_OTHERS; isInitialized_ = false; - + defaultPropertyMap_.clear(); #ifdef SENSOR_ENABLE headTracker_ = std::make_shared(); #endif @@ -230,16 +237,31 @@ void AudioEffectChainManager::InitAudioEffectChainManager(std::vector> &effectLibraryList) { std::lock_guard lock(dynamicMutex_); - const std::unordered_map &map = effectChainManagerParam.sceneTypeToChainNameMap; maxEffectChainCount_ = effectChainManagerParam.maxExtraNum + 1; priorSceneList_ = effectChainManagerParam.priorSceneList; + ConstructEffectChainMgrMaps(effectChains, effectChainManagerParam, effectLibraryList); + AUDIO_INFO_LOG("EffectToLibraryEntryMap size %{public}zu", effectToLibraryEntryMap_.size()); + AUDIO_DEBUG_LOG("EffectChainToEffectsMap size %{public}zu, SceneTypeAndModeToEffectChainNameMap size %{public}zu", + effectChainToEffectsMap_.size(), sceneTypeAndModeToEffectChainNameMap_.size()); + InitHdiStateInner(); +#ifdef WINDOW_MANAGER_ENABLE + AUDIO_DEBUG_LOG("Call RegisterDisplayListener."); +#endif + isInitialized_ = true; + RecoverAllChains(); +} + +void AudioEffectChainManager::ConstructEffectChainMgrMaps(std::vector &effectChains, + const EffectChainManagerParam &effectChainManagerParam, + std::vector> &effectLibraryList) +{ + const std::unordered_map &map = effectChainManagerParam.sceneTypeToChainNameMap; std::set effectSet; for (EffectChain efc: effectChains) { for (std::string effect: efc.apply) { effectSet.insert(effect); } } - // Construct EffectToLibraryEntryMap that stores libEntry for each effect name std::shared_ptr libEntry = nullptr; std::string libName; @@ -274,16 +296,8 @@ void AudioEffectChainManager::InitAudioEffectChainManager(std::vectorSetSpatialDeviceType(spatialDeviceType_); audioEffectChain->SetSpatializationSceneType(spatializationSceneType_); audioEffectChain->SetSpatializationEnabled(spatializationEnabled_); + if (!hasLoadedEffectProperties_) { + LoadEffectProperties(); + } std::string tSceneType = (sceneType == DEFAULT_SCENE_TYPE ? DEFAULT_PRESET_SCENE : sceneType); for (std::string effect: effectChainToEffectsMap_[effectChain]) { AudioEffectHandle handle = nullptr; @@ -1327,6 +1344,24 @@ int32_t AudioEffectChainManager::SetAudioEffectProperty(const AudioEffectPropert return ret; } +void AudioEffectChainManager::LoadEffectProperties() +{ + AudioSettingProvider &settingProvider = AudioSettingProvider::GetInstance(AUDIO_POLICY_SERVICE_ID); + CHECK_AND_RETURN_LOG(settingProvider.CheckOsAccountReady(), "os account not ready"); + for (const auto &[effect, key] : AUDIO_PERSISTENCE_EFFECT_KEY) { + std::string prop = ""; + ErrCode ret = settingProvider.GetStringValue(key, prop, "system"); + if (!prop.empty() && ret == SUCCESS) { + AUDIO_INFO_LOG("effect->name %{public}s prop %{public}s", effect.c_str(), prop.c_str()); + effectPropertyMap_[effect] = prop; + } else { + AUDIO_ERR_LOG("get prop failed for key %{public}s", key.c_str()); + effectPropertyMap_[effect] = defaultPropertyMap_[effect]; + } + } + hasLoadedEffectProperties_ = true; +} + int32_t AudioEffectChainManager::SetAudioEffectProperty(const AudioEffectPropertyArray &propertyArray) { std::lock_guard lock(dynamicMutex_); diff --git a/frameworks/native/audioeffect/src/audio_enhance_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_enhance_chain_manager.cpp index 9284fa97b5..c79c029849 100644 --- a/frameworks/native/audioeffect/src/audio_enhance_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_enhance_chain_manager.cpp @@ -202,6 +202,7 @@ void AudioEnhanceChainManager::UpdateEnhancePropertyMapFromDb(DeviceType deviceT std::string deviceTypeName = ""; GetDeviceTypeName(deviceType, deviceTypeName); AudioSettingProvider &settingProvider = AudioSettingProvider::GetInstance(AUDIO_POLICY_SERVICE_ID); + CHECK_AND_RETURN_LOG(settingProvider.CheckOsAccountReady(), "os account not ready"); for (auto &[enhance, prop] : enhancePropertyMap_) { std::string property = ""; if (deviceTypeName == "") { @@ -214,13 +215,13 @@ void AudioEnhanceChainManager::UpdateEnhancePropertyMapFromDb(DeviceType deviceT } else { key = enhance + "_&_" + deviceTypeName; } - ErrCode ret = settingProvider.GetStringValue(key, property); + ErrCode ret = settingProvider.GetStringValue(key, property, "system"); if (ret == SUCCESS) { prop = property; AUDIO_INFO_LOG("Get Effect_&_DeviceType:%{public}s is Property:%{public}s", key.c_str(), property.c_str()); } else { - ret = settingProvider.PutStringValue(key, defaultPropertyMap_[enhance]); + ret = settingProvider.PutStringValue(key, defaultPropertyMap_[enhance], "system"); if (ret != SUCCESS) { AUDIO_ERR_LOG("set to default Property:%{public}s, failed, ErrCode : %{public}d", defaultPropertyMap_[enhance].c_str(), ret); @@ -884,7 +885,8 @@ int32_t AudioEnhanceChainManager::SetAudioEnhancePropertyToChains(AudioEnhancePr int32_t AudioEnhanceChainManager::WriteEnhancePropertyToDb(const std::string &key, const std::string &property) { AudioSettingProvider &settingProvider = AudioSettingProvider::GetInstance(AUDIO_POLICY_SERVICE_ID); - ErrCode ret = settingProvider.PutStringValue(key, property); + CHECK_AND_RETURN_RET_LOG(settingProvider.CheckOsAccountReady(), ERROR, "os account not ready"); + ErrCode ret = settingProvider.PutStringValue(key, property, "system"); CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, ERR_OPERATION_FAILED, "Write Enhance Property to Database failed"); AUDIO_INFO_LOG("success, write Enhance_&_DeviceType:%{public}s is Property:%{public}s to Database", key.c_str(), property.c_str()); diff --git a/services/audio_policy/server/include/service/service/audio_server_proxy.h b/services/audio_policy/server/include/service/service/audio_server_proxy.h index 3cf1edc6ee..a59487459c 100644 --- a/services/audio_policy/server/include/service/service/audio_server_proxy.h +++ b/services/audio_policy/server/include/service/service/audio_server_proxy.h @@ -94,6 +94,7 @@ public: void SetAudioBalanceValueProxy(float audioBalance); int32_t SetSupportStreamUsageProxy(std::vector usage); int32_t SetCaptureSilentStateProxy(bool state); + void NotifyAccountsChanged(); private: AudioServerProxy() {} ~AudioServerProxy() {} diff --git a/services/audio_policy/server/src/service/audio_policy_service.cpp b/services/audio_policy/server/src/service/audio_policy_service.cpp index 4a8cb1d6d9..77a95356de 100644 --- a/services/audio_policy/server/src/service/audio_policy_service.cpp +++ b/services/audio_policy/server/src/service/audio_policy_service.cpp @@ -1696,6 +1696,7 @@ void AudioPolicyService::NotifyAccountsChanged(const int &id) audioPolicyManager_.NotifyAccountsChanged(id); RegisterDataObserver(); SubscribeAccessibilityConfigObserver(); + AudioServerProxy::GetInstance().NotifyAccountsChanged(); } int32_t AudioPolicyService::GetCurActivateCount() diff --git a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp index ccf7ef56b5..cc928038cd 100644 --- a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp +++ b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp @@ -150,6 +150,7 @@ bool VolumeDataMaintainer::GetVolumeInternal(DeviceType deviceType, AudioStreamT if (ret != SUCCESS) { AUDIO_ERR_LOG("Get streamType %{public}d, deviceType %{public}d, Volume FromDataBase volumeMap failed.", streamType, deviceType); + CHECK_AND_RETURN_RET_LOG(audioSettingProvider.CheckOsAccountReady(), ERROR, "os account not ready"); return false; } else { volumeLevelMap_[streamType] = volumeValue; diff --git a/services/audio_policy/server/src/service/service/audio_server_proxy.cpp b/services/audio_policy/server/src/service/service/audio_server_proxy.cpp index 8746bf5f98..1a0997ef93 100644 --- a/services/audio_policy/server/src/service/service/audio_server_proxy.cpp +++ b/services/audio_policy/server/src/service/service/audio_server_proxy.cpp @@ -478,5 +478,14 @@ int32_t AudioServerProxy::SetCaptureSilentStateProxy(bool state) #endif } ++void AudioServerProxy::NotifyAccountsChanged() +{ + const sptr gsp = GetAudioServerProxy(); + CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable"); + std::string identity = IPCSkeleton::ResetCallingIdentity(); + gsp->NotifyAccountsChanged(); + IPCSkeleton::SetCallingIdentity(identity); +} + } } diff --git a/services/audio_service/client/include/audio_manager_base.h b/services/audio_service/client/include/audio_manager_base.h index a72a99a1d8..18bea3ab11 100644 --- a/services/audio_service/client/include/audio_manager_base.h +++ b/services/audio_service/client/include/audio_manager_base.h @@ -493,6 +493,8 @@ public: * @return Returns result 0 if success, error number else. */ virtual int32_t GenerateSessionId(uint32_t &sessionId) = 0; + + virtual void NotifyAccountsChanged() = 0; public: DECLARE_INTERFACE_DESCRIPTOR(u"IStandardAudioService"); }; @@ -572,6 +574,7 @@ private: int HandleGetOfflineAudioEffectChains(MessageParcel &data, MessageParcel &reply); int HandleGetStandbyStatus(MessageParcel &data, MessageParcel &reply); int HandleGenerateSessionId(MessageParcel &data, MessageParcel &reply); + int HandleNotifyAccountsChanged(MessageParcel &data, MessageParcel &reply); int HandleSecondPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); int HandleThirdPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); diff --git a/services/audio_service/client/include/audio_manager_proxy.h b/services/audio_service/client/include/audio_manager_proxy.h index b0aa7cb30f..ef2d222f74 100644 --- a/services/audio_service/client/include/audio_manager_proxy.h +++ b/services/audio_service/client/include/audio_manager_proxy.h @@ -113,6 +113,7 @@ public: int32_t GetOfflineAudioEffectChains(std::vector &effectChains) override; int32_t GetStandbyStatus(uint32_t sessionId, bool &isStandby, int64_t &enterStandbyTime) override; int32_t GenerateSessionId(uint32_t &sessionId) override; + void NotifyAccountsChanged() override; private: static inline BrokerDelegator delegator_; }; 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 6943f26eeb..ac9c74162e 100644 --- a/services/audio_service/client/include/pulseaudio_ipc_interface_code.h +++ b/services/audio_service/client/include/pulseaudio_ipc_interface_code.h @@ -89,6 +89,7 @@ namespace AudioStandard { GET_OFFLINE_AUDIO_EFFECT_CHAINS, GET_STANDBY_STATUS, GENERATE_SESSION_ID, + NOTIFY_ACCOUNTS_CHANGED, AUDIO_SERVER_CODE_MAX = GENERATE_SESSION_ID, }; } // namespace AudioStandard diff --git a/services/audio_service/client/src/audio_manager_proxy.cpp b/services/audio_service/client/src/audio_manager_proxy.cpp index c474daa8af..ff0b990479 100644 --- a/services/audio_service/client/src/audio_manager_proxy.cpp +++ b/services/audio_service/client/src/audio_manager_proxy.cpp @@ -1428,5 +1428,16 @@ int32_t AudioManagerProxy::GenerateSessionId(uint32_t &sessionId) sessionId = reply.ReadUint32(); return 0; } + +void AudioManagerProxy::NotifyAccountsChanged() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + int32_t error = Remote()->SendRequest( + static_cast(AudioServerInterfaceCode::NOTIFY_ACCOUNTS_CHANGED), data, reply, option); + CHECK_AND_RETURN_LOG(error == ERR_NONE, "failed,error:%d", error); +} } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_service/server/include/audio_server.h b/services/audio_service/server/include/audio_server.h index 44ae4da86a..941e338dd8 100644 --- a/services/audio_service/server/include/audio_server.h +++ b/services/audio_service/server/include/audio_server.h @@ -185,6 +185,8 @@ public: int32_t GetStandbyStatus(uint32_t sessionId, bool &isStandby, int64_t &enterStandbyTime) override; int32_t GenerateSessionId(uint32_t &sessionId) override; + + void NotifyAccountsChanged() override; protected: void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; diff --git a/services/audio_service/server/src/audio_manager_stub.cpp b/services/audio_service/server/src/audio_manager_stub.cpp index a9d1e1f340..c9eabbd84d 100644 --- a/services/audio_service/server/src/audio_manager_stub.cpp +++ b/services/audio_service/server/src/audio_manager_stub.cpp @@ -787,6 +787,8 @@ int AudioManagerStub::HandleFourthPartCode(uint32_t code, MessageParcel &data, M return HandleLoadHdiEffectModel(data, reply); case static_cast(AudioServerInterfaceCode::UPDATE_EFFECT_BT_OFFLOAD_SUPPORTED): return HandleUpdateEffectBtOffloadSupported(data, reply); + case static_cast(AudioServerInterfaceCode::NOTIFY_ACCOUNTS_CHANGED): + return HandleNotifyAccountsChanged(data, reply); default: return HandleFifthPartCode(code, data, reply, option); } @@ -1105,5 +1107,12 @@ int AudioManagerStub::HandleGenerateSessionId(MessageParcel &data, MessageParcel reply.WriteUint32(sessionId); return AUDIO_OK; } + +int AudioManagerStub::HandleNotifyAccountsChanged(MessageParcel &data, MessageParcel &reply) +{ + NotifyAccountsChanged(); + return AUDIO_OK; +} + } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_service/server/src/audio_server_effect.cpp b/services/audio_service/server/src/audio_server_effect.cpp index 1ba760cd3c..6b049f9f72 100644 --- a/services/audio_service/server/src/audio_server_effect.cpp +++ b/services/audio_service/server/src/audio_server_effect.cpp @@ -322,5 +322,13 @@ bool AudioServer::LoadAudioEffectLibraries(const std::vector libraries, } return loadSuccess; } + +void AudioServer::NotifyAccountsChanged() +{ + AudioEffectChainManager *audioEffectChainManager = AudioEffectChainManager::GetInstance(); + CHECK_AND_RETURN_LOG(audioEffectChainManager != nullptr, "audioEffectChainManager is nullptr"); + audioEffectChainManager->LoadEffectProperties(); +} + } // namespace AudioStandard } // namespace OHOS -- Gitee From 941d932b88e7b0791ac5dc5a54629505c8275eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Wed, 5 Feb 2025 17:00:16 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../include/audio_effect_chain_manager.h | 2 ++ .../src/audio_effect_chain_manager.cpp | 16 +++++++++++----- .../src/service/service/audio_server_proxy.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h index 598f29b861..5b36fa5674 100644 --- a/frameworks/native/audioeffect/include/audio_effect_chain_manager.h +++ b/frameworks/native/audioeffect/include/audio_effect_chain_manager.h @@ -198,6 +198,8 @@ private: int32_t EffectVolumeUpdateInner(std::shared_ptr audioEffectVolume); void InitHdiStateInner(); void UpdateSpatializationEnabled(AudioSpatializationState spatializationState); + void ConfigureAudioEffectChain(std::shared_ptr audioEffectChain, + const std::string &effectMode); std::map> effectToLibraryEntryMap_; std::map effectToLibraryNameMap_; std::map> effectChainToEffectsMap_; diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index f3d2c6ecd8..66827eb139 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -341,11 +341,7 @@ int32_t AudioEffectChainManager::SetAudioEffectChainDynamic(const std::string &s effectChain = effectNone; } - audioEffectChain->SetEffectMode(effectMode); - audioEffectChain->SetExtraSceneType(extraSceneType_); - audioEffectChain->SetSpatialDeviceType(spatialDeviceType_); - audioEffectChain->SetSpatializationSceneType(spatializationSceneType_); - audioEffectChain->SetSpatializationEnabled(spatializationEnabled_); + ConfigureAudioEffectChain(audioEffectChain, effectMode); if (!hasLoadedEffectProperties_) { LoadEffectProperties(); } @@ -376,6 +372,16 @@ int32_t AudioEffectChainManager::SetAudioEffectChainDynamic(const std::string &s return SUCCESS; } +void AudioEffectChainManager::ConfigureAudioEffectChain(std::shared_ptr audioEffectChain, + const std::string &effectMode) +{ + audioEffectChain->SetEffectMode(effectMode); + audioEffectChain->SetExtraSceneType(extraSceneType_); + audioEffectChain->SetSpatialDeviceType(spatialDeviceType_); + audioEffectChain->SetSpatializationSceneType(spatializationSceneType_); + audioEffectChain->SetSpatializationEnabled(spatializationEnabled_); +} + bool AudioEffectChainManager::CheckAndRemoveSessionID(const std::string &sessionID) { std::lock_guard lock(dynamicMutex_); diff --git a/services/audio_policy/server/src/service/service/audio_server_proxy.cpp b/services/audio_policy/server/src/service/service/audio_server_proxy.cpp index 1a0997ef93..1ffd632813 100644 --- a/services/audio_policy/server/src/service/service/audio_server_proxy.cpp +++ b/services/audio_policy/server/src/service/service/audio_server_proxy.cpp @@ -478,7 +478,7 @@ int32_t AudioServerProxy::SetCaptureSilentStateProxy(bool state) #endif } -+void AudioServerProxy::NotifyAccountsChanged() +void AudioServerProxy::NotifyAccountsChanged() { const sptr gsp = GetAudioServerProxy(); CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable"); -- Gitee From f757e8ffe9c5ce99a47dbed1d79f9a79197e9c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Wed, 5 Feb 2025 18:49:26 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../native/audioeffect/src/audio_effect_chain_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index 66827eb139..84df62ae9c 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -30,6 +30,7 @@ namespace { const std::unordered_map AUDIO_PERSISTENCE_EFFECT_KEY { {"voip_down", "settings.sound_ai_voip_down_selection"}, }; +const std::vector AUDIO_PERSISTENCE_SCENE {"SCENE_VOIP_DOWN"}; } static int32_t CheckValidEffectLibEntry(const std::shared_ptr &libEntry, const std::string &effect, const std::string &libName) @@ -342,7 +343,9 @@ int32_t AudioEffectChainManager::SetAudioEffectChainDynamic(const std::string &s } ConfigureAudioEffectChain(audioEffectChain, effectMode); - if (!hasLoadedEffectProperties_) { + bool exists = std::find(AUDIO_PERSISTENCE_SCENE.begin(), AUDIO_PERSISTENCE_SCENE.end(), sceneType) != + AUDIO_PERSISTENCE_SCENE.end(); + if (exists && !hasLoadedEffectProperties_) { LoadEffectProperties(); } std::string tSceneType = (sceneType == DEFAULT_SCENE_TYPE ? DEFAULT_PRESET_SCENE : sceneType); -- Gitee From 811e4f62424615851a7d1204677cce3cbdf065c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 6 Feb 2025 11:19:40 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index 84df62ae9c..8caf526a03 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -1355,6 +1355,7 @@ int32_t AudioEffectChainManager::SetAudioEffectProperty(const AudioEffectPropert void AudioEffectChainManager::LoadEffectProperties() { + hasLoadedEffectProperties_ = false; AudioSettingProvider &settingProvider = AudioSettingProvider::GetInstance(AUDIO_POLICY_SERVICE_ID); CHECK_AND_RETURN_LOG(settingProvider.CheckOsAccountReady(), "os account not ready"); for (const auto &[effect, key] : AUDIO_PERSISTENCE_EFFECT_KEY) { -- Gitee From 157bac35550109b47315220a0c66c3e45038f2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 6 Feb 2025 11:22:19 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../server/src/service/manager/volume_data_maintainer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp index cc928038cd..ccf7ef56b5 100644 --- a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp +++ b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp @@ -150,7 +150,6 @@ bool VolumeDataMaintainer::GetVolumeInternal(DeviceType deviceType, AudioStreamT if (ret != SUCCESS) { AUDIO_ERR_LOG("Get streamType %{public}d, deviceType %{public}d, Volume FromDataBase volumeMap failed.", streamType, deviceType); - CHECK_AND_RETURN_RET_LOG(audioSettingProvider.CheckOsAccountReady(), ERROR, "os account not ready"); return false; } else { volumeLevelMap_[streamType] = volumeValue; -- Gitee From 2a1ec2408b79e3ddbca703b322a82285153f7d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 6 Feb 2025 15:14:43 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../native/audioeffect/src/audio_effect_chain_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index 8caf526a03..d5894f264d 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -245,9 +245,6 @@ void AudioEffectChainManager::InitAudioEffectChainManager(std::vectorname %{public}s defaultProp %{public}s", effect.c_str(), prop.c_str()); + effectPropertyMap_[effect] = defaultPropertyMap_[effect]; + } } } hasLoadedEffectProperties_ = true; -- Gitee From c9f5032faae93362e16d971ba7f12444962e8967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 6 Feb 2025 15:57:43 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../native/audioeffect/src/audio_effect_chain_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp index d5894f264d..a77fdadfba 100644 --- a/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp +++ b/frameworks/native/audioeffect/src/audio_effect_chain_manager.cpp @@ -1363,7 +1363,7 @@ void AudioEffectChainManager::LoadEffectProperties() effectPropertyMap_[effect] = prop; } else { AUDIO_ERR_LOG("get prop failed for key %{public}s", key.c_str()); - if(defaultPropertyMap_.count(effect) != 0) { + if (defaultPropertyMap_.count(effect) != 0) { AUDIO_INFO_LOG("effect->name %{public}s defaultProp %{public}s", effect.c_str(), prop.c_str()); effectPropertyMap_[effect] = defaultPropertyMap_[effect]; } -- Gitee From b64de257420fadf4a84aaea9ee9d845051ec224d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Fri, 7 Feb 2025 09:33:43 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- services/audio_service/server/src/audio_server_effect.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/audio_service/server/src/audio_server_effect.cpp b/services/audio_service/server/src/audio_server_effect.cpp index 6b049f9f72..0e27b05c6d 100644 --- a/services/audio_service/server/src/audio_server_effect.cpp +++ b/services/audio_service/server/src/audio_server_effect.cpp @@ -325,6 +325,9 @@ bool AudioServer::LoadAudioEffectLibraries(const std::vector libraries, void AudioServer::NotifyAccountsChanged() { + int32_t callingUid = IPCSkeleton::GetCallingUid(); + CHECK_AND_RETURN_LOG(PermissionUtil::VerifyIsAudio(), "refused for %{public}d", callingUid); + AudioEffectChainManager *audioEffectChainManager = AudioEffectChainManager::GetInstance(); CHECK_AND_RETURN_LOG(audioEffectChainManager != nullptr, "audioEffectChainManager is nullptr"); audioEffectChainManager->LoadEffectProperties(); -- Gitee From f04affd7a8a10d9d20d49060a8f5f63e0b30a462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Fri, 7 Feb 2025 10:01:56 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=B8=8B=E8=A1=8C=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- services/audio_service/client/src/audio_manager_proxy.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/audio_service/client/src/audio_manager_proxy.cpp b/services/audio_service/client/src/audio_manager_proxy.cpp index ff0b990479..3cb15ee9c6 100644 --- a/services/audio_service/client/src/audio_manager_proxy.cpp +++ b/services/audio_service/client/src/audio_manager_proxy.cpp @@ -1435,6 +1435,9 @@ void AudioManagerProxy::NotifyAccountsChanged() MessageParcel reply; MessageOption option; + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_LOG(ret, "WriteInterfaceToken failed"); + int32_t error = Remote()->SendRequest( static_cast(AudioServerInterfaceCode::NOTIFY_ACCOUNTS_CHANGED), data, reply, option); CHECK_AND_RETURN_LOG(error == ERR_NONE, "failed,error:%d", error); -- Gitee From 09f8c8475b505a5b35c8a89253e931eb7ec9299c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Fri, 7 Feb 2025 16:30:44 +0800 Subject: [PATCH 10/10] =?UTF-8?q?IPC=20=E6=9D=83=E9=99=90=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- .../client/include/pulseaudio_ipc_interface_code.h | 2 +- services/audio_service/server/src/audio_manager_stub.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 ac9c74162e..bb441e33b6 100644 --- a/services/audio_service/client/include/pulseaudio_ipc_interface_code.h +++ b/services/audio_service/client/include/pulseaudio_ipc_interface_code.h @@ -90,7 +90,7 @@ namespace AudioStandard { GET_STANDBY_STATUS, GENERATE_SESSION_ID, NOTIFY_ACCOUNTS_CHANGED, - AUDIO_SERVER_CODE_MAX = GENERATE_SESSION_ID, + AUDIO_SERVER_CODE_MAX = NOTIFY_ACCOUNTS_CHANGED, }; } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_service/server/src/audio_manager_stub.cpp b/services/audio_service/server/src/audio_manager_stub.cpp index c9eabbd84d..9d6b52b1bc 100644 --- a/services/audio_service/server/src/audio_manager_stub.cpp +++ b/services/audio_service/server/src/audio_manager_stub.cpp @@ -109,6 +109,7 @@ const char *g_audioServerCodeStrs[] = { "GET_OFFLINE_AUDIO_EFFECT_CHAINS", "GET_STANDBY_STATUS", "GENERATE_SESSION_ID", + "NOTIFY_ACCOUNTS_CHANGED", }; constexpr size_t codeNums = sizeof(g_audioServerCodeStrs) / sizeof(const char *); static_assert(codeNums == (static_cast (AudioServerInterfaceCode::AUDIO_SERVER_CODE_MAX) + 1), -- Gitee