• 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 #ifndef AUDIO_SYSTEM_MANAGER_ADAPTER_IMPL_H
17 #define AUDIO_SYSTEM_MANAGER_ADAPTER_IMPL_H
18 
19 #include "audio_system_manager_adapter.h"
20 
21 #include "audio_system_manager.h"
22 
23 namespace OHOS::NWeb {
24 using namespace OHOS::AudioStandard;
25 
26 class AudioManagerCallbackAdapterImpl : public AudioManagerCallback {
27 public:
28     explicit AudioManagerCallbackAdapterImpl(std::shared_ptr<AudioManagerCallbackAdapter> cb);
29 
30     ~AudioManagerCallbackAdapterImpl() override = default;
31 
32     void OnInterrupt(const InterruptAction &interruptAction) override;
33 
34 private:
35     std::shared_ptr<AudioManagerCallbackAdapter> cb_ = nullptr;
36 };
37 
38 class AudioSystemManagerAdapterImpl : public AudioSystemManagerAdapter {
39 public:
40     AudioSystemManagerAdapterImpl() = default;
41 
42     static AudioSystemManagerAdapterImpl& GetInstance();
43 
44     ~AudioSystemManagerAdapterImpl() override = default;
45 
46     bool HasAudioOutputDevices() const override;
47 
48     bool HasAudioInputDevices() const override;
49 
50     int32_t RequestAudioFocus(const AudioAdapterInterrupt &audioInterrupt) override;
51 
52     int32_t AbandonAudioFocus(const AudioAdapterInterrupt &audioInterrupt) override;
53 
54     int32_t SetAudioManagerInterruptCallback(const std::shared_ptr<AudioManagerCallbackAdapter> &callback) override;
55 
56     int32_t UnsetAudioManagerInterruptCallback() override;
57 
58     static AudioStreamType GetStreamType(AudioAdapterStreamType streamType);
59 
60 private:
61     std::shared_ptr<AudioManagerCallbackAdapterImpl> callback_;
62 };
63 }  // namespace OHOS::NWeb
64 
65 #endif // AUDIO_SYSTEM_MANAGER_ADAPTER_IMPL_H