• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "audio_errors.h"
17 #include "audio_policy_manager.h"
18 #include "audio_log.h"
19 #include "audio_routing_manager.h"
20 
21 namespace OHOS {
22 namespace AudioStandard {
23 using namespace std;
GetInstance()24 AudioRoutingManager *AudioRoutingManager::GetInstance()
25 {
26     static AudioRoutingManager audioRoutingManager;
27     return &audioRoutingManager;
28 }
29 
GetCallingPid()30 uint32_t AudioRoutingManager::GetCallingPid()
31 {
32     return getpid();
33 }
34 
SetMicStateChangeCallback(const std::shared_ptr<AudioManagerMicStateChangeCallback> & callback)35 int32_t AudioRoutingManager::SetMicStateChangeCallback(
36     const std::shared_ptr<AudioManagerMicStateChangeCallback> &callback)
37 {
38     AudioSystemManager* audioSystemManager = AudioSystemManager::GetInstance();
39     std::shared_ptr<AudioGroupManager> groupManager = audioSystemManager->GetGroupManager(DEFAULT_VOLUME_GROUP_ID);
40     if (groupManager == nullptr) {
41         AUDIO_ERR_LOG("setMicrophoneMuteCallback falied, groupManager is null");
42         return ERR_INVALID_PARAM;
43     }
44     return groupManager->SetMicStateChangeCallback(callback);
45 }
46 } // namespace AudioStandard
47 } // namespace OHOS
48