• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <vector>
20 
21 #include "StreamAlsa.h"
22 #include "StreamSwitcher.h"
23 
24 namespace aidl::android::hardware::audio::core {
25 
26 class StreamPrimary : public StreamAlsa {
27   public:
28     StreamPrimary(StreamContext* context, const Metadata& metadata);
29 
30   protected:
31     std::vector<alsa::DeviceProfile> getDeviceProfiles() override;
32 
33     const bool mIsInput;
34 };
35 
36 class StreamInPrimary final : public StreamIn, public StreamSwitcher, public StreamInHwGainHelper {
37   public:
38     friend class ndk::SharedRefBase;
39     StreamInPrimary(
40             StreamContext&& context,
41             const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
42             const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
43 
44   private:
45     static bool useStubStream(const ::aidl::android::media::audio::common::AudioDevice& device);
46 
47     DeviceSwitchBehavior switchCurrentStream(
48             const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices)
49             override;
50     std::unique_ptr<StreamCommonInterfaceEx> createNewStream(
51             const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
52             StreamContext* context, const Metadata& metadata) override;
onClose(StreamDescriptor::State)53     void onClose(StreamDescriptor::State) override { defaultOnClose(); }
54 
55     ndk::ScopedAStatus getHwGain(std::vector<float>* _aidl_return) override;
56     ndk::ScopedAStatus setHwGain(const std::vector<float>& in_channelGains) override;
57 };
58 
59 class StreamOutPrimary final : public StreamOut,
60                                public StreamSwitcher,
61                                public StreamOutHwVolumeHelper {
62   public:
63     friend class ndk::SharedRefBase;
64     StreamOutPrimary(StreamContext&& context,
65                      const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
66                      const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
67                              offloadInfo);
68 
69   private:
70     static bool useStubStream(const ::aidl::android::media::audio::common::AudioDevice& device);
71 
72     DeviceSwitchBehavior switchCurrentStream(
73             const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices)
74             override;
75     std::unique_ptr<StreamCommonInterfaceEx> createNewStream(
76             const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices,
77             StreamContext* context, const Metadata& metadata) override;
onClose(StreamDescriptor::State)78     void onClose(StreamDescriptor::State) override { defaultOnClose(); }
79 
80     ndk::ScopedAStatus getHwVolume(std::vector<float>* _aidl_return) override;
81     ndk::ScopedAStatus setHwVolume(const std::vector<float>& in_channelVolumes) override;
82 };
83 
84 }  // namespace aidl::android::hardware::audio::core
85