1 /* 2 * Copyright (c) 2021-2025 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_POLICY_MANAGER_H 17 #define ST_AUDIO_POLICY_MANAGER_H 18 19 #include <cstdint> 20 #include <memory> 21 #include "audio_client_tracker_callback_stub.h" 22 #include "audio_effect.h" 23 #include "audio_concurrency_callback.h" 24 #include "audio_concurrency_state_listener_stub.h" 25 #include "audio_interrupt_callback.h" 26 #include "audio_policy_base.h" 27 #include "audio_policy_manager_listener_stub.h" 28 #include "audio_policy_client_stub_impl.h" 29 #include "audio_routing_manager.h" 30 #include "audio_routing_manager_listener_stub.h" 31 #include "audio_anahs_manager_listener_stub.h" 32 #include "audio_policy_interface.h" 33 #include "audio_system_manager.h" 34 #include "i_standard_client_tracker.h" 35 #include "audio_policy_log.h" 36 #include "microphone_descriptor.h" 37 #include "audio_spatialization_manager.h" 38 #include "audio_spatialization_state_change_listener_stub.h" 39 #include "i_standard_spatialization_state_change_listener.h" 40 #include "audio_combine_denoising_manager.h" 41 42 namespace OHOS { 43 namespace AudioStandard { 44 using InternalDeviceType = DeviceType; 45 using InternalAudioCapturerOptions = AudioCapturerOptions; 46 47 struct CallbackChangeInfo { 48 std::mutex mutex; 49 bool isEnable = false; 50 }; 51 52 class AudioPolicyManager { 53 public: 54 static AudioPolicyManager& GetInstance(); 55 static const sptr<IAudioPolicy> GetAudioPolicyManagerProxy(); 56 57 int32_t GetMaxVolumeLevel(AudioVolumeType volumeType); 58 59 int32_t GetMinVolumeLevel(AudioVolumeType volumeType); 60 61 int32_t SetSystemVolumeLevel(AudioVolumeType volumeType, int32_t volumeLevel, bool isLegacy = false, 62 int32_t volumeFlag = 0); 63 64 int32_t SetSystemVolumeLevelWithDevice(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType deviceType, 65 int32_t volumeFlag = 0); 66 int32_t SetAppVolumeLevel(int32_t appUid, int32_t volumeLevel, int32_t volumeFlag = 0); 67 68 int32_t SetAppVolumeMuted(int32_t appUid, bool muted, int32_t volumeFlag = 0); 69 70 bool IsAppVolumeMute(int32_t appUid, bool muted); 71 72 int32_t SetSelfAppVolumeLevel(int32_t volumeLevel, int32_t volumeFlag = 0); 73 74 AudioStreamType GetSystemActiveVolumeType(const int32_t clientUid); 75 76 int32_t GetSystemVolumeLevel(AudioVolumeType volumeType); 77 78 int32_t GetAppVolumeLevel(int32_t appUid); 79 80 int32_t GetSelfAppVolumeLevel(); 81 82 int32_t SetLowPowerVolume(int32_t streamId, float volume); 83 84 float GetLowPowerVolume(int32_t streamId); 85 86 float GetSingleStreamVolume(int32_t streamId); 87 88 int32_t SetStreamMute(AudioVolumeType volumeType, bool mute, bool isLegacy = false, 89 const DeviceType &deviceType = DEVICE_TYPE_NONE); 90 91 bool GetStreamMute(AudioVolumeType volumeType); 92 93 bool IsStreamActive(AudioVolumeType volumeType); 94 95 int32_t SelectOutputDevice(sptr<AudioRendererFilter> audioRendererFilter, 96 std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors); 97 98 std::string GetSelectedDeviceInfo(int32_t uid, int32_t pid, AudioStreamType streamType); 99 100 int32_t SelectInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter, 101 std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors); 102 103 int32_t ExcludeOutputDevices(AudioDeviceUsage audioDevUsage, 104 std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors); 105 106 int32_t UnexcludeOutputDevices(AudioDeviceUsage audioDevUsage, 107 std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors); 108 109 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetExcludedDevices( 110 AudioDeviceUsage audioDevUsage); 111 112 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag); 113 114 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevicesInner(DeviceFlag deviceFlag); 115 116 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetOutputDevice( 117 sptr<AudioRendererFilter> audioRendererFilter); 118 119 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetInputDevice( 120 sptr<AudioCapturerFilter> audioCapturerFilter); 121 122 int32_t SetDeviceActive(InternalDeviceType deviceType, bool active, const int32_t uid = INVALID_UID); 123 124 bool IsDeviceActive(InternalDeviceType deviceType); 125 126 DeviceType GetActiveOutputDevice(); 127 128 DeviceType GetActiveInputDevice(); 129 130 int32_t SetRingerModeLegacy(AudioRingerMode ringMode); 131 132 int32_t SetRingerMode(AudioRingerMode ringMode); 133 134 #ifdef FEATURE_DTMF_TONE 135 std::vector<int32_t> GetSupportedTones(const std::string &countryCode); 136 137 std::shared_ptr<ToneInfo> GetToneConfig(int32_t ltonetype, const std::string &countryCode); 138 #endif 139 140 AudioRingerMode GetRingerMode(); 141 142 int32_t SetAudioScene(AudioScene scene); 143 144 int32_t SetMicrophoneMute(bool isMute); 145 146 int32_t SetMicrophoneMuteAudioConfig(bool isMute); 147 148 int32_t SetMicrophoneMutePersistent(const bool isMute, const PolicyType type); 149 150 bool GetPersistentMicMuteState(); 151 152 bool IsMicrophoneMuteLegacy(); 153 154 bool IsMicrophoneMute(); 155 156 AudioScene GetAudioScene(); 157 158 int32_t SetDeviceChangeCallback(const int32_t clientId, const DeviceFlag flag, 159 const std::shared_ptr<AudioManagerDeviceChangeCallback> &callback); 160 161 int32_t UnsetDeviceChangeCallback(const int32_t clientId, DeviceFlag flag, 162 std::shared_ptr<AudioManagerDeviceChangeCallback> &cb); 163 164 int32_t SetDistribuitedOutputChangeCallback(const std::shared_ptr<AudioDistribuitedOutputChangeCallback> &cb); 165 166 int32_t SetRingerModeCallback(const int32_t clientId, 167 const std::shared_ptr<AudioRingerModeCallback> &callback, API_VERSION api_v = API_9); 168 169 int32_t SetAppVolumeChangeCallbackForUid(const int32_t appUid, 170 const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback); 171 172 int32_t UnsetAppVolumeCallbackForUid( 173 const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback = nullptr); 174 175 int32_t SetSelfAppVolumeChangeCallback(const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback); 176 177 int32_t UnsetSelfAppVolumeCallback(const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback); 178 179 int32_t UnsetRingerModeCallback(const int32_t clientId); 180 181 int32_t UnsetRingerModeCallback(const int32_t clientId, 182 const std::shared_ptr<AudioRingerModeCallback> &callback); 183 184 int32_t SetMicStateChangeCallback(const int32_t clientId, 185 const std::shared_ptr<AudioManagerMicStateChangeCallback> &callback); 186 187 int32_t UnsetMicStateChangeCallback(const std::shared_ptr<AudioManagerMicStateChangeCallback> &callback); 188 189 int32_t SetAudioInterruptCallback(const uint32_t sessionID, 190 const std::shared_ptr<AudioInterruptCallback> &callback, uint32_t clientUid, const int32_t zoneID = 0); 191 192 int32_t UnsetAudioInterruptCallback(const uint32_t sessionID, const int32_t zoneID = 0); 193 194 int32_t ActivateAudioInterrupt( 195 AudioInterrupt &audioInterrupt, const int32_t zoneID = 0, const bool isUpdatedAudioStrategy = false); 196 197 int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt, const int32_t zoneID = 0); 198 199 int32_t SetQueryClientTypeCallback(const std::shared_ptr<AudioQueryClientTypeCallback> &callback); 200 201 int32_t SetAudioManagerInterruptCallback(const int32_t clientId, 202 const std::shared_ptr<AudioInterruptCallback> &callback); 203 204 int32_t UnsetAudioManagerInterruptCallback(const int32_t clientId); 205 206 int32_t RequestAudioFocus(const int32_t clientId, const AudioInterrupt &audioInterrupt); 207 208 int32_t AbandonAudioFocus(const int32_t clientId, const AudioInterrupt &audioInterrupt); 209 210 AudioStreamType GetStreamInFocus(const int32_t zoneID = 0); 211 212 AudioStreamType GetStreamInFocusByUid(const int32_t uid, const int32_t zoneID = 0); 213 214 int32_t GetSessionInfoInFocus(AudioInterrupt &audioInterrupt, const int32_t zoneID = 0); 215 216 int32_t ActivateAudioSession(const AudioSessionStrategy &strategy); 217 218 int32_t DeactivateAudioSession(); 219 220 bool IsAudioSessionActivated(); 221 222 int32_t SetAudioSessionCallback(const std::shared_ptr<AudioSessionCallback> &audioSessionCallback); 223 224 int32_t UnsetAudioSessionCallback(); 225 226 int32_t UnsetAudioSessionCallback(const std::shared_ptr<AudioSessionCallback> &audioSessionCallback); 227 228 int32_t SetVolumeKeyEventCallback(const int32_t clientPid, 229 const std::shared_ptr<VolumeKeyEventCallback> &callback, API_VERSION api_v = API_9); 230 231 int32_t UnsetVolumeKeyEventCallback(const std::shared_ptr<VolumeKeyEventCallback> &callback); 232 233 int32_t ReconfigureAudioChannel(const uint32_t &count, DeviceType deviceType); 234 235 int32_t GetPreferredOutputStreamType(AudioRendererInfo &rendererInfo); 236 237 int32_t GetPreferredInputStreamType(AudioCapturerInfo &capturerInfo); 238 239 int32_t RegisterAudioRendererEventListener(const std::shared_ptr<AudioRendererStateChangeCallback> &callback); 240 241 int32_t UnregisterAudioRendererEventListener( 242 const std::vector<std::shared_ptr<AudioRendererStateChangeCallback>> &callbacks); 243 244 int32_t UnregisterAudioRendererEventListener( 245 const std::shared_ptr<AudioRendererStateChangeCallback> &callback); 246 247 int32_t RegisterAudioCapturerEventListener(const int32_t clientPid, 248 const std::shared_ptr<AudioCapturerStateChangeCallback> &callback); 249 250 int32_t UnregisterAudioCapturerEventListener(const int32_t clientPid); 251 252 int32_t RegisterDeviceChangeWithInfoCallback( 253 const uint32_t sessionID, const std::weak_ptr<DeviceChangeWithInfoCallback> &callback); 254 255 int32_t UnregisterDeviceChangeWithInfoCallback(const uint32_t sessionID); 256 257 int32_t RegisterTracker(AudioMode &mode, AudioStreamChangeInfo &streamChangeInfo, 258 const std::shared_ptr<AudioClientTracker> &clientTrackerObj); 259 260 int32_t UpdateTracker(AudioMode &mode, AudioStreamChangeInfo &streamChangeInfo); 261 262 int32_t GetCurrentRendererChangeInfos( 263 std::vector<std::shared_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos); 264 265 int32_t GetCurrentCapturerChangeInfos( 266 std::vector<std::shared_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos); 267 268 int32_t UpdateStreamState(const int32_t clientUid, StreamSetState streamSetState, 269 StreamUsage streamUsage); 270 271 int32_t GetVolumeGroupInfos(std::string networkId, std::vector<sptr<VolumeGroupInfo>> &infos); 272 273 int32_t GetNetworkIdByGroupId(int32_t groupId, std::string &networkId); 274 275 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetPreferredOutputDeviceDescriptors( 276 AudioRendererInfo &rendererInfo, bool forceNoBTPermission = false); 277 278 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetPreferredInputDeviceDescriptors( 279 AudioCapturerInfo &captureInfo); 280 281 int32_t SetPreferredOutputDeviceChangeCallback(const AudioRendererInfo &rendererInfo, 282 const std::shared_ptr<AudioPreferredOutputDeviceChangeCallback> &callback); 283 284 int32_t SetPreferredInputDeviceChangeCallback(const AudioCapturerInfo &capturerInfo, 285 const std::shared_ptr<AudioPreferredInputDeviceChangeCallback> &callback); 286 287 int32_t UnsetPreferredOutputDeviceChangeCallback( 288 const std::shared_ptr<AudioPreferredOutputDeviceChangeCallback> &callback = nullptr); 289 290 int32_t UnsetPreferredInputDeviceChangeCallback( 291 const std::shared_ptr<AudioPreferredInputDeviceChangeCallback> &callback = nullptr); 292 293 int32_t GetAudioFocusInfoList(std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList, 294 const int32_t zoneID = 0); 295 296 int32_t RegisterFocusInfoChangeCallback(const int32_t clientId, 297 const std::shared_ptr<AudioFocusInfoChangeCallback> &callback); 298 299 int32_t UnregisterFocusInfoChangeCallback(const int32_t clientId); 300 301 static void AudioPolicyServerDied(pid_t pid, pid_t uid); 302 303 int32_t SetSystemSoundUri(const std::string &key, const std::string &uri); 304 305 std::string GetSystemSoundUri(const std::string &key); 306 307 float GetMinStreamVolume(void); 308 309 float GetMaxStreamVolume(void); 310 int32_t RegisterAudioPolicyServerDiedCb(const int32_t clientPid, 311 const std::shared_ptr<AudioRendererPolicyServiceDiedCallback> &callback); 312 int32_t RegisterAudioPolicyServerDiedCb(const int32_t clientPid, 313 const std::shared_ptr<AudioCapturerPolicyServiceDiedCallback> &callback); 314 int32_t UnregisterAudioPolicyServerDiedCb(const int32_t clientPid); 315 316 int32_t RegisterAudioStreamPolicyServerDiedCb( 317 const std::shared_ptr<AudioStreamPolicyServiceDiedCallback> &callback); 318 int32_t UnregisterAudioStreamPolicyServerDiedCb( 319 const std::shared_ptr<AudioStreamPolicyServiceDiedCallback> &callback); 320 321 bool IsVolumeUnadjustable(); 322 323 int32_t AdjustVolumeByStep(VolumeAdjustType adjustType); 324 325 int32_t AdjustSystemVolumeByStep(AudioVolumeType volumeType, VolumeAdjustType adjustType); 326 327 float GetSystemVolumeInDb(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType deviceType); 328 329 int32_t GetMaxRendererInstances(); 330 331 int32_t QueryEffectSceneMode(SupportedEffectConfig &supportedEffectConfig); 332 333 int32_t GetHardwareOutputSamplingRate(const std::shared_ptr<AudioDeviceDescriptor> &desc); 334 335 void RecoverAudioPolicyCallbackClient(); 336 337 std::vector<sptr<MicrophoneDescriptor>> GetAudioCapturerMicrophoneDescriptors(int32_t sessionID); 338 339 std::vector<sptr<MicrophoneDescriptor>> GetAvailableMicrophones(); 340 341 int32_t SetDeviceAbsVolumeSupported(const std::string &macAddress, const bool support); 342 343 bool IsAbsVolumeScene(); 344 345 int32_t SetA2dpDeviceVolume(const std::string &macAddress, const int32_t volume, const bool updateUi); 346 347 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetAvailableDevices(AudioDeviceUsage usage); 348 349 int32_t SetAvailableDeviceChangeCallback(const int32_t clientId, const AudioDeviceUsage usage, 350 const std::shared_ptr<AudioManagerAvailableDeviceChangeCallback>& callback); 351 352 int32_t UnsetAvailableDeviceChangeCallback(const int32_t clientId, AudioDeviceUsage usage); 353 354 bool IsSpatializationEnabled(); 355 356 bool IsSpatializationEnabled(const std::string address); 357 358 bool IsSpatializationEnabledForCurrentDevice(); 359 360 int32_t SetSpatializationEnabled(const bool enable); 361 362 int32_t SetSpatializationEnabled( 363 const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice, const bool enable); 364 365 bool IsHeadTrackingEnabled(); 366 367 bool IsHeadTrackingEnabled(const std::string address); 368 369 int32_t SetHeadTrackingEnabled(const bool enable); 370 371 int32_t SetHeadTrackingEnabled( 372 const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice, const bool enable); 373 374 int32_t RegisterSpatializationEnabledEventListener( 375 const std::shared_ptr<AudioSpatializationEnabledChangeCallback> &callback); 376 377 int32_t RegisterSpatializationEnabledForCurrentDeviceEventListener( 378 const std::shared_ptr<AudioSpatializationEnabledChangeForCurrentDeviceCallback> &callback); 379 380 int32_t RegisterHeadTrackingEnabledEventListener( 381 const std::shared_ptr<AudioHeadTrackingEnabledChangeCallback> &callback); 382 383 int32_t RegisterNnStateEventListener(const std::shared_ptr<AudioNnStateChangeCallback> &callback); 384 385 int32_t UnregisterSpatializationEnabledEventListener(); 386 387 int32_t UnregisterSpatializationEnabledForCurrentDeviceEventListener(); 388 389 int32_t UnregisterHeadTrackingEnabledEventListener(); 390 391 int32_t UnregisterNnStateEventListener(); 392 393 AudioSpatializationState GetSpatializationState(const StreamUsage streamUsage); 394 395 bool IsSpatializationSupported(); 396 397 bool IsSpatializationSupportedForDevice(const std::string address); 398 399 bool IsHeadTrackingSupported(); 400 401 bool IsHeadTrackingSupportedForDevice(const std::string address); 402 403 int32_t UpdateSpatialDeviceState(const AudioSpatialDeviceState audioSpatialDeviceState); 404 405 int32_t RegisterSpatializationStateEventListener(const uint32_t sessionID, const StreamUsage streamUsage, 406 const std::shared_ptr<AudioSpatializationStateChangeCallback> &callback); 407 408 int32_t ConfigDistributedRoutingRole(std::shared_ptr<AudioDeviceDescriptor> descriptor, CastType type); 409 410 int32_t SetDistributedRoutingRoleCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback); 411 412 int32_t UnsetDistributedRoutingRoleCallback(); 413 414 int32_t UnregisterSpatializationStateEventListener(const uint32_t sessionID); 415 416 int32_t CreateAudioInterruptZone(const std::set<int32_t> &pids, const int32_t zoneID); 417 418 int32_t AddAudioInterruptZonePids(const std::set<int32_t> &pids, const int32_t zoneID); 419 420 int32_t RemoveAudioInterruptZonePids(const std::set<int32_t> &pids, const int32_t zoneID); 421 422 int32_t ReleaseAudioInterruptZone(const int32_t zoneID); 423 424 int32_t SetCallDeviceActive(InternalDeviceType deviceType, bool active, std::string address, 425 const int32_t uid = INVALID_UID); 426 427 std::shared_ptr<AudioDeviceDescriptor> GetActiveBluetoothDevice(); 428 429 ConverterConfig GetConverterConfig(); 430 431 void FetchOutputDeviceForTrack(AudioStreamChangeInfo &streamChangeInfo, 432 const AudioStreamDeviceChangeReasonExt reason); 433 434 void FetchInputDeviceForTrack(AudioStreamChangeInfo &streamChangeInfo); 435 436 bool IsHighResolutionExist(); 437 438 int32_t SetHighResolutionExist(bool highResExist); 439 440 AudioSpatializationSceneType GetSpatializationSceneType(); 441 442 int32_t SetSpatializationSceneType(const AudioSpatializationSceneType spatializationSceneType); 443 444 float GetMaxAmplitude(const int32_t deviceId); 445 446 int32_t DisableSafeMediaVolume(); 447 448 bool IsHeadTrackingDataRequested(const std::string &macAddress); 449 450 int32_t RegisterHeadTrackingDataRequestedEventListener(const std::string &macAddress, 451 const std::shared_ptr<HeadTrackingDataRequestedChangeCallback> &callback); 452 453 int32_t UnregisterHeadTrackingDataRequestedEventListener(const std::string &macAddress); 454 455 int32_t SetAudioDeviceRefinerCallback(const std::shared_ptr<AudioDeviceRefiner> &callback); 456 457 int32_t UnsetAudioDeviceRefinerCallback(); 458 459 int32_t SetAudioClientInfoMgrCallback(const std::shared_ptr<AudioClientInfoMgrCallback> &callback); 460 461 int32_t TriggerFetchDevice(AudioStreamDeviceChangeReasonExt reason); 462 463 int32_t SetPreferredDevice(const PreferredType preferredType, const std::shared_ptr<AudioDeviceDescriptor> &desc, 464 const int32_t uid = INVALID_UID); 465 466 int32_t SetAudioDeviceAnahsCallback(const std::shared_ptr<AudioDeviceAnahs> &callback); 467 468 int32_t UnsetAudioDeviceAnahsCallback(); 469 470 int32_t MoveToNewPipe(const uint32_t sessionId, const AudioPipeType pipeType); 471 472 int32_t SetAudioConcurrencyCallback(const uint32_t sessionID, 473 const std::shared_ptr<AudioConcurrencyCallback> &callback); 474 475 int32_t UnsetAudioConcurrencyCallback(const uint32_t sessionID); 476 477 int32_t ActivateAudioConcurrency(const AudioPipeType &pipeType); 478 479 void ResetClientTrackerStubMap(); 480 481 void RemoveClientTrackerStub(int32_t sessionId); 482 483 void CheckAndRemoveClientTrackerStub(const AudioMode &mode, const AudioStreamChangeInfo &streamChangeInfo); 484 485 int32_t InjectInterruption(const std::string networkId, InterruptEvent &event); 486 487 int32_t SetMicrophoneBlockedCallback(const int32_t clientId, 488 const std::shared_ptr<AudioManagerMicrophoneBlockedCallback> &callback); 489 490 int32_t UnsetMicrophoneBlockedCallback(const int32_t clientId, 491 const std::shared_ptr<AudioManagerMicrophoneBlockedCallback> &callback); 492 493 int32_t SetAudioSceneChangeCallback(const int32_t clientId, 494 const std::shared_ptr<AudioManagerAudioSceneChangedCallback> &callback); 495 496 int32_t UnsetAudioSceneChangeCallback( 497 const std::shared_ptr<AudioManagerAudioSceneChangedCallback> &callback); 498 499 int32_t LoadSplitModule(const std::string &splitArgs, const std::string &networkId); 500 501 bool IsAllowedPlayback(const int32_t &uid, const int32_t &pid); 502 503 int32_t SetVoiceRingtoneMute(bool isMute); 504 505 void SaveRemoteInfo(const std::string &networkId, DeviceType deviceType); 506 507 int32_t SetVirtualCall(const bool isVirtual); 508 509 int32_t SetDeviceConnectionStatus(const std::shared_ptr<AudioDeviceDescriptor> &desc, const bool isConnected); 510 511 int32_t SetQueryAllowedPlaybackCallback(const std::shared_ptr<AudioQueryAllowedPlaybackCallback> &callback); 512 513 int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray); 514 int32_t SetAudioEffectProperty(const AudioEffectPropertyArrayV3 &propertyArray); 515 int32_t GetAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray); 516 517 int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArray &propertyArray); 518 int32_t GetSupportedAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray); 519 int32_t SetAudioEffectProperty(const AudioEffectPropertyArray &propertyArray); 520 int32_t GetAudioEffectProperty(AudioEffectPropertyArray &propertyArray); 521 int32_t SetAudioEnhanceProperty(const AudioEnhancePropertyArray &propertyArray); 522 int32_t GetAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray); 523 private: AudioPolicyManager()524 AudioPolicyManager() {} ~AudioPolicyManager()525 ~AudioPolicyManager() {} 526 527 int32_t RegisterPolicyCallbackClientFunc(const sptr<IAudioPolicy> &gsp); 528 int32_t SetClientCallbacksEnable(const CallbackChange &callbackchange, const bool &enable); 529 int32_t SetCallbackStreamInfo(const CallbackChange &callbackChange); 530 int32_t SetCallbackRendererInfo(const AudioRendererInfo &rendererInfo); 531 int32_t SetCallbackCapturerInfo(const AudioCapturerInfo &capturerInfo); 532 533 std::mutex listenerStubMutex_; 534 std::mutex registerCallbackMutex_; 535 std::mutex stateChangelistenerStubMutex_; 536 std::mutex clientTrackerStubMutex_; 537 sptr<AudioPolicyClientStubImpl> audioPolicyClientStubCB_; 538 std::atomic<bool> isAudioPolicyClientRegisted_ = false; 539 540 static std::unordered_map<int32_t, std::weak_ptr<AudioRendererPolicyServiceDiedCallback>> rendererCBMap_; 541 static std::weak_ptr<AudioCapturerPolicyServiceDiedCallback> capturerCB_; 542 static std::vector<std::weak_ptr<AudioStreamPolicyServiceDiedCallback>> audioStreamCBMap_; 543 static std::unordered_map<int32_t, sptr<AudioClientTrackerCallbackStub>> clientTrackerStubMap_; 544 545 bool isAudioRendererEventListenerRegistered = false; 546 bool isAudioCapturerEventListenerRegistered = false; 547 548 std::array<CallbackChangeInfo, CALLBACK_MAX> callbackChangeInfos_ = {}; 549 std::vector<AudioRendererInfo> rendererInfos_; 550 std::vector<AudioCapturerInfo> capturerInfos_; 551 }; 552 } // namespce AudioStandard 553 } // namespace OHOS 554 555 #endif // ST_AUDIO_POLICY_MANAGER_H 556