xref: /aosp_15_r20/frameworks/av/media/libaudiohal/impl/DeviceHalAidl.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1*ec779b8eSAndroid Build Coastguard Worker /*
2*ec779b8eSAndroid Build Coastguard Worker  * Copyright (C) 2022 The Android Open Source Project
3*ec779b8eSAndroid Build Coastguard Worker  *
4*ec779b8eSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*ec779b8eSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*ec779b8eSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*ec779b8eSAndroid Build Coastguard Worker  *
8*ec779b8eSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*ec779b8eSAndroid Build Coastguard Worker  *
10*ec779b8eSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*ec779b8eSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*ec779b8eSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*ec779b8eSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*ec779b8eSAndroid Build Coastguard Worker  * limitations under the License.
15*ec779b8eSAndroid Build Coastguard Worker  */
16*ec779b8eSAndroid Build Coastguard Worker 
17*ec779b8eSAndroid Build Coastguard Worker #pragma once
18*ec779b8eSAndroid Build Coastguard Worker 
19*ec779b8eSAndroid Build Coastguard Worker #include <map>
20*ec779b8eSAndroid Build Coastguard Worker #include <memory>
21*ec779b8eSAndroid Build Coastguard Worker #include <mutex>
22*ec779b8eSAndroid Build Coastguard Worker #include <string>
23*ec779b8eSAndroid Build Coastguard Worker #include <vector>
24*ec779b8eSAndroid Build Coastguard Worker 
25*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/media/audio/IHalAdapterVendorExtension.h>
26*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/hardware/audio/core/BpModule.h>
27*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/hardware/audio/core/sounddose/BpSoundDose.h>
28*ec779b8eSAndroid Build Coastguard Worker #include <android-base/thread_annotations.h>
29*ec779b8eSAndroid Build Coastguard Worker #include <media/audiohal/DeviceHalInterface.h>
30*ec779b8eSAndroid Build Coastguard Worker #include <media/audiohal/EffectHalInterface.h>
31*ec779b8eSAndroid Build Coastguard Worker 
32*ec779b8eSAndroid Build Coastguard Worker #include "Cleanups.h"
33*ec779b8eSAndroid Build Coastguard Worker #include "ConversionHelperAidl.h"
34*ec779b8eSAndroid Build Coastguard Worker #include "Hal2AidlMapper.h"
35*ec779b8eSAndroid Build Coastguard Worker 
36*ec779b8eSAndroid Build Coastguard Worker namespace android {
37*ec779b8eSAndroid Build Coastguard Worker 
38*ec779b8eSAndroid Build Coastguard Worker class StreamOutHalInterfaceCallback;
39*ec779b8eSAndroid Build Coastguard Worker class StreamOutHalInterfaceEventCallback;
40*ec779b8eSAndroid Build Coastguard Worker class StreamOutHalInterfaceLatencyModeCallback;
41*ec779b8eSAndroid Build Coastguard Worker 
42*ec779b8eSAndroid Build Coastguard Worker // The role of the broker is to connect AIDL callback interface implementations
43*ec779b8eSAndroid Build Coastguard Worker // with StreamOut callback implementations. Since AIDL requires all callbacks
44*ec779b8eSAndroid Build Coastguard Worker // to be provided upfront, while libaudiohal interfaces allow late registration,
45*ec779b8eSAndroid Build Coastguard Worker // there is a need to coordinate the matching process.
46*ec779b8eSAndroid Build Coastguard Worker class CallbackBroker : public virtual RefBase {
47*ec779b8eSAndroid Build Coastguard Worker   public:
48*ec779b8eSAndroid Build Coastguard Worker     virtual ~CallbackBroker() = default;
49*ec779b8eSAndroid Build Coastguard Worker     // The cookie is always the stream instance pointer. We don't use weak pointers to avoid extra
50*ec779b8eSAndroid Build Coastguard Worker     // costs on reference counting. The stream cleans up related entries on destruction. Since
51*ec779b8eSAndroid Build Coastguard Worker     // access to the callbacks map is synchronized, the possibility for pointer aliasing due to
52*ec779b8eSAndroid Build Coastguard Worker     // allocation of a new stream at the address of previously deleted stream is avoided.
53*ec779b8eSAndroid Build Coastguard Worker     virtual void clearCallbacks(void* cookie) = 0;
54*ec779b8eSAndroid Build Coastguard Worker     virtual sp<StreamOutHalInterfaceCallback> getStreamOutCallback(void* cookie) = 0;
55*ec779b8eSAndroid Build Coastguard Worker     virtual void setStreamOutCallback(void* cookie, const sp<StreamOutHalInterfaceCallback>&) = 0;
56*ec779b8eSAndroid Build Coastguard Worker     virtual sp<StreamOutHalInterfaceEventCallback> getStreamOutEventCallback(void* cookie) = 0;
57*ec779b8eSAndroid Build Coastguard Worker     virtual void setStreamOutEventCallback(void* cookie,
58*ec779b8eSAndroid Build Coastguard Worker             const sp<StreamOutHalInterfaceEventCallback>&) = 0;
59*ec779b8eSAndroid Build Coastguard Worker     virtual sp<StreamOutHalInterfaceLatencyModeCallback> getStreamOutLatencyModeCallback(
60*ec779b8eSAndroid Build Coastguard Worker             void* cookie) = 0;
61*ec779b8eSAndroid Build Coastguard Worker     virtual void setStreamOutLatencyModeCallback(
62*ec779b8eSAndroid Build Coastguard Worker             void* cookie, const sp<StreamOutHalInterfaceLatencyModeCallback>&) = 0;
63*ec779b8eSAndroid Build Coastguard Worker };
64*ec779b8eSAndroid Build Coastguard Worker 
65*ec779b8eSAndroid Build Coastguard Worker class MicrophoneInfoProvider : public virtual RefBase {
66*ec779b8eSAndroid Build Coastguard Worker   public:
67*ec779b8eSAndroid Build Coastguard Worker     using Info = std::vector<::aidl::android::media::audio::common::MicrophoneInfo>;
68*ec779b8eSAndroid Build Coastguard Worker     virtual ~MicrophoneInfoProvider() = default;
69*ec779b8eSAndroid Build Coastguard Worker     // Returns a nullptr if the HAL does not support microphone info retrieval.
70*ec779b8eSAndroid Build Coastguard Worker     virtual Info const* getMicrophoneInfo() = 0;
71*ec779b8eSAndroid Build Coastguard Worker };
72*ec779b8eSAndroid Build Coastguard Worker 
73*ec779b8eSAndroid Build Coastguard Worker class DeviceHalAidl : public DeviceHalInterface, public ConversionHelperAidl,
74*ec779b8eSAndroid Build Coastguard Worker                       public CallbackBroker, public MicrophoneInfoProvider {
75*ec779b8eSAndroid Build Coastguard Worker   public:
76*ec779b8eSAndroid Build Coastguard Worker     status_t getAudioPorts(std::vector<media::audio::common::AudioPort> *ports) override;
77*ec779b8eSAndroid Build Coastguard Worker 
78*ec779b8eSAndroid Build Coastguard Worker     status_t getAudioRoutes(std::vector<media::AudioRoute> *routes) override;
79*ec779b8eSAndroid Build Coastguard Worker 
80*ec779b8eSAndroid Build Coastguard Worker     status_t getSupportedModes(std::vector<media::audio::common::AudioMode> *modes) override;
81*ec779b8eSAndroid Build Coastguard Worker 
82*ec779b8eSAndroid Build Coastguard Worker     // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
83*ec779b8eSAndroid Build Coastguard Worker     status_t getSupportedDevices(uint32_t *devices) override;
84*ec779b8eSAndroid Build Coastguard Worker 
85*ec779b8eSAndroid Build Coastguard Worker     // Check to see if the audio hardware interface has been initialized.
86*ec779b8eSAndroid Build Coastguard Worker     status_t initCheck() override;
87*ec779b8eSAndroid Build Coastguard Worker 
88*ec779b8eSAndroid Build Coastguard Worker     // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
89*ec779b8eSAndroid Build Coastguard Worker     status_t setVoiceVolume(float volume) override;
90*ec779b8eSAndroid Build Coastguard Worker 
91*ec779b8eSAndroid Build Coastguard Worker     // Set the audio volume for all audio activities other than voice call.
92*ec779b8eSAndroid Build Coastguard Worker     status_t setMasterVolume(float volume) override;
93*ec779b8eSAndroid Build Coastguard Worker 
94*ec779b8eSAndroid Build Coastguard Worker     // Get the current master volume value for the HAL.
95*ec779b8eSAndroid Build Coastguard Worker     status_t getMasterVolume(float *volume) override;
96*ec779b8eSAndroid Build Coastguard Worker 
97*ec779b8eSAndroid Build Coastguard Worker     // Called when the audio mode changes.
98*ec779b8eSAndroid Build Coastguard Worker     status_t setMode(audio_mode_t mode) override;
99*ec779b8eSAndroid Build Coastguard Worker 
100*ec779b8eSAndroid Build Coastguard Worker     // Muting control.
101*ec779b8eSAndroid Build Coastguard Worker     status_t setMicMute(bool state) override;
102*ec779b8eSAndroid Build Coastguard Worker 
103*ec779b8eSAndroid Build Coastguard Worker     status_t getMicMute(bool* state) override;
104*ec779b8eSAndroid Build Coastguard Worker 
105*ec779b8eSAndroid Build Coastguard Worker     status_t setMasterMute(bool state) override;
106*ec779b8eSAndroid Build Coastguard Worker 
107*ec779b8eSAndroid Build Coastguard Worker     status_t getMasterMute(bool *state) override;
108*ec779b8eSAndroid Build Coastguard Worker 
109*ec779b8eSAndroid Build Coastguard Worker     // Set global audio parameters.
110*ec779b8eSAndroid Build Coastguard Worker     status_t setParameters(const String8& kvPairs) override;
111*ec779b8eSAndroid Build Coastguard Worker 
112*ec779b8eSAndroid Build Coastguard Worker     // Get global audio parameters.
113*ec779b8eSAndroid Build Coastguard Worker     status_t getParameters(const String8& keys, String8 *values) override;
114*ec779b8eSAndroid Build Coastguard Worker 
115*ec779b8eSAndroid Build Coastguard Worker     // Returns audio input buffer size according to parameters passed.
116*ec779b8eSAndroid Build Coastguard Worker     status_t getInputBufferSize(struct audio_config* config, size_t* size) override;
117*ec779b8eSAndroid Build Coastguard Worker 
118*ec779b8eSAndroid Build Coastguard Worker     // Creates and opens the audio hardware output stream. The stream is closed
119*ec779b8eSAndroid Build Coastguard Worker     // by releasing all references to the returned object.
120*ec779b8eSAndroid Build Coastguard Worker     status_t openOutputStream(audio_io_handle_t handle, audio_devices_t devices,
121*ec779b8eSAndroid Build Coastguard Worker                               audio_output_flags_t flags, struct audio_config* config,
122*ec779b8eSAndroid Build Coastguard Worker                               const char* address, sp<StreamOutHalInterface>* outStream,
123*ec779b8eSAndroid Build Coastguard Worker                               const std::vector<playback_track_metadata_v7_t>&
124*ec779b8eSAndroid Build Coastguard Worker                                                                sourceMetadata = {}) override;
125*ec779b8eSAndroid Build Coastguard Worker 
126*ec779b8eSAndroid Build Coastguard Worker     // Creates and opens the audio hardware input stream. The stream is closed
127*ec779b8eSAndroid Build Coastguard Worker     // by releasing all references to the returned object.
128*ec779b8eSAndroid Build Coastguard Worker     status_t openInputStream(audio_io_handle_t handle, audio_devices_t devices,
129*ec779b8eSAndroid Build Coastguard Worker                              struct audio_config* config, audio_input_flags_t flags,
130*ec779b8eSAndroid Build Coastguard Worker                              const char* address, audio_source_t source,
131*ec779b8eSAndroid Build Coastguard Worker                              audio_devices_t outputDevice, const char* outputDeviceAddress,
132*ec779b8eSAndroid Build Coastguard Worker                              sp<StreamInHalInterface>* inStream) override;
133*ec779b8eSAndroid Build Coastguard Worker 
134*ec779b8eSAndroid Build Coastguard Worker     // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
135*ec779b8eSAndroid Build Coastguard Worker     status_t supportsAudioPatches(bool* supportsPatches) override;
136*ec779b8eSAndroid Build Coastguard Worker 
137*ec779b8eSAndroid Build Coastguard Worker     // Creates an audio patch between several source and sink ports.
138*ec779b8eSAndroid Build Coastguard Worker     status_t createAudioPatch(unsigned int num_sources, const struct audio_port_config* sources,
139*ec779b8eSAndroid Build Coastguard Worker                               unsigned int num_sinks, const struct audio_port_config* sinks,
140*ec779b8eSAndroid Build Coastguard Worker                               audio_patch_handle_t* patch) override;
141*ec779b8eSAndroid Build Coastguard Worker 
142*ec779b8eSAndroid Build Coastguard Worker     // Releases an audio patch.
143*ec779b8eSAndroid Build Coastguard Worker     status_t releaseAudioPatch(audio_patch_handle_t patch) override;
144*ec779b8eSAndroid Build Coastguard Worker 
145*ec779b8eSAndroid Build Coastguard Worker     // Fills the list of supported attributes for a given audio port.
146*ec779b8eSAndroid Build Coastguard Worker     status_t getAudioPort(struct audio_port* port) override;
147*ec779b8eSAndroid Build Coastguard Worker 
148*ec779b8eSAndroid Build Coastguard Worker     // Fills the list of supported attributes for a given audio port.
149*ec779b8eSAndroid Build Coastguard Worker     status_t getAudioPort(struct audio_port_v7 *port) override;
150*ec779b8eSAndroid Build Coastguard Worker 
151*ec779b8eSAndroid Build Coastguard Worker     // Set audio port configuration.
152*ec779b8eSAndroid Build Coastguard Worker     status_t setAudioPortConfig(const struct audio_port_config* config) override;
153*ec779b8eSAndroid Build Coastguard Worker 
154*ec779b8eSAndroid Build Coastguard Worker     // List microphones
155*ec779b8eSAndroid Build Coastguard Worker     status_t getMicrophones(std::vector<audio_microphone_characteristic_t>* microphones) override;
156*ec779b8eSAndroid Build Coastguard Worker 
157*ec779b8eSAndroid Build Coastguard Worker     status_t addDeviceEffect(
158*ec779b8eSAndroid Build Coastguard Worker             const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
159*ec779b8eSAndroid Build Coastguard Worker 
160*ec779b8eSAndroid Build Coastguard Worker     status_t removeDeviceEffect(
161*ec779b8eSAndroid Build Coastguard Worker             const struct audio_port_config *device, sp<EffectHalInterface> effect) override;
162*ec779b8eSAndroid Build Coastguard Worker 
163*ec779b8eSAndroid Build Coastguard Worker     status_t getMmapPolicyInfos(media::audio::common::AudioMMapPolicyType policyType __unused,
164*ec779b8eSAndroid Build Coastguard Worker                                 std::vector<media::audio::common::AudioMMapPolicyInfo>* policyInfos
165*ec779b8eSAndroid Build Coastguard Worker                                         __unused) override;
166*ec779b8eSAndroid Build Coastguard Worker 
167*ec779b8eSAndroid Build Coastguard Worker     int32_t getAAudioMixerBurstCount() override;
168*ec779b8eSAndroid Build Coastguard Worker 
169*ec779b8eSAndroid Build Coastguard Worker     int32_t getAAudioHardwareBurstMinUsec() override;
170*ec779b8eSAndroid Build Coastguard Worker 
171*ec779b8eSAndroid Build Coastguard Worker     error::Result<audio_hw_sync_t> getHwAvSync() override;
172*ec779b8eSAndroid Build Coastguard Worker 
173*ec779b8eSAndroid Build Coastguard Worker     status_t supportsBluetoothVariableLatency(bool* supports __unused) override;
174*ec779b8eSAndroid Build Coastguard Worker 
175*ec779b8eSAndroid Build Coastguard Worker     status_t getSoundDoseInterface(const std::string& module,
176*ec779b8eSAndroid Build Coastguard Worker                                    ::ndk::SpAIBinder* soundDoseBinder) override;
177*ec779b8eSAndroid Build Coastguard Worker 
178*ec779b8eSAndroid Build Coastguard Worker     status_t prepareToDisconnectExternalDevice(const struct audio_port_v7 *port) override;
179*ec779b8eSAndroid Build Coastguard Worker 
180*ec779b8eSAndroid Build Coastguard Worker     status_t setConnectedState(const struct audio_port_v7 *port, bool connected) override;
181*ec779b8eSAndroid Build Coastguard Worker 
182*ec779b8eSAndroid Build Coastguard Worker     status_t setSimulateDeviceConnections(bool enabled) override;
183*ec779b8eSAndroid Build Coastguard Worker 
184*ec779b8eSAndroid Build Coastguard Worker     status_t getAudioMixPort(const struct audio_port_v7* devicePort,
185*ec779b8eSAndroid Build Coastguard Worker                              struct audio_port_v7* mixPort) override;
186*ec779b8eSAndroid Build Coastguard Worker 
187*ec779b8eSAndroid Build Coastguard Worker     status_t dump(int fd, const Vector<String16>& args) override;
188*ec779b8eSAndroid Build Coastguard Worker 
189*ec779b8eSAndroid Build Coastguard Worker   private:
190*ec779b8eSAndroid Build Coastguard Worker     friend class sp<DeviceHalAidl>;
191*ec779b8eSAndroid Build Coastguard Worker 
192*ec779b8eSAndroid Build Coastguard Worker     struct Callbacks {  // No need to use `atomic_wp` because access is serialized.
193*ec779b8eSAndroid Build Coastguard Worker         wp<StreamOutHalInterfaceCallback> out;
194*ec779b8eSAndroid Build Coastguard Worker         wp<StreamOutHalInterfaceEventCallback> event;
195*ec779b8eSAndroid Build Coastguard Worker         wp<StreamOutHalInterfaceLatencyModeCallback> latency;
196*ec779b8eSAndroid Build Coastguard Worker     };
197*ec779b8eSAndroid Build Coastguard Worker     struct Microphones {
198*ec779b8eSAndroid Build Coastguard Worker         enum Status { UNKNOWN, NOT_SUPPORTED, QUERIED };
199*ec779b8eSAndroid Build Coastguard Worker         Status status = Status::UNKNOWN;
200*ec779b8eSAndroid Build Coastguard Worker         MicrophoneInfoProvider::Info info;
201*ec779b8eSAndroid Build Coastguard Worker     };
202*ec779b8eSAndroid Build Coastguard Worker 
203*ec779b8eSAndroid Build Coastguard Worker     // Must not be constructed directly by clients.
204*ec779b8eSAndroid Build Coastguard Worker     DeviceHalAidl(
205*ec779b8eSAndroid Build Coastguard Worker             const std::string& instance,
206*ec779b8eSAndroid Build Coastguard Worker             const std::shared_ptr<::aidl::android::hardware::audio::core::IModule>& module,
207*ec779b8eSAndroid Build Coastguard Worker             const std::shared_ptr<::aidl::android::media::audio::IHalAdapterVendorExtension>& vext);
208*ec779b8eSAndroid Build Coastguard Worker 
209*ec779b8eSAndroid Build Coastguard Worker     ~DeviceHalAidl() override = default;
210*ec779b8eSAndroid Build Coastguard Worker 
211*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndRetrieveBtA2dpParameters(AudioParameter &keys, AudioParameter *result);
212*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndRetrieveBtLeParameters(AudioParameter &keys, AudioParameter *result);
213*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateBtA2dpParameters(AudioParameter &parameters);
214*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateBtHfpParameters(AudioParameter &parameters);
215*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateBtLeParameters(AudioParameter &parameters);
216*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateBtScoParameters(AudioParameter &parameters);
217*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateScreenParameters(AudioParameter &parameters);
218*ec779b8eSAndroid Build Coastguard Worker     status_t filterAndUpdateTelephonyParameters(AudioParameter &parameters);
219*ec779b8eSAndroid Build Coastguard Worker 
220*ec779b8eSAndroid Build Coastguard Worker     // CallbackBroker implementation
221*ec779b8eSAndroid Build Coastguard Worker     void clearCallbacks(void* cookie) override;
222*ec779b8eSAndroid Build Coastguard Worker     sp<StreamOutHalInterfaceCallback> getStreamOutCallback(void* cookie) override;
223*ec779b8eSAndroid Build Coastguard Worker     void setStreamOutCallback(void* cookie, const sp<StreamOutHalInterfaceCallback>& cb) override;
224*ec779b8eSAndroid Build Coastguard Worker     sp<StreamOutHalInterfaceEventCallback> getStreamOutEventCallback(void* cookie) override;
225*ec779b8eSAndroid Build Coastguard Worker     void setStreamOutEventCallback(void* cookie,
226*ec779b8eSAndroid Build Coastguard Worker             const sp<StreamOutHalInterfaceEventCallback>& cb) override;
227*ec779b8eSAndroid Build Coastguard Worker     sp<StreamOutHalInterfaceLatencyModeCallback> getStreamOutLatencyModeCallback(
228*ec779b8eSAndroid Build Coastguard Worker             void* cookie) override;
229*ec779b8eSAndroid Build Coastguard Worker     void setStreamOutLatencyModeCallback(
230*ec779b8eSAndroid Build Coastguard Worker             void* cookie, const sp<StreamOutHalInterfaceLatencyModeCallback>& cb) override;
231*ec779b8eSAndroid Build Coastguard Worker     // Implementation helpers.
232*ec779b8eSAndroid Build Coastguard Worker     template<class C> sp<C> getCallbackImpl(void* cookie, wp<C> Callbacks::* field);
233*ec779b8eSAndroid Build Coastguard Worker     template<class C> void setCallbackImpl(void* cookie, wp<C> Callbacks::* field, const sp<C>& cb);
234*ec779b8eSAndroid Build Coastguard Worker 
235*ec779b8eSAndroid Build Coastguard Worker     // MicrophoneInfoProvider implementation
236*ec779b8eSAndroid Build Coastguard Worker     MicrophoneInfoProvider::Info const* getMicrophoneInfo() override;
237*ec779b8eSAndroid Build Coastguard Worker 
238*ec779b8eSAndroid Build Coastguard Worker     // See below, the lock is only used to serialize calling into the interface.
isModuleInitialized()239*ec779b8eSAndroid Build Coastguard Worker     bool isModuleInitialized() const NO_THREAD_SAFETY_ANALYSIS { return mModule != nullptr; }
isTelephonyInitialized()240*ec779b8eSAndroid Build Coastguard Worker     bool isTelephonyInitialized() const NO_THREAD_SAFETY_ANALYSIS { return mTelephony != nullptr; }
241*ec779b8eSAndroid Build Coastguard Worker 
242*ec779b8eSAndroid Build Coastguard Worker     mutable std::mutex mLock;
243*ec779b8eSAndroid Build Coastguard Worker     // GUARDED_BY is used to prevent concurrent calls into these interfaces from multiple threads.
244*ec779b8eSAndroid Build Coastguard Worker     // There is no requirement for IModule and its helper interfaces implementations
245*ec779b8eSAndroid Build Coastguard Worker     // to be thread-safe.
246*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::IModule> mModule
247*ec779b8eSAndroid Build Coastguard Worker             GUARDED_BY(mLock);
248*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::ITelephony> mTelephony
249*ec779b8eSAndroid Build Coastguard Worker             GUARDED_BY(mLock);
250*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetooth> mBluetooth
251*ec779b8eSAndroid Build Coastguard Worker             GUARDED_BY(mLock);
252*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetoothA2dp> mBluetoothA2dp
253*ec779b8eSAndroid Build Coastguard Worker             GUARDED_BY(mLock);
254*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetoothLe> mBluetoothLe
255*ec779b8eSAndroid Build Coastguard Worker             GUARDED_BY(mLock);
256*ec779b8eSAndroid Build Coastguard Worker 
257*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::hardware::audio::core::sounddose::ISoundDose> mSoundDose;
258*ec779b8eSAndroid Build Coastguard Worker     const std::shared_ptr<::aidl::android::media::audio::IHalAdapterVendorExtension> mVendorExt;
259*ec779b8eSAndroid Build Coastguard Worker 
260*ec779b8eSAndroid Build Coastguard Worker     std::mutex mCallbacksLock;
261*ec779b8eSAndroid Build Coastguard Worker     // Use 'mCallbacksLock' only to implement exclusive access to 'mCallbacks'. Never hold it
262*ec779b8eSAndroid Build Coastguard Worker     // while making any calls.
263*ec779b8eSAndroid Build Coastguard Worker     std::map<void*, Callbacks> mCallbacks GUARDED_BY(mCallbacksLock);
264*ec779b8eSAndroid Build Coastguard Worker     std::set<audio_port_handle_t> mDeviceDisconnectionNotified GUARDED_BY(mLock);
265*ec779b8eSAndroid Build Coastguard Worker     Hal2AidlMapper mMapper GUARDED_BY(mLock);
266*ec779b8eSAndroid Build Coastguard Worker     LockedAccessor<Hal2AidlMapper> mMapperAccessor;
267*ec779b8eSAndroid Build Coastguard Worker     Microphones mMicrophones GUARDED_BY(mLock);
268*ec779b8eSAndroid Build Coastguard Worker };
269*ec779b8eSAndroid Build Coastguard Worker 
270*ec779b8eSAndroid Build Coastguard Worker } // namespace android
271