1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ST_AUDIO_EFFECT_MANAGER_H 17 #define ST_AUDIO_EFFECT_MANAGER_H 18 19 #include "audio_log.h" 20 #include "audio_effect.h" 21 #include "audio_effect_config_parser.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class AudioEffectManager { 26 public: 27 explicit AudioEffectManager(); 28 ~AudioEffectManager(); GetAudioEffectManager()29 static AudioEffectManager& GetAudioEffectManager() 30 { 31 static AudioEffectManager audioEffectManager; 32 return audioEffectManager; 33 } 34 void EffectManagerInit(); 35 void GetOriginalEffectConfig(OriginalEffectConfig &oriEffectConfig); 36 void GetAvailableEffects(std::vector<Effect> &availableEffects); 37 void UpdateAvailableEffects(std::vector<Effect> &newAvailableEffects); 38 void GetSupportedEffectConfig(SupportedEffectConfig &supportedEffectConfig); 39 void BuildAvailableAEConfig(); 40 void SetMasterSinkAvailable(); 41 void SetEffectChainManagerAvailable(); 42 bool CanLoadEffectSinks(); 43 void ConstructSceneTypeToEffectChainNameMap(std::unordered_map<std::string, std::string> &map); 44 bool CheckEffectSinkName(std::string &sinkName); 45 int32_t QueryEffectManagerSceneMode(SupportedEffectConfig &supportedEffectConfig); 46 47 private: 48 OriginalEffectConfig oriEffectConfig_; 49 std::vector<Effect> availableEffects_; 50 SupportedEffectConfig supportedEffectConfig_; 51 int32_t existDefault_ = 0; 52 bool isMasterSinkAvailable_ = false; 53 bool isEffectChainManagerAvailable_ = false; 54 55 void UpdateAvailableAEConfig(OriginalEffectConfig &aeConfig); 56 void UpdateEffectChains(std::vector<std::string> &availableLayout); 57 void UpdateDuplicateBypassMode(ProcessNew &preProcessNew); 58 void UpdateDuplicateMode(ProcessNew &preProcessNew); 59 void UpdateDuplicateDevice(ProcessNew &preProcessNew); 60 int32_t UpdateUnavailableEffectChains(std::vector<std::string> &availableLayout, ProcessNew &preProcessNew); 61 }; 62 } // namespce AudioStandard 63 } // namespace OHOS 64 #endif // ST_AUDIO_EFFECT_MANAGER_H