blob: 4b6ab892265d6a6b59258dc81560cca3f695cfef [file] [log] [blame]
Andy Hung440901d2023-06-29 21:19:25 -07001/*
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
Andy Hungc6f227f2023-07-18 18:31:50 -070019#include <android/media/IAudioTrackCallback.h>
20#include <android/media/IEffectClient.h>
21#include <audiomanager/IAudioManager.h>
Andy Hung954b9712023-08-28 18:36:53 -070022#include <audio_utils/mutex.h>
Andy Hungc6f227f2023-07-18 18:31:50 -070023#include <audio_utils/MelProcessor.h>
24#include <binder/MemoryDealer.h>
25#include <datapath/AudioStreamIn.h>
26#include <datapath/AudioStreamOut.h>
27#include <datapath/VolumeInterface.h>
28#include <fastpath/FastMixerDumpState.h>
29#include <media/DeviceDescriptorBase.h>
30#include <media/MmapStreamInterface.h>
31#include <media/audiohal/StreamHalInterface.h>
32#include <media/nblog/NBLog.h>
33#include <timing/SyncEvent.h>
Andy Hungc6f227f2023-07-18 18:31:50 -070034#include <utils/RefBase.h>
35#include <vibrator/ExternalVibration.h>
36
37#include <optional>
Andy Hung440901d2023-06-29 21:19:25 -070038
39namespace android {
40
Andy Hung87c693c2023-07-06 20:56:16 -070041class IAfDirectOutputThread;
42class IAfDuplicatingThread;
Andy Hung7aa7d102023-07-07 15:58:48 -070043class IAfMmapCaptureThread;
44class IAfMmapPlaybackThread;
Andy Hung87c693c2023-07-06 20:56:16 -070045class IAfPlaybackThread;
46class IAfRecordThread;
Andy Hungc6f227f2023-07-18 18:31:50 -070047
48class IAfEffectChain;
49class IAfEffectHandle;
50class IAfEffectModule;
51class IAfPatchPanel;
52class IAfPatchRecord;
53class IAfPatchTrack;
54class IAfRecordTrack;
55class IAfTrack;
56class IAfTrackBase;
57class Client;
Andy Hung583043b2023-07-17 17:05:00 -070058class MelReporter;
59
Andy Hung25a80ac2023-07-19 12:47:35 -070060// Used internally for Threads.cpp and AudioFlinger.cpp
61struct stream_type_t {
62 float volume = 1.f;
63 bool mute = false;
64};
65
Andy Hung583043b2023-07-17 17:05:00 -070066// Note this is exposed through IAfThreadBase::afThreadCallback()
67// and hence may be used by the Effect / Track framework.
68class IAfThreadCallback : public virtual RefBase {
69public:
Andy Hung972bec12023-08-31 16:13:39 -070070 virtual audio_utils::mutex& mutex() const
71 RETURN_CAPABILITY(audio_utils::AudioFlinger_Mutex) = 0;
72 virtual bool isNonOffloadableGlobalEffectEnabled_l() const
Andy Hungab65b182023-09-06 19:41:47 -070073 REQUIRES(mutex()) EXCLUDES_ThreadBase_Mutex = 0; // Tracks
Andy Hung583043b2023-07-17 17:05:00 -070074 virtual audio_unique_id_t nextUniqueId(audio_unique_id_use_t use) = 0;
75 virtual bool btNrecIsOff() const = 0;
Andy Hung972bec12023-08-31 16:13:39 -070076 virtual float masterVolume_l() const
77 REQUIRES(mutex()) = 0;
78 virtual bool masterMute_l() const
79 REQUIRES(mutex()) = 0;
80 virtual float getMasterBalance_l() const
81 REQUIRES(mutex()) = 0;
82 virtual bool streamMute_l(audio_stream_type_t stream) const
83 REQUIRES(mutex()) = 0;
Andy Hung583043b2023-07-17 17:05:00 -070084 virtual audio_mode_t getMode() const = 0;
85 virtual bool isLowRamDevice() const = 0;
86 virtual bool isAudioPolicyReady() const = 0; // Effects
Andy Hung1d2d2aea2023-07-19 16:22:58 -070087 virtual uint32_t getScreenState() const = 0;
Andy Hung972bec12023-08-31 16:13:39 -070088 virtual std::optional<media::AudioVibratorInfo> getDefaultVibratorInfo_l() const
89 REQUIRES(mutex()) = 0;
Andy Hung583043b2023-07-17 17:05:00 -070090 virtual const sp<IAfPatchPanel>& getPatchPanel() const = 0;
91 virtual const sp<MelReporter>& getMelReporter() const = 0;
92 virtual const sp<EffectsFactoryHalInterface>& getEffectsFactoryHal() const = 0;
93 virtual sp<IAudioManager> getOrCreateAudioManager() = 0; // Tracks
94
Andy Hung972bec12023-08-31 16:13:39 -070095 virtual bool updateOrphanEffectChains(const sp<IAfEffectModule>& effect)
96 EXCLUDES_AudioFlinger_Mutex = 0;
97 virtual status_t moveEffectChain_ll(audio_session_t sessionId,
Francois Gaffief2591bc2021-11-22 18:20:16 +010098 IAfPlaybackThread* srcThread, IAfPlaybackThread* dstThread,
99 IAfEffectChain* srcChain = nullptr)
Andy Hung972bec12023-08-31 16:13:39 -0700100 REQUIRES(mutex(), audio_utils::ThreadBase_Mutex) = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700101
102 virtual void requestLogMerge() = 0;
Andy Hung972bec12023-08-31 16:13:39 -0700103 virtual sp<NBLog::Writer> newWriter_l(size_t size, const char *name)
104 REQUIRES(mutex()) = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700105 virtual void unregisterWriter(const sp<NBLog::Writer>& writer) = 0;
106
107 virtual sp<audioflinger::SyncEvent> createSyncEvent(AudioSystem::sync_event_t type,
108 audio_session_t triggerSession,
109 audio_session_t listenerSession,
110 const audioflinger::SyncEventCallback& callBack,
Andy Hung972bec12023-08-31 16:13:39 -0700111 const wp<IAfTrackBase>& cookie)
112 EXCLUDES_AudioFlinger_Mutex = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700113
Andy Hungab65b182023-09-06 19:41:47 -0700114 // Hold either AudioFlinger::mutex or ThreadBase::mutex
115 virtual void ioConfigChanged_l(audio_io_config_event_t event,
Andy Hung583043b2023-07-17 17:05:00 -0700116 const sp<AudioIoDescriptor>& ioDesc,
Andy Hung972bec12023-08-31 16:13:39 -0700117 pid_t pid = 0) EXCLUDES_AudioFlinger_ClientMutex = 0;
118 virtual void onNonOffloadableGlobalEffectEnable() EXCLUDES_AudioFlinger_Mutex = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700119 virtual void onSupportedLatencyModesChanged(
Andy Hung972bec12023-08-31 16:13:39 -0700120 audio_io_handle_t output, const std::vector<audio_latency_mode_t>& modes)
121 EXCLUDES_AudioFlinger_ClientMutex = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700122};
Andy Hung87c693c2023-07-06 20:56:16 -0700123
Andy Hung440901d2023-06-29 21:19:25 -0700124class IAfThreadBase : public virtual RefBase {
125public:
126 enum type_t {
127 MIXER, // Thread class is MixerThread
128 DIRECT, // Thread class is DirectOutputThread
129 DUPLICATING, // Thread class is DuplicatingThread
130 RECORD, // Thread class is RecordThread
131 OFFLOAD, // Thread class is OffloadThread
132 MMAP_PLAYBACK, // Thread class for MMAP playback stream
133 MMAP_CAPTURE, // Thread class for MMAP capture stream
134 SPATIALIZER, //
135 BIT_PERFECT, // Thread class for BitPerfectThread
136 // When adding a value, also update IAfThreadBase::threadTypeToString()
137 };
138
139 static const char* threadTypeToString(type_t type);
Andy Hung25a80ac2023-07-19 12:47:35 -0700140 static std::string formatToString(audio_format_t format); // compliant for MediaMetrics
Andy Hung81994d62023-07-20 21:44:14 -0700141 static bool isValidPcmSinkChannelMask(audio_channel_mask_t channelMask);
142 static bool isValidPcmSinkFormat(audio_format_t format);
143
Andy Hung440901d2023-06-29 21:19:25 -0700144 virtual status_t readyToRun() = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700145 virtual void clearPowerManager() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700146 virtual status_t initCheck() const = 0;
147 virtual type_t type() const = 0;
148 virtual bool isDuplicating() const = 0;
149 virtual audio_io_handle_t id() const = 0;
150 virtual uint32_t sampleRate() const = 0;
151 virtual audio_channel_mask_t channelMask() const = 0;
152 virtual audio_channel_mask_t mixerChannelMask() const = 0;
153 virtual audio_format_t format() const = 0;
154 virtual uint32_t channelCount() const = 0;
155
156 // Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
157 // and returns the [normal mix] buffer's frame count.
158 virtual size_t frameCount() const = 0;
159 virtual audio_channel_mask_t hapticChannelMask() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700160 virtual uint32_t hapticChannelCount() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700161 virtual uint32_t latency_l() const = 0; // NO_THREAD_SAFETY_ANALYSIS
162 virtual void setVolumeForOutput_l(float left, float right) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700163
164 // Return's the HAL's frame count i.e. fast mixer buffer size.
165 virtual size_t frameCountHAL() const = 0;
166 virtual size_t frameSize() const = 0;
167 // Should be "virtual status_t requestExitAndWait()" and override same
168 // method in Thread, but Thread::requestExitAndWait() is not yet virtual.
Andy Hungab65b182023-09-06 19:41:47 -0700169 virtual void exit() EXCLUDES_ThreadBase_Mutex = 0;
170 virtual bool checkForNewParameter_l(const String8& keyValuePair, status_t& status)
171 REQUIRES(mutex()) = 0;
172 virtual status_t setParameters(const String8& keyValuePairs) EXCLUDES_ThreadBase_Mutex = 0;
173 virtual String8 getParameters(const String8& keys) EXCLUDES_ThreadBase_Mutex = 0;
174 virtual void ioConfigChanged_l(
Andy Hung440901d2023-06-29 21:19:25 -0700175 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700176 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE)
177 /* holds either AF::mutex or TB::mutex */ = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700178
179 // sendConfigEvent_l() must be called with ThreadBase::mLock held
180 // Can temporarily release the lock if waiting for a reply from
181 // processConfigEvents_l().
182 // status_t sendConfigEvent_l(sp<ConfigEvent>& event);
183 virtual void sendIoConfigEvent(
184 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700185 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700186 virtual void sendIoConfigEvent_l(
187 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700188 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) REQUIRES(mutex()) = 0;
189 virtual void sendPrioConfigEvent(pid_t pid, pid_t tid, int32_t prio, bool forApp)
190 EXCLUDES_ThreadBase_Mutex = 0;
191 virtual void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio, bool forApp)
192 REQUIRES(mutex()) = 0;
193 virtual status_t sendSetParameterConfigEvent_l(const String8& keyValuePair)
194 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700195 virtual status_t sendCreateAudioPatchConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700196 const struct audio_patch* patch, audio_patch_handle_t* handle)
197 EXCLUDES_ThreadBase_Mutex = 0;
198 virtual status_t sendReleaseAudioPatchConfigEvent(audio_patch_handle_t handle)
199 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700200 virtual status_t sendUpdateOutDeviceConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700201 const DeviceDescriptorBaseVector& outDevices) EXCLUDES_ThreadBase_Mutex = 0;
202 virtual void sendResizeBufferConfigEvent_l(int32_t maxSharedAudioHistoryMs)
203 REQUIRES(mutex()) = 0;
204 virtual void sendCheckOutputStageEffectsEvent() EXCLUDES_ThreadBase_Mutex = 0;
205 virtual void sendCheckOutputStageEffectsEvent_l()
206 REQUIRES(mutex()) = 0;
207 virtual void sendHalLatencyModesChangedEvent_l()
208 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700209
Andy Hungab65b182023-09-06 19:41:47 -0700210 virtual void processConfigEvents_l()
211 REQUIRES(mutex()) = 0;
212 virtual void setCheckOutputStageEffects() = 0; // no mutex needed
213 virtual void cacheParameters_l()
214 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700215 virtual status_t createAudioPatch_l(
Andy Hungab65b182023-09-06 19:41:47 -0700216 const struct audio_patch* patch, audio_patch_handle_t* handle)
217 REQUIRES(mutex()) = 0;
218 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle)
219 REQUIRES(mutex()) = 0;
220 virtual void updateOutDevices(const DeviceDescriptorBaseVector& outDevices)
221 EXCLUDES_ThreadBase_Mutex = 0;
222 virtual void toAudioPortConfig(struct audio_port_config* config)
223 EXCLUDES_ThreadBase_Mutex = 0;
224 virtual void resizeInputBuffer_l(int32_t maxSharedAudioHistoryMs)
225 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700226
227 // see note at declaration of mStandby, mOutDevice and mInDevice
228 virtual bool inStandby() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700229 virtual const DeviceTypeSet outDeviceTypes_l() const REQUIRES(mutex()) = 0;
230 virtual audio_devices_t inDeviceType_l() const REQUIRES(mutex()) = 0;
231 virtual DeviceTypeSet getDeviceTypes_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700232 virtual const AudioDeviceTypeAddrVector& outDeviceTypeAddrs() const = 0;
233 virtual const AudioDeviceTypeAddr& inDeviceTypeAddr() const = 0;
234 virtual bool isOutput() const = 0;
235 virtual bool isOffloadOrMmap() const = 0;
236 virtual sp<StreamHalInterface> stream() const = 0;
237 virtual sp<IAfEffectHandle> createEffect_l(
238 const sp<Client>& client,
239 const sp<media::IEffectClient>& effectClient,
240 int32_t priority,
241 audio_session_t sessionId,
242 effect_descriptor_t* desc,
243 int* enabled,
244 status_t* status /*non-NULL*/,
245 bool pinned,
246 bool probe,
Andy Hung972bec12023-08-31 16:13:39 -0700247 bool notifyFramesProcessed)
Andy Hungab65b182023-09-06 19:41:47 -0700248 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700249
250 // return values for hasAudioSession (bit field)
251 enum effect_state {
252 EFFECT_SESSION = 0x1, // the audio session corresponds to at least one
253 // effect
254 TRACK_SESSION = 0x2, // the audio session corresponds to at least one
255 // track
256 FAST_SESSION = 0x4, // the audio session corresponds to at least one
257 // fast track
258 SPATIALIZED_SESSION = 0x8, // the audio session corresponds to at least one
259 // spatialized track
260 BIT_PERFECT_SESSION = 0x10 // the audio session corresponds to at least one
261 // bit-perfect track
262 };
263
264 // get effect chain corresponding to session Id.
Andy Hungab65b182023-09-06 19:41:47 -0700265 virtual sp<IAfEffectChain> getEffectChain(audio_session_t sessionId) const
266 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700267 // same as getEffectChain() but must be called with ThreadBase mutex locked
Andy Hungab65b182023-09-06 19:41:47 -0700268 virtual sp<IAfEffectChain> getEffectChain_l(audio_session_t sessionId) const
269 REQUIRES(mutex()) = 0;
270 virtual std::vector<int> getEffectIds_l(audio_session_t sessionId) const
271 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700272 // add an effect chain to the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700273 virtual status_t addEffectChain_l(const sp<IAfEffectChain>& chain)
274 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700275 // remove an effect chain from the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700276 virtual size_t removeEffectChain_l(const sp<IAfEffectChain>& chain)
277 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700278 // lock all effect chains Mutexes. Must be called before releasing the
279 // ThreadBase mutex before processing the mixer and effects. This guarantees the
280 // integrity of the chains during the process.
281 // Also sets the parameter 'effectChains' to current value of mEffectChains.
Andy Hungab65b182023-09-06 19:41:47 -0700282 virtual void lockEffectChains_l(Vector<sp<IAfEffectChain>>& effectChains)
Shunkai Yaod125e402024-01-20 03:19:06 +0000283 REQUIRES(mutex()) EXCLUDES_EffectChain_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700284 // unlock effect chains after process
Andy Hungab65b182023-09-06 19:41:47 -0700285 virtual void unlockEffectChains(const Vector<sp<IAfEffectChain>>& effectChains)
286 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700287 // get a copy of mEffectChains vector
Andy Hungab65b182023-09-06 19:41:47 -0700288 virtual Vector<sp<IAfEffectChain>> getEffectChains_l() const
289 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700290 // set audio mode to all effect chains
Andy Hungab65b182023-09-06 19:41:47 -0700291 virtual void setMode(audio_mode_t mode)
292 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700293 // get effect module with corresponding ID on specified audio session
Andy Hungab65b182023-09-06 19:41:47 -0700294 virtual sp<IAfEffectModule> getEffect(audio_session_t sessionId, int effectId) const
295 EXCLUDES_ThreadBase_Mutex = 0;
296 virtual sp<IAfEffectModule> getEffect_l(audio_session_t sessionId, int effectId) const
297 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700298 // add and effect module. Also creates the effect chain is none exists for
299 // the effects audio session. Only called in a context of moving an effect
300 // from one thread to another
Andy Hung972bec12023-08-31 16:13:39 -0700301 virtual status_t addEffect_ll(const sp<IAfEffectModule>& effect)
302 REQUIRES(audio_utils::AudioFlinger_Mutex, mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700303 // remove and effect module. Also removes the effect chain is this was the last
304 // effect
Andy Hungab65b182023-09-06 19:41:47 -0700305 virtual void removeEffect_l(const sp<IAfEffectModule>& effect, bool release = false)
306 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700307 // disconnect an effect handle from module and destroy module if last handle
Andy Hungab65b182023-09-06 19:41:47 -0700308 virtual void disconnectEffectHandle(IAfEffectHandle* handle, bool unpinIfLast)
309 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700310 // detach all tracks connected to an auxiliary effect
Andy Hungab65b182023-09-06 19:41:47 -0700311 virtual void detachAuxEffect_l(int effectId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700312 // returns a combination of:
313 // - EFFECT_SESSION if effects on this audio session exist in one chain
314 // - TRACK_SESSION if tracks on this audio session exist
315 // - FAST_SESSION if fast tracks on this audio session exist
316 // - SPATIALIZED_SESSION if spatialized tracks on this audio session exist
Andy Hungab65b182023-09-06 19:41:47 -0700317 virtual uint32_t hasAudioSession_l(audio_session_t sessionId) const REQUIRES(mutex()) = 0;
318 virtual uint32_t hasAudioSession(audio_session_t sessionId) const
319 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700320
321 // the value returned by default implementation is not important as the
322 // strategy is only meaningful for PlaybackThread which implements this method
Andy Hungab65b182023-09-06 19:41:47 -0700323 virtual product_strategy_t getStrategyForSession_l(audio_session_t sessionId) const
324 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700325
326 // check if some effects must be suspended/restored when an effect is enabled
327 // or disabled
328 virtual void checkSuspendOnEffectEnabled(
Andy Hungab65b182023-09-06 19:41:47 -0700329 bool enabled, audio_session_t sessionId, bool threadLocked)
330 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700331
Andy Hungab65b182023-09-06 19:41:47 -0700332 virtual status_t setSyncEvent(const sp<audioflinger::SyncEvent>& event)
333 EXCLUDES_ThreadBase_Mutex = 0;
334 // internally static, perhaps make static member.
Andy Hung440901d2023-06-29 21:19:25 -0700335 virtual bool isValidSyncEvent(const sp<audioflinger::SyncEvent>& event) const = 0;
336
337 // Return a reference to a per-thread heap which can be used to allocate IMemory
338 // objects that will be read-only to client processes, read/write to mediaserver,
339 // and shared by all client processes of the thread.
340 // The heap is per-thread rather than common across all threads, because
341 // clients can't be trusted not to modify the offset of the IMemory they receive.
342 // If a thread does not have such a heap, this method returns 0.
343 virtual sp<MemoryDealer> readOnlyHeap() const = 0;
344
345 virtual sp<IMemory> pipeMemory() const = 0;
346
Andy Hungab65b182023-09-06 19:41:47 -0700347 virtual void systemReady() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700348
349 // checkEffectCompatibility_l() must be called with ThreadBase::mLock held
350 virtual status_t checkEffectCompatibility_l(
Andy Hungab65b182023-09-06 19:41:47 -0700351 const effect_descriptor_t* desc, audio_session_t sessionId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700352
Andy Hungab65b182023-09-06 19:41:47 -0700353 virtual void broadcast_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700354
Andy Hungab65b182023-09-06 19:41:47 -0700355 virtual bool isTimestampCorrectionEnabled_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700356
357 virtual bool isMsdDevice() const = 0;
358
Andy Hungab65b182023-09-06 19:41:47 -0700359 virtual void dump(int fd, const Vector<String16>& args) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700360
361 // deliver stats to mediametrics.
Andy Hungab65b182023-09-06 19:41:47 -0700362 virtual void sendStatistics(bool force) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700363
Andy Hung972bec12023-08-31 16:13:39 -0700364 virtual audio_utils::mutex& mutex() const
365 RETURN_CAPABILITY(audio_utils::ThreadBase_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700366
Andy Hungab65b182023-09-06 19:41:47 -0700367 virtual void onEffectEnable(const sp<IAfEffectModule>& effect) EXCLUDES_ThreadBase_Mutex = 0;
368 virtual void onEffectDisable() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700369
370 // invalidateTracksForAudioSession_l must be called with holding mLock.
Andy Hungab65b182023-09-06 19:41:47 -0700371 virtual void invalidateTracksForAudioSession_l(audio_session_t sessionId) const
372 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700373 // Invalidate all the tracks with the given audio session.
Andy Hungab65b182023-09-06 19:41:47 -0700374 virtual void invalidateTracksForAudioSession(audio_session_t sessionId) const
375 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700376
377 virtual bool isStreamInitialized() const = 0;
Andy Hung972bec12023-08-31 16:13:39 -0700378 virtual void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor)
379 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
380 virtual void stopMelComputation_l()
381 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700382
Andy Hungab65b182023-09-06 19:41:47 -0700383 virtual product_strategy_t getStrategyForStream(audio_stream_type_t stream) const
384 EXCLUDES_AUDIO_ALL = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700385
386 virtual void setEffectSuspended_l(
Andy Hungab65b182023-09-06 19:41:47 -0700387 const effect_uuid_t* type, bool suspend, audio_session_t sessionId)
388 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700389
Andy Hung6c498e92023-12-05 17:28:17 -0800390 // Wait while the Thread is busy. This is done to ensure that
391 // the Thread is not busy releasing the Tracks, during which the Thread mutex
392 // may be temporarily unlocked. Some Track methods will use this method to
393 // avoid races.
394 virtual void waitWhileThreadBusy_l(audio_utils::unique_lock& ul)
395 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700396 // Dynamic cast to derived interface
397 virtual sp<IAfDirectOutputThread> asIAfDirectOutputThread() { return nullptr; }
398 virtual sp<IAfDuplicatingThread> asIAfDuplicatingThread() { return nullptr; }
399 virtual sp<IAfPlaybackThread> asIAfPlaybackThread() { return nullptr; }
400 virtual sp<IAfRecordThread> asIAfRecordThread() { return nullptr; }
Andy Hung583043b2023-07-17 17:05:00 -0700401 virtual IAfThreadCallback* afThreadCallback() const = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700402};
403
Andy Hung87c693c2023-07-06 20:56:16 -0700404class IAfPlaybackThread : public virtual IAfThreadBase, public virtual VolumeInterface {
Andy Hung440901d2023-06-29 21:19:25 -0700405public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700406 static sp<IAfPlaybackThread> createBitPerfectThread(
Andy Hung583043b2023-07-17 17:05:00 -0700407 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
408 audio_io_handle_t id, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700409
410 static sp<IAfPlaybackThread> createDirectOutputThread(
Andy Hung583043b2023-07-17 17:05:00 -0700411 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
412 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700413
414 static sp<IAfPlaybackThread> createMixerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700415 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
416 audio_io_handle_t id, bool systemReady, type_t type = MIXER,
417 audio_config_base_t* mixerConfig = nullptr);
Andy Hungee58e4a2023-07-07 13:47:37 -0700418
419 static sp<IAfPlaybackThread> createOffloadThread(
Andy Hung583043b2023-07-17 17:05:00 -0700420 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
421 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700422
423 static sp<IAfPlaybackThread> createSpatializerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700424 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
425 audio_io_handle_t id, bool systemReady, audio_config_base_t* mixerConfig);
Andy Hungee58e4a2023-07-07 13:47:37 -0700426
Andy Hung87c693c2023-07-06 20:56:16 -0700427 static constexpr int8_t kMaxTrackStopRetriesOffload = 2;
428
Andy Hung440901d2023-06-29 21:19:25 -0700429 enum mixer_state {
430 MIXER_IDLE, // no active tracks
431 MIXER_TRACKS_ENABLED, // at least one active track, but no track has any data ready
432 MIXER_TRACKS_READY, // at least one active track, and at least one track has data
433 MIXER_DRAIN_TRACK, // drain currently playing track
434 MIXER_DRAIN_ALL, // fully drain the hardware
435 // standby mode does not have an enum value
436 // suspend by audio policy manager is orthogonal to mixer state
437 };
438
439 // return estimated latency in milliseconds, as reported by HAL
440 virtual uint32_t latency() const = 0; // should be in IAfThreadBase?
441
Andy Hungab65b182023-09-06 19:41:47 -0700442 virtual uint32_t& fastTrackAvailMask_l() REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700443
Andy Hung440901d2023-06-29 21:19:25 -0700444 virtual sp<IAfTrack> createTrack_l(
445 const sp<Client>& client,
446 audio_stream_type_t streamType,
447 const audio_attributes_t& attr,
448 uint32_t* sampleRate,
449 audio_format_t format,
450 audio_channel_mask_t channelMask,
451 size_t* pFrameCount,
452 size_t* pNotificationFrameCount,
453 uint32_t notificationsPerBuffer,
454 float speed,
455 const sp<IMemory>& sharedBuffer,
456 audio_session_t sessionId,
457 audio_output_flags_t* flags,
458 pid_t creatorPid,
459 const AttributionSourceState& attributionSource,
460 pid_t tid,
461 status_t* status /*non-NULL*/,
462 audio_port_handle_t portId,
463 const sp<media::IAudioTrackCallback>& callback,
464 bool isSpatialized,
jiabin94ed47c2023-07-27 23:34:20 +0000465 bool isBitPerfect,
Andy Hung972bec12023-08-31 16:13:39 -0700466 audio_output_flags_t* afTrackFlags)
467 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700468
Andy Hungab65b182023-09-06 19:41:47 -0700469 virtual status_t addTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
470 virtual bool destroyTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
471 virtual bool isTrackActive(const sp<IAfTrack>& track) const REQUIRES(mutex()) = 0;
472 virtual void addOutputTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700473
Andy Hungab65b182023-09-06 19:41:47 -0700474 virtual AudioStreamOut* getOutput_l() const REQUIRES(mutex()) = 0;
Andy Hung8d672e02023-09-15 18:19:28 -0700475 virtual AudioStreamOut* getOutput() const EXCLUDES_ThreadBase_Mutex = 0;
476 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700477
478 // a very large number of suspend() will eventually wraparound, but unlikely
479 virtual void suspend() = 0;
480 virtual void restore() = 0;
481 virtual bool isSuspended() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700482 virtual status_t getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames) const
483 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700484 // Consider also removing and passing an explicit mMainBuffer initialization
485 // parameter to AF::IAfTrack::Track().
486 virtual float* sinkBuffer() const = 0;
487
Andy Hungab65b182023-09-06 19:41:47 -0700488 virtual status_t attachAuxEffect(const sp<IAfTrack>& track, int EffectId)
489 EXCLUDES_ThreadBase_Mutex = 0;
490 virtual status_t attachAuxEffect_l(const sp<IAfTrack>& track, int EffectId)
491 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700492
493 // called with AudioFlinger lock held
Andy Hungab65b182023-09-06 19:41:47 -0700494 virtual bool invalidateTracks_l(audio_stream_type_t streamType) REQUIRES(mutex()) = 0;
495 virtual bool invalidateTracks_l(std::set<audio_port_handle_t>& portIds) REQUIRES(mutex()) = 0;
496 virtual void invalidateTracks(audio_stream_type_t streamType)
497 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700498 // Invalidate tracks by a set of port ids. The port id will be removed from
499 // the given set if the corresponding track is found and invalidated.
Andy Hungab65b182023-09-06 19:41:47 -0700500 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
501 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700502
Andy Hungab65b182023-09-06 19:41:47 -0700503 virtual status_t getTimestamp_l(AudioTimestamp& timestamp) REQUIRES(mutex()) = 0;
504 virtual void addPatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
505 virtual void deletePatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700506
507 // Return the asynchronous signal wait time.
Andy Hungab65b182023-09-06 19:41:47 -0700508 virtual int64_t computeWaitTimeNs_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700509 // returns true if the track is allowed to be added to the thread.
510 virtual bool isTrackAllowed_l(
511 audio_channel_mask_t channelMask, audio_format_t format, audio_session_t sessionId,
Andy Hungab65b182023-09-06 19:41:47 -0700512 uid_t uid) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700513
514 virtual bool supportsHapticPlayback() const = 0;
515
Andy Hungab65b182023-09-06 19:41:47 -0700516 virtual void setDownStreamPatch(const struct audio_patch* patch)
517 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700518
Andy Hungab65b182023-09-06 19:41:47 -0700519 virtual IAfTrack* getTrackById_l(audio_port_handle_t trackId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700520
521 virtual bool hasMixer() const = 0;
522
523 virtual status_t setRequestedLatencyMode(audio_latency_mode_t mode) = 0;
524
Andy Hungab65b182023-09-06 19:41:47 -0700525 virtual status_t getSupportedLatencyModes(std::vector<audio_latency_mode_t>* modes)
526 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700527
528 virtual status_t setBluetoothVariableLatencyEnabled(bool enabled) = 0;
529
Andy Hungab65b182023-09-06 19:41:47 -0700530 virtual void setStandby() EXCLUDES_ThreadBase_Mutex = 0;
531 virtual void setStandby_l() REQUIRES(mutex()) = 0;
532 virtual bool waitForHalStart() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700533
534 virtual bool hasFastMixer() const = 0;
535 virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex) const = 0;
536 virtual const std::atomic<int64_t>& framesWritten() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700537
538 virtual bool usesHwAvSync() const = 0;
539};
540
541class IAfDirectOutputThread : public virtual IAfPlaybackThread {
542public:
543 virtual status_t selectPresentation(int presentationId, int programId) = 0;
544};
545
546class IAfDuplicatingThread : public virtual IAfPlaybackThread {
547public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700548 static sp<IAfDuplicatingThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700549 const sp<IAfThreadCallback>& afThreadCallback, IAfPlaybackThread* mainThread,
Andy Hungee58e4a2023-07-07 13:47:37 -0700550 audio_io_handle_t id, bool systemReady);
551
Andy Hungab65b182023-09-06 19:41:47 -0700552 virtual void addOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700553 virtual uint32_t waitTimeMs() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700554 virtual void removeOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700555};
556
557class IAfRecordThread : public virtual IAfThreadBase {
558public:
559 static sp<IAfRecordThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700560 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamIn* input,
561 audio_io_handle_t id, bool systemReady);
Andy Hung87c693c2023-07-06 20:56:16 -0700562
563 virtual sp<IAfRecordTrack> createRecordTrack_l(
564 const sp<Client>& client,
565 const audio_attributes_t& attr,
566 uint32_t* pSampleRate,
567 audio_format_t format,
568 audio_channel_mask_t channelMask,
569 size_t* pFrameCount,
570 audio_session_t sessionId,
571 size_t* pNotificationFrameCount,
572 pid_t creatorPid,
573 const AttributionSourceState& attributionSource,
574 audio_input_flags_t* flags,
575 pid_t tid,
576 status_t* status /*non-NULL*/,
577 audio_port_handle_t portId,
Andy Hung972bec12023-08-31 16:13:39 -0700578 int32_t maxSharedAudioHistoryMs)
Andy Hungab65b182023-09-06 19:41:47 -0700579 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
580 virtual void destroyTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
581 virtual void removeTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700582
583 virtual status_t start(
584 IAfRecordTrack* recordTrack, AudioSystem::sync_event_t event,
Andy Hungab65b182023-09-06 19:41:47 -0700585 audio_session_t triggerSession) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700586
587 // ask the thread to stop the specified track, and
588 // return true if the caller should then do it's part of the stopping process
Andy Hungab65b182023-09-06 19:41:47 -0700589 virtual bool stop(IAfRecordTrack* recordTrack) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700590
Andy Hungab65b182023-09-06 19:41:47 -0700591 // NO_THREAD_SAFETY_ANALYSIS: consider atomics
Andy Hung87c693c2023-07-06 20:56:16 -0700592 virtual AudioStreamIn* getInput() const = 0;
593 virtual AudioStreamIn* clearInput() = 0;
594
595 virtual status_t getActiveMicrophones(
Andy Hungab65b182023-09-06 19:41:47 -0700596 std::vector<media::MicrophoneInfoFw>* activeMicrophones)
597 const EXCLUDES_ThreadBase_Mutex = 0;
598 virtual status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction)
599 EXCLUDES_ThreadBase_Mutex = 0;
600 virtual status_t setPreferredMicrophoneFieldDimension(float zoom)
601 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700602
Andy Hungab65b182023-09-06 19:41:47 -0700603 virtual void addPatchTrack(const sp<IAfPatchRecord>& record)
604 EXCLUDES_ThreadBase_Mutex = 0;
605 virtual void deletePatchTrack(const sp<IAfPatchRecord>& record)
606 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700607 virtual bool fastTrackAvailable() const = 0;
608 virtual void setFastTrackAvailable(bool available) = 0;
609
Andy Hungab65b182023-09-06 19:41:47 -0700610 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
611 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700612 virtual bool hasFastCapture() const = 0;
613
Andy Hung3f49ebb2023-09-19 14:48:41 -0700614 virtual void checkBtNrec() EXCLUDES_ThreadBase_Mutex = 0;
615 virtual uint32_t getInputFramesLost() const EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700616
617 virtual status_t shareAudioHistory(
618 const std::string& sharedAudioPackageName,
619 audio_session_t sharedSessionId = AUDIO_SESSION_NONE,
Andy Hungab65b182023-09-06 19:41:47 -0700620 int64_t sharedAudioStartMs = -1) EXCLUDES_ThreadBase_Mutex = 0;
621 virtual void resetAudioHistory_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700622};
623
Andy Hung7aa7d102023-07-07 15:58:48 -0700624class IAfMmapThread : public virtual IAfThreadBase {
625public:
626 // createIAudioTrackAdapter() is a static constructor which creates an
627 // MmapStreamInterface AIDL interface adapter from the MmapThread object that
628 // may be passed back to the client.
629 //
630 // Only one AIDL MmapStreamInterface interface adapter should be created per MmapThread.
631 static sp<MmapStreamInterface> createMmapStreamInterfaceAdapter(
632 const sp<IAfMmapThread>& mmapThread);
633
634 virtual void configure(
635 const audio_attributes_t* attr,
636 audio_stream_type_t streamType,
637 audio_session_t sessionId,
638 const sp<MmapStreamCallback>& callback,
639 audio_port_handle_t deviceId,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700640 audio_port_handle_t portId) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700641 virtual void disconnect() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700642
643 // MmapStreamInterface handling (see adapter)
644 virtual status_t createMmapBuffer(
Andy Hung3f49ebb2023-09-19 14:48:41 -0700645 int32_t minSizeFrames, struct audio_mmap_buffer_info* info)
646 EXCLUDES_ThreadBase_Mutex = 0;
647 virtual status_t getMmapPosition(struct audio_mmap_position* position) const
648 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700649 virtual status_t start(
650 const AudioClient& client, const audio_attributes_t* attr,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700651 audio_port_handle_t* handle) EXCLUDES_ThreadBase_Mutex = 0;
652 virtual status_t stop(audio_port_handle_t handle) EXCLUDES_ThreadBase_Mutex = 0;
653 virtual status_t standby() EXCLUDES_ThreadBase_Mutex = 0;
654 virtual status_t getExternalPosition(uint64_t* position, int64_t* timeNanos) const
655 EXCLUDES_ThreadBase_Mutex = 0;
656 virtual status_t reportData(const void* buffer, size_t frameCount)
657 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700658
Andy Hung99b1ba62023-07-14 11:00:08 -0700659 // TODO(b/291317898) move to IAfThreadBase?
Andy Hungab65b182023-09-06 19:41:47 -0700660 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
661 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700662
Andy Hung99b1ba62023-07-14 11:00:08 -0700663 // Sets the UID records silence - TODO(b/291317898) move to IAfMmapCaptureThread
Andy Hungab65b182023-09-06 19:41:47 -0700664 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
665 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700666
667 virtual sp<IAfMmapPlaybackThread> asIAfMmapPlaybackThread() { return nullptr; }
668 virtual sp<IAfMmapCaptureThread> asIAfMmapCaptureThread() { return nullptr; }
669};
670
671class IAfMmapPlaybackThread : public virtual IAfMmapThread, public virtual VolumeInterface {
672public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700673 static sp<IAfMmapPlaybackThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700674 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
675 AudioHwDevice* hwDev, AudioStreamOut* output, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700676
Andy Hungab65b182023-09-06 19:41:47 -0700677 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700678};
679
680class IAfMmapCaptureThread : public virtual IAfMmapThread {
681public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700682 static sp<IAfMmapCaptureThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700683 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
684 AudioHwDevice* hwDev, AudioStreamIn* input, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700685
Andy Hungab65b182023-09-06 19:41:47 -0700686 virtual AudioStreamIn* clearInput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700687};
688
Andy Hung440901d2023-06-29 21:19:25 -0700689} // namespace android