blob: 46a67e8ef7b78e71b38f85c2af759cf941af77fe [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;
Andy Hung583043b2023-07-17 17:05:00 -0700118 virtual void onSupportedLatencyModesChanged(
Andy Hung972bec12023-08-31 16:13:39 -0700119 audio_io_handle_t output, const std::vector<audio_latency_mode_t>& modes)
120 EXCLUDES_AudioFlinger_ClientMutex = 0;
Andy Hung583043b2023-07-17 17:05:00 -0700121};
Andy Hung87c693c2023-07-06 20:56:16 -0700122
Andy Hung440901d2023-06-29 21:19:25 -0700123class IAfThreadBase : public virtual RefBase {
124public:
125 enum type_t {
126 MIXER, // Thread class is MixerThread
127 DIRECT, // Thread class is DirectOutputThread
128 DUPLICATING, // Thread class is DuplicatingThread
129 RECORD, // Thread class is RecordThread
130 OFFLOAD, // Thread class is OffloadThread
131 MMAP_PLAYBACK, // Thread class for MMAP playback stream
132 MMAP_CAPTURE, // Thread class for MMAP capture stream
133 SPATIALIZER, //
134 BIT_PERFECT, // Thread class for BitPerfectThread
135 // When adding a value, also update IAfThreadBase::threadTypeToString()
136 };
137
138 static const char* threadTypeToString(type_t type);
Andy Hung25a80ac2023-07-19 12:47:35 -0700139 static std::string formatToString(audio_format_t format); // compliant for MediaMetrics
Andy Hung81994d62023-07-20 21:44:14 -0700140 static bool isValidPcmSinkChannelMask(audio_channel_mask_t channelMask);
141 static bool isValidPcmSinkFormat(audio_format_t format);
142
Andy Hung440901d2023-06-29 21:19:25 -0700143 virtual status_t readyToRun() = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700144 virtual void clearPowerManager() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700145 virtual status_t initCheck() const = 0;
146 virtual type_t type() const = 0;
147 virtual bool isDuplicating() const = 0;
148 virtual audio_io_handle_t id() const = 0;
149 virtual uint32_t sampleRate() const = 0;
150 virtual audio_channel_mask_t channelMask() const = 0;
151 virtual audio_channel_mask_t mixerChannelMask() const = 0;
152 virtual audio_format_t format() const = 0;
153 virtual uint32_t channelCount() const = 0;
154
155 // Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
156 // and returns the [normal mix] buffer's frame count.
157 virtual size_t frameCount() const = 0;
158 virtual audio_channel_mask_t hapticChannelMask() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700159 virtual uint32_t hapticChannelCount() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700160 virtual uint32_t latency_l() const = 0; // NO_THREAD_SAFETY_ANALYSIS
161 virtual void setVolumeForOutput_l(float left, float right) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700162
163 // Return's the HAL's frame count i.e. fast mixer buffer size.
164 virtual size_t frameCountHAL() const = 0;
165 virtual size_t frameSize() const = 0;
166 // Should be "virtual status_t requestExitAndWait()" and override same
167 // method in Thread, but Thread::requestExitAndWait() is not yet virtual.
Andy Hungab65b182023-09-06 19:41:47 -0700168 virtual void exit() EXCLUDES_ThreadBase_Mutex = 0;
169 virtual bool checkForNewParameter_l(const String8& keyValuePair, status_t& status)
170 REQUIRES(mutex()) = 0;
171 virtual status_t setParameters(const String8& keyValuePairs) EXCLUDES_ThreadBase_Mutex = 0;
172 virtual String8 getParameters(const String8& keys) EXCLUDES_ThreadBase_Mutex = 0;
173 virtual void ioConfigChanged_l(
Andy Hung440901d2023-06-29 21:19:25 -0700174 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700175 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE)
176 /* holds either AF::mutex or TB::mutex */ = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700177
178 // sendConfigEvent_l() must be called with ThreadBase::mLock held
179 // Can temporarily release the lock if waiting for a reply from
180 // processConfigEvents_l().
181 // status_t sendConfigEvent_l(sp<ConfigEvent>& event);
182 virtual void sendIoConfigEvent(
183 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700184 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700185 virtual void sendIoConfigEvent_l(
186 audio_io_config_event_t event, pid_t pid = 0,
Andy Hungab65b182023-09-06 19:41:47 -0700187 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) REQUIRES(mutex()) = 0;
188 virtual void sendPrioConfigEvent(pid_t pid, pid_t tid, int32_t prio, bool forApp)
189 EXCLUDES_ThreadBase_Mutex = 0;
190 virtual void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio, bool forApp)
191 REQUIRES(mutex()) = 0;
192 virtual status_t sendSetParameterConfigEvent_l(const String8& keyValuePair)
193 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700194 virtual status_t sendCreateAudioPatchConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700195 const struct audio_patch* patch, audio_patch_handle_t* handle)
196 EXCLUDES_ThreadBase_Mutex = 0;
197 virtual status_t sendReleaseAudioPatchConfigEvent(audio_patch_handle_t handle)
198 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700199 virtual status_t sendUpdateOutDeviceConfigEvent(
Andy Hungab65b182023-09-06 19:41:47 -0700200 const DeviceDescriptorBaseVector& outDevices) EXCLUDES_ThreadBase_Mutex = 0;
201 virtual void sendResizeBufferConfigEvent_l(int32_t maxSharedAudioHistoryMs)
202 REQUIRES(mutex()) = 0;
203 virtual void sendCheckOutputStageEffectsEvent() EXCLUDES_ThreadBase_Mutex = 0;
204 virtual void sendCheckOutputStageEffectsEvent_l()
205 REQUIRES(mutex()) = 0;
206 virtual void sendHalLatencyModesChangedEvent_l()
207 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700208
Andy Hungab65b182023-09-06 19:41:47 -0700209 virtual void processConfigEvents_l()
210 REQUIRES(mutex()) = 0;
211 virtual void setCheckOutputStageEffects() = 0; // no mutex needed
212 virtual void cacheParameters_l()
213 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700214 virtual status_t createAudioPatch_l(
Andy Hungab65b182023-09-06 19:41:47 -0700215 const struct audio_patch* patch, audio_patch_handle_t* handle)
216 REQUIRES(mutex()) = 0;
217 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle)
218 REQUIRES(mutex()) = 0;
219 virtual void updateOutDevices(const DeviceDescriptorBaseVector& outDevices)
220 EXCLUDES_ThreadBase_Mutex = 0;
221 virtual void toAudioPortConfig(struct audio_port_config* config)
222 EXCLUDES_ThreadBase_Mutex = 0;
223 virtual void resizeInputBuffer_l(int32_t maxSharedAudioHistoryMs)
224 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700225
226 // see note at declaration of mStandby, mOutDevice and mInDevice
227 virtual bool inStandby() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700228 virtual const DeviceTypeSet outDeviceTypes_l() const REQUIRES(mutex()) = 0;
229 virtual audio_devices_t inDeviceType_l() const REQUIRES(mutex()) = 0;
230 virtual DeviceTypeSet getDeviceTypes_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700231 virtual const AudioDeviceTypeAddrVector& outDeviceTypeAddrs() const = 0;
232 virtual const AudioDeviceTypeAddr& inDeviceTypeAddr() const = 0;
233 virtual bool isOutput() const = 0;
234 virtual bool isOffloadOrMmap() const = 0;
235 virtual sp<StreamHalInterface> stream() const = 0;
236 virtual sp<IAfEffectHandle> createEffect_l(
237 const sp<Client>& client,
238 const sp<media::IEffectClient>& effectClient,
239 int32_t priority,
240 audio_session_t sessionId,
241 effect_descriptor_t* desc,
242 int* enabled,
243 status_t* status /*non-NULL*/,
244 bool pinned,
245 bool probe,
Andy Hung972bec12023-08-31 16:13:39 -0700246 bool notifyFramesProcessed)
Andy Hungab65b182023-09-06 19:41:47 -0700247 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700248
249 // return values for hasAudioSession (bit field)
250 enum effect_state {
251 EFFECT_SESSION = 0x1, // the audio session corresponds to at least one
252 // effect
253 TRACK_SESSION = 0x2, // the audio session corresponds to at least one
254 // track
255 FAST_SESSION = 0x4, // the audio session corresponds to at least one
256 // fast track
257 SPATIALIZED_SESSION = 0x8, // the audio session corresponds to at least one
258 // spatialized track
259 BIT_PERFECT_SESSION = 0x10 // the audio session corresponds to at least one
260 // bit-perfect track
261 };
262
263 // get effect chain corresponding to session Id.
Andy Hungab65b182023-09-06 19:41:47 -0700264 virtual sp<IAfEffectChain> getEffectChain(audio_session_t sessionId) const
265 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700266 // same as getEffectChain() but must be called with ThreadBase mutex locked
Andy Hungab65b182023-09-06 19:41:47 -0700267 virtual sp<IAfEffectChain> getEffectChain_l(audio_session_t sessionId) const
268 REQUIRES(mutex()) = 0;
269 virtual std::vector<int> getEffectIds_l(audio_session_t sessionId) const
270 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700271 // add an effect chain to the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700272 virtual status_t addEffectChain_l(const sp<IAfEffectChain>& chain)
273 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700274 // remove an effect chain from the chain list (mEffectChains)
Andy Hungab65b182023-09-06 19:41:47 -0700275 virtual size_t removeEffectChain_l(const sp<IAfEffectChain>& chain)
276 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700277 // lock all effect chains Mutexes. Must be called before releasing the
278 // ThreadBase mutex before processing the mixer and effects. This guarantees the
279 // integrity of the chains during the process.
280 // Also sets the parameter 'effectChains' to current value of mEffectChains.
Andy Hungab65b182023-09-06 19:41:47 -0700281 virtual void lockEffectChains_l(Vector<sp<IAfEffectChain>>& effectChains)
282 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700283 // unlock effect chains after process
Andy Hungab65b182023-09-06 19:41:47 -0700284 virtual void unlockEffectChains(const Vector<sp<IAfEffectChain>>& effectChains)
285 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700286 // get a copy of mEffectChains vector
Andy Hungab65b182023-09-06 19:41:47 -0700287 virtual Vector<sp<IAfEffectChain>> getEffectChains_l() const
288 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700289 // set audio mode to all effect chains
Andy Hungab65b182023-09-06 19:41:47 -0700290 virtual void setMode(audio_mode_t mode)
291 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700292 // get effect module with corresponding ID on specified audio session
Andy Hungab65b182023-09-06 19:41:47 -0700293 virtual sp<IAfEffectModule> getEffect(audio_session_t sessionId, int effectId) const
294 EXCLUDES_ThreadBase_Mutex = 0;
295 virtual sp<IAfEffectModule> getEffect_l(audio_session_t sessionId, int effectId) const
296 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700297 // add and effect module. Also creates the effect chain is none exists for
298 // the effects audio session. Only called in a context of moving an effect
299 // from one thread to another
Andy Hung972bec12023-08-31 16:13:39 -0700300 virtual status_t addEffect_ll(const sp<IAfEffectModule>& effect)
301 REQUIRES(audio_utils::AudioFlinger_Mutex, mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700302 // remove and effect module. Also removes the effect chain is this was the last
303 // effect
Andy Hungab65b182023-09-06 19:41:47 -0700304 virtual void removeEffect_l(const sp<IAfEffectModule>& effect, bool release = false)
305 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700306 // disconnect an effect handle from module and destroy module if last handle
Andy Hungab65b182023-09-06 19:41:47 -0700307 virtual void disconnectEffectHandle(IAfEffectHandle* handle, bool unpinIfLast)
308 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700309 // detach all tracks connected to an auxiliary effect
Andy Hungab65b182023-09-06 19:41:47 -0700310 virtual void detachAuxEffect_l(int effectId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700311 // returns a combination of:
312 // - EFFECT_SESSION if effects on this audio session exist in one chain
313 // - TRACK_SESSION if tracks on this audio session exist
314 // - FAST_SESSION if fast tracks on this audio session exist
315 // - SPATIALIZED_SESSION if spatialized tracks on this audio session exist
Andy Hungab65b182023-09-06 19:41:47 -0700316 virtual uint32_t hasAudioSession_l(audio_session_t sessionId) const REQUIRES(mutex()) = 0;
317 virtual uint32_t hasAudioSession(audio_session_t sessionId) const
318 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700319
320 // the value returned by default implementation is not important as the
321 // strategy is only meaningful for PlaybackThread which implements this method
Andy Hungab65b182023-09-06 19:41:47 -0700322 virtual product_strategy_t getStrategyForSession_l(audio_session_t sessionId) const
323 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700324
325 // check if some effects must be suspended/restored when an effect is enabled
326 // or disabled
327 virtual void checkSuspendOnEffectEnabled(
Andy Hungab65b182023-09-06 19:41:47 -0700328 bool enabled, audio_session_t sessionId, bool threadLocked)
329 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700330
Andy Hungab65b182023-09-06 19:41:47 -0700331 virtual status_t setSyncEvent(const sp<audioflinger::SyncEvent>& event)
332 EXCLUDES_ThreadBase_Mutex = 0;
333 // internally static, perhaps make static member.
Andy Hung440901d2023-06-29 21:19:25 -0700334 virtual bool isValidSyncEvent(const sp<audioflinger::SyncEvent>& event) const = 0;
335
336 // Return a reference to a per-thread heap which can be used to allocate IMemory
337 // objects that will be read-only to client processes, read/write to mediaserver,
338 // and shared by all client processes of the thread.
339 // The heap is per-thread rather than common across all threads, because
340 // clients can't be trusted not to modify the offset of the IMemory they receive.
341 // If a thread does not have such a heap, this method returns 0.
342 virtual sp<MemoryDealer> readOnlyHeap() const = 0;
343
344 virtual sp<IMemory> pipeMemory() const = 0;
345
Andy Hungab65b182023-09-06 19:41:47 -0700346 virtual void systemReady() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700347
348 // checkEffectCompatibility_l() must be called with ThreadBase::mLock held
349 virtual status_t checkEffectCompatibility_l(
Andy Hungab65b182023-09-06 19:41:47 -0700350 const effect_descriptor_t* desc, audio_session_t sessionId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700351
Andy Hungab65b182023-09-06 19:41:47 -0700352 virtual void broadcast_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700353
Andy Hungab65b182023-09-06 19:41:47 -0700354 virtual bool isTimestampCorrectionEnabled_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700355
356 virtual bool isMsdDevice() const = 0;
357
Andy Hungab65b182023-09-06 19:41:47 -0700358 virtual void dump(int fd, const Vector<String16>& args) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700359
360 // deliver stats to mediametrics.
Andy Hungab65b182023-09-06 19:41:47 -0700361 virtual void sendStatistics(bool force) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700362
Andy Hung972bec12023-08-31 16:13:39 -0700363 virtual audio_utils::mutex& mutex() const
364 RETURN_CAPABILITY(audio_utils::ThreadBase_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700365
Andy Hungab65b182023-09-06 19:41:47 -0700366 virtual void onEffectEnable(const sp<IAfEffectModule>& effect) EXCLUDES_ThreadBase_Mutex = 0;
367 virtual void onEffectDisable() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700368
369 // invalidateTracksForAudioSession_l must be called with holding mLock.
Andy Hungab65b182023-09-06 19:41:47 -0700370 virtual void invalidateTracksForAudioSession_l(audio_session_t sessionId) const
371 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700372 // Invalidate all the tracks with the given audio session.
Andy Hungab65b182023-09-06 19:41:47 -0700373 virtual void invalidateTracksForAudioSession(audio_session_t sessionId) const
374 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700375
376 virtual bool isStreamInitialized() const = 0;
Andy Hung972bec12023-08-31 16:13:39 -0700377 virtual void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor)
378 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
379 virtual void stopMelComputation_l()
380 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700381
Andy Hungab65b182023-09-06 19:41:47 -0700382 virtual product_strategy_t getStrategyForStream(audio_stream_type_t stream) const
383 EXCLUDES_AUDIO_ALL = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700384
385 virtual void setEffectSuspended_l(
Andy Hungab65b182023-09-06 19:41:47 -0700386 const effect_uuid_t* type, bool suspend, audio_session_t sessionId)
387 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700388
Andy Hung6c498e92023-12-05 17:28:17 -0800389 // Wait while the Thread is busy. This is done to ensure that
390 // the Thread is not busy releasing the Tracks, during which the Thread mutex
391 // may be temporarily unlocked. Some Track methods will use this method to
392 // avoid races.
393 virtual void waitWhileThreadBusy_l(audio_utils::unique_lock& ul)
394 REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700395 // Dynamic cast to derived interface
396 virtual sp<IAfDirectOutputThread> asIAfDirectOutputThread() { return nullptr; }
397 virtual sp<IAfDuplicatingThread> asIAfDuplicatingThread() { return nullptr; }
398 virtual sp<IAfPlaybackThread> asIAfPlaybackThread() { return nullptr; }
399 virtual sp<IAfRecordThread> asIAfRecordThread() { return nullptr; }
Andy Hung583043b2023-07-17 17:05:00 -0700400 virtual IAfThreadCallback* afThreadCallback() const = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700401};
402
Andy Hung87c693c2023-07-06 20:56:16 -0700403class IAfPlaybackThread : public virtual IAfThreadBase, public virtual VolumeInterface {
Andy Hung440901d2023-06-29 21:19:25 -0700404public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700405 static sp<IAfPlaybackThread> createBitPerfectThread(
Andy Hung583043b2023-07-17 17:05:00 -0700406 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
407 audio_io_handle_t id, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700408
409 static sp<IAfPlaybackThread> createDirectOutputThread(
Andy Hung583043b2023-07-17 17:05:00 -0700410 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
411 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700412
413 static sp<IAfPlaybackThread> createMixerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700414 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
415 audio_io_handle_t id, bool systemReady, type_t type = MIXER,
416 audio_config_base_t* mixerConfig = nullptr);
Andy Hungee58e4a2023-07-07 13:47:37 -0700417
418 static sp<IAfPlaybackThread> createOffloadThread(
Andy Hung583043b2023-07-17 17:05:00 -0700419 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
420 audio_io_handle_t id, bool systemReady, const audio_offload_info_t& offloadInfo);
Andy Hungee58e4a2023-07-07 13:47:37 -0700421
422 static sp<IAfPlaybackThread> createSpatializerThread(
Andy Hung583043b2023-07-17 17:05:00 -0700423 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamOut* output,
424 audio_io_handle_t id, bool systemReady, audio_config_base_t* mixerConfig);
Andy Hungee58e4a2023-07-07 13:47:37 -0700425
Andy Hung87c693c2023-07-06 20:56:16 -0700426 static constexpr int8_t kMaxTrackStopRetriesOffload = 2;
427
Andy Hung440901d2023-06-29 21:19:25 -0700428 enum mixer_state {
429 MIXER_IDLE, // no active tracks
430 MIXER_TRACKS_ENABLED, // at least one active track, but no track has any data ready
431 MIXER_TRACKS_READY, // at least one active track, and at least one track has data
432 MIXER_DRAIN_TRACK, // drain currently playing track
433 MIXER_DRAIN_ALL, // fully drain the hardware
434 // standby mode does not have an enum value
435 // suspend by audio policy manager is orthogonal to mixer state
436 };
437
438 // return estimated latency in milliseconds, as reported by HAL
439 virtual uint32_t latency() const = 0; // should be in IAfThreadBase?
440
Andy Hungab65b182023-09-06 19:41:47 -0700441 virtual uint32_t& fastTrackAvailMask_l() REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700442
Andy Hung440901d2023-06-29 21:19:25 -0700443 virtual sp<IAfTrack> createTrack_l(
444 const sp<Client>& client,
445 audio_stream_type_t streamType,
446 const audio_attributes_t& attr,
447 uint32_t* sampleRate,
448 audio_format_t format,
449 audio_channel_mask_t channelMask,
450 size_t* pFrameCount,
451 size_t* pNotificationFrameCount,
452 uint32_t notificationsPerBuffer,
453 float speed,
454 const sp<IMemory>& sharedBuffer,
455 audio_session_t sessionId,
456 audio_output_flags_t* flags,
457 pid_t creatorPid,
458 const AttributionSourceState& attributionSource,
459 pid_t tid,
460 status_t* status /*non-NULL*/,
461 audio_port_handle_t portId,
462 const sp<media::IAudioTrackCallback>& callback,
463 bool isSpatialized,
jiabin94ed47c2023-07-27 23:34:20 +0000464 bool isBitPerfect,
Andy Hung972bec12023-08-31 16:13:39 -0700465 audio_output_flags_t* afTrackFlags)
466 REQUIRES(audio_utils::AudioFlinger_Mutex) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700467
Andy Hungab65b182023-09-06 19:41:47 -0700468 virtual status_t addTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
469 virtual bool destroyTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
470 virtual bool isTrackActive(const sp<IAfTrack>& track) const REQUIRES(mutex()) = 0;
471 virtual void addOutputTrack_l(const sp<IAfTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700472
Andy Hungab65b182023-09-06 19:41:47 -0700473 virtual AudioStreamOut* getOutput_l() const REQUIRES(mutex()) = 0;
Andy Hung8d672e02023-09-15 18:19:28 -0700474 virtual AudioStreamOut* getOutput() const EXCLUDES_ThreadBase_Mutex = 0;
475 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700476
477 // a very large number of suspend() will eventually wraparound, but unlikely
478 virtual void suspend() = 0;
479 virtual void restore() = 0;
480 virtual bool isSuspended() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700481 virtual status_t getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames) const
482 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700483 // Consider also removing and passing an explicit mMainBuffer initialization
484 // parameter to AF::IAfTrack::Track().
485 virtual float* sinkBuffer() const = 0;
486
Andy Hungab65b182023-09-06 19:41:47 -0700487 virtual status_t attachAuxEffect(const sp<IAfTrack>& track, int EffectId)
488 EXCLUDES_ThreadBase_Mutex = 0;
489 virtual status_t attachAuxEffect_l(const sp<IAfTrack>& track, int EffectId)
490 REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700491
492 // called with AudioFlinger lock held
Andy Hungab65b182023-09-06 19:41:47 -0700493 virtual bool invalidateTracks_l(audio_stream_type_t streamType) REQUIRES(mutex()) = 0;
494 virtual bool invalidateTracks_l(std::set<audio_port_handle_t>& portIds) REQUIRES(mutex()) = 0;
495 virtual void invalidateTracks(audio_stream_type_t streamType)
496 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700497 // Invalidate tracks by a set of port ids. The port id will be removed from
498 // the given set if the corresponding track is found and invalidated.
Andy Hungab65b182023-09-06 19:41:47 -0700499 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
500 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700501
Andy Hungab65b182023-09-06 19:41:47 -0700502 virtual status_t getTimestamp_l(AudioTimestamp& timestamp) REQUIRES(mutex()) = 0;
503 virtual void addPatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
504 virtual void deletePatchTrack(const sp<IAfPatchTrack>& track) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700505
506 // Return the asynchronous signal wait time.
Andy Hungab65b182023-09-06 19:41:47 -0700507 virtual int64_t computeWaitTimeNs_l() const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700508 // returns true if the track is allowed to be added to the thread.
509 virtual bool isTrackAllowed_l(
510 audio_channel_mask_t channelMask, audio_format_t format, audio_session_t sessionId,
Andy Hungab65b182023-09-06 19:41:47 -0700511 uid_t uid) const REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700512
513 virtual bool supportsHapticPlayback() const = 0;
514
Andy Hungab65b182023-09-06 19:41:47 -0700515 virtual void setDownStreamPatch(const struct audio_patch* patch)
516 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700517
Andy Hungab65b182023-09-06 19:41:47 -0700518 virtual IAfTrack* getTrackById_l(audio_port_handle_t trackId) REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700519
520 virtual bool hasMixer() const = 0;
521
522 virtual status_t setRequestedLatencyMode(audio_latency_mode_t mode) = 0;
523
Andy Hungab65b182023-09-06 19:41:47 -0700524 virtual status_t getSupportedLatencyModes(std::vector<audio_latency_mode_t>* modes)
525 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700526
527 virtual status_t setBluetoothVariableLatencyEnabled(bool enabled) = 0;
528
Andy Hungab65b182023-09-06 19:41:47 -0700529 virtual void setStandby() EXCLUDES_ThreadBase_Mutex = 0;
530 virtual void setStandby_l() REQUIRES(mutex()) = 0;
531 virtual bool waitForHalStart() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700532
533 virtual bool hasFastMixer() const = 0;
534 virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex) const = 0;
535 virtual const std::atomic<int64_t>& framesWritten() const = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700536
537 virtual bool usesHwAvSync() const = 0;
538};
539
540class IAfDirectOutputThread : public virtual IAfPlaybackThread {
541public:
542 virtual status_t selectPresentation(int presentationId, int programId) = 0;
543};
544
545class IAfDuplicatingThread : public virtual IAfPlaybackThread {
546public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700547 static sp<IAfDuplicatingThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700548 const sp<IAfThreadCallback>& afThreadCallback, IAfPlaybackThread* mainThread,
Andy Hungee58e4a2023-07-07 13:47:37 -0700549 audio_io_handle_t id, bool systemReady);
550
Andy Hungab65b182023-09-06 19:41:47 -0700551 virtual void addOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700552 virtual uint32_t waitTimeMs() const = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700553 virtual void removeOutputTrack(IAfPlaybackThread* thread) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700554};
555
556class IAfRecordThread : public virtual IAfThreadBase {
557public:
558 static sp<IAfRecordThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700559 const sp<IAfThreadCallback>& afThreadCallback, AudioStreamIn* input,
560 audio_io_handle_t id, bool systemReady);
Andy Hung87c693c2023-07-06 20:56:16 -0700561
562 virtual sp<IAfRecordTrack> createRecordTrack_l(
563 const sp<Client>& client,
564 const audio_attributes_t& attr,
565 uint32_t* pSampleRate,
566 audio_format_t format,
567 audio_channel_mask_t channelMask,
568 size_t* pFrameCount,
569 audio_session_t sessionId,
570 size_t* pNotificationFrameCount,
571 pid_t creatorPid,
572 const AttributionSourceState& attributionSource,
573 audio_input_flags_t* flags,
574 pid_t tid,
575 status_t* status /*non-NULL*/,
576 audio_port_handle_t portId,
Andy Hung972bec12023-08-31 16:13:39 -0700577 int32_t maxSharedAudioHistoryMs)
Andy Hungab65b182023-09-06 19:41:47 -0700578 REQUIRES(audio_utils::AudioFlinger_Mutex) EXCLUDES_ThreadBase_Mutex = 0;
579 virtual void destroyTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
580 virtual void removeTrack_l(const sp<IAfRecordTrack>& track) REQUIRES(mutex()) = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700581
582 virtual status_t start(
583 IAfRecordTrack* recordTrack, AudioSystem::sync_event_t event,
Andy Hungab65b182023-09-06 19:41:47 -0700584 audio_session_t triggerSession) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700585
586 // ask the thread to stop the specified track, and
587 // return true if the caller should then do it's part of the stopping process
Andy Hungab65b182023-09-06 19:41:47 -0700588 virtual bool stop(IAfRecordTrack* recordTrack) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700589
Andy Hungab65b182023-09-06 19:41:47 -0700590 // NO_THREAD_SAFETY_ANALYSIS: consider atomics
Andy Hung87c693c2023-07-06 20:56:16 -0700591 virtual AudioStreamIn* getInput() const = 0;
592 virtual AudioStreamIn* clearInput() = 0;
593
594 virtual status_t getActiveMicrophones(
Andy Hungab65b182023-09-06 19:41:47 -0700595 std::vector<media::MicrophoneInfoFw>* activeMicrophones)
596 const EXCLUDES_ThreadBase_Mutex = 0;
597 virtual status_t setPreferredMicrophoneDirection(audio_microphone_direction_t direction)
598 EXCLUDES_ThreadBase_Mutex = 0;
599 virtual status_t setPreferredMicrophoneFieldDimension(float zoom)
600 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700601
Andy Hungab65b182023-09-06 19:41:47 -0700602 virtual void addPatchTrack(const sp<IAfPatchRecord>& record)
603 EXCLUDES_ThreadBase_Mutex = 0;
604 virtual void deletePatchTrack(const sp<IAfPatchRecord>& record)
605 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700606 virtual bool fastTrackAvailable() const = 0;
607 virtual void setFastTrackAvailable(bool available) = 0;
608
Andy Hungab65b182023-09-06 19:41:47 -0700609 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
610 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700611 virtual bool hasFastCapture() const = 0;
612
Andy Hung3f49ebb2023-09-19 14:48:41 -0700613 virtual void checkBtNrec() EXCLUDES_ThreadBase_Mutex = 0;
614 virtual uint32_t getInputFramesLost() const EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung87c693c2023-07-06 20:56:16 -0700615
616 virtual status_t shareAudioHistory(
617 const std::string& sharedAudioPackageName,
618 audio_session_t sharedSessionId = AUDIO_SESSION_NONE,
Andy Hungab65b182023-09-06 19:41:47 -0700619 int64_t sharedAudioStartMs = -1) EXCLUDES_ThreadBase_Mutex = 0;
620 virtual void resetAudioHistory_l() REQUIRES(mutex()) = 0;
Andy Hung440901d2023-06-29 21:19:25 -0700621};
622
Andy Hung7aa7d102023-07-07 15:58:48 -0700623class IAfMmapThread : public virtual IAfThreadBase {
624public:
625 // createIAudioTrackAdapter() is a static constructor which creates an
626 // MmapStreamInterface AIDL interface adapter from the MmapThread object that
627 // may be passed back to the client.
628 //
629 // Only one AIDL MmapStreamInterface interface adapter should be created per MmapThread.
630 static sp<MmapStreamInterface> createMmapStreamInterfaceAdapter(
631 const sp<IAfMmapThread>& mmapThread);
632
633 virtual void configure(
634 const audio_attributes_t* attr,
635 audio_stream_type_t streamType,
636 audio_session_t sessionId,
637 const sp<MmapStreamCallback>& callback,
638 audio_port_handle_t deviceId,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700639 audio_port_handle_t portId) EXCLUDES_ThreadBase_Mutex = 0;
Andy Hungab65b182023-09-06 19:41:47 -0700640 virtual void disconnect() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700641
642 // MmapStreamInterface handling (see adapter)
643 virtual status_t createMmapBuffer(
Andy Hung3f49ebb2023-09-19 14:48:41 -0700644 int32_t minSizeFrames, struct audio_mmap_buffer_info* info)
645 EXCLUDES_ThreadBase_Mutex = 0;
646 virtual status_t getMmapPosition(struct audio_mmap_position* position) const
647 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700648 virtual status_t start(
649 const AudioClient& client, const audio_attributes_t* attr,
Andy Hung3f49ebb2023-09-19 14:48:41 -0700650 audio_port_handle_t* handle) EXCLUDES_ThreadBase_Mutex = 0;
651 virtual status_t stop(audio_port_handle_t handle) EXCLUDES_ThreadBase_Mutex = 0;
652 virtual status_t standby() EXCLUDES_ThreadBase_Mutex = 0;
653 virtual status_t getExternalPosition(uint64_t* position, int64_t* timeNanos) const
654 EXCLUDES_ThreadBase_Mutex = 0;
655 virtual status_t reportData(const void* buffer, size_t frameCount)
656 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700657
Andy Hung99b1ba62023-07-14 11:00:08 -0700658 // TODO(b/291317898) move to IAfThreadBase?
Andy Hungab65b182023-09-06 19:41:47 -0700659 virtual void invalidateTracks(std::set<audio_port_handle_t>& portIds)
660 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700661
Andy Hung99b1ba62023-07-14 11:00:08 -0700662 // Sets the UID records silence - TODO(b/291317898) move to IAfMmapCaptureThread
Andy Hungab65b182023-09-06 19:41:47 -0700663 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced)
664 EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700665
666 virtual sp<IAfMmapPlaybackThread> asIAfMmapPlaybackThread() { return nullptr; }
667 virtual sp<IAfMmapCaptureThread> asIAfMmapCaptureThread() { return nullptr; }
668};
669
670class IAfMmapPlaybackThread : public virtual IAfMmapThread, public virtual VolumeInterface {
671public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700672 static sp<IAfMmapPlaybackThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700673 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
674 AudioHwDevice* hwDev, AudioStreamOut* output, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700675
Andy Hungab65b182023-09-06 19:41:47 -0700676 virtual AudioStreamOut* clearOutput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700677};
678
679class IAfMmapCaptureThread : public virtual IAfMmapThread {
680public:
Andy Hungee58e4a2023-07-07 13:47:37 -0700681 static sp<IAfMmapCaptureThread> create(
Andy Hung583043b2023-07-17 17:05:00 -0700682 const sp<IAfThreadCallback>& afThreadCallback, audio_io_handle_t id,
683 AudioHwDevice* hwDev, AudioStreamIn* input, bool systemReady);
Andy Hungee58e4a2023-07-07 13:47:37 -0700684
Andy Hungab65b182023-09-06 19:41:47 -0700685 virtual AudioStreamIn* clearInput() EXCLUDES_ThreadBase_Mutex = 0;
Andy Hung7aa7d102023-07-07 15:58:48 -0700686};
687
Andy Hung440901d2023-06-29 21:19:25 -0700688} // namespace android