1 /*
2  * Copyright (c) 2021-2022 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_SYSTEM_MANAGER_H
17 #define ST_AUDIO_SYSTEM_MANAGER_H
18 
19 #include <cstdlib>
20 #include <list>
21 #include <map>
22 #include <mutex>
23 #include <vector>
24 #include <unordered_map>
25 
26 #include "parcel.h"
27 #include "audio_info.h"
28 #include "audio_interrupt_callback.h"
29 #include "audio_group_manager.h"
30 #include "audio_routing_manager.h"
31 
32 namespace OHOS {
33 namespace AudioStandard {
34 
35 class AudioDeviceDescriptor;
36 class AudioDeviceDescriptor : public Parcelable {
37     friend class AudioSystemManager;
38 public:
39     DeviceType getType();
40     DeviceRole getRole() const;
41     DeviceType deviceType_ = DEVICE_TYPE_NONE;
42     DeviceRole deviceRole_ = DEVICE_ROLE_NONE;
43     int32_t deviceId_ = 0;
44     int32_t channelMasks_ = 0;
45     int32_t channelIndexMasks_ = 0;
46     std::string deviceName_;
47     std::string macAddress_;
48     int32_t interruptGroupId_ = 0;
49     int32_t volumeGroupId_ = 0;
50     std::string networkId_;
51     std::string displayName_;
52     bool exceptionFlag_ = false;
53     DeviceStreamInfo audioStreamInfo_ = {};
54     DeviceCategory deviceCategory_ = CATEGORY_DEFAULT;
55     int64_t connectTimeStamp_ = 0;
56     std::shared_ptr<AudioDeviceDescriptor> pairDeviceDescriptor_;
57     ConnectState connectState_ = CONNECTED;
58     bool isScoRealConnected_ = false;
59     bool isEnable_ = true;
60     bool isVgsSupported_ = false;
61 
62     AudioDeviceDescriptor();
63     AudioDeviceDescriptor(DeviceType type, DeviceRole role, int32_t interruptGroupId, int32_t volumeGroupId,
64         std::string networkId);
65     AudioDeviceDescriptor(DeviceType type, DeviceRole role);
66     AudioDeviceDescriptor(const AudioDeviceDescriptor &deviceDescriptor);
67     AudioDeviceDescriptor(const sptr<AudioDeviceDescriptor> &deviceDescriptor);
68     virtual ~AudioDeviceDescriptor();
69 
70     bool Marshalling(Parcel &parcel) const override;
71     static sptr<AudioDeviceDescriptor> Unmarshalling(Parcel &parcel);
72     void SetDeviceInfo(std::string deviceName, std::string macAddress);
73     void SetDeviceCapability(const DeviceStreamInfo &audioStreamInfo, int32_t channelMask,
74         int32_t channelIndexMasks = 0);
75 
76     bool isSameDevice(const DeviceInfo &deviceInfo);
77     bool isSameDeviceDesc(const std::unique_ptr<AudioDeviceDescriptor> &deviceDescriptor);
78 };
79 
80 struct AudioSpatialEnabledStateForDevice {
81     sptr<AudioDeviceDescriptor> deviceDescriptor;
82     bool enabled;
83 };
84 
85 struct DistributedRoutingInfo {
86     sptr<AudioDeviceDescriptor> descriptor;
87     CastType type;
88 };
89 
90 class InterruptGroupInfo;
91 class InterruptGroupInfo : public Parcelable {
92     friend class AudioSystemManager;
93 public:
94     int32_t interruptGroupId_ = 0;
95     int32_t mappingId_ = 0;
96     std::string groupName_;
97     std::string networkId_;
98     ConnectType connectType_ = CONNECT_TYPE_LOCAL;
99     InterruptGroupInfo();
100     InterruptGroupInfo(int32_t interruptGroupId, int32_t mappingId, std::string groupName, std::string networkId,
101         ConnectType type);
102     virtual ~InterruptGroupInfo();
103     bool Marshalling(Parcel &parcel) const override;
104     static sptr<InterruptGroupInfo> Unmarshalling(Parcel &parcel);
105 };
106 
107 class VolumeGroupInfo;
108 class VolumeGroupInfo : public Parcelable {
109     friend class AudioSystemManager;
110 public:
111     int32_t volumeGroupId_ = 0;
112     int32_t mappingId_ = 0;
113     std::string groupName_;
114     std::string networkId_;
115     ConnectType connectType_ = CONNECT_TYPE_LOCAL;
116 
117     /**
118      * @brief Volume group info.
119      *
120      * @since 9
121      */
122     VolumeGroupInfo();
123 
124     /**
125      * @brief Volume group info.
126      *
127      * @param volumeGroupId volumeGroupId
128      * @param mappingId mappingId
129      * @param groupName groupName
130      * @param networkId networkId
131      * @param type type
132      * @since 9
133      */
134     VolumeGroupInfo(int32_t volumeGroupId, int32_t mappingId, std::string groupName, std::string networkId,
135         ConnectType type);
136     virtual ~VolumeGroupInfo();
137 
138     /**
139      * @brief Marshall.
140      *
141      * @since 8
142      * @return bool
143      */
144     bool Marshalling(Parcel &parcel) const override;
145 
146     /**
147      * @brief Unmarshall.
148      *
149      * @since 8
150      * @return Returns volume group info
151      */
152     static sptr<VolumeGroupInfo> Unmarshalling(Parcel &parcel);
153 };
154 
155 /**
156  * Describes the device change type and device information.
157  *
158  * @since 7
159  */
160 struct DeviceChangeAction {
161     DeviceChangeType type;
162     DeviceFlag flag;
163     std::vector<sptr<AudioDeviceDescriptor>> deviceDescriptors;
164 };
165 
166 /**
167  * Describes the mic phone blocked device information.
168  *
169  * @since 13
170  */
171 struct MicrophoneBlockedInfo {
172     DeviceBlockStatus blockStatus;
173     std::vector<sptr<AudioDeviceDescriptor>> devices;
174 };
175 
176 /**
177  * @brief AudioRendererFilter is used for select speficed AudioRenderer.
178  */
179 class AudioRendererFilter;
180 class AudioRendererFilter : public Parcelable {
181     friend class AudioSystemManager;
182 public:
183     AudioRendererFilter();
184     virtual ~AudioRendererFilter();
185 
186     int32_t uid = -1;
187     AudioRendererInfo rendererInfo = {};
188     AudioStreamType streamType = AudioStreamType::STREAM_DEFAULT;
189     int32_t streamId = -1;
190 
191     bool Marshalling(Parcel &parcel) const override;
192     static sptr<AudioRendererFilter> Unmarshalling(Parcel &in);
193 };
194 
195 /**
196  * @brief AudioCapturerFilter is used for select speficed audiocapturer.
197  */
198 class AudioCapturerFilter;
199 class AudioCapturerFilter : public Parcelable {
200     friend class AudioSystemManager;
201 public:
202     AudioCapturerFilter();
203     virtual ~AudioCapturerFilter();
204 
205     int32_t uid = -1;
206     AudioCapturerInfo capturerInfo = {SOURCE_TYPE_INVALID, 0};
207 
208     bool Marshalling(Parcel &parcel) const override;
209     static sptr<AudioCapturerFilter> Unmarshalling(Parcel &in);
210 };
211 
212 // AudioManagerCallback OnInterrupt is added to handle compilation error in call manager
213 // Once call manager adapt to new interrupt APIs, this will be removed
214 class AudioManagerCallback {
215 public:
216     virtual ~AudioManagerCallback() = default;
217     /**
218      * Called when an interrupt is received.
219      *
220      * @param interruptAction Indicates the InterruptAction information needed by client.
221      * For details, refer InterruptAction struct in audio_info.h
222      */
223     virtual void OnInterrupt(const InterruptAction &interruptAction) = 0;
224     std::mutex cbMutex_;
225 };
226 
227 class AudioManagerInterruptCallbackImpl : public AudioInterruptCallback {
228 public:
229     explicit AudioManagerInterruptCallbackImpl();
230     virtual ~AudioManagerInterruptCallbackImpl();
231 
232     /**
233      * Called when an interrupt is received.
234      *
235      * @param interruptAction Indicates the InterruptAction information needed by client.
236      * For details, refer InterruptAction struct in audio_info.h
237      * @since 7
238      */
239     void OnInterrupt(const InterruptEventInternal &interruptEvent) override;
240     void SaveCallback(const std::weak_ptr<AudioManagerCallback> &callback);
241 private:
242     std::weak_ptr<AudioManagerCallback> callback_;
243     std::shared_ptr<AudioManagerCallback> cb_;
244 };
245 
246 class AudioManagerDeviceChangeCallback {
247 public:
248     virtual ~AudioManagerDeviceChangeCallback() = default;
249     /**
250      * Called when an interrupt is received.
251      *
252      * @param deviceChangeAction Indicates the DeviceChangeAction information needed by client.
253      * For details, refer DeviceChangeAction struct
254      * @since 8
255      */
256     virtual void OnDeviceChange(const DeviceChangeAction &deviceChangeAction) = 0;
257 };
258 
259 class AudioQueryClientTypeCallback {
260 public:
261     virtual ~AudioQueryClientTypeCallback() = default;
262     virtual bool OnQueryClientType(const std::string &bundleName, uint32_t uid) = 0;
263 };
264 
265 class AudioManagerAvailableDeviceChangeCallback {
266 public:
267     virtual ~AudioManagerAvailableDeviceChangeCallback() = default;
268     /**
269      * Called when an interrupt is received.
270      *
271      * @param deviceChangeAction Indicates the DeviceChangeAction information needed by client.
272      * For details, refer DeviceChangeAction struct
273      * @since 11
274      */
275     virtual void OnAvailableDeviceChange(const AudioDeviceUsage usage,
276         const DeviceChangeAction &deviceChangeAction) = 0;
277 };
278 
279 class AudioManagerMicrophoneBlockedCallback {
280 public:
281     virtual ~AudioManagerMicrophoneBlockedCallback() = default;
282     /**
283      * Called when micro phone is blocked.
284      *
285      * @param microphoneBlockedInfo Indicates the MisPhoneBlockedInfo information needed by client.
286      * For details, refer MisPhoneBlockedInfo struct
287      * @since 13
288      */
289     virtual void OnMicrophoneBlocked(const MicrophoneBlockedInfo &microphoneBlockedInfo) = 0;
290 };
291 
292 class VolumeKeyEventCallback {
293 public:
294     virtual ~VolumeKeyEventCallback() = default;
295     /**
296      * @brief VolumeKeyEventCallback will be executed when hard volume key is pressed up/down
297      *
298      * @param volumeEvent the volume event info.
299      * @since 8
300      */
301     virtual void OnVolumeKeyEvent(VolumeEvent volumeEvent) = 0;
302 };
303 
304 class AudioParameterCallback {
305 public:
306     virtual ~AudioParameterCallback() = default;
307     /**
308      * @brief AudioParameterCallback will be executed when parameter change.
309      *
310      * @param networkId networkId
311      * @param key  Audio paramKey
312      * @param condition condition
313      * @param value value
314      * @since 9
315      */
316     virtual void OnAudioParameterChange(const std::string networkId, const AudioParamKey key,
317         const std::string& condition, const std::string& value) = 0;
318 };
319 
320 class AudioCapturerSourceCallback {
321 public:
322     virtual ~AudioCapturerSourceCallback() = default;
323     virtual void OnCapturerState(bool isActive) = 0;
324 };
325 
326 class WakeUpSourceCloseCallback {
327 public:
328     virtual ~WakeUpSourceCloseCallback() = default;
329     virtual void OnWakeupClose() = 0;
330 };
331 
332 class WakeUpSourceCallback : public AudioCapturerSourceCallback, public WakeUpSourceCloseCallback {
333 public:
334     virtual ~WakeUpSourceCallback() = default;
335     // Stop all listening capturers from sending false callbacks;
336     // when all capturers have stopped, allow one capturer to start sending true callbacks
337     virtual void OnCapturerState(bool isActive) = 0;
338     virtual void OnWakeupClose() = 0;
339 };
340 
341 class AudioPreferredOutputDeviceChangeCallback;
342 
343 class AudioFocusInfoChangeCallback {
344 public:
345     virtual ~AudioFocusInfoChangeCallback() = default;
346     /**
347      * Called when focus info change.
348      *
349      * @param focusInfoList Indicates the focusInfoList information needed by client.
350      * For details, refer audioFocusInfoList_ struct in audio_policy_server.h
351      * @since 9
352      */
353     virtual void OnAudioFocusInfoChange(const std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList) = 0;
354 
OnAudioFocusRequested(const AudioInterrupt &)355     virtual void OnAudioFocusRequested(const AudioInterrupt &) {}
356 
OnAudioFocusAbandoned(const AudioInterrupt &)357     virtual void OnAudioFocusAbandoned(const AudioInterrupt &) {}
358 };
359 
360 class AudioFocusInfoChangeCallbackImpl : public AudioFocusInfoChangeCallback {
361 public:
362     explicit AudioFocusInfoChangeCallbackImpl();
363     virtual ~AudioFocusInfoChangeCallbackImpl();
364 
365     /**
366      * Called when focus info change.
367      *
368      * @param focusInfoList Indicates the focusInfoList information needed by client.
369      * For details, refer audioFocusInfoList_ struct in audio_policy_server.h
370      * @since 9
371      */
372     void OnAudioFocusInfoChange(const std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList) override;
373     void OnAudioFocusRequested(const AudioInterrupt &requestFocus) override;
374     void OnAudioFocusAbandoned(const AudioInterrupt &abandonFocus) override;
375     void SaveCallback(const std::weak_ptr<AudioFocusInfoChangeCallback> &callback);
376 
377     /**
378      *  Cancel when focus info change.
379      *
380      * @since 9
381      */
382     void RemoveCallback(const std::weak_ptr<AudioFocusInfoChangeCallback> &callback);
383 private:
384     std::list<std::weak_ptr<AudioFocusInfoChangeCallback>> callbackList_;
385     std::shared_ptr<AudioFocusInfoChangeCallback> cb_;
386     std::mutex cbListMutex_;
387 };
388 
389 class AudioDistributedRoutingRoleCallback {
390 public:
391     virtual ~AudioDistributedRoutingRoleCallback() = default;
392 
393     /**
394      * Called when audio device descriptor change.
395      *
396      * @param descriptor Indicates the descriptor needed by client.
397      * For details, refer AudioDeviceDescriptor in audio_system_manager.h
398      * @since 9
399      */
400     virtual void OnDistributedRoutingRoleChange(const AudioDeviceDescriptor *descriptor, const CastType type) = 0;
401     std::mutex cbMutex_;
402 };
403 
404 class AudioDistributedRoutingRoleCallbackImpl : public AudioDistributedRoutingRoleCallback {
405 public:
406     explicit AudioDistributedRoutingRoleCallbackImpl();
407     virtual ~AudioDistributedRoutingRoleCallbackImpl();
408 
409     /**
410      * Called when audio device descriptor change.
411      *
412      * @param descriptor Indicates the descriptor needed by client.
413      * For details, refer AudioDeviceDescriptor in audio_system_manager.h
414      * @since 9
415      */
416     void OnDistributedRoutingRoleChange(const AudioDeviceDescriptor *descriptor, const CastType type) override;
417     void SaveCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
418     void RemoveCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
419 private:
420     std::list<std::shared_ptr<AudioDistributedRoutingRoleCallback>> callbackList_;
421     std::shared_ptr<AudioDistributedRoutingRoleCallback> cb_;
422     std::mutex cbListMutex_;
423 };
424 
425 class AudioDeviceRefiner {
426 public:
427     virtual ~AudioDeviceRefiner() = default;
428 
429     virtual int32_t OnAudioOutputDeviceRefined(std::vector<std::unique_ptr<AudioDeviceDescriptor>> &descs,
430         RouterType routerType, StreamUsage streamUsage, int32_t clientUid, AudioPipeType audioPipeType) = 0;
431     virtual int32_t OnAudioInputDeviceRefined(std::vector<std::unique_ptr<AudioDeviceDescriptor>> &descs,
432         RouterType routerType, SourceType sourceType, int32_t clientUid, AudioPipeType audioPipeType) = 0;
433 };
434 
435 /**
436  * @brief The AudioSystemManager class is an abstract definition of audio manager.
437  *        Provides a series of client/interfaces for audio management
438  */
439 
440 class AudioSystemManager {
441 public:
442     static AudioSystemManager *GetInstance();
443 
444     /**
445      * @brief Map volume to HDI.
446      *
447      * @param volume volume value.
448      * @return Returns current volume.
449      * @since 8
450      */
451     static float MapVolumeToHDI(int32_t volume);
452 
453     /**
454      * @brief Map volume from HDI.
455      *
456      * @param volume volume value.
457      * @return Returns current volume.
458      * @since 8
459      */
460     static int32_t MapVolumeFromHDI(float volume);
461 
462     /**
463      * @brief Get audio streamType.
464      *
465      * @param contentType Enumerates the audio content type.
466      * @param streamUsage Enumerates the stream usage.
467      * @return Returns Audio streamType.
468      * @since 8
469      */
470     static AudioStreamType GetStreamType(ContentType contentType, StreamUsage streamUsage);
471 
472     /**
473      * @brief Set the stream volume.
474      *
475      * @param volumeType Enumerates the audio volume type.
476      * @param volume The volume to be set for the current stream.
477      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
478      * defined in {@link audio_errors.h} otherwise.
479      * @since 8
480      */
481     int32_t SetVolume(AudioVolumeType volumeType, int32_t volume) const;
482 
483     /**
484      * @brief Obtains the current stream volume.
485      *
486      * @param volumeType Enumerates the audio volume type.
487      * @return Returns current stream volume.
488      * @since 8
489      */
490     int32_t GetVolume(AudioVolumeType volumeType) const;
491 
492     /**
493      * @brief Set volume discount factor.
494      *
495      * @param streamId stream Unique identification.
496      * @param volume Adjustment percentage.
497      * @return Whether the operation is effective
498      * @since 9
499      */
500     int32_t SetLowPowerVolume(int32_t streamId, float volume) const;
501 
502     /**
503      * @brief get volume discount factor.
504      *
505      * @param streamId stream Unique identification.
506      * @return Returns current stream volume.
507      * @since 9
508      */
509     float GetLowPowerVolume(int32_t streamId) const;
510 
511     /**
512      * @brief get single stream volume.
513      *
514      * @param streamId stream Unique identification.
515      * @return Returns current stream volume.
516      * @since 9
517      */
518     float GetSingleStreamVolume(int32_t streamId) const;
519 
520     /**
521      * @brief get max stream volume.
522      *
523      * @param volumeType audio volume type.
524      * @return Returns current stream volume.
525      * @since 8
526      */
527     int32_t GetMaxVolume(AudioVolumeType volumeType);
528 
529     /**
530      * @brief get min stream volume.
531      *
532      * @param volumeType audio volume type.
533      * @return Returns current stream volume.
534      * @since 8
535      */
536     int32_t GetMinVolume(AudioVolumeType volumeType);
537 
538     /**
539      * @brief set stream mute.
540      *
541      * @param volumeType audio volume type.
542      * @param mute Specifies whether the stream is muted.
543      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
544      * in {@link audio_errors.h} otherwise.
545      * @since 8
546      */
547     int32_t SetMute(AudioVolumeType volumeType, bool mute) const;
548 
549     /**
550      * @brief is stream mute.
551      *
552      * @param volumeType audio volume type.
553      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
554      * @since 8
555      */
556     bool IsStreamMute(AudioVolumeType volumeType) const;
557 
558     /**
559      * @brief Set global microphone mute state.
560      *
561      * @param mute Specifies whether the Microphone is muted.
562      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
563      * in {@link audio_errors.h} otherwise.
564      * @since 8
565      */
566     int32_t SetMicrophoneMute(bool isMute);
567 
568     /**
569      * @brief get global microphone mute state.
570      *
571      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
572      * @since 9
573      */
574     bool IsMicrophoneMute();
575 
576     /**
577      * @brief Select output device.
578      *
579      * @param audioDeviceDescriptors Output device object.
580      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
581      * in {@link audio_errors.h} otherwise.
582      * @since 9
583      */
584     int32_t SelectOutputDevice(std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
585 
586     /**
587      * @brief Select input device.
588      *
589      * @param audioDeviceDescriptors Output device object.
590      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
591      * in {@link audio_errors.h} otherwise.
592      * @since 9
593      */
594     int32_t SelectInputDevice(std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
595 
596     /**
597      * @brief get selected device info.
598      *
599      * @param uid identifier.
600      * @param pid identifier.
601      * @param streamType audio stream type.
602      * @return Returns device info.
603      * @since 9
604      */
605     std::string GetSelectedDeviceInfo(int32_t uid, int32_t pid, AudioStreamType streamType) const;
606 
607     /**
608      * @brief Select the audio output device according to the filter conditions.
609      *
610      * @param audioRendererFilter filter conditions.
611      * @param audioDeviceDescriptors Output device object.
612      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
613      * in {@link audio_errors.h} otherwise.
614      * @since 9
615      */
616     int32_t SelectOutputDevice(sptr<AudioRendererFilter> audioRendererFilter,
617         std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
618 
619     /**
620      * @brief Select the audio input device according to the filter conditions.
621      *
622      * @param audioRendererFilter filter conditions.
623      * @param audioDeviceDescriptors Output device object.
624      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
625      * in {@link audio_errors.h} otherwise.
626      * @since 9
627      */
628     int32_t SelectInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter,
629         std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
630 
631     /**
632      * @brief Get the list of audio devices.
633      *
634      * @param deviceFlag Flag of device type.
635      * @param GetAudioParameter Key of audio parameters to be obtained.
636      * @return Returns the device list is obtained.
637      * @since 9
638      */
639     std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag);
640 
641     /**
642      * @brief Get the list of audio devices (inner).
643      *
644      * @param deviceFlag Flag of device type.
645      * @return Returns the device list is obtained.
646      * @since 12
647      */
648     std::vector<sptr<AudioDeviceDescriptor>> GetDevicesInner(DeviceFlag deviceFlag);
649 
650     /**
651      * @brief Get audio parameter.
652      *
653      * @param key Key of audio parameters to be obtained.
654      * @return Returns the value of the obtained audio parameter
655      * @since 9
656      */
657     const std::string GetAudioParameter(const std::string key);
658 
659     /**
660      * @brief set audio parameter.
661      *
662      * @param key The key of the set audio parameter.
663      * @param value The value of the set audio parameter.
664      * @since 9
665      */
666     void SetAudioParameter(const std::string &key, const std::string &value);
667 
668     /**
669      * @brief set audio parameter.
670      *
671      * @parame key The key of the set audio parameter.
672      * @param value The value of the set audio parameter.
673      * @since 12
674      */
675     int32_t SetAsrAecMode(const AsrAecMode asrAecMode);
676     /**
677      * @brief set audio parameter.
678      *
679      * @parame key The key of the set audio parameter.
680      * @param value The value of the set audio parameter.
681      * @since 12
682      */
683     int32_t GetAsrAecMode(AsrAecMode &asrAecMode);
684     /**
685      * @brief set audio parameter.
686      *
687      * @parame key The key of the set audio parameter.
688      * @param value The value of the set audio parameter.
689      * @since 12
690      */
691     int32_t SetAsrNoiseSuppressionMode(const AsrNoiseSuppressionMode asrNoiseSuppressionMode);
692     /**
693      * @brief set audio parameter.
694      *
695      * @parame key The key of the set audio parameter.
696      * @param value The value of the set audio parameter.
697      * @since 12
698      */
699     int32_t GetAsrNoiseSuppressionMode(AsrNoiseSuppressionMode &asrNoiseSuppressionMode);
700     /**
701      * @brief set audio parameter.
702      *
703      * @parame key The key of the set audio parameter.
704      * @param value The value of the set audio parameter.
705      * @since 12
706      */
707     int32_t SetAsrWhisperDetectionMode(const AsrWhisperDetectionMode asrWhisperDetectionMode);
708     /**
709      * @brief set audio parameter.
710      *
711      * @parame key The key of the set audio parameter.
712      * @param value The value of the set audio parameter.
713      * @since 12
714      */
715     int32_t GetAsrWhisperDetectionMode(AsrWhisperDetectionMode &asrWhisperDetectionMode);
716     /**
717      * @brief set audio parameter.
718      *
719      * @parame key The key of the set audio parameter.
720      * @param value The value of the set audio parameter.
721      * @since 12
722      */
723     int32_t SetAsrVoiceControlMode(const AsrVoiceControlMode asrVoiceControlMode, bool on);
724     /**
725      * @brief set audio parameter.
726      *
727      * @parame key The key of the set audio parameter.
728      * @param value The value of the set audio parameter.
729      * @since 12
730      */
731     int32_t SetAsrVoiceMuteMode(const AsrVoiceMuteMode asrVoiceMuteMode, bool on);
732     /**
733      * @brief set audio parameter.
734      *
735      * @parame key The key of the set audio parameter.
736      * @param value The value of the set audio parameter.
737      * @since 12
738      */
739     int32_t IsWhispering();
740 
741     /**
742      * @brief Get audio parameter.
743      *
744      * @param mainKey Main key of audio parameters to be obtained.
745      * @param subKeys subKeys of audio parameters to be obtained.
746      * @param result value of sub key parameters.
747      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
748      * @since 11
749      */
750     int32_t GetExtraParameters(const std::string &mainKey,
751         const std::vector<std::string> &subKeys, std::vector<std::pair<std::string, std::string>> &result);
752 
753     /**
754      * @brief Set audio parameters.
755      *
756      * @param key The main key of the set audio parameter.
757      * @param kvpairs The pairs with sub keys and values of the set audio parameter.
758      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
759      * @since 11
760      */
761     int32_t SetExtraParameters(const std::string &key,
762         const std::vector<std::pair<std::string, std::string>> &kvpairs);
763 
764     /**
765      * @brief Get transaction Id.
766      *
767      * @param deviceType device type.
768      * @param deviceRole device role.
769      * @return Returns transaction Id.
770      * @since 9
771      */
772     uint64_t GetTransactionId(DeviceType deviceType, DeviceRole deviceRole);
773 
774     /**
775      * @brief Set device active.
776      *
777      * @param deviceType device type.
778      * @param flag Device activation status.
779      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
780      * in {@link audio_errors.h} otherwise.
781      * @since 9
782      */
783     int32_t SetDeviceActive(ActiveDeviceType deviceType, bool flag) const;
784 
785     /**
786      * @brief get device active.
787      *
788      * @param deviceType device type.
789      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
790      * @since 9
791      */
792     bool IsDeviceActive(ActiveDeviceType deviceType) const;
793 
794     /**
795      * @brief get active output device.
796      *
797      * @return Returns device type.
798      * @since 9
799      */
800     DeviceType GetActiveOutputDevice();
801 
802     /**
803      * @brief get active input device.
804      *
805      * @return Returns device type.
806      * @since 9
807      */
808     DeviceType GetActiveInputDevice();
809 
810     /**
811      * @brief Is stream active.
812      *
813      * @param volumeType audio volume type.
814      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
815      * @since 9
816      */
817     bool IsStreamActive(AudioVolumeType volumeType) const;
818 
819     /**
820      * @brief Set ringer mode.
821      *
822      * @param ringMode audio ringer mode.
823      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
824      * in {@link audio_errors.h} otherwise.
825      * @since 8
826      */
827     int32_t SetRingerMode(AudioRingerMode ringMode);
828 
829     /**
830      * @brief Get ringer mode.
831      *
832      * @return Returns audio ringer mode.
833      * @since 8
834      */
835     AudioRingerMode GetRingerMode();
836 
837     /**
838      * @brief Set audio scene.
839      *
840      * @param scene audio scene.
841      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
842      * in {@link audio_errors.h} otherwise.
843      * @since 8
844      */
845     int32_t SetAudioScene(const AudioScene &scene);
846 
847     /**
848      * @brief Get audio scene.
849      *
850      * @return Returns audio scene.
851      * @since 8
852      */
853     AudioScene GetAudioScene() const;
854 
855     /**
856      * @brief Registers the deviceChange callback listener.
857      *
858      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
859      * defined in {@link audio_errors.h} otherwise.
860      * @since 8
861      */
862     int32_t SetDeviceChangeCallback(const DeviceFlag flag, const std::shared_ptr<AudioManagerDeviceChangeCallback>
863         &callback);
864 
865     /**
866      * @brief Unregisters the deviceChange callback listener
867      *
868      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
869      * defined in {@link audio_errors.h} otherwise.
870      * @since 8
871      */
872     int32_t UnsetDeviceChangeCallback(DeviceFlag flag = DeviceFlag::ALL_DEVICES_FLAG,
873         std::shared_ptr<AudioManagerDeviceChangeCallback> callback = nullptr);
874 
875     /**
876      * @brief Registers the ringerMode callback listener.
877      *
878      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
879      * defined in {@link audio_errors.h} otherwise.
880      * @since 8
881      */
882     int32_t SetRingerModeCallback(const int32_t clientId,
883                                   const std::shared_ptr<AudioRingerModeCallback> &callback);
884 
885     /**
886      * @brief Unregisters the VolumeKeyEvent callback listener
887      *
888      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
889      * defined in {@link audio_errors.h} otherwise.
890      * @since 8
891      */
892     int32_t UnsetRingerModeCallback(const int32_t clientId) const;
893 
894     /**
895      * @brief registers the volumeKeyEvent callback listener
896      *
897      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
898      * defined in {@link audio_errors.h} otherwise.
899      * @since 8
900      */
901     int32_t RegisterVolumeKeyEventCallback(const int32_t clientPid,
902         const std::shared_ptr<VolumeKeyEventCallback> &callback, API_VERSION api_v = API_9);
903 
904     /**
905      * @brief Unregisters the volumeKeyEvent callback listener
906      *
907      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
908      * defined in {@link audio_errors.h} otherwise.
909      * @since 8
910      */
911     int32_t UnregisterVolumeKeyEventCallback(const int32_t clientPid,
912         const std::shared_ptr<VolumeKeyEventCallback> &callback = nullptr);
913 
914     /**
915      * @brief Set mono audio state
916      *
917      * @param monoState mono state
918      * @since 8
919      */
920     void SetAudioMonoState(bool monoState);
921 
922     /**
923      * @brief Set audio balance value
924      *
925      * @param balanceValue balance value
926      * @since 8
927      */
928     void SetAudioBalanceValue(float balanceValue);
929 
930     /**
931      * @brief Set system sound uri
932      *
933      * @param key the key of uri
934      * @param uri the value of uri
935      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
936      * defined in {@link audio_errors.h} otherwise.
937      * @since 10
938      */
939     int32_t SetSystemSoundUri(const std::string &key, const std::string &uri);
940 
941     /**
942      * @brief Get system sound uri
943      *
944      * @param key the key of uri
945      * @return Returns the value of uri for the key
946      * @since 10
947      */
948     std::string GetSystemSoundUri(const std::string &key);
949 
950     // Below APIs are added to handle compilation error in call manager
951     // Once call manager adapt to new interrupt APIs, this will be removed
952 
953     /**
954      * @brief registers the audioManager callback listener
955      *
956      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
957      * defined in {@link audio_errors.h} otherwise.
958      * @since 8
959      */
960     int32_t SetAudioManagerCallback(const AudioVolumeType streamType,
961                                     const std::shared_ptr<AudioManagerCallback> &callback);
962 
963     /**
964      * @brief Unregisters the audioManager callback listener
965      *
966      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
967      * defined in {@link audio_errors.h} otherwise.
968      * @since 8
969      */
970     int32_t UnsetAudioManagerCallback(const AudioVolumeType streamType) const;
971 
972     /**
973      * @brief Activate audio Interrupt
974      *
975      * @param audioInterrupt audioInterrupt
976      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
977      * defined in {@link audio_errors.h} otherwise.
978      * @since 8
979      */
980     int32_t ActivateAudioInterrupt(const AudioInterrupt &audioInterrupt);
981 
982     /**
983      * @brief Deactivactivate audio Interrupt
984      *
985      * @param audioInterrupt audioInterrupt
986      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
987      * defined in {@link audio_errors.h} otherwise.
988      * @since 8
989      */
990     int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt) const;
991 
992     /**
993      * @brief registers the Interrupt callback listener
994      *
995      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
996      * defined in {@link audio_errors.h} otherwise.
997      * @since 8
998      */
999     int32_t SetAudioManagerInterruptCallback(const std::shared_ptr<AudioManagerCallback> &callback);
1000 
1001     /**
1002      * @brief Unregisters the Interrupt callback listener
1003      *
1004      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1005      * defined in {@link audio_errors.h} otherwise.
1006      * @since 8
1007      */
1008     int32_t UnsetAudioManagerInterruptCallback();
1009 
1010     /**
1011      * @brief Request audio focus
1012      *
1013      * @param audioInterrupt audioInterrupt
1014      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1015      * defined in {@link audio_errors.h} otherwise.
1016      * @since 8
1017      */
1018     int32_t RequestAudioFocus(const AudioInterrupt &audioInterrupt);
1019 
1020     /**
1021      * @brief Abandon audio focus
1022      *
1023      * @param audioInterrupt audioInterrupt
1024      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1025      * defined in {@link audio_errors.h} otherwise.
1026      * @since 8
1027      */
1028     int32_t AbandonAudioFocus(const AudioInterrupt &audioInterrupt);
1029 
1030     /**
1031      * @brief Reconfigure audio channel
1032      *
1033      * @param count count
1034      * @param deviceType device type
1035      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1036      * defined in {@link audio_errors.h} otherwise.
1037      * @since 8
1038      */
1039     int32_t ReconfigureAudioChannel(const uint32_t &count, DeviceType deviceType);
1040 
1041     /**
1042      * @brief Request independent interrupt
1043      *
1044      * @param focusType focus type
1045      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1046      * in {@link audio_errors.h} otherwise.
1047      * @since 8
1048      */
1049     bool RequestIndependentInterrupt(FocusType focusType);
1050 
1051     /**
1052      * @brief Abandon independent interrupt
1053      *
1054      * @param focusType focus type
1055      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1056      * in {@link audio_errors.h} otherwise.
1057      * @since 8
1058      */
1059     bool AbandonIndependentInterrupt(FocusType focusType);
1060 
1061     /**
1062      * @brief Get audio latency from Xml
1063      *
1064      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1065      * defined in {@link audio_errors.h} otherwise.
1066      * @since 8
1067      */
1068     int32_t GetAudioLatencyFromXml() const;
1069 
1070     /**
1071      * @brief Get audio sink from Xml
1072      *
1073      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1074      * defined in {@link audio_errors.h} otherwise.
1075      * @since 8
1076      */
1077     uint32_t GetSinkLatencyFromXml() const;
1078 
1079     /**
1080      * @brief Update stream state
1081      *
1082      * @param clientUid client Uid
1083      * @param streamSetState streamSetState
1084      * @param streamUsage streamUsage
1085      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1086      * defined in {@link audio_errors.h} otherwise.
1087      * @since 8
1088      */
1089     int32_t UpdateStreamState(const int32_t clientUid, StreamSetState streamSetState,
1090                                     StreamUsage streamUsage);
1091 
1092     /**
1093      * @brief Get Pin Value From Type
1094      *
1095      * @param deviceType deviceType
1096      * @param deviceRole deviceRole
1097      * @return Returns Enumerate AudioPin
1098      * @since 8
1099      */
1100     AudioPin GetPinValueFromType(DeviceType deviceType, DeviceRole deviceRole) const;
1101 
1102     /**
1103      * @brief Get type Value From Pin
1104      *
1105      * @param pin AudioPin
1106      * @return Returns Enumerate DeviceType
1107      * @since 8
1108      */
1109     DeviceType GetTypeValueFromPin(AudioPin pin) const;
1110 
1111     /**
1112      * @brief Get volume groups
1113      *
1114      * @param networkId networkId
1115      * @param info VolumeGroupInfo
1116      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1117      * defined in {@link audio_errors.h} otherwise.
1118      * @since 8
1119      */
1120     int32_t GetVolumeGroups(std::string networkId, std::vector<sptr<VolumeGroupInfo>> &info);
1121 
1122     /**
1123      * @brief Get volume groups manager
1124      *
1125      * @param networkId networkId
1126      * @return Returns AudioGroupManager
1127      * @since 8
1128      */
1129     std::shared_ptr<AudioGroupManager> GetGroupManager(int32_t groupId);
1130 
1131     /**
1132      * @brief Get active output deviceDescriptors
1133      *
1134      * @return Returns AudioDeviceDescriptor
1135      * @since 8
1136      */
1137     std::vector<sptr<AudioDeviceDescriptor>> GetActiveOutputDeviceDescriptors();
1138 
1139     /**
1140      * @brief Get preferred input device deviceDescriptors
1141      *
1142      * @return Returns AudioDeviceDescriptor
1143      * @since 10
1144      */
1145     int32_t GetPreferredInputDeviceDescriptors();
1146 
1147     /**
1148      * @brief Get audio focus info
1149      *
1150      * @return Returns success or not
1151      * @since 10
1152      */
1153     int32_t GetAudioFocusInfoList(std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList);
1154 
1155     /**
1156      * @brief Register callback to listen audio focus info change event
1157      *
1158      * @return Returns success or not
1159      * @since 10
1160      */
1161     int32_t RegisterFocusInfoChangeCallback(const std::shared_ptr<AudioFocusInfoChangeCallback> &callback);
1162 
1163     /**
1164      * @brief Unregister callback to listen audio focus info change event
1165      *
1166      * @return Returns success or not
1167      * @since 10
1168      */
1169     int32_t UnregisterFocusInfoChangeCallback(
1170         const std::shared_ptr<AudioFocusInfoChangeCallback> &callback = nullptr);
1171 
1172     /**
1173      * @brief Ask audio native process to request thread priority for client
1174      *
1175      * @param tid Target thread id
1176      * @since 10
1177      */
1178     void RequestThreadPriority(uint32_t tid);
1179 
1180     int32_t SetAudioCapturerSourceCallback(const std::shared_ptr<AudioCapturerSourceCallback> &callback);
1181 
1182     int32_t SetWakeUpSourceCloseCallback(const std::shared_ptr<WakeUpSourceCloseCallback> &callback);
1183 
1184     /**
1185      * @brief Set whether or not absolute volume is supported for the specified Bluetooth device
1186      *
1187      * @return Returns success or not
1188      * @since 11
1189      */
1190     int32_t SetDeviceAbsVolumeSupported(const std::string &macAddress, const bool support);
1191 
1192     /**
1193      * @brief Set the absolute volume value for the specified Bluetooth device
1194      *
1195      * @return Returns success or not
1196      * @since 11
1197      */
1198     int32_t SetA2dpDeviceVolume(const std::string &macAddress, const int32_t volume, const bool updateUi);
1199     /**
1200      * @brief Registers the availbale deviceChange callback listener.
1201      *
1202      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1203      * defined in {@link audio_errors.h} otherwise.
1204      * @since 11
1205      */
1206     int32_t SetAvailableDeviceChangeCallback(const AudioDeviceUsage usage,
1207         const std::shared_ptr<AudioManagerAvailableDeviceChangeCallback>& callback);
1208     /**
1209      * @brief UnRegisters the availbale deviceChange callback listener.
1210      *
1211      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1212      * defined in {@link audio_errors.h} otherwise.
1213      * @since 11
1214      */
1215     int32_t UnsetAvailableDeviceChangeCallback(AudioDeviceUsage usage);
1216 
1217     /**
1218      * @brief Switch the output device accoring different cast type.
1219      *
1220      * @return Returns {@link SUCCESS} if device is successfully switched; returns an error code
1221      * defined in {@link audio_errors.h} otherwise.
1222      * @since 11
1223      */
1224     int32_t ConfigDistributedRoutingRole(AudioDeviceDescriptor *desciptor, CastType type);
1225 
1226     /**
1227      * @brief Registers the descriptor Change callback listener.
1228      *
1229      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1230      * defined in {@link audio_errors.h} otherwise.
1231      * @since 11
1232      */
1233     int32_t SetDistributedRoutingRoleCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
1234 
1235     /**
1236      * @brief UnRegisters the descriptor Change callback callback listener.
1237      *
1238      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1239      * defined in {@link audio_errors.h} otherwise.
1240      * @since 11
1241      */
1242     int32_t UnsetDistributedRoutingRoleCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
1243 
1244     /**
1245      * @brief Set device address.
1246      *
1247      * @param deviceType device type.
1248      * @param flag Device activation status.
1249      * @param address Device address
1250      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1251      * in {@link audio_errors.h} otherwise.
1252      * @since 11
1253      */
1254     int32_t SetCallDeviceActive(ActiveDeviceType deviceType, bool flag, std::string address) const;
1255 
1256     /**
1257      * @brief get the effect algorithmic latency value for a specified audio stream.
1258      *
1259      * @param sessionId the session ID value for the stream
1260      * @return Returns the effect algorithmic latency in ms.
1261      * @since 12
1262      */
1263     uint32_t GetEffectLatency(const std::string &sessionId);
1264 
1265     /**
1266      * @brief set useraction command
1267      *
1268      * @param actionCommand action command
1269      * @param paramInfo information
1270      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1271      * in {@link audio_errors.h} otherwise.
1272      * @since 12
1273      */
1274     int32_t DisableSafeMediaVolume();
1275 
1276     static void AudioServerDied(pid_t pid);
1277 
1278     int32_t SetMicrophoneBlockedCallback(const std::shared_ptr<AudioManagerMicrophoneBlockedCallback>& callback);
1279     int32_t UnsetMicrophoneBlockedCallback(std::shared_ptr<AudioManagerMicrophoneBlockedCallback> callback = nullptr);
1280 
1281     std::string GetSelfBundleName(int32_t uid);
1282 
1283     std::string GetSelfBundleName();
1284 
1285     int32_t SetQueryClientTypeCallback(const std::shared_ptr<AudioQueryClientTypeCallback> &callback);
1286 
1287     /**
1288      * @brief inject interruption event.
1289      *
1290      * @param networkId networkId.
1291      * @param event Indicates the InterruptEvent information needed by client.
1292      * For details, refer InterruptEvent struct in audio_interrupt_info.h
1293      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1294      * in {@link audio_errors.h} otherwise.
1295      * @since 12
1296      */
1297     int32_t InjectInterruption(const std::string networkId, InterruptEvent &event);
1298 
1299     /**
1300     * @brief Load the split module for audio stream separation.
1301     *
1302     * @param splitArgs Specifies the types of audio to be split into different streams.
1303     * @param networkId The network identifier of the output device.
1304     * @return Returns {@link SUCCESS} if the module is loaded successfully; otherwise, returns an error code defined
1305     * in {@link audio_errors.h}.
1306     * @since 12
1307     */
1308     int32_t LoadSplitModule(const std::string &splitArgs, const std::string &networkId);
1309 
1310     /**
1311     * @brief Set Custmoized Ring Back Tone mute state.
1312     *
1313     * @param isMute Specifies whether the Customized Ring Back Tone is muted.
1314     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1315     * in {@link audio_errors.h}.
1316     */
1317     int32_t SetVoiceRingtoneMute(bool isMute);
1318 
1319 private:
1320     class WakeUpCallbackImpl : public WakeUpSourceCallback {
1321     public:
WakeUpCallbackImpl(AudioSystemManager * audioSystemManager)1322         WakeUpCallbackImpl(AudioSystemManager *audioSystemManager)
1323             :audioSystemManager_(audioSystemManager)
1324         {
1325         }
OnCapturerState(bool isActive)1326         void OnCapturerState(bool isActive) override
1327         {
1328             auto callback = audioSystemManager_ -> audioCapturerSourceCallback_;
1329             if (callback != nullptr) {
1330                 callback -> OnCapturerState(isActive);
1331             }
1332         }
OnWakeupClose()1333         void OnWakeupClose() override
1334         {
1335             auto callback = audioSystemManager_ -> audioWakeUpSourceCloseCallback_;
1336             if (callback != nullptr) {
1337                 callback -> OnWakeupClose();
1338             }
1339         }
1340     private:
1341         AudioSystemManager *audioSystemManager_;
1342     };
1343 
1344     static constexpr int32_t MAX_VOLUME_LEVEL = 15;
1345     static constexpr int32_t MIN_VOLUME_LEVEL = 0;
1346     static constexpr int32_t CONST_FACTOR = 100;
1347     static const std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> streamTypeMap_;
1348 
1349     AudioSystemManager();
1350     virtual ~AudioSystemManager();
1351 
1352     static std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> CreateStreamMap();
1353     static void CreateStreamMap(std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> &streamMap);
1354     int32_t GetCallingPid();
1355 
1356     int32_t RegisterWakeupSourceCallback();
1357     void OtherDeviceTypeCases(DeviceType deviceType) const;
1358 
1359     int32_t cbClientId_ = -1;
1360     int32_t volumeChangeClientPid_ = -1;
1361     AudioRingerMode ringModeBackup_ = RINGER_MODE_NORMAL;
1362     std::shared_ptr<AudioManagerDeviceChangeCallback> deviceChangeCallback_ = nullptr;
1363     std::shared_ptr<AudioInterruptCallback> audioInterruptCallback_ = nullptr;
1364     std::shared_ptr<AudioRingerModeCallback> ringerModeCallback_ = nullptr;
1365     std::shared_ptr<AudioFocusInfoChangeCallback> audioFocusInfoCallback_ = nullptr;
1366     std::shared_ptr<AudioDistributedRoutingRoleCallback> audioDistributedRoutingRoleCallback_ = nullptr;
1367     std::vector<std::shared_ptr<AudioGroupManager>> groupManagerMap_;
1368     std::mutex ringerModeCallbackMutex_;
1369 
1370     std::shared_ptr<AudioCapturerSourceCallback> audioCapturerSourceCallback_ = nullptr;
1371     std::shared_ptr<WakeUpSourceCloseCallback> audioWakeUpSourceCloseCallback_ = nullptr;
1372 
1373     std::shared_ptr<WakeUpCallbackImpl> remoteWakeUpCallback_;
1374 };
1375 } // namespace AudioStandard
1376 } // namespace OHOS
1377 #endif // ST_AUDIO_SYSTEM_MANAGER_H
1378