• 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 
17 #include "audio_spatialization_state_change_listener.h"
18 #include "audio_policy_log.h"
19 
20 namespace OHOS {
21 namespace AudioStandard {
22 
AudioSpatializationStateChangeListener()23 AudioSpatializationStateChangeListener::AudioSpatializationStateChangeListener()
24 {
25     AUDIO_DEBUG_LOG("Instance create");
26 }
27 
~AudioSpatializationStateChangeListener()28 AudioSpatializationStateChangeListener::~AudioSpatializationStateChangeListener()
29 {
30     AUDIO_DEBUG_LOG("Instance destroy");
31 }
32 
OnSpatializationStateChange(const AudioSpatializationState & spatializationState)33 int32_t AudioSpatializationStateChangeListener::OnSpatializationStateChange(
34     const AudioSpatializationState &spatializationState)
35 {
36     AUDIO_DEBUG_LOG("OnSpatializationStateChange");
37 
38     std::shared_ptr<AudioSpatializationStateChangeCallback> cb = callback_.lock();
39     if (cb == nullptr) {
40         AUDIO_ERR_LOG("callback_ is nullptr");
41         return AUDIO_ERR;
42     }
43 
44     cb->OnSpatializationStateChange(spatializationState);
45     return AUDIO_OK;
46 }
47 
SetCallback(const std::weak_ptr<AudioSpatializationStateChangeCallback> & callback)48 void AudioSpatializationStateChangeListener::SetCallback(
49     const std::weak_ptr<AudioSpatializationStateChangeCallback> &callback)
50 {
51     AUDIO_DEBUG_LOG("SetCallback");
52     callback_ = callback;
53 }
54 
55 } // AudioStandard
56 } // OHOS
57