• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 POLICY_HANDLER_H
17 #define POLICY_HANDLER_H
18 
19 #include <sstream>
20 #include <map>
21 #include <mutex>
22 #include <vector>
23 
24 #include "audio_info.h"
25 #include "i_policy_provider_ipc.h"
26 
27 namespace OHOS {
28 namespace AudioStandard {
29 class PolicyHandler {
30 public:
31     static PolicyHandler& GetInstance();
32 
33     ~PolicyHandler();
34 
35     void Dump(std::stringstream &dumpString);
36 
37     // would be called only once
38     bool ConfigPolicyProvider(const sptr<IPolicyProviderIpc> policyProvider);
39 
40     bool GetProcessDeviceInfo(const AudioProcessConfig &config, DeviceInfo &deviceInfo);
41 
42     bool InitVolumeMap();
43 
44     bool GetSharedVolume(AudioStreamType streamType, DeviceType deviceType, Volume &vol);
45 
46     void SetActiveOutputDevice(DeviceType deviceType);
47 
48     DeviceType GetActiveOutPutDevice();
49 
50 private:
51     PolicyHandler();
52     sptr<IPolicyProviderIpc> iPolicyProvider_ = nullptr;
53 
54 private:
55     std::shared_ptr<AudioSharedMemory> policyVolumeMap_ = nullptr;
56     volatile Volume *volumeVector_ = nullptr;
57     DeviceType deviceType_ = DEVICE_TYPE_SPEAKER;
58 };
59 } // namespace AudioStandard
60 } // namespace OHOS
61 #endif // POLICY_HANDLER_H
62