blob: 066090b20a451f55ccfae8fc0fb13cb2c4ba3ba5 [file] [log] [blame]
Eric Laurent81784c32012-11-19 14:55:58 -08001/*
2**
3** Copyright 2012, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef INCLUDING_FROM_AUDIOFLINGER_H
19 #error This header file should only be included from AudioFlinger.h
20#endif
21
22class ThreadBase : public Thread {
23public:
24
25#include "TrackBase.h"
26
27 enum type_t {
28 MIXER, // Thread class is MixerThread
29 DIRECT, // Thread class is DirectOutputThread
30 DUPLICATING, // Thread class is DuplicatingThread
Eric Laurentbfb1b832013-01-07 09:53:42 -080031 RECORD, // Thread class is RecordThread
32 OFFLOAD // Thread class is OffloadThread
Eric Laurent81784c32012-11-19 14:55:58 -080033 };
34
Glenn Kasten97b7b752014-09-28 13:04:24 -070035 static const char *threadTypeToString(type_t type);
36
Eric Laurent81784c32012-11-19 14:55:58 -080037 ThreadBase(const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id,
38 audio_devices_t outDevice, audio_devices_t inDevice, type_t type);
39 virtual ~ThreadBase();
40
Glenn Kastencf04c2c2013-08-06 07:41:16 -070041 virtual status_t readyToRun();
42
Eric Laurent81784c32012-11-19 14:55:58 -080043 void dumpBase(int fd, const Vector<String16>& args);
44 void dumpEffectChains(int fd, const Vector<String16>& args);
45
46 void clearPowerManager();
47
48 // base for record and playback
49 enum {
50 CFG_EVENT_IO,
Eric Laurent10351942014-05-08 18:49:52 -070051 CFG_EVENT_PRIO,
52 CFG_EVENT_SET_PARAMETER,
Eric Laurent1c333e22014-05-20 10:48:17 -070053 CFG_EVENT_CREATE_AUDIO_PATCH,
54 CFG_EVENT_RELEASE_AUDIO_PATCH,
Eric Laurent81784c32012-11-19 14:55:58 -080055 };
56
Eric Laurent10351942014-05-08 18:49:52 -070057 class ConfigEventData: public RefBase {
Eric Laurent81784c32012-11-19 14:55:58 -080058 public:
Eric Laurent10351942014-05-08 18:49:52 -070059 virtual ~ConfigEventData() {}
Eric Laurent81784c32012-11-19 14:55:58 -080060
61 virtual void dump(char *buffer, size_t size) = 0;
Eric Laurent10351942014-05-08 18:49:52 -070062 protected:
63 ConfigEventData() {}
Eric Laurent81784c32012-11-19 14:55:58 -080064 };
65
Eric Laurent10351942014-05-08 18:49:52 -070066 // Config event sequence by client if status needed (e.g binder thread calling setParameters()):
67 // 1. create SetParameterConfigEvent. This sets mWaitStatus in config event
68 // 2. Lock mLock
69 // 3. Call sendConfigEvent_l(): Append to mConfigEvents and mWaitWorkCV.signal
70 // 4. sendConfigEvent_l() reads status from event->mStatus;
71 // 5. sendConfigEvent_l() returns status
72 // 6. Unlock
73 //
74 // Parameter sequence by server: threadLoop calling processConfigEvents_l():
75 // 1. Lock mLock
76 // 2. If there is an entry in mConfigEvents proceed ...
77 // 3. Read first entry in mConfigEvents
78 // 4. Remove first entry from mConfigEvents
79 // 5. Process
80 // 6. Set event->mStatus
81 // 7. event->mCond.signal
82 // 8. Unlock
Eric Laurent81784c32012-11-19 14:55:58 -080083
Eric Laurent10351942014-05-08 18:49:52 -070084 class ConfigEvent: public RefBase {
85 public:
86 virtual ~ConfigEvent() {}
87
88 void dump(char *buffer, size_t size) { mData->dump(buffer, size); }
89
90 const int mType; // event type e.g. CFG_EVENT_IO
91 Mutex mLock; // mutex associated with mCond
92 Condition mCond; // condition for status return
93 status_t mStatus; // status communicated to sender
94 bool mWaitStatus; // true if sender is waiting for status
95 sp<ConfigEventData> mData; // event specific parameter data
96
97 protected:
98 ConfigEvent(int type) : mType(type), mStatus(NO_ERROR), mWaitStatus(false), mData(NULL) {}
99 };
100
101 class IoConfigEventData : public ConfigEventData {
102 public:
Eric Laurent73e26b62015-04-27 16:55:58 -0700103 IoConfigEventData(audio_io_config_event event) :
104 mEvent(event) {}
Eric Laurent81784c32012-11-19 14:55:58 -0800105
106 virtual void dump(char *buffer, size_t size) {
Eric Laurent73e26b62015-04-27 16:55:58 -0700107 snprintf(buffer, size, "IO event: event %d\n", mEvent);
Eric Laurent81784c32012-11-19 14:55:58 -0800108 }
109
Eric Laurent73e26b62015-04-27 16:55:58 -0700110 const audio_io_config_event mEvent;
Eric Laurent81784c32012-11-19 14:55:58 -0800111 };
112
Eric Laurent10351942014-05-08 18:49:52 -0700113 class IoConfigEvent : public ConfigEvent {
Eric Laurent81784c32012-11-19 14:55:58 -0800114 public:
Eric Laurent73e26b62015-04-27 16:55:58 -0700115 IoConfigEvent(audio_io_config_event event) :
Eric Laurent10351942014-05-08 18:49:52 -0700116 ConfigEvent(CFG_EVENT_IO) {
Eric Laurent73e26b62015-04-27 16:55:58 -0700117 mData = new IoConfigEventData(event);
Eric Laurent10351942014-05-08 18:49:52 -0700118 }
119 virtual ~IoConfigEvent() {}
120 };
Eric Laurent81784c32012-11-19 14:55:58 -0800121
Eric Laurent10351942014-05-08 18:49:52 -0700122 class PrioConfigEventData : public ConfigEventData {
123 public:
124 PrioConfigEventData(pid_t pid, pid_t tid, int32_t prio) :
125 mPid(pid), mTid(tid), mPrio(prio) {}
Eric Laurent81784c32012-11-19 14:55:58 -0800126
127 virtual void dump(char *buffer, size_t size) {
128 snprintf(buffer, size, "Prio event: pid %d, tid %d, prio %d\n", mPid, mTid, mPrio);
129 }
130
Eric Laurent81784c32012-11-19 14:55:58 -0800131 const pid_t mPid;
132 const pid_t mTid;
133 const int32_t mPrio;
134 };
135
Eric Laurent10351942014-05-08 18:49:52 -0700136 class PrioConfigEvent : public ConfigEvent {
137 public:
138 PrioConfigEvent(pid_t pid, pid_t tid, int32_t prio) :
139 ConfigEvent(CFG_EVENT_PRIO) {
140 mData = new PrioConfigEventData(pid, tid, prio);
141 }
142 virtual ~PrioConfigEvent() {}
143 };
144
145 class SetParameterConfigEventData : public ConfigEventData {
146 public:
147 SetParameterConfigEventData(String8 keyValuePairs) :
148 mKeyValuePairs(keyValuePairs) {}
149
150 virtual void dump(char *buffer, size_t size) {
151 snprintf(buffer, size, "KeyValue: %s\n", mKeyValuePairs.string());
152 }
153
154 const String8 mKeyValuePairs;
155 };
156
157 class SetParameterConfigEvent : public ConfigEvent {
158 public:
159 SetParameterConfigEvent(String8 keyValuePairs) :
160 ConfigEvent(CFG_EVENT_SET_PARAMETER) {
161 mData = new SetParameterConfigEventData(keyValuePairs);
162 mWaitStatus = true;
163 }
164 virtual ~SetParameterConfigEvent() {}
165 };
166
Eric Laurent1c333e22014-05-20 10:48:17 -0700167 class CreateAudioPatchConfigEventData : public ConfigEventData {
168 public:
169 CreateAudioPatchConfigEventData(const struct audio_patch patch,
170 audio_patch_handle_t handle) :
171 mPatch(patch), mHandle(handle) {}
172
173 virtual void dump(char *buffer, size_t size) {
174 snprintf(buffer, size, "Patch handle: %u\n", mHandle);
175 }
176
177 const struct audio_patch mPatch;
178 audio_patch_handle_t mHandle;
179 };
180
181 class CreateAudioPatchConfigEvent : public ConfigEvent {
182 public:
183 CreateAudioPatchConfigEvent(const struct audio_patch patch,
184 audio_patch_handle_t handle) :
185 ConfigEvent(CFG_EVENT_CREATE_AUDIO_PATCH) {
186 mData = new CreateAudioPatchConfigEventData(patch, handle);
187 mWaitStatus = true;
188 }
189 virtual ~CreateAudioPatchConfigEvent() {}
190 };
191
192 class ReleaseAudioPatchConfigEventData : public ConfigEventData {
193 public:
194 ReleaseAudioPatchConfigEventData(const audio_patch_handle_t handle) :
195 mHandle(handle) {}
196
197 virtual void dump(char *buffer, size_t size) {
198 snprintf(buffer, size, "Patch handle: %u\n", mHandle);
199 }
200
201 audio_patch_handle_t mHandle;
202 };
203
204 class ReleaseAudioPatchConfigEvent : public ConfigEvent {
205 public:
206 ReleaseAudioPatchConfigEvent(const audio_patch_handle_t handle) :
207 ConfigEvent(CFG_EVENT_RELEASE_AUDIO_PATCH) {
208 mData = new ReleaseAudioPatchConfigEventData(handle);
209 mWaitStatus = true;
210 }
211 virtual ~ReleaseAudioPatchConfigEvent() {}
212 };
Eric Laurent81784c32012-11-19 14:55:58 -0800213
214 class PMDeathRecipient : public IBinder::DeathRecipient {
215 public:
216 PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
217 virtual ~PMDeathRecipient() {}
218
219 // IBinder::DeathRecipient
220 virtual void binderDied(const wp<IBinder>& who);
221
222 private:
223 PMDeathRecipient(const PMDeathRecipient&);
224 PMDeathRecipient& operator = (const PMDeathRecipient&);
225
226 wp<ThreadBase> mThread;
227 };
228
229 virtual status_t initCheck() const = 0;
230
231 // static externally-visible
232 type_t type() const { return mType; }
233 audio_io_handle_t id() const { return mId;}
234
235 // dynamic externally-visible
236 uint32_t sampleRate() const { return mSampleRate; }
Eric Laurent81784c32012-11-19 14:55:58 -0800237 audio_channel_mask_t channelMask() const { return mChannelMask; }
Andy Hung463be252014-07-10 16:56:07 -0700238 audio_format_t format() const { return mHALFormat; }
Eric Laurent83b88082014-06-20 18:31:16 -0700239 uint32_t channelCount() const { return mChannelCount; }
Eric Laurent81784c32012-11-19 14:55:58 -0800240 // Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
Glenn Kasten9b58f632013-07-16 11:37:48 -0700241 // and returns the [normal mix] buffer's frame count.
242 virtual size_t frameCount() const = 0;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800243 size_t frameSize() const { return mFrameSize; }
Eric Laurent81784c32012-11-19 14:55:58 -0800244
245 // Should be "virtual status_t requestExitAndWait()" and override same
246 // method in Thread, but Thread::requestExitAndWait() is not yet virtual.
247 void exit();
Eric Laurent10351942014-05-08 18:49:52 -0700248 virtual bool checkForNewParameter_l(const String8& keyValuePair,
249 status_t& status) = 0;
Eric Laurent81784c32012-11-19 14:55:58 -0800250 virtual status_t setParameters(const String8& keyValuePairs);
251 virtual String8 getParameters(const String8& keys) = 0;
Eric Laurent73e26b62015-04-27 16:55:58 -0700252 virtual void ioConfigChanged(audio_io_config_event event) = 0;
Eric Laurent10351942014-05-08 18:49:52 -0700253 // sendConfigEvent_l() must be called with ThreadBase::mLock held
254 // Can temporarily release the lock if waiting for a reply from
255 // processConfigEvents_l().
256 status_t sendConfigEvent_l(sp<ConfigEvent>& event);
Eric Laurent73e26b62015-04-27 16:55:58 -0700257 void sendIoConfigEvent(audio_io_config_event event);
258 void sendIoConfigEvent_l(audio_io_config_event event);
Eric Laurent81784c32012-11-19 14:55:58 -0800259 void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio);
Eric Laurent10351942014-05-08 18:49:52 -0700260 status_t sendSetParameterConfigEvent_l(const String8& keyValuePair);
Eric Laurent1c333e22014-05-20 10:48:17 -0700261 status_t sendCreateAudioPatchConfigEvent(const struct audio_patch *patch,
262 audio_patch_handle_t *handle);
263 status_t sendReleaseAudioPatchConfigEvent(audio_patch_handle_t handle);
Eric Laurent021cf962014-05-13 10:18:14 -0700264 void processConfigEvents_l();
Eric Laurent10351942014-05-08 18:49:52 -0700265 virtual void cacheParameters_l() = 0;
Eric Laurent1c333e22014-05-20 10:48:17 -0700266 virtual status_t createAudioPatch_l(const struct audio_patch *patch,
267 audio_patch_handle_t *handle) = 0;
268 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle) = 0;
Eric Laurent83b88082014-06-20 18:31:16 -0700269 virtual void getAudioPortConfig(struct audio_port_config *config) = 0;
Eric Laurent1c333e22014-05-20 10:48:17 -0700270
Eric Laurent81784c32012-11-19 14:55:58 -0800271
272 // see note at declaration of mStandby, mOutDevice and mInDevice
273 bool standby() const { return mStandby; }
274 audio_devices_t outDevice() const { return mOutDevice; }
275 audio_devices_t inDevice() const { return mInDevice; }
276
277 virtual audio_stream_t* stream() const = 0;
278
279 sp<EffectHandle> createEffect_l(
280 const sp<AudioFlinger::Client>& client,
281 const sp<IEffectClient>& effectClient,
282 int32_t priority,
283 int sessionId,
284 effect_descriptor_t *desc,
285 int *enabled,
Glenn Kasten9156ef32013-08-06 15:39:08 -0700286 status_t *status /*non-NULL*/);
Eric Laurent81784c32012-11-19 14:55:58 -0800287
288 // return values for hasAudioSession (bit field)
289 enum effect_state {
290 EFFECT_SESSION = 0x1, // the audio session corresponds to at least one
291 // effect
292 TRACK_SESSION = 0x2 // the audio session corresponds to at least one
293 // track
294 };
295
296 // get effect chain corresponding to session Id.
297 sp<EffectChain> getEffectChain(int sessionId);
298 // same as getEffectChain() but must be called with ThreadBase mutex locked
299 sp<EffectChain> getEffectChain_l(int sessionId) const;
300 // add an effect chain to the chain list (mEffectChains)
301 virtual status_t addEffectChain_l(const sp<EffectChain>& chain) = 0;
302 // remove an effect chain from the chain list (mEffectChains)
303 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain) = 0;
304 // lock all effect chains Mutexes. Must be called before releasing the
305 // ThreadBase mutex before processing the mixer and effects. This guarantees the
306 // integrity of the chains during the process.
307 // Also sets the parameter 'effectChains' to current value of mEffectChains.
308 void lockEffectChains_l(Vector< sp<EffectChain> >& effectChains);
309 // unlock effect chains after process
310 void unlockEffectChains(const Vector< sp<EffectChain> >& effectChains);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800311 // get a copy of mEffectChains vector
312 Vector< sp<EffectChain> > getEffectChains_l() const { return mEffectChains; };
Eric Laurent81784c32012-11-19 14:55:58 -0800313 // set audio mode to all effect chains
314 void setMode(audio_mode_t mode);
315 // get effect module with corresponding ID on specified audio session
316 sp<AudioFlinger::EffectModule> getEffect(int sessionId, int effectId);
317 sp<AudioFlinger::EffectModule> getEffect_l(int sessionId, int effectId);
318 // add and effect module. Also creates the effect chain is none exists for
319 // the effects audio session
320 status_t addEffect_l(const sp< EffectModule>& effect);
321 // remove and effect module. Also removes the effect chain is this was the last
322 // effect
323 void removeEffect_l(const sp< EffectModule>& effect);
324 // detach all tracks connected to an auxiliary effect
Glenn Kasten0f11b512014-01-31 16:18:54 -0800325 virtual void detachAuxEffect_l(int effectId __unused) {}
Eric Laurent81784c32012-11-19 14:55:58 -0800326 // returns either EFFECT_SESSION if effects on this audio session exist in one
327 // chain, or TRACK_SESSION if tracks on this audio session exist, or both
328 virtual uint32_t hasAudioSession(int sessionId) const = 0;
329 // the value returned by default implementation is not important as the
330 // strategy is only meaningful for PlaybackThread which implements this method
Glenn Kasten0f11b512014-01-31 16:18:54 -0800331 virtual uint32_t getStrategyForSession_l(int sessionId __unused) { return 0; }
Eric Laurent81784c32012-11-19 14:55:58 -0800332
333 // suspend or restore effect according to the type of effect passed. a NULL
334 // type pointer means suspend all effects in the session
335 void setEffectSuspended(const effect_uuid_t *type,
336 bool suspend,
337 int sessionId = AUDIO_SESSION_OUTPUT_MIX);
338 // check if some effects must be suspended/restored when an effect is enabled
339 // or disabled
340 void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
341 bool enabled,
342 int sessionId = AUDIO_SESSION_OUTPUT_MIX);
343 void checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
344 bool enabled,
345 int sessionId = AUDIO_SESSION_OUTPUT_MIX);
346
347 virtual status_t setSyncEvent(const sp<SyncEvent>& event) = 0;
348 virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const = 0;
349
Glenn Kastenb880f5e2014-05-07 08:43:45 -0700350 // Return a reference to a per-thread heap which can be used to allocate IMemory
351 // objects that will be read-only to client processes, read/write to mediaserver,
352 // and shared by all client processes of the thread.
353 // The heap is per-thread rather than common across all threads, because
354 // clients can't be trusted not to modify the offset of the IMemory they receive.
355 // If a thread does not have such a heap, this method returns 0.
356 virtual sp<MemoryDealer> readOnlyHeap() const { return 0; }
Eric Laurent81784c32012-11-19 14:55:58 -0800357
Glenn Kasten6181ffd2014-05-13 10:41:52 -0700358 virtual sp<IMemory> pipeMemory() const { return 0; }
359
Eric Laurent81784c32012-11-19 14:55:58 -0800360 mutable Mutex mLock;
361
362protected:
363
364 // entry describing an effect being suspended in mSuspendedSessions keyed vector
365 class SuspendedSessionDesc : public RefBase {
366 public:
367 SuspendedSessionDesc() : mRefCount(0) {}
368
369 int mRefCount; // number of active suspend requests
370 effect_uuid_t mType; // effect type UUID
371 };
372
Marco Nelissene14a5d62013-10-03 08:51:24 -0700373 void acquireWakeLock(int uid = -1);
374 void acquireWakeLock_l(int uid = -1);
Eric Laurent81784c32012-11-19 14:55:58 -0800375 void releaseWakeLock();
376 void releaseWakeLock_l();
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800377 void updateWakeLockUids(const SortedVector<int> &uids);
378 void updateWakeLockUids_l(const SortedVector<int> &uids);
379 void getPowerManager_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800380 void setEffectSuspended_l(const effect_uuid_t *type,
381 bool suspend,
382 int sessionId);
383 // updated mSuspendedSessions when an effect suspended or restored
384 void updateSuspendedSessions_l(const effect_uuid_t *type,
385 bool suspend,
386 int sessionId);
387 // check if some effects must be suspended when an effect chain is added
388 void checkSuspendOnAddEffectChain_l(const sp<EffectChain>& chain);
389
Narayan Kamath014e7fa2013-10-14 15:03:38 +0100390 String16 getWakeLockTag();
391
Eric Laurent81784c32012-11-19 14:55:58 -0800392 virtual void preExit() { }
393
394 friend class AudioFlinger; // for mEffectChains
395
396 const type_t mType;
397
398 // Used by parameters, config events, addTrack_l, exit
399 Condition mWaitWorkCV;
400
401 const sp<AudioFlinger> mAudioFlinger;
Glenn Kasten9b58f632013-07-16 11:37:48 -0700402
Glenn Kastendeca2ae2014-02-07 10:25:56 -0800403 // updated by PlaybackThread::readOutputParameters_l() or
404 // RecordThread::readInputParameters_l()
Eric Laurent81784c32012-11-19 14:55:58 -0800405 uint32_t mSampleRate;
406 size_t mFrameCount; // output HAL, direct output, record
Eric Laurent81784c32012-11-19 14:55:58 -0800407 audio_channel_mask_t mChannelMask;
Glenn Kastenf6ed4232013-07-16 11:16:27 -0700408 uint32_t mChannelCount;
Eric Laurent81784c32012-11-19 14:55:58 -0800409 size_t mFrameSize;
Glenn Kasten97b7b752014-09-28 13:04:24 -0700410 // not HAL frame size, this is for output sink (to pipe to fast mixer)
Andy Hung463be252014-07-10 16:56:07 -0700411 audio_format_t mFormat; // Source format for Recording and
412 // Sink format for Playback.
413 // Sink format may be different than
414 // HAL format if Fastmixer is used.
415 audio_format_t mHALFormat;
Glenn Kasten70949c42013-08-06 07:40:12 -0700416 size_t mBufferSize; // HAL buffer size for read() or write()
Eric Laurent81784c32012-11-19 14:55:58 -0800417
Eric Laurent10351942014-05-08 18:49:52 -0700418 Vector< sp<ConfigEvent> > mConfigEvents;
Eric Laurent81784c32012-11-19 14:55:58 -0800419
420 // These fields are written and read by thread itself without lock or barrier,
Glenn Kasten4944acb2013-08-19 08:39:20 -0700421 // and read by other threads without lock or barrier via standby(), outDevice()
Eric Laurent81784c32012-11-19 14:55:58 -0800422 // and inDevice().
423 // Because of the absence of a lock or barrier, any other thread that reads
424 // these fields must use the information in isolation, or be prepared to deal
425 // with possibility that it might be inconsistent with other information.
Glenn Kasten4944acb2013-08-19 08:39:20 -0700426 bool mStandby; // Whether thread is currently in standby.
Eric Laurent81784c32012-11-19 14:55:58 -0800427 audio_devices_t mOutDevice; // output device
428 audio_devices_t mInDevice; // input device
Glenn Kastenf59497b2015-01-26 16:35:47 -0800429 audio_source_t mAudioSource;
Eric Laurent81784c32012-11-19 14:55:58 -0800430
431 const audio_io_handle_t mId;
432 Vector< sp<EffectChain> > mEffectChains;
433
Glenn Kastend7dca052015-03-05 16:05:54 -0800434 static const int kThreadNameLength = 16; // prctl(PR_SET_NAME) limit
435 char mThreadName[kThreadNameLength]; // guaranteed NUL-terminated
Eric Laurent81784c32012-11-19 14:55:58 -0800436 sp<IPowerManager> mPowerManager;
437 sp<IBinder> mWakeLockToken;
438 const sp<PMDeathRecipient> mDeathRecipient;
439 // list of suspended effects per session and per type. The first vector is
440 // keyed by session ID, the second by type UUID timeLow field
441 KeyedVector< int, KeyedVector< int, sp<SuspendedSessionDesc> > >
442 mSuspendedSessions;
Glenn Kastenab7d72f2013-02-27 09:05:28 -0800443 static const size_t kLogSize = 4 * 1024;
Glenn Kasten9e58b552013-01-18 15:09:48 -0800444 sp<NBLog::Writer> mNBLogWriter;
Eric Laurent81784c32012-11-19 14:55:58 -0800445};
446
447// --- PlaybackThread ---
448class PlaybackThread : public ThreadBase {
449public:
450
451#include "PlaybackTracks.h"
452
453 enum mixer_state {
454 MIXER_IDLE, // no active tracks
455 MIXER_TRACKS_ENABLED, // at least one active track, but no track has any data ready
Eric Laurentbfb1b832013-01-07 09:53:42 -0800456 MIXER_TRACKS_READY, // at least one active track, and at least one track has data
457 MIXER_DRAIN_TRACK, // drain currently playing track
458 MIXER_DRAIN_ALL, // fully drain the hardware
Eric Laurent81784c32012-11-19 14:55:58 -0800459 // standby mode does not have an enum value
460 // suspend by audio policy manager is orthogonal to mixer state
461 };
462
Eric Laurentbfb1b832013-01-07 09:53:42 -0800463 // retry count before removing active track in case of underrun on offloaded thread:
464 // we need to make sure that AudioTrack client has enough time to send large buffers
465//FIXME may be more appropriate if expressed in time units. Need to revise how underrun is handled
466 // for offloaded tracks
467 static const int8_t kMaxTrackRetriesOffload = 20;
468
Eric Laurent81784c32012-11-19 14:55:58 -0800469 PlaybackThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
470 audio_io_handle_t id, audio_devices_t device, type_t type);
471 virtual ~PlaybackThread();
472
473 void dump(int fd, const Vector<String16>& args);
474
475 // Thread virtuals
Eric Laurent81784c32012-11-19 14:55:58 -0800476 virtual bool threadLoop();
477
478 // RefBase
479 virtual void onFirstRef();
480
481protected:
482 // Code snippets that were lifted up out of threadLoop()
483 virtual void threadLoop_mix() = 0;
484 virtual void threadLoop_sleepTime() = 0;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800485 virtual ssize_t threadLoop_write();
486 virtual void threadLoop_drain();
Eric Laurent81784c32012-11-19 14:55:58 -0800487 virtual void threadLoop_standby();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800488 virtual void threadLoop_exit();
Eric Laurent81784c32012-11-19 14:55:58 -0800489 virtual void threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove);
490
491 // prepareTracks_l reads and writes mActiveTracks, and returns
492 // the pending set of tracks to remove via Vector 'tracksToRemove'. The caller
493 // is responsible for clearing or destroying this Vector later on, when it
494 // is safe to do so. That will drop the final ref count and destroy the tracks.
495 virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove) = 0;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800496 void removeTracks_l(const Vector< sp<Track> >& tracksToRemove);
497
498 void writeCallback();
Eric Laurent3b4529e2013-09-05 18:09:19 -0700499 void resetWriteBlocked(uint32_t sequence);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800500 void drainCallback();
Eric Laurent3b4529e2013-09-05 18:09:19 -0700501 void resetDraining(uint32_t sequence);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800502
503 static int asyncCallback(stream_callback_event_t event, void *param, void *cookie);
504
505 virtual bool waitingAsyncCallback();
506 virtual bool waitingAsyncCallback_l();
507 virtual bool shouldStandby_l();
Haynes Mathew George4c6a4332014-01-15 12:31:39 -0800508 virtual void onAddNewTrack_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800509
510 // ThreadBase virtuals
511 virtual void preExit();
512
513public:
514
515 virtual status_t initCheck() const { return (mOutput == NULL) ? NO_INIT : NO_ERROR; }
516
517 // return estimated latency in milliseconds, as reported by HAL
518 uint32_t latency() const;
519 // same, but lock must already be held
520 uint32_t latency_l() const;
521
522 void setMasterVolume(float value);
523 void setMasterMute(bool muted);
524
525 void setStreamVolume(audio_stream_type_t stream, float value);
526 void setStreamMute(audio_stream_type_t stream, bool muted);
527
528 float streamVolume(audio_stream_type_t stream) const;
529
530 sp<Track> createTrack_l(
531 const sp<AudioFlinger::Client>& client,
532 audio_stream_type_t streamType,
533 uint32_t sampleRate,
534 audio_format_t format,
535 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -0800536 size_t *pFrameCount,
Eric Laurent81784c32012-11-19 14:55:58 -0800537 const sp<IMemory>& sharedBuffer,
538 int sessionId,
539 IAudioFlinger::track_flags_t *flags,
540 pid_t tid,
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800541 int uid,
Glenn Kasten9156ef32013-08-06 15:39:08 -0700542 status_t *status /*non-NULL*/);
Eric Laurent81784c32012-11-19 14:55:58 -0800543
544 AudioStreamOut* getOutput() const;
545 AudioStreamOut* clearOutput();
546 virtual audio_stream_t* stream() const;
547
548 // a very large number of suspend() will eventually wraparound, but unlikely
549 void suspend() { (void) android_atomic_inc(&mSuspended); }
550 void restore()
551 {
552 // if restore() is done without suspend(), get back into
553 // range so that the next suspend() will operate correctly
554 if (android_atomic_dec(&mSuspended) <= 0) {
555 android_atomic_release_store(0, &mSuspended);
556 }
557 }
558 bool isSuspended() const
559 { return android_atomic_acquire_load(&mSuspended) > 0; }
560
561 virtual String8 getParameters(const String8& keys);
Eric Laurent73e26b62015-04-27 16:55:58 -0700562 virtual void ioConfigChanged(audio_io_config_event event);
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000563 status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
Andy Hung010a1a12014-03-13 13:57:33 -0700564 // FIXME rename mixBuffer() to sinkBuffer() and remove int16_t* dependency.
565 // Consider also removing and passing an explicit mMainBuffer initialization
566 // parameter to AF::PlaybackThread::Track::Track().
567 int16_t *mixBuffer() const {
568 return reinterpret_cast<int16_t *>(mSinkBuffer); };
Eric Laurent81784c32012-11-19 14:55:58 -0800569
570 virtual void detachAuxEffect_l(int effectId);
571 status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
572 int EffectId);
573 status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
574 int EffectId);
575
576 virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
577 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
578 virtual uint32_t hasAudioSession(int sessionId) const;
579 virtual uint32_t getStrategyForSession_l(int sessionId);
580
581
582 virtual status_t setSyncEvent(const sp<SyncEvent>& event);
583 virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const;
Glenn Kastenfb1fdc92013-07-10 17:03:19 -0700584
585 // called with AudioFlinger lock held
Eric Laurent81784c32012-11-19 14:55:58 -0800586 void invalidateTracks(audio_stream_type_t streamType);
587
Glenn Kasten9b58f632013-07-16 11:37:48 -0700588 virtual size_t frameCount() const { return mNormalFrameCount; }
589
590 // Return's the HAL's frame count i.e. fast mixer buffer size.
591 size_t frameCountHAL() const { return mFrameCount; }
Eric Laurent81784c32012-11-19 14:55:58 -0800592
Eric Laurent83b88082014-06-20 18:31:16 -0700593 status_t getTimestamp_l(AudioTimestamp& timestamp);
594
595 void addPatchTrack(const sp<PatchTrack>& track);
596 void deletePatchTrack(const sp<PatchTrack>& track);
597
598 virtual void getAudioPortConfig(struct audio_port_config *config);
Eric Laurentaccc1472013-09-20 09:36:34 -0700599
Eric Laurent81784c32012-11-19 14:55:58 -0800600protected:
Glenn Kastendeca2ae2014-02-07 10:25:56 -0800601 // updated by readOutputParameters_l()
Glenn Kasten9b58f632013-07-16 11:37:48 -0700602 size_t mNormalFrameCount; // normal mixer and effects
603
Andy Hung010a1a12014-03-13 13:57:33 -0700604 void* mSinkBuffer; // frame size aligned sink buffer
Eric Laurent81784c32012-11-19 14:55:58 -0800605
Andy Hung98ef9782014-03-04 14:46:50 -0800606 // TODO:
607 // Rearrange the buffer info into a struct/class with
608 // clear, copy, construction, destruction methods.
609 //
610 // mSinkBuffer also has associated with it:
611 //
612 // mSinkBufferSize: Sink Buffer Size
613 // mFormat: Sink Buffer Format
614
Andy Hung69aed5f2014-02-25 17:24:40 -0800615 // Mixer Buffer (mMixerBuffer*)
616 //
617 // In the case of floating point or multichannel data, which is not in the
618 // sink format, it is required to accumulate in a higher precision or greater channel count
619 // buffer before downmixing or data conversion to the sink buffer.
620
621 // Set to "true" to enable the Mixer Buffer otherwise mixer output goes to sink buffer.
622 bool mMixerBufferEnabled;
623
624 // Storage, 32 byte aligned (may make this alignment a requirement later).
625 // Due to constraints on mNormalFrameCount, the buffer size is a multiple of 16 frames.
626 void* mMixerBuffer;
627
628 // Size of mMixerBuffer in bytes: mNormalFrameCount * #channels * sampsize.
629 size_t mMixerBufferSize;
630
631 // The audio format of mMixerBuffer. Set to AUDIO_FORMAT_PCM_(FLOAT|16_BIT) only.
632 audio_format_t mMixerBufferFormat;
633
634 // An internal flag set to true by MixerThread::prepareTracks_l()
635 // when mMixerBuffer contains valid data after mixing.
636 bool mMixerBufferValid;
637
Andy Hung98ef9782014-03-04 14:46:50 -0800638 // Effects Buffer (mEffectsBuffer*)
639 //
640 // In the case of effects data, which is not in the sink format,
641 // it is required to accumulate in a different buffer before data conversion
642 // to the sink buffer.
643
644 // Set to "true" to enable the Effects Buffer otherwise effects output goes to sink buffer.
645 bool mEffectBufferEnabled;
646
647 // Storage, 32 byte aligned (may make this alignment a requirement later).
648 // Due to constraints on mNormalFrameCount, the buffer size is a multiple of 16 frames.
649 void* mEffectBuffer;
650
651 // Size of mEffectsBuffer in bytes: mNormalFrameCount * #channels * sampsize.
652 size_t mEffectBufferSize;
653
654 // The audio format of mEffectsBuffer. Set to AUDIO_FORMAT_PCM_16_BIT only.
655 audio_format_t mEffectBufferFormat;
656
657 // An internal flag set to true by MixerThread::prepareTracks_l()
658 // when mEffectsBuffer contains valid data after mixing.
659 //
660 // When this is set, all mixer data is routed into the effects buffer
661 // for any processing (including output processing).
662 bool mEffectBufferValid;
663
Eric Laurent81784c32012-11-19 14:55:58 -0800664 // suspend count, > 0 means suspended. While suspended, the thread continues to pull from
665 // tracks and mix, but doesn't write to HAL. A2DP and SCO HAL implementations can't handle
666 // concurrent use of both of them, so Audio Policy Service suspends one of the threads to
667 // workaround that restriction.
668 // 'volatile' means accessed via atomic operations and no lock.
669 volatile int32_t mSuspended;
670
671 // FIXME overflows every 6+ hours at 44.1 kHz stereo 16-bit samples
672 // mFramesWritten would be better, or 64-bit even better
673 size_t mBytesWritten;
674private:
675 // mMasterMute is in both PlaybackThread and in AudioFlinger. When a
676 // PlaybackThread needs to find out if master-muted, it checks it's local
677 // copy rather than the one in AudioFlinger. This optimization saves a lock.
678 bool mMasterMute;
679 void setMasterMute_l(bool muted) { mMasterMute = muted; }
680protected:
681 SortedVector< wp<Track> > mActiveTracks; // FIXME check if this could be sp<>
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800682 SortedVector<int> mWakeLockUids;
683 int mActiveTracksGeneration;
Eric Laurentfd477972013-10-25 18:10:40 -0700684 wp<Track> mLatestActiveTrack; // latest track added to mActiveTracks
Eric Laurent81784c32012-11-19 14:55:58 -0800685
686 // Allocate a track name for a given channel mask.
687 // Returns name >= 0 if successful, -1 on failure.
Andy Hunge8a1ced2014-05-09 15:02:21 -0700688 virtual int getTrackName_l(audio_channel_mask_t channelMask,
689 audio_format_t format, int sessionId) = 0;
Eric Laurent81784c32012-11-19 14:55:58 -0800690 virtual void deleteTrackName_l(int name) = 0;
691
692 // Time to sleep between cycles when:
693 virtual uint32_t activeSleepTimeUs() const; // mixer state MIXER_TRACKS_ENABLED
694 virtual uint32_t idleSleepTimeUs() const = 0; // mixer state MIXER_IDLE
695 virtual uint32_t suspendSleepTimeUs() const = 0; // audio policy manager suspended us
696 // No sleep when mixer state == MIXER_TRACKS_READY; relies on audio HAL stream->write()
697 // No sleep in standby mode; waits on a condition
698
699 // Code snippets that are temporarily lifted up out of threadLoop() until the merge
700 void checkSilentMode_l();
701
702 // Non-trivial for DUPLICATING only
703 virtual void saveOutputTracks() { }
704 virtual void clearOutputTracks() { }
705
706 // Cache various calculated values, at threadLoop() entry and after a parameter change
707 virtual void cacheParameters_l();
708
709 virtual uint32_t correctLatency_l(uint32_t latency) const;
710
Eric Laurent1c333e22014-05-20 10:48:17 -0700711 virtual status_t createAudioPatch_l(const struct audio_patch *patch,
712 audio_patch_handle_t *handle);
713 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle);
714
Eric Laurent0f7b5f22014-12-19 10:43:21 -0800715 bool usesHwAvSync() const { return (mType == DIRECT) && (mOutput != NULL) &&
716 (mOutput->flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC); }
717
Eric Laurent81784c32012-11-19 14:55:58 -0800718private:
719
720 friend class AudioFlinger; // for numerous
721
Eric Laurent81784c32012-11-19 14:55:58 -0800722 PlaybackThread& operator = (const PlaybackThread&);
723
724 status_t addTrack_l(const sp<Track>& track);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800725 bool destroyTrack_l(const sp<Track>& track);
Eric Laurent81784c32012-11-19 14:55:58 -0800726 void removeTrack_l(const sp<Track>& track);
Eric Laurentede6c3b2013-09-19 14:37:46 -0700727 void broadcast_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800728
Glenn Kastendeca2ae2014-02-07 10:25:56 -0800729 void readOutputParameters_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800730
731 virtual void dumpInternals(int fd, const Vector<String16>& args);
732 void dumpTracks(int fd, const Vector<String16>& args);
733
734 SortedVector< sp<Track> > mTracks;
Eric Laurent223fd5c2014-11-11 13:43:36 -0800735 stream_type_t mStreamTypes[AUDIO_STREAM_CNT];
Eric Laurent81784c32012-11-19 14:55:58 -0800736 AudioStreamOut *mOutput;
737
738 float mMasterVolume;
739 nsecs_t mLastWriteTime;
740 int mNumWrites;
741 int mNumDelayedWrites;
742 bool mInWrite;
743
744 // FIXME rename these former local variables of threadLoop to standard "m" names
745 nsecs_t standbyTime;
Andy Hung25c2dac2014-02-27 14:56:00 -0800746 size_t mSinkBufferSize;
Eric Laurent81784c32012-11-19 14:55:58 -0800747
748 // cached copies of activeSleepTimeUs() and idleSleepTimeUs() made by cacheParameters_l()
749 uint32_t activeSleepTime;
750 uint32_t idleSleepTime;
751
752 uint32_t sleepTime;
753
754 // mixer status returned by prepareTracks_l()
755 mixer_state mMixerStatus; // current cycle
756 // previous cycle when in prepareTracks_l()
757 mixer_state mMixerStatusIgnoringFastTracks;
758 // FIXME or a separate ready state per track
759
760 // FIXME move these declarations into the specific sub-class that needs them
761 // MIXER only
762 uint32_t sleepTimeShift;
763
764 // same as AudioFlinger::mStandbyTimeInNsecs except for DIRECT which uses a shorter value
765 nsecs_t standbyDelay;
766
767 // MIXER only
768 nsecs_t maxPeriod;
769
770 // DUPLICATING only
771 uint32_t writeFrames;
772
Eric Laurentbfb1b832013-01-07 09:53:42 -0800773 size_t mBytesRemaining;
774 size_t mCurrentWriteLength;
775 bool mUseAsyncWrite;
Eric Laurent3b4529e2013-09-05 18:09:19 -0700776 // mWriteAckSequence contains current write sequence on bits 31-1. The write sequence is
777 // incremented each time a write(), a flush() or a standby() occurs.
778 // Bit 0 is set when a write blocks and indicates a callback is expected.
779 // Bit 0 is reset by the async callback thread calling resetWriteBlocked(). Out of sequence
780 // callbacks are ignored.
781 uint32_t mWriteAckSequence;
782 // mDrainSequence contains current drain sequence on bits 31-1. The drain sequence is
783 // incremented each time a drain is requested or a flush() or standby() occurs.
784 // Bit 0 is set when the drain() command is called at the HAL and indicates a callback is
785 // expected.
786 // Bit 0 is reset by the async callback thread calling resetDraining(). Out of sequence
787 // callbacks are ignored.
788 uint32_t mDrainSequence;
Eric Laurentede6c3b2013-09-19 14:37:46 -0700789 // A condition that must be evaluated by prepareTrack_l() has changed and we must not wait
790 // for async write callback in the thread loop before evaluating it
Eric Laurentbfb1b832013-01-07 09:53:42 -0800791 bool mSignalPending;
792 sp<AsyncCallbackThread> mCallbackThread;
793
Eric Laurent81784c32012-11-19 14:55:58 -0800794private:
795 // The HAL output sink is treated as non-blocking, but current implementation is blocking
796 sp<NBAIO_Sink> mOutputSink;
797 // If a fast mixer is present, the blocking pipe sink, otherwise clear
798 sp<NBAIO_Sink> mPipeSink;
799 // The current sink for the normal mixer to write it's (sub)mix, mOutputSink or mPipeSink
800 sp<NBAIO_Sink> mNormalSink;
Glenn Kasten46909e72013-02-26 09:20:22 -0800801#ifdef TEE_SINK
Eric Laurent81784c32012-11-19 14:55:58 -0800802 // For dumpsys
803 sp<NBAIO_Sink> mTeeSink;
804 sp<NBAIO_Source> mTeeSource;
Glenn Kasten46909e72013-02-26 09:20:22 -0800805#endif
Eric Laurent81784c32012-11-19 14:55:58 -0800806 uint32_t mScreenState; // cached copy of gScreenState
Glenn Kastenab7d72f2013-02-27 09:05:28 -0800807 static const size_t kFastMixerLogSize = 4 * 1024;
Glenn Kasten9e58b552013-01-18 15:09:48 -0800808 sp<NBLog::Writer> mFastMixerNBLogWriter;
Eric Laurent81784c32012-11-19 14:55:58 -0800809public:
810 virtual bool hasFastMixer() const = 0;
Glenn Kasten0f11b512014-01-31 16:18:54 -0800811 virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex __unused) const
Eric Laurent81784c32012-11-19 14:55:58 -0800812 { FastTrackUnderruns dummy; return dummy; }
813
814protected:
815 // accessed by both binder threads and within threadLoop(), lock on mutex needed
816 unsigned mFastTrackAvailMask; // bit i set if fast track [i] is available
Eric Laurentd1f69b02014-12-15 14:33:13 -0800817 bool mHwSupportsPause;
818 bool mHwPaused;
819 bool mFlushPending;
Glenn Kastenbd096fd2013-08-23 13:53:56 -0700820private:
821 // timestamp latch:
822 // D input is written by threadLoop_write while mutex is unlocked, and read while locked
823 // Q output is written while locked, and read while locked
824 struct {
825 AudioTimestamp mTimestamp;
826 uint32_t mUnpresentedFrames;
Glenn Kasten4c053ea2014-09-28 14:41:07 -0700827 KeyedVector<Track *, uint32_t> mFramesReleased;
Glenn Kastenbd096fd2013-08-23 13:53:56 -0700828 } mLatchD, mLatchQ;
Glenn Kasten4c053ea2014-09-28 14:41:07 -0700829 bool mLatchDValid; // true means mLatchD is valid
830 // (except for mFramesReleased which is filled in later),
831 // and clock it into latch at next opportunity
Glenn Kastenbd096fd2013-08-23 13:53:56 -0700832 bool mLatchQValid; // true means mLatchQ is valid
Eric Laurent81784c32012-11-19 14:55:58 -0800833};
834
835class MixerThread : public PlaybackThread {
836public:
837 MixerThread(const sp<AudioFlinger>& audioFlinger,
838 AudioStreamOut* output,
839 audio_io_handle_t id,
840 audio_devices_t device,
841 type_t type = MIXER);
842 virtual ~MixerThread();
843
844 // Thread virtuals
845
Eric Laurent10351942014-05-08 18:49:52 -0700846 virtual bool checkForNewParameter_l(const String8& keyValuePair,
847 status_t& status);
Eric Laurent81784c32012-11-19 14:55:58 -0800848 virtual void dumpInternals(int fd, const Vector<String16>& args);
849
850protected:
851 virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
Andy Hunge8a1ced2014-05-09 15:02:21 -0700852 virtual int getTrackName_l(audio_channel_mask_t channelMask,
853 audio_format_t format, int sessionId);
Eric Laurent81784c32012-11-19 14:55:58 -0800854 virtual void deleteTrackName_l(int name);
855 virtual uint32_t idleSleepTimeUs() const;
856 virtual uint32_t suspendSleepTimeUs() const;
857 virtual void cacheParameters_l();
858
859 // threadLoop snippets
Eric Laurentbfb1b832013-01-07 09:53:42 -0800860 virtual ssize_t threadLoop_write();
Eric Laurent81784c32012-11-19 14:55:58 -0800861 virtual void threadLoop_standby();
862 virtual void threadLoop_mix();
863 virtual void threadLoop_sleepTime();
864 virtual void threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove);
865 virtual uint32_t correctLatency_l(uint32_t latency) const;
866
Eric Laurent054d9d32015-04-24 08:48:48 -0700867 virtual status_t createAudioPatch_l(const struct audio_patch *patch,
868 audio_patch_handle_t *handle);
869 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle);
870
Eric Laurent81784c32012-11-19 14:55:58 -0800871 AudioMixer* mAudioMixer; // normal mixer
872private:
873 // one-time initialization, no locks required
Glenn Kasten4d23ca32014-05-13 10:39:51 -0700874 sp<FastMixer> mFastMixer; // non-0 if there is also a fast mixer
Eric Laurent81784c32012-11-19 14:55:58 -0800875 sp<AudioWatchdog> mAudioWatchdog; // non-0 if there is an audio watchdog thread
876
877 // contents are not guaranteed to be consistent, no locks required
878 FastMixerDumpState mFastMixerDumpState;
879#ifdef STATE_QUEUE_DUMP
880 StateQueueObserverDump mStateQueueObserverDump;
881 StateQueueMutatorDump mStateQueueMutatorDump;
882#endif
883 AudioWatchdogDump mAudioWatchdogDump;
884
885 // accessible only within the threadLoop(), no locks required
886 // mFastMixer->sq() // for mutating and pushing state
887 int32_t mFastMixerFutex; // for cold idle
888
889public:
Glenn Kasten4d23ca32014-05-13 10:39:51 -0700890 virtual bool hasFastMixer() const { return mFastMixer != 0; }
Eric Laurent81784c32012-11-19 14:55:58 -0800891 virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex) const {
892 ALOG_ASSERT(fastIndex < FastMixerState::kMaxFastTracks);
893 return mFastMixerDumpState.mTracks[fastIndex].mUnderruns;
894 }
Eric Laurent83b88082014-06-20 18:31:16 -0700895
Eric Laurent81784c32012-11-19 14:55:58 -0800896};
897
898class DirectOutputThread : public PlaybackThread {
899public:
900
901 DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
902 audio_io_handle_t id, audio_devices_t device);
903 virtual ~DirectOutputThread();
904
905 // Thread virtuals
906
Eric Laurent10351942014-05-08 18:49:52 -0700907 virtual bool checkForNewParameter_l(const String8& keyValuePair,
908 status_t& status);
Eric Laurente659ef42014-09-29 13:06:46 -0700909 virtual void flushHw_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800910
911protected:
Andy Hunge8a1ced2014-05-09 15:02:21 -0700912 virtual int getTrackName_l(audio_channel_mask_t channelMask,
913 audio_format_t format, int sessionId);
Eric Laurent81784c32012-11-19 14:55:58 -0800914 virtual void deleteTrackName_l(int name);
915 virtual uint32_t activeSleepTimeUs() const;
916 virtual uint32_t idleSleepTimeUs() const;
917 virtual uint32_t suspendSleepTimeUs() const;
918 virtual void cacheParameters_l();
919
920 // threadLoop snippets
921 virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
922 virtual void threadLoop_mix();
923 virtual void threadLoop_sleepTime();
Eric Laurentd1f69b02014-12-15 14:33:13 -0800924 virtual void threadLoop_exit();
925 virtual bool shouldStandby_l();
Eric Laurent81784c32012-11-19 14:55:58 -0800926
Eric Laurent81784c32012-11-19 14:55:58 -0800927 // volumes last sent to audio HAL with stream->set_volume()
928 float mLeftVolFloat;
929 float mRightVolFloat;
930
Eric Laurentbfb1b832013-01-07 09:53:42 -0800931 DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
932 audio_io_handle_t id, uint32_t device, ThreadBase::type_t type);
933 void processVolume_l(Track *track, bool lastTrack);
934
Eric Laurent81784c32012-11-19 14:55:58 -0800935 // prepareTracks_l() tells threadLoop_mix() the name of the single active track
936 sp<Track> mActiveTrack;
937public:
938 virtual bool hasFastMixer() const { return false; }
939};
940
Eric Laurentbfb1b832013-01-07 09:53:42 -0800941class OffloadThread : public DirectOutputThread {
942public:
943
944 OffloadThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
945 audio_io_handle_t id, uint32_t device);
Eric Laurent6a51d7e2013-10-17 18:59:26 -0700946 virtual ~OffloadThread() {};
Eric Laurente659ef42014-09-29 13:06:46 -0700947 virtual void flushHw_l();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800948
949protected:
950 // threadLoop snippets
951 virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
952 virtual void threadLoop_exit();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800953
954 virtual bool waitingAsyncCallback();
955 virtual bool waitingAsyncCallback_l();
Haynes Mathew George4c6a4332014-01-15 12:31:39 -0800956 virtual void onAddNewTrack_l();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800957
958private:
Eric Laurentbfb1b832013-01-07 09:53:42 -0800959 size_t mPausedWriteLength; // length in bytes of write interrupted by pause
960 size_t mPausedBytesRemaining; // bytes still waiting in mixbuffer after resume
Eric Laurentd7e59222013-11-15 12:02:28 -0800961 wp<Track> mPreviousTrack; // used to detect track switch
Eric Laurentbfb1b832013-01-07 09:53:42 -0800962};
963
964class AsyncCallbackThread : public Thread {
965public:
966
Eric Laurent4de95592013-09-26 15:28:21 -0700967 AsyncCallbackThread(const wp<PlaybackThread>& playbackThread);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800968
969 virtual ~AsyncCallbackThread();
970
971 // Thread virtuals
972 virtual bool threadLoop();
973
974 // RefBase
975 virtual void onFirstRef();
976
977 void exit();
Eric Laurent3b4529e2013-09-05 18:09:19 -0700978 void setWriteBlocked(uint32_t sequence);
979 void resetWriteBlocked();
980 void setDraining(uint32_t sequence);
981 void resetDraining();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800982
983private:
Eric Laurent4de95592013-09-26 15:28:21 -0700984 const wp<PlaybackThread> mPlaybackThread;
Eric Laurent3b4529e2013-09-05 18:09:19 -0700985 // mWriteAckSequence corresponds to the last write sequence passed by the offload thread via
986 // setWriteBlocked(). The sequence is shifted one bit to the left and the lsb is used
987 // to indicate that the callback has been received via resetWriteBlocked()
Eric Laurent4de95592013-09-26 15:28:21 -0700988 uint32_t mWriteAckSequence;
Eric Laurent3b4529e2013-09-05 18:09:19 -0700989 // mDrainSequence corresponds to the last drain sequence passed by the offload thread via
990 // setDraining(). The sequence is shifted one bit to the left and the lsb is used
991 // to indicate that the callback has been received via resetDraining()
Eric Laurent4de95592013-09-26 15:28:21 -0700992 uint32_t mDrainSequence;
993 Condition mWaitWorkCV;
994 Mutex mLock;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800995};
996
Eric Laurent81784c32012-11-19 14:55:58 -0800997class DuplicatingThread : public MixerThread {
998public:
999 DuplicatingThread(const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread,
1000 audio_io_handle_t id);
1001 virtual ~DuplicatingThread();
1002
1003 // Thread virtuals
1004 void addOutputTrack(MixerThread* thread);
1005 void removeOutputTrack(MixerThread* thread);
1006 uint32_t waitTimeMs() const { return mWaitTimeMs; }
1007protected:
1008 virtual uint32_t activeSleepTimeUs() const;
1009
1010private:
1011 bool outputsReady(const SortedVector< sp<OutputTrack> > &outputTracks);
1012protected:
1013 // threadLoop snippets
1014 virtual void threadLoop_mix();
1015 virtual void threadLoop_sleepTime();
Eric Laurentbfb1b832013-01-07 09:53:42 -08001016 virtual ssize_t threadLoop_write();
Eric Laurent81784c32012-11-19 14:55:58 -08001017 virtual void threadLoop_standby();
1018 virtual void cacheParameters_l();
1019
1020private:
1021 // called from threadLoop, addOutputTrack, removeOutputTrack
1022 virtual void updateWaitTime_l();
1023protected:
1024 virtual void saveOutputTracks();
1025 virtual void clearOutputTracks();
1026private:
1027
1028 uint32_t mWaitTimeMs;
1029 SortedVector < sp<OutputTrack> > outputTracks;
1030 SortedVector < sp<OutputTrack> > mOutputTracks;
1031public:
1032 virtual bool hasFastMixer() const { return false; }
1033};
1034
1035
1036// record thread
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001037class RecordThread : public ThreadBase
Eric Laurent81784c32012-11-19 14:55:58 -08001038{
1039public:
1040
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001041 class RecordTrack;
Andy Hung73c02e42015-03-29 01:13:58 -07001042
1043 /* The ResamplerBufferProvider is used to retrieve recorded input data from the
1044 * RecordThread. It maintains local state on the relative position of the read
1045 * position of the RecordTrack compared with the RecordThread.
1046 */
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001047 class ResamplerBufferProvider : public AudioBufferProvider
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001048 {
1049 public:
Andy Hung73c02e42015-03-29 01:13:58 -07001050 ResamplerBufferProvider(RecordTrack* recordTrack) :
1051 mRecordTrack(recordTrack),
1052 mRsmpInUnrel(0), mRsmpInFront(0) { }
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001053 virtual ~ResamplerBufferProvider() { }
Andy Hung73c02e42015-03-29 01:13:58 -07001054
1055 // called to set the ResamplerBufferProvider to head of the RecordThread data buffer,
1056 // skipping any previous data read from the hal.
1057 virtual void reset();
1058
1059 /* Synchronizes RecordTrack position with the RecordThread.
1060 * Calculates available frames and handle overruns if the RecordThread
1061 * has advanced faster than the ResamplerBufferProvider has retrieved data.
1062 * TODO: why not do this for every getNextBuffer?
1063 *
1064 * Parameters
1065 * framesAvailable: pointer to optional output size_t to store record track
1066 * frames available.
1067 * hasOverrun: pointer to optional boolean, returns true if track has overrun.
1068 */
1069
1070 virtual void sync(size_t *framesAvailable = NULL, bool *hasOverrun = NULL);
1071
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001072 // AudioBufferProvider interface
1073 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts);
1074 virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
1075 private:
1076 RecordTrack * const mRecordTrack;
Andy Hung73c02e42015-03-29 01:13:58 -07001077 size_t mRsmpInUnrel; // unreleased frames remaining from
1078 // most recent getNextBuffer
1079 // for debug only
1080 int32_t mRsmpInFront; // next available frame
1081 // rolling counter that is never cleared
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001082 };
1083
Andy Hung97a893e2015-03-29 01:03:07 -07001084 /* The RecordBufferConverter is used for format, channel, and sample rate
1085 * conversion for a RecordTrack.
1086 *
1087 * TODO: Self contained, so move to a separate file later.
1088 *
1089 * RecordBufferConverter uses the convert() method rather than exposing a
1090 * buffer provider interface; this is to save a memory copy.
1091 */
1092 class RecordBufferConverter
1093 {
1094 public:
1095 RecordBufferConverter(
1096 audio_channel_mask_t srcChannelMask, audio_format_t srcFormat,
1097 uint32_t srcSampleRate,
1098 audio_channel_mask_t dstChannelMask, audio_format_t dstFormat,
1099 uint32_t dstSampleRate);
1100
1101 ~RecordBufferConverter();
1102
1103 /* Converts input data from an AudioBufferProvider by format, channelMask,
1104 * and sampleRate to a destination buffer.
1105 *
1106 * Parameters
1107 * dst: buffer to place the converted data.
1108 * provider: buffer provider to obtain source data.
1109 * frames: number of frames to convert
1110 *
1111 * Returns the number of frames converted.
1112 */
1113 size_t convert(void *dst, AudioBufferProvider *provider, size_t frames);
1114
1115 // returns NO_ERROR if constructor was successful
1116 status_t initCheck() const {
1117 // mSrcChannelMask set on successful updateParameters
1118 return mSrcChannelMask != AUDIO_CHANNEL_INVALID ? NO_ERROR : NO_INIT;
1119 }
1120
1121 // allows dynamic reconfigure of all parameters
1122 status_t updateParameters(
1123 audio_channel_mask_t srcChannelMask, audio_format_t srcFormat,
1124 uint32_t srcSampleRate,
1125 audio_channel_mask_t dstChannelMask, audio_format_t dstFormat,
1126 uint32_t dstSampleRate);
1127
1128 // called to reset resampler buffers on record track discontinuity
1129 void reset() {
1130 if (mResampler != NULL) {
1131 mResampler->reset();
1132 }
1133 }
1134
1135 private:
Andy Hungd330ee42015-04-20 13:23:41 -07001136 // format conversion when not using resampler
1137 void convertNoResampler(void *dst, const void *src, size_t frames);
1138
1139 // format conversion when using resampler; modifies src in-place
1140 void convertResampler(void *dst, /*not-a-const*/ void *src, size_t frames);
Andy Hung97a893e2015-03-29 01:03:07 -07001141
1142 // user provided information
1143 audio_channel_mask_t mSrcChannelMask;
1144 audio_format_t mSrcFormat;
1145 uint32_t mSrcSampleRate;
1146 audio_channel_mask_t mDstChannelMask;
1147 audio_format_t mDstFormat;
1148 uint32_t mDstSampleRate;
1149
1150 // derived information
1151 uint32_t mSrcChannelCount;
1152 uint32_t mDstChannelCount;
1153 size_t mDstFrameSize;
1154
1155 // format conversion buffer
1156 void *mBuf;
1157 size_t mBufFrames;
1158 size_t mBufFrameSize;
1159
1160 // resampler info
1161 AudioResampler *mResampler;
Andy Hungd330ee42015-04-20 13:23:41 -07001162
1163 bool mIsLegacyDownmix; // legacy stereo to mono conversion needed
1164 bool mIsLegacyUpmix; // legacy mono to stereo conversion needed
1165 bool mRequiresFloat; // data processing requires float (e.g. resampler)
1166 PassthruBufferProvider *mInputConverterProvider; // converts input to float
1167 int8_t mIdxAry[sizeof(uint32_t) * 8]; // used for channel mask conversion
Andy Hung97a893e2015-03-29 01:03:07 -07001168 };
1169
Eric Laurent81784c32012-11-19 14:55:58 -08001170#include "RecordTracks.h"
1171
1172 RecordThread(const sp<AudioFlinger>& audioFlinger,
1173 AudioStreamIn *input,
Eric Laurent81784c32012-11-19 14:55:58 -08001174 audio_io_handle_t id,
Eric Laurentd3922f72013-02-01 17:57:04 -08001175 audio_devices_t outDevice,
Glenn Kasten46909e72013-02-26 09:20:22 -08001176 audio_devices_t inDevice
1177#ifdef TEE_SINK
1178 , const sp<NBAIO_Sink>& teeSink
1179#endif
1180 );
Eric Laurent81784c32012-11-19 14:55:58 -08001181 virtual ~RecordThread();
1182
1183 // no addTrack_l ?
1184 void destroyTrack_l(const sp<RecordTrack>& track);
1185 void removeTrack_l(const sp<RecordTrack>& track);
1186
1187 void dumpInternals(int fd, const Vector<String16>& args);
1188 void dumpTracks(int fd, const Vector<String16>& args);
1189
1190 // Thread virtuals
1191 virtual bool threadLoop();
Eric Laurent81784c32012-11-19 14:55:58 -08001192
1193 // RefBase
1194 virtual void onFirstRef();
1195
1196 virtual status_t initCheck() const { return (mInput == NULL) ? NO_INIT : NO_ERROR; }
Glenn Kastene198c362013-08-13 09:13:36 -07001197
Glenn Kastenb880f5e2014-05-07 08:43:45 -07001198 virtual sp<MemoryDealer> readOnlyHeap() const { return mReadOnlyHeap; }
1199
Glenn Kasten6dbb5e32014-05-13 10:38:42 -07001200 virtual sp<IMemory> pipeMemory() const { return mPipeMemory; }
1201
Eric Laurent81784c32012-11-19 14:55:58 -08001202 sp<AudioFlinger::RecordThread::RecordTrack> createRecordTrack_l(
1203 const sp<AudioFlinger::Client>& client,
1204 uint32_t sampleRate,
1205 audio_format_t format,
1206 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -08001207 size_t *pFrameCount,
Eric Laurent81784c32012-11-19 14:55:58 -08001208 int sessionId,
Glenn Kasten7df8c0b2014-07-03 12:23:29 -07001209 size_t *notificationFrames,
Marco Nelissen462fd2f2013-01-14 14:12:05 -08001210 int uid,
Glenn Kastenddb0ccf2013-07-31 16:14:50 -07001211 IAudioFlinger::track_flags_t *flags,
Eric Laurent81784c32012-11-19 14:55:58 -08001212 pid_t tid,
Glenn Kasten9156ef32013-08-06 15:39:08 -07001213 status_t *status /*non-NULL*/);
Eric Laurent81784c32012-11-19 14:55:58 -08001214
1215 status_t start(RecordTrack* recordTrack,
1216 AudioSystem::sync_event_t event,
1217 int triggerSession);
1218
1219 // ask the thread to stop the specified track, and
1220 // return true if the caller should then do it's part of the stopping process
Glenn Kastena8356f62013-07-25 14:37:52 -07001221 bool stop(RecordTrack* recordTrack);
Eric Laurent81784c32012-11-19 14:55:58 -08001222
1223 void dump(int fd, const Vector<String16>& args);
1224 AudioStreamIn* clearInput();
1225 virtual audio_stream_t* stream() const;
1226
Eric Laurent81784c32012-11-19 14:55:58 -08001227
Eric Laurent10351942014-05-08 18:49:52 -07001228 virtual bool checkForNewParameter_l(const String8& keyValuePair,
1229 status_t& status);
1230 virtual void cacheParameters_l() {}
Eric Laurent81784c32012-11-19 14:55:58 -08001231 virtual String8 getParameters(const String8& keys);
Eric Laurent73e26b62015-04-27 16:55:58 -07001232 virtual void ioConfigChanged(audio_io_config_event event);
Eric Laurent1c333e22014-05-20 10:48:17 -07001233 virtual status_t createAudioPatch_l(const struct audio_patch *patch,
1234 audio_patch_handle_t *handle);
1235 virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle);
Eric Laurent83b88082014-06-20 18:31:16 -07001236
1237 void addPatchRecord(const sp<PatchRecord>& record);
1238 void deletePatchRecord(const sp<PatchRecord>& record);
1239
Glenn Kastendeca2ae2014-02-07 10:25:56 -08001240 void readInputParameters_l();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001241 virtual uint32_t getInputFramesLost();
Eric Laurent81784c32012-11-19 14:55:58 -08001242
1243 virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
1244 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
1245 virtual uint32_t hasAudioSession(int sessionId) const;
1246
1247 // Return the set of unique session IDs across all tracks.
1248 // The keys are the session IDs, and the associated values are meaningless.
1249 // FIXME replace by Set [and implement Bag/Multiset for other uses].
1250 KeyedVector<int, bool> sessionIds() const;
1251
1252 virtual status_t setSyncEvent(const sp<SyncEvent>& event);
1253 virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const;
1254
1255 static void syncStartEventCallback(const wp<SyncEvent>& event);
Eric Laurent81784c32012-11-19 14:55:58 -08001256
Glenn Kasten9b58f632013-07-16 11:37:48 -07001257 virtual size_t frameCount() const { return mFrameCount; }
Glenn Kasten6dbb5e32014-05-13 10:38:42 -07001258 bool hasFastCapture() const { return mFastCapture != 0; }
Eric Laurent83b88082014-06-20 18:31:16 -07001259 virtual void getAudioPortConfig(struct audio_port_config *config);
Glenn Kasten9b58f632013-07-16 11:37:48 -07001260
Eric Laurent81784c32012-11-19 14:55:58 -08001261private:
Eric Laurent81784c32012-11-19 14:55:58 -08001262 // Enter standby if not already in standby, and set mStandby flag
Glenn Kasten93e471f2013-08-19 08:40:07 -07001263 void standbyIfNotAlreadyInStandby();
Eric Laurent81784c32012-11-19 14:55:58 -08001264
1265 // Call the HAL standby method unconditionally, and don't change mStandby flag
Glenn Kastene198c362013-08-13 09:13:36 -07001266 void inputStandBy();
Eric Laurent81784c32012-11-19 14:55:58 -08001267
1268 AudioStreamIn *mInput;
1269 SortedVector < sp<RecordTrack> > mTracks;
Glenn Kasten2b806402013-11-20 16:37:38 -08001270 // mActiveTracks has dual roles: it indicates the current active track(s), and
Eric Laurent81784c32012-11-19 14:55:58 -08001271 // is used together with mStartStopCond to indicate start()/stop() progress
Glenn Kasten2b806402013-11-20 16:37:38 -08001272 SortedVector< sp<RecordTrack> > mActiveTracks;
1273 // generation counter for mActiveTracks
1274 int mActiveTracksGen;
Eric Laurent81784c32012-11-19 14:55:58 -08001275 Condition mStartStopCond;
Glenn Kasten9b58f632013-07-16 11:37:48 -07001276
Glenn Kasten85948432013-08-19 12:09:05 -07001277 // resampler converts input at HAL Hz to output at AudioRecord client Hz
Andy Hung57446612015-04-19 23:56:46 -07001278 void *mRsmpInBuffer; //
Glenn Kasten85948432013-08-19 12:09:05 -07001279 size_t mRsmpInFrames; // size of resampler input in frames
1280 size_t mRsmpInFramesP2;// size rounded up to a power-of-2
Glenn Kasten6dd62fb2013-12-05 16:35:58 -08001281
1282 // rolling index that is never cleared
Glenn Kasten85948432013-08-19 12:09:05 -07001283 int32_t mRsmpInRear; // last filled frame + 1
Glenn Kasten85948432013-08-19 12:09:05 -07001284
Eric Laurent81784c32012-11-19 14:55:58 -08001285 // For dumpsys
1286 const sp<NBAIO_Sink> mTeeSink;
Glenn Kastenb880f5e2014-05-07 08:43:45 -07001287
1288 const sp<MemoryDealer> mReadOnlyHeap;
Glenn Kasten6dbb5e32014-05-13 10:38:42 -07001289
1290 // one-time initialization, no locks required
Glenn Kastenb187de12014-12-30 08:18:15 -08001291 sp<FastCapture> mFastCapture; // non-0 if there is also
1292 // a fast capture
Glenn Kasten6dbb5e32014-05-13 10:38:42 -07001293 // FIXME audio watchdog thread
1294
1295 // contents are not guaranteed to be consistent, no locks required
1296 FastCaptureDumpState mFastCaptureDumpState;
1297#ifdef STATE_QUEUE_DUMP
1298 // FIXME StateQueue observer and mutator dump fields
1299#endif
1300 // FIXME audio watchdog dump
1301
1302 // accessible only within the threadLoop(), no locks required
1303 // mFastCapture->sq() // for mutating and pushing state
1304 int32_t mFastCaptureFutex; // for cold idle
1305
1306 // The HAL input source is treated as non-blocking,
1307 // but current implementation is blocking
1308 sp<NBAIO_Source> mInputSource;
1309 // The source for the normal capture thread to read from: mInputSource or mPipeSource
1310 sp<NBAIO_Source> mNormalSource;
1311 // If a fast capture is present, the non-blocking pipe sink written to by fast capture,
1312 // otherwise clear
1313 sp<NBAIO_Sink> mPipeSink;
1314 // If a fast capture is present, the non-blocking pipe source read by normal thread,
1315 // otherwise clear
1316 sp<NBAIO_Source> mPipeSource;
1317 // Depth of pipe from fast capture to normal thread and fast clients, always power of 2
1318 size_t mPipeFramesP2;
1319 // If a fast capture is present, the Pipe as IMemory, otherwise clear
1320 sp<IMemory> mPipeMemory;
1321
1322 static const size_t kFastCaptureLogSize = 4 * 1024;
1323 sp<NBLog::Writer> mFastCaptureNBLogWriter;
1324
1325 bool mFastTrackAvail; // true if fast track available
Eric Laurent81784c32012-11-19 14:55:58 -08001326};