1 /* 2 * Copyright (c) 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_FOCUS_INFO_CHANGE_CALLBACK_IMPL_H 17 #define ST_AUDIO_FOCUS_INFO_CHANGE_CALLBACK_IMPL_H 18 19 #include <list> 20 #include <mutex> 21 22 #include "audio_interrupt_info.h" 23 #include "audio_policy_interface.h" 24 25 namespace OHOS { 26 namespace AudioStandard { 27 28 class AudioFocusInfoChangeCallbackImpl : public AudioFocusInfoChangeCallback { 29 public: 30 explicit AudioFocusInfoChangeCallbackImpl(); 31 virtual ~AudioFocusInfoChangeCallbackImpl(); 32 33 void OnAudioFocusInfoChange(const std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList) override; 34 void OnAudioFocusRequested(const AudioInterrupt &requestFocus) override; 35 void OnAudioFocusAbandoned(const AudioInterrupt &abandonFocus) override; 36 void SaveCallback(const std::weak_ptr<AudioFocusInfoChangeCallback> &callback); 37 void RemoveCallback(const std::weak_ptr<AudioFocusInfoChangeCallback> &callback); 38 private: 39 std::list<std::weak_ptr<AudioFocusInfoChangeCallback>> callbackList_; 40 std::shared_ptr<AudioFocusInfoChangeCallback> cb_; 41 std::mutex cbListMutex_; 42 }; 43 } // namespace AudioStandard 44 } // namespace OHOS 45 #endif // ST_AUDIO_FOCUS_INFO_CHANGE_CALLBACK_IMPL_H 46 47