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_policy_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 ConstructEffectChainManagerParam(EffectChainManagerParam &effectChainMgrParam);
44     void ConstructEnhanceChainManagerParam(EffectChainManagerParam &enhanceChainMgrParam);
45     int32_t QueryEffectManagerSceneMode(SupportedEffectConfig &supportedEffectConfig);
46 private:
47     OriginalEffectConfig oriEffectConfig_;
48     std::vector<Effect> availableEffects_;
49     SupportedEffectConfig supportedEffectConfig_;
50     int32_t existDefault_ = 0;
51     bool isMasterSinkAvailable_ = false;
52     bool isEffectChainManagerAvailable_ = false;
53     std::vector<std::string> postSceneTypeSet_;
54 
55     void UpdateAvailableAEConfig(OriginalEffectConfig &aeConfig);
56     void UpdateEffectChains(std::vector<std::string> &availableLayout);
57     void UpdateDuplicateBypassMode(ProcessNew &processNew);
58     void UpdateDuplicateMode(ProcessNew &processNew);
59     void UpdateDuplicateDefaultScene(ProcessNew &processNew);
60     void UpdateDuplicateScene(ProcessNew &processNew);
61     void UpdateDuplicateDevice(ProcessNew &processNew);
62     int32_t UpdateUnavailableEffectChains(std::vector<std::string> &availableLayout, ProcessNew &processNew);
63     bool VerifySceneMappingItem(const SceneMappingItem &item);
64 };
65 } // namespce AudioStandard
66 } // namespace OHOS
67 #endif // ST_AUDIO_EFFECT_MANAGER_H