blob: c2a58c65f06a502f5d632c7a6b280c647a739be4 [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,
98 IAfPlaybackThread* srcThread, IAfPlaybackThread* dstThread)
99 REQUIRES(mutex(), audio_utils::ThreadBase_Mutex) = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700100
101 virtual void requestLogMerge() = 0;
Andy Hung972bec12023-08-31 16:13:39 -0700102 virtual sp<NBLog::Writer> newWriter_l(size_t size, const char *name)
103 REQUIRES(mutex()) = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700104 virtual void unregisterWriter(const sp<NBLog::Writer>& writer) = 0;
105
106 virtual sp<audioflinger::SyncEvent> createSyncEvent(AudioSystem::sync_event_t type,
107 audio_session_t triggerSession,
108 audio_session_t listenerSession,
109 const audioflinger::SyncEventCallback& callBack,
Andy Hung972bec12023-08-31 16:13:39 -0700110 const wp<IAfTrackBase>& cookie)
111 EXCLUDES_AudioFlinger_Mutex = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700112
Andy Hungab65b182023-09-06 19:41:47 -0700113 // Hold either AudioFlinger::mutex or ThreadBase::mutex
114 virtual void ioConfigChanged_l(audio_io_config_event_t event,
Andy Hung583043b2023-07-17 17:05:00 -0700115 const sp<AudioIoDescriptor>& ioDesc,
Andy Hung972bec12023-08-31 16:13:39 -0700116 pid_t pid = 0) EXCLUDES_AudioFlinger_ClientMutex = 0;
117 virtual void onNonOffloadableGlobalEffectEnable() EXCLUDES_AudioFlinger_Mutex = 0;
Mikhail Naganovf548cd32024-05-29 17:06:46 +0000118 virtual void onSupportedLatencyModesChanged(audio_io_handle_t output,
119 const std::vector<audio_latency_mode_t>& modes)
Andy Hung972bec12023-08-31 16:13:39 -0700120 EXCLUDES_AudioFlinger_ClientMutex = 0;
Mikhail Naganovf548cd32024-05-29 17:06:46 +0000121
122 virtual void onHardError(std::set<audio_port_handle_t>& trackPortIds) = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700123};
Andy Hung87c693c2023-07-06 20:56:16 -0700124
Andy Hung440901d2023-06-29 21:19:25 -0700125class IAfThreadBase : public virtual RefBase {
126public:
127 enum type_t {
128 MIXER, // Thread class is MixerThread
129 DIRECT, // Thread class is DirectOutputThread
130 DUPLICATING, // Thread class is DuplicatingThread
131 RECORD, // Thread class is RecordThread
132 OFFLOAD, // Thread class is OffloadThread
133 MMAP_PLAYBACK, // Thread class for MMAP playback stream
134 MMAP_CAPTURE, // Thread class for MMAP capture stream
135 SPATIALIZER, //
136 BIT_PERFECT, // Thread class for BitPerfectThread
137 // When adding a value, also update IAfThreadBase::threadTypeToString()
138 };
139
140 static const char* threadTypeToString(type_t type);
Andy Hung25a80ac2023-07-19 12:47:35 -0700141 static std::string formatToString(audio_format_t format); // compliant for MediaMetrics
Andy Hung81994d62023-07-20 21:44:14 -0700142 static bool isValidPcmSinkChannelMask(audio_channel_mask_t channelMask);
143 static bool isValidPcmSinkFormat(audio_format_t format);
144
Andy Hung440901d2023-06-29 21:19:25 -0700145 virtual status_t readyToRun() = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700146 virtual void clearPowerManager() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700147 virtual status_t initCheck() const = 0;
148 virtual type_t type() const = 0;
149 virtual bool isDuplicating() const = 0;
150 virtual audio_io_handle_t id() const = 0;
151 virtual uint32_t sampleRate() const = 0;
152 virtual audio_channel_mask_t channelMask() const = 0;
153 virtual audio_channel_mask_t mixerChannelMask() const = 0;
154 virtual audio_format_t format() const = 0;
155 virtual uint32_t channelCount() const = 0;
156
157 // Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
158 // and returns the [normal mix] buffer's frame count.
159 virtual size_t frameCount() const = 0;
160 virtual audio_channel_mask_t hapticChannelMask() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700161 virtual uint32_t hapticChannelCount() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700162 virtual uint32_t latency_l() const = 0; // NO_THREAD_SAFETY_ANALYSIS
163 virtual void setVolumeForOutput_l(float left, float right) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700164
165 // Return's the HAL's frame count i.e. fast mixer buffer size.
166 virtual size_t frameCountHAL() const = 0;
167 virtual size_t frameSize() const = 0;
168 // Should be "virtual status_t requestExitAndWait()" and override same
169 // method in Thread, but Thread::requestExitAndWait() is not yet virtual.
Andy Hungab65b182023-09-06 19:41:47 -0700170 virtual void exit() EXCLUDES_ThreadBase_Mutex = 0;
171 virtual bool checkForNewParameter_l(const String8& keyValuePair, status_t& status)
172 REQUIRES(mutex()) = 0;
173 virtual status_t setParameters(const String8& keyValuePairs) EXCLUDES_ThreadBase_Mutex = 0;
174 virtual String8 getParameters(const String8& keys) EXCLUDES_ThreadBase_Mutex = 0;
175 virtual void ioConfigChanged_l(
Andy Hung440901d2023-06-29 21:19:25 -0700176 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700177 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE)
178 /* holds either AF::mutex or TB::mutex */ = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700179
180 // sendConfigEvent_l() must be called with ThreadBase::mLock held
181 // Can temporarily release the lock if waiting for a reply from
182 // processConfigEvents_l().
183 // status_t sendConfigEvent_l(sp<ConfigEvent>& event);
184 virtual void sendIoConfigEvent(
185 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700186 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700187 virtual void sendIoConfigEvent_l(
188 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700189 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) REQUIRES(mutex()) = 0;
190 virtual void sendPrioConfigEvent(pid_t pid, pid_t tid, int32_t prio, bool forApp)
191 EXCLUDES_ThreadBase_Mutex = 0;
192 virtual void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio, bool forApp)
193 REQUIRES(mutex()) = 0;
194 virtual status_t sendSetParameterConfigEvent_l(const String8& keyValuePair)
195 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700196 virtual status_t sendCreateAudioPatchConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700197 const struct audio_patch* patch, audio_patch_handle_t* handle)
198 EXCLUDES_ThreadBase_Mutex = 0;
199 virtual status_t sendReleaseAudioPatchConfigEvent(audio_patch_handle_t handle)
200 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700201 virtual status_t sendUpdateOutDeviceConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700202 const DeviceDescriptorBaseVector& outDevices) EXCLUDES_ThreadBase_Mutex = 0;
203 virtual void sendResizeBufferConfigEvent_l(int32_t maxSharedAudioHistoryMs)
204 REQUIRES(mutex()) = 0;
205 virtual void sendCheckOutputStageEffectsEvent() EXCLUDES_ThreadBase_Mutex = 0;
206 virtual void sendCheckOutputStageEffectsEvent_l()
207 REQUIRES(mutex()) = 0;
208 virtual void sendHalLatencyModesChangedEvent_l()
209 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700210
Andy Hungab65b182023-09-06 19:41:47 -0700211 virtual void processConfigEvents_l()
212 REQUIRES(mutex()) = 0;
213 virtual void setCheckOutputStageEffects() = 0; // no mutex needed
214 virtual void cacheParameters_l()
215 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700216 virtual status_t createAudioPatch_l(
Andy Hungab65b182023-09-06 19:41:47 -0700217 const struct audio_patch* patch, audio_patch_handle_t* handle)
218 REQUIRES(mutex()) = 0;
219 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle)
220 REQUIRES(mutex()) = 0;
221 virtual void updateOutDevices(const DeviceDescriptorBaseVector& outDevices)
222 EXCLUDES_ThreadBase_Mutex = 0;
223 virtual void toAudioPortConfig(struct audio_port_config* config)
224 EXCLUDES_ThreadBase_Mutex = 0;
225 virtual void resizeInputBuffer_l(int32_t maxSharedAudioHistoryMs)
226 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700227
228 // see note at declaration of mStandby, mOutDevice and mInDevice
229 virtual bool inStandby() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700230 virtual const DeviceTypeSet outDeviceTypes_l() const REQUIRES(mutex()) = 0;
231 virtual audio_devices_t inDeviceType_l() const REQUIRES(mutex()) = 0;
232 virtual DeviceTypeSet getDeviceTypes_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700233 virtual const AudioDeviceTypeAddrVector& outDeviceTypeAddrs() const = 0;
234 virtual const AudioDeviceTypeAddr& inDeviceTypeAddr() const = 0;
235 virtual bool isOutput() const = 0;
236 virtual bool isOffloadOrMmap() const = 0;
237 virtual sp<StreamHalInterface> stream() const = 0;
238 virtual sp<IAfEffectHandle> createEffect_l(
239 const sp<Client>& client,
240 const sp<media::IEffectClient>& effectClient,
241 int32_t priority,
242 audio_session_t sessionId,
243 effect_descriptor_t* desc,
244 int* enabled,
245 status_t* status /*non-NULL*/,
246 bool pinned,
247 bool probe,
Andy Hung972bec12023-08-31 16:13:39 -0700248 bool notifyFramesProcessed)
Andy Hungab65b182023-09-06 19:41:47 -0700249 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700250
251 // return values for hasAudioSession (bit field)
252 enum effect_state {
253 EFFECT_SESSION = 0x1, // the audio session corresponds to at least one
254 // effect
255 TRACK_SESSION = 0x2, // the audio session corresponds to at least one
256 // track
257 FAST_SESSION = 0x4, // the audio session corresponds to at least one
258 // fast track
259 SPATIALIZED_SESSION = 0x8, // the audio session corresponds to at least one
260 // spatialized track
261 BIT_PERFECT_SESSION = 0x10 // the audio session corresponds to at least one
262 // bit-perfect track
263 };
264
265 // get effect chain corresponding to session Id.
Andy Hungab65b182023-09-06 19:41:47 -0700266 virtual sp<IAfEffectChain> getEffectChain(audio_session_t sessionId) const
267 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700268 // same as getEffectChain() but must be called with ThreadBase mutex locked
Andy Hungab65b182023-09-06 19:41:47 -0700269 virtual sp<IAfEffectChain> getEffectChain_l(audio_session_t sessionId) const
270 REQUIRES(mutex()) = 0;
271 virtual std::vector<int> getEffectIds_l(audio_session_t sessionId) const
272 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700273 // add an effect chain to the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700274 virtual status_t addEffectChain_l(const sp<IAfEffectChain>& chain)
275 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700276 // remove an effect chain from the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700277 virtual size_t removeEffectChain_l(const sp<IAfEffectChain>& chain)
278 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700279 // lock all effect chains Mutexes. Must be called before releasing the
280 // ThreadBase mutex before processing the mixer and effects. This guarantees the
281 // integrity of the chains during the process.
282 // Also sets the parameter 'effectChains' to current value of mEffectChains.
Andy Hungab65b182023-09-06 19:41:47 -0700283 virtual void lockEffectChains_l(Vector<sp<IAfEffectChain>>& effectChains)
284 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700285 // unlock effect chains after process
Andy Hungab65b182023-09-06 19:41:47 -0700286 virtual void unlockEffectChains(const Vector<sp<IAfEffectChain>>& effectChains)
287 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700288 // get a copy of mEffectChains vector
Andy Hungab65b182023-09-06 19:41:47 -0700289 virtual Vector<sp<IAfEffectChain>> getEffectChains_l() const
290 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700291 // set audio mode to all effect chains
Andy Hungab65b182023-09-06 19:41:47 -0700292 virtual void setMode(audio_mode_t mode)
293 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700294 // get effect module with corresponding ID on specified audio session
Andy Hungab65b182023-09-06 19:41:47 -0700295 virtual sp<IAfEffectModule> getEffect(audio_session_t sessionId, int effectId) const
296 EXCLUDES_ThreadBase_Mutex = 0;
297 virtual sp<IAfEffectModule> getEffect_l(audio_session_t sessionId, int effectId) const
298 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700299 // add and effect module. Also creates the effect chain is none exists for
300 // the effects audio session. Only called in a context of moving an effect
301 // from one thread to another
Andy Hung972bec12023-08-31 16:13:39 -0700302 virtual status_t addEffect_ll(const sp<IAfEffectModule>& effect)
303 REQUIRES(audio_utils::AudioFlinger_Mutex, mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700304 // remove and effect module. Also removes the effect chain is this was the last
305 // effect
Andy Hungab65b182023-09-06 19:41:47 -0700306 virtual void removeEffect_l(const sp<IAfEffectModule>& effect, bool release = false)
307 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700308 // disconnect an effect handle from module and destroy module if last handle
Andy Hungab65b182023-09-06 19:41:47 -0700309 virtual void disconnectEffectHandle(IAfEffectHandle* handle, bool unpinIfLast)
310 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700311 // detach all tracks connected to an auxiliary effect
Andy Hungab65b182023-09-06 19:41:47 -0700312 virtual void detachAuxEffect_l(int effectId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700313 // returns a combination of:
314 // - EFFECT_SESSION if effects on this audio session exist in one chain
315 // - TRACK_SESSION if tracks on this audio session exist
316 // - FAST_SESSION if fast tracks on this audio session exist
317 // - SPATIALIZED_SESSION if spatialized tracks on this audio session exist
Andy Hungab65b182023-09-06 19:41:47 -0700318 virtual uint32_t hasAudioSession_l(audio_session_t sessionId) const REQUIRES(mutex()) = 0;
319 virtual uint32_t hasAudioSession(audio_session_t sessionId) const
320 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700321
322 // the value returned by default implementation is not important as the
323 // strategy is only meaningful for PlaybackThread which implements this method
Andy Hungab65b182023-09-06 19:41:47 -0700324 virtual product_strategy_t getStrategyForSession_l(audio_session_t sessionId) const
325 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700326
327 // check if some effects must be suspended/restored when an effect is enabled
328 // or disabled
329 virtual void checkSuspendOnEffectEnabled(
Andy Hungab65b182023-09-06 19:41:47 -0700330 bool enabled, audio_session_t sessionId, bool threadLocked)
331 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700332
Andy Hungab65b182023-09-06 19:41:47 -0700333 virtual status_t setSyncEvent(const sp<audioflinger::SyncEvent>& event)
334 EXCLUDES_ThreadBase_Mutex = 0;
335 // internally static, perhaps make static member.
Andy Hung440901d2023-06-29 21:19:25 -0700336 virtual bool isValidSyncEvent(const sp<audioflinger::SyncEvent>& event) const = 0;
337
338 // Return a reference to a per-thread heap which can be used to allocate IMemory
339 // objects that will be read-only to client processes, read/write to mediaserver,
340 // and shared by all client processes of the thread.
341 // The heap is per-thread rather than common across all threads, because
342 // clients can't be trusted not to modify the offset of the IMemory they receive.
343 // If a thread does not have such a heap, this method returns 0.
344 virtual sp<MemoryDealer> readOnlyHeap() const = 0;
345
346 virtual sp<IMemory> pipeMemory() const = 0;
347
Andy Hungab65b182023-09-06 19:41:47 -0700348 virtual void systemReady() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700349
350 // checkEffectCompatibility_l() must be called with ThreadBase::mLock held
351 virtual status_t checkEffectCompatibility_l(
Andy Hungab65b182023-09-06 19:41:47 -0700352 const effect_descriptor_t* desc, audio_session_t sessionId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700353
Andy Hungab65b182023-09-06 19:41:47 -0700354 virtual void broadcast_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700355
Andy Hungab65b182023-09-06 19:41:47 -0700356 virtual bool isTimestampCorrectionEnabled_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700357
358 virtual bool isMsdDevice() const = 0;
359
Andy Hungab65b182023-09-06 19:41:47 -0700360 virtual void dump(int fd, const Vector<String16>& args) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700361
362 // deliver stats to mediametrics.
Andy Hungab65b182023-09-06 19:41:47 -0700363 virtual void sendStatistics(bool force) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700364
Andy Hung972bec12023-08-31 16:13:39 -0700365 virtual audio_utils::mutex& mutex() const
366 RETURN_CAPABILITY(audio_utils::ThreadBase_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700367
Andy Hungab65b182023-09-06 19:41:47 -0700368 virtual void onEffectEnable(const sp<IAfEffectModule>& effect) EXCLUDES_ThreadBase_Mutex = 0;
369 virtual void onEffectDisable() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700370
371 // invalidateTracksForAudioSession_l must be called with holding mLock.
Andy Hungab65b182023-09-06 19:41:47 -0700372 virtual void invalidateTracksForAudioSession_l(audio_session_t sessionId) const
373 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700374 // Invalidate all the tracks with the given audio session.
Andy Hungab65b182023-09-06 19:41:47 -0700375 virtual void invalidateTracksForAudioSession(audio_session_t sessionId) const
376 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700377
378 virtual bool isStreamInitialized() const = 0;
Andy Hung972bec12023-08-31 16:13:39 -0700379 virtual void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor)
380 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
381 virtual void stopMelComputation_l()
382 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700383
Andy Hungab65b182023-09-06 19:41:47 -0700384 virtual product_strategy_t getStrategyForStream(audio_stream_type_t stream) const
385 EXCLUDES_AUDIO_ALL = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700386
387 virtual void setEffectSuspended_l(
Andy Hungab65b182023-09-06 19:41:47 -0700388 const effect_uuid_t* type, bool suspend, audio_session_t sessionId)
389 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700390
Andy Hunga7187712023-12-05 17:28:17 -0800391 // Wait while the Thread is busy. This is done to ensure that
392 // the Thread is not busy releasing the Tracks, during which the Thread mutex
393 // may be temporarily unlocked. Some Track methods will use this method to
394 // avoid races.
395 virtual void waitWhileThreadBusy_l(audio_utils::unique_lock& ul)
396 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700397 // Dynamic cast to derived interface
398 virtual sp<IAfDirectOutputThread> asIAfDirectOutputThread() { return nullptr; }
399 virtual sp<IAfDuplicatingThread> asIAfDuplicatingThread() { return nullptr; }
400 virtual sp<IAfPlaybackThread> asIAfPlaybackThread() { return nullptr; }
401 virtual sp<IAfRecordThread> asIAfRecordThread() { return nullptr; }
Andy Hung583043b2023-07-17 17:05:00 -0700402 virtual IAfThreadCallback* afThreadCallback() const = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700403};
404
Andy Hung87c693c2023-07-06 20:56:16 -0700405class IAfPlaybackThread : public virtual IAfThreadBase, public virtual VolumeInterface {
Andy Hung440901d2023-06-29 21:19:25 -0700406public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700407 static sp<IAfPlaybackThread> createBitPerfectThread(
Andy Hung583043b2023-07-17 17:05:00 -0700408 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
409 audio_io_handle_t id, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700410
411 static sp<IAfPlaybackThread> createDirectOutputThread(
Andy Hung583043b2023-07-17 17:05:00 -0700412 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
413 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700414
415 static sp<IAfPlaybackThread> createMixerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700416 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
417 audio_io_handle_t id, bool systemReady, type_t type = MIXER,
418 audio_config_base_t* mixerConfig = nullptr);
Andy Hungee58e4a2023-07-07 13:47:37 -0700419
420 static sp<IAfPlaybackThread> createOffloadThread(
Andy Hung583043b2023-07-17 17:05:00 -0700421 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
422 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700423
424 static sp<IAfPlaybackThread> createSpatializerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700425 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
426 audio_io_handle_t id, bool systemReady, audio_config_base_t* mixerConfig);
Andy Hungee58e4a2023-07-07 13:47:37 -0700427
Andy Hung87c693c2023-07-06 20:56:16 -0700428 static constexpr int8_t kMaxTrackStopRetriesOffload = 2;
429
Andy Hung440901d2023-06-29 21:19:25 -0700430 enum mixer_state {
431 MIXER_IDLE, // no active tracks
432 MIXER_TRACKS_ENABLED, // at least one active track, but no track has any data ready
433 MIXER_TRACKS_READY, // at least one active track, and at least one track has data
434 MIXER_DRAIN_TRACK, // drain currently playing track
435 MIXER_DRAIN_ALL, // fully drain the hardware
436 // standby mode does not have an enum value
437 // suspend by audio policy manager is orthogonal to mixer state
438 };
439
440 // return estimated latency in milliseconds, as reported by HAL
441 virtual uint32_t latency() const = 0; // should be in IAfThreadBase?
442
Andy Hungab65b182023-09-06 19:41:47 -0700443 virtual uint32_t& fastTrackAvailMask_l() REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700444
Andy Hung440901d2023-06-29 21:19:25 -0700445 virtual sp<IAfTrack> createTrack_l(
446 const sp<Client>& client,
447 audio_stream_type_t streamType,
448 const audio_attributes_t& attr,
449 uint32_t* sampleRate,
450 audio_format_t format,
451 audio_channel_mask_t channelMask,
452 size_t* pFrameCount,
453 size_t* pNotificationFrameCount,
454 uint32_t notificationsPerBuffer,
455 float speed,
456 const sp<IMemory>& sharedBuffer,
457 audio_session_t sessionId,
458 audio_output_flags_t* flags,
459 pid_t creatorPid,
460 const AttributionSourceState& attributionSource,
461 pid_t tid,
462 status_t* status /*non-NULL*/,
463 audio_port_handle_t portId,
464 const sp<media::IAudioTrackCallback>& callback,
465 bool isSpatialized,
jiabin94ed47c2023-07-27 23:34:20 +0000466 bool isBitPerfect,
Andy Hung972bec12023-08-31 16:13:39 -0700467 audio_output_flags_t* afTrackFlags)
468 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700469
Andy Hungab65b182023-09-06 19:41:47 -0700470 virtual status_t addTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
471 virtual bool destroyTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
472 virtual bool isTrackActive(const sp<IAfTrack>& track) const REQUIRES(mutex()) = 0;
473 virtual void addOutputTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700474
Andy Hungab65b182023-09-06 19:41:47 -0700475 virtual AudioStreamOut* getOutput_l() const REQUIRES(mutex()) = 0;
Andy Hung8d672e02023-09-15 18:19:28 -0700476 virtual AudioStreamOut* getOutput() const EXCLUDES_ThreadBase_Mutex = 0;
477 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700478
479 // a very large number of suspend() will eventually wraparound, but unlikely
480 virtual void suspend() = 0;
481 virtual void restore() = 0;
482 virtual bool isSuspended() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700483 virtual status_t getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames) const
484 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700485 // Consider also removing and passing an explicit mMainBuffer initialization
486 // parameter to AF::IAfTrack::Track().
487 virtual float* sinkBuffer() const = 0;
488
Andy Hungab65b182023-09-06 19:41:47 -0700489 virtual status_t attachAuxEffect(const sp<IAfTrack>& track, int EffectId)
490 EXCLUDES_ThreadBase_Mutex = 0;
491 virtual status_t attachAuxEffect_l(const sp<IAfTrack>& track, int EffectId)
492 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700493
494 // called with AudioFlinger lock held
Andy Hungab65b182023-09-06 19:41:47 -0700495 virtual bool invalidateTracks_l(audio_stream_type_t streamType) REQUIRES(mutex()) = 0;
496 virtual bool invalidateTracks_l(std::set<audio_port_handle_t>& portIds) REQUIRES(mutex()) = 0;
497 virtual void invalidateTracks(audio_stream_type_t streamType)
498 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700499 // Invalidate tracks by a set of port ids. The port id will be removed from
500 // the given set if the corresponding track is found and invalidated.
Andy Hungab65b182023-09-06 19:41:47 -0700501 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
502 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700503
Andy Hungab65b182023-09-06 19:41:47 -0700504 virtual status_t getTimestamp_l(AudioTimestamp& timestamp) REQUIRES(mutex()) = 0;
505 virtual void addPatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
506 virtual void deletePatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700507
508 // Return the asynchronous signal wait time.
Andy Hungab65b182023-09-06 19:41:47 -0700509 virtual int64_t computeWaitTimeNs_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700510 // returns true if the track is allowed to be added to the thread.
511 virtual bool isTrackAllowed_l(
512 audio_channel_mask_t channelMask, audio_format_t format, audio_session_t sessionId,
Andy Hungab65b182023-09-06 19:41:47 -0700513 uid_t uid) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700514
515 virtual bool supportsHapticPlayback() const = 0;
516
Andy Hungab65b182023-09-06 19:41:47 -0700517 virtual void setDownStreamPatch(const struct audio_patch* patch)
518 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700519
Andy Hungab65b182023-09-06 19:41:47 -0700520 virtual IAfTrack* getTrackById_l(audio_port_handle_t trackId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700521
522 virtual bool hasMixer() const = 0;
523
524 virtual status_t setRequestedLatencyMode(audio_latency_mode_t mode) = 0;
525
Andy Hungab65b182023-09-06 19:41:47 -0700526 virtual status_t getSupportedLatencyModes(std::vector<audio_latency_mode_t>* modes)
527 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700528
529 virtual status_t setBluetoothVariableLatencyEnabled(bool enabled) = 0;
530
Andy Hungab65b182023-09-06 19:41:47 -0700531 virtual void setStandby() EXCLUDES_ThreadBase_Mutex = 0;
532 virtual void setStandby_l() REQUIRES(mutex()) = 0;
533 virtual bool waitForHalStart() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700534
535 virtual bool hasFastMixer() const = 0;
536 virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex) const = 0;
537 virtual const std::atomic<int64_t>& framesWritten() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700538
539 virtual bool usesHwAvSync() const = 0;
540};
541
542class IAfDirectOutputThread : public virtual IAfPlaybackThread {
543public:
544 virtual status_t selectPresentation(int presentationId, int programId) = 0;
545};
546
547class IAfDuplicatingThread : public virtual IAfPlaybackThread {
548public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700549 static sp<IAfDuplicatingThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700550 const sp<IAfThreadCallback>& afThreadCallback, IAfPlaybackThread* mainThread,
Andy Hungee58e4a2023-07-07 13:47:37 -0700551 audio_io_handle_t id, bool systemReady);
552
Andy Hungab65b182023-09-06 19:41:47 -0700553 virtual void addOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700554 virtual uint32_t waitTimeMs() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700555 virtual void removeOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700556};
557
558class IAfRecordThread : public virtual IAfThreadBase {
559public:
560 static sp<IAfRecordThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700561 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamIn* input,
562 audio_io_handle_t id, bool systemReady);
Andy Hung87c693c2023-07-06 20:56:16 -0700563
564 virtual sp<IAfRecordTrack> createRecordTrack_l(
565 const sp<Client>& client,
566 const audio_attributes_t& attr,
567 uint32_t* pSampleRate,
568 audio_format_t format,
569 audio_channel_mask_t channelMask,
570 size_t* pFrameCount,
571 audio_session_t sessionId,
572 size_t* pNotificationFrameCount,
573 pid_t creatorPid,
574 const AttributionSourceState& attributionSource,
575 audio_input_flags_t* flags,
576 pid_t tid,
577 status_t* status /*non-NULL*/,
578 audio_port_handle_t portId,
Andy Hung972bec12023-08-31 16:13:39 -0700579 int32_t maxSharedAudioHistoryMs)
Andy Hungab65b182023-09-06 19:41:47 -0700580 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
581 virtual void destroyTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
582 virtual void removeTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700583
584 virtual status_t start(
585 IAfRecordTrack* recordTrack, AudioSystem::sync_event_t event,
Andy Hungab65b182023-09-06 19:41:47 -0700586 audio_session_t triggerSession) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700587
588 // ask the thread to stop the specified track, and
589 // return true if the caller should then do it's part of the stopping process
Andy Hungab65b182023-09-06 19:41:47 -0700590 virtual bool stop(IAfRecordTrack* recordTrack) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700591
Andy Hungab65b182023-09-06 19:41:47 -0700592 // NO_THREAD_SAFETY_ANALYSIS: consider atomics
Andy Hung87c693c2023-07-06 20:56:16 -0700593 virtual AudioStreamIn* getInput() const = 0;
594 virtual AudioStreamIn* clearInput() = 0;
595
596 virtual status_t getActiveMicrophones(
Andy Hungab65b182023-09-06 19:41:47 -0700597 std::vector<media::MicrophoneInfoFw>* activeMicrophones)
598 const EXCLUDES_ThreadBase_Mutex = 0;
599 virtual status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction)
600 EXCLUDES_ThreadBase_Mutex = 0;
601 virtual status_t setPreferredMicrophoneFieldDimension(float zoom)
602 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700603
Andy Hungab65b182023-09-06 19:41:47 -0700604 virtual void addPatchTrack(const sp<IAfPatchRecord>& record)
605 EXCLUDES_ThreadBase_Mutex = 0;
606 virtual void deletePatchTrack(const sp<IAfPatchRecord>& record)
607 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700608 virtual bool fastTrackAvailable() const = 0;
609 virtual void setFastTrackAvailable(bool available) = 0;
610
Andy Hungab65b182023-09-06 19:41:47 -0700611 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
612 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700613 virtual bool hasFastCapture() const = 0;
614
Andy Hung3f49ebb2023-09-19 14:48:41 -0700615 virtual void checkBtNrec() EXCLUDES_ThreadBase_Mutex = 0;
616 virtual uint32_t getInputFramesLost() const EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700617
618 virtual status_t shareAudioHistory(
619 const std::string& sharedAudioPackageName,
620 audio_session_t sharedSessionId = AUDIO_SESSION_NONE,
Andy Hungab65b182023-09-06 19:41:47 -0700621 int64_t sharedAudioStartMs = -1) EXCLUDES_ThreadBase_Mutex = 0;
622 virtual void resetAudioHistory_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700623};
624
Andy Hung7aa7d102023-07-07 15:58:48 -0700625class IAfMmapThread : public virtual IAfThreadBase {
626public:
627 // createIAudioTrackAdapter() is a static constructor which creates an
628 // MmapStreamInterface AIDL interface adapter from the MmapThread object that
629 // may be passed back to the client.
630 //
631 // Only one AIDL MmapStreamInterface interface adapter should be created per MmapThread.
632 static sp<MmapStreamInterface> createMmapStreamInterfaceAdapter(
633 const sp<IAfMmapThread>& mmapThread);
634
635 virtual void configure(
636 const audio_attributes_t* attr,
637 audio_stream_type_t streamType,
638 audio_session_t sessionId,
639 const sp<MmapStreamCallback>& callback,
640 audio_port_handle_t deviceId,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700641 audio_port_handle_t portId) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700642 virtual void disconnect() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700643
644 // MmapStreamInterface handling (see adapter)
645 virtual status_t createMmapBuffer(
Andy Hung3f49ebb2023-09-19 14:48:41 -0700646 int32_t minSizeFrames, struct audio_mmap_buffer_info* info)
647 EXCLUDES_ThreadBase_Mutex = 0;
648 virtual status_t getMmapPosition(struct audio_mmap_position* position) const
649 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700650 virtual status_t start(
651 const AudioClient& client, const audio_attributes_t* attr,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700652 audio_port_handle_t* handle) EXCLUDES_ThreadBase_Mutex = 0;
653 virtual status_t stop(audio_port_handle_t handle) EXCLUDES_ThreadBase_Mutex = 0;
654 virtual status_t standby() EXCLUDES_ThreadBase_Mutex = 0;
655 virtual status_t getExternalPosition(uint64_t* position, int64_t* timeNanos) const
656 EXCLUDES_ThreadBase_Mutex = 0;
657 virtual status_t reportData(const void* buffer, size_t frameCount)
658 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700659
Andy Hung99b1ba62023-07-14 11:00:08 -0700660 // TODO(b/291317898) move to IAfThreadBase?
Andy Hungab65b182023-09-06 19:41:47 -0700661 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
662 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700663
Andy Hung99b1ba62023-07-14 11:00:08 -0700664 // Sets the UID records silence - TODO(b/291317898) move to IAfMmapCaptureThread
Andy Hungab65b182023-09-06 19:41:47 -0700665 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
666 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700667
668 virtual sp<IAfMmapPlaybackThread> asIAfMmapPlaybackThread() { return nullptr; }
669 virtual sp<IAfMmapCaptureThread> asIAfMmapCaptureThread() { return nullptr; }
670};
671
672class IAfMmapPlaybackThread : public virtual IAfMmapThread, public virtual VolumeInterface {
673public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700674 static sp<IAfMmapPlaybackThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700675 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
676 AudioHwDevice* hwDev, AudioStreamOut* output, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700677
Andy Hungab65b182023-09-06 19:41:47 -0700678 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700679};
680
681class IAfMmapCaptureThread : public virtual IAfMmapThread {
682public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700683 static sp<IAfMmapCaptureThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700684 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
685 AudioHwDevice* hwDev, AudioStreamIn* input, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700686
Andy Hungab65b182023-09-06 19:41:47 -0700687 virtual AudioStreamIn* clearInput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700688};
689
Andy Hung440901d2023-06-29 21:19:25 -0700690} // namespace android