blob: 80a99453215f72b796db9577605cb6a4d202e2d5 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/* //device/include/server/AudioFlinger/AudioFlinger.h
2**
3** Copyright 2007, 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 ANDROID_AUDIO_FLINGER_H
19#define ANDROID_AUDIO_FLINGER_H
20
21#include <stdint.h>
22#include <sys/types.h>
Eric Laurent8ac9f8d2009-12-18 05:47:48 -080023#include <limits.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25#include <media/IAudioFlinger.h>
26#include <media/IAudioFlingerClient.h>
27#include <media/IAudioTrack.h>
28#include <media/IAudioRecord.h>
29#include <media/AudioTrack.h>
30
31#include <utils/Atomic.h>
32#include <utils/Errors.h>
33#include <utils/threads.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034#include <utils/SortedVector.h>
Dima Zavin31f188892011-04-18 16:57:27 -070035#include <utils/TypeHelpers.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036#include <utils/Vector.h>
37
Mathias Agopian24651682010-07-14 18:41:18 -070038#include <binder/BinderService.h>
39#include <binder/MemoryDealer.h>
40
Dima Zavin34bb4192011-05-11 14:15:23 -070041#include <system/audio.h>
Dima Zavin290029d2011-06-13 18:16:26 -070042#include <hardware/audio.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
44#include "AudioBufferProvider.h"
45
Eric Laurent6dbdc402011-07-22 09:04:31 -070046#include <powermanager/IPowerManager.h>
47
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048namespace android {
49
50class audio_track_cblk_t;
Eric Laurent65b65452010-06-01 23:49:17 -070051class effect_param_cblk_t;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052class AudioMixer;
53class AudioBuffer;
Eric Laurenta553c252009-07-17 12:17:14 -070054class AudioResampler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056// ----------------------------------------------------------------------------
57
58#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
59#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
60
61
62// ----------------------------------------------------------------------------
63
64static const nsecs_t kStandbyTimeInNsecs = seconds(3);
65
Mathias Agopian24651682010-07-14 18:41:18 -070066class AudioFlinger :
67 public BinderService<AudioFlinger>,
68 public BnAudioFlinger
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069{
Mathias Agopian24651682010-07-14 18:41:18 -070070 friend class BinderService<AudioFlinger>;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071public:
Mathias Agopian24651682010-07-14 18:41:18 -070072 static char const* getServiceName() { return "media.audio_flinger"; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073
74 virtual status_t dump(int fd, const Vector<String16>& args);
75
76 // IAudioFlinger interface
77 virtual sp<IAudioTrack> createTrack(
78 pid_t pid,
79 int streamType,
80 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -070081 uint32_t format,
82 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 int frameCount,
84 uint32_t flags,
85 const sp<IMemory>& sharedBuffer,
Eric Laurentddb78e72009-07-28 08:44:33 -070086 int output,
Eric Laurent65b65452010-06-01 23:49:17 -070087 int *sessionId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 status_t *status);
89
Eric Laurentddb78e72009-07-28 08:44:33 -070090 virtual uint32_t sampleRate(int output) const;
91 virtual int channelCount(int output) const;
Jean-Michel Trivi54392232011-05-24 15:53:33 -070092 virtual uint32_t format(int output) const;
Eric Laurentddb78e72009-07-28 08:44:33 -070093 virtual size_t frameCount(int output) const;
94 virtual uint32_t latency(int output) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095
96 virtual status_t setMasterVolume(float value);
97 virtual status_t setMasterMute(bool muted);
98
99 virtual float masterVolume() const;
100 virtual bool masterMute() const;
101
Eric Laurentddb78e72009-07-28 08:44:33 -0700102 virtual status_t setStreamVolume(int stream, float value, int output);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 virtual status_t setStreamMute(int stream, bool muted);
104
Eric Laurentddb78e72009-07-28 08:44:33 -0700105 virtual float streamVolume(int stream, int output) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 virtual bool streamMute(int stream) const;
107
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108 virtual status_t setMode(int mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109
110 virtual status_t setMicMute(bool state);
111 virtual bool getMicMute() const;
112
Eric Laurentddb78e72009-07-28 08:44:33 -0700113 virtual status_t setParameters(int ioHandle, const String8& keyValuePairs);
114 virtual String8 getParameters(int ioHandle, const String8& keys);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115
116 virtual void registerClient(const sp<IAudioFlingerClient>& client);
Eric Laurenta553c252009-07-17 12:17:14 -0700117
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
Eric Laurent47d0a922010-02-26 02:47:27 -0800119 virtual unsigned int getInputFramesLost(int ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700120
Eric Laurentddb78e72009-07-28 08:44:33 -0700121 virtual int openOutput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700122 uint32_t *pSamplingRate,
123 uint32_t *pFormat,
124 uint32_t *pChannels,
125 uint32_t *pLatencyMs,
126 uint32_t flags);
127
Eric Laurentddb78e72009-07-28 08:44:33 -0700128 virtual int openDuplicateOutput(int output1, int output2);
Eric Laurenta553c252009-07-17 12:17:14 -0700129
Eric Laurentddb78e72009-07-28 08:44:33 -0700130 virtual status_t closeOutput(int output);
Eric Laurenta553c252009-07-17 12:17:14 -0700131
Eric Laurentddb78e72009-07-28 08:44:33 -0700132 virtual status_t suspendOutput(int output);
Eric Laurenta553c252009-07-17 12:17:14 -0700133
Eric Laurentddb78e72009-07-28 08:44:33 -0700134 virtual status_t restoreOutput(int output);
Eric Laurenta553c252009-07-17 12:17:14 -0700135
Eric Laurentddb78e72009-07-28 08:44:33 -0700136 virtual int openInput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700137 uint32_t *pSamplingRate,
138 uint32_t *pFormat,
139 uint32_t *pChannels,
140 uint32_t acoustics);
141
Eric Laurentddb78e72009-07-28 08:44:33 -0700142 virtual status_t closeInput(int input);
Eric Laurenta553c252009-07-17 12:17:14 -0700143
Eric Laurentddb78e72009-07-28 08:44:33 -0700144 virtual status_t setStreamOutput(uint32_t stream, int output);
Eric Laurenta553c252009-07-17 12:17:14 -0700145
Eric Laurent415f3e22009-10-21 08:14:22 -0700146 virtual status_t setVoiceVolume(float volume);
147
Eric Laurent0986e792010-01-19 17:37:09 -0800148 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output);
149
Eric Laurent65b65452010-06-01 23:49:17 -0700150 virtual int newAudioSessionId();
151
Eric Laurent65b65452010-06-01 23:49:17 -0700152 virtual status_t queryNumberEffects(uint32_t *numEffects);
153
Eric Laurent53334cd2010-06-23 17:38:20 -0700154 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *descriptor);
Eric Laurent65b65452010-06-01 23:49:17 -0700155
156 virtual status_t getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *descriptor);
157
158 virtual sp<IEffect> createEffect(pid_t pid,
159 effect_descriptor_t *pDesc,
160 const sp<IEffectClient>& effectClient,
161 int32_t priority,
Eric Laurent464d5b32011-06-17 21:29:58 -0700162 int io,
Eric Laurent65b65452010-06-01 23:49:17 -0700163 int sessionId,
164 status_t *status,
165 int *id,
166 int *enabled);
167
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700168 virtual status_t moveEffects(int session, int srcOutput, int dstOutput);
Eric Laurent53334cd2010-06-23 17:38:20 -0700169
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 enum hardware_call_state {
171 AUDIO_HW_IDLE = 0,
172 AUDIO_HW_INIT,
173 AUDIO_HW_OUTPUT_OPEN,
174 AUDIO_HW_OUTPUT_CLOSE,
175 AUDIO_HW_INPUT_OPEN,
176 AUDIO_HW_INPUT_CLOSE,
177 AUDIO_HW_STANDBY,
178 AUDIO_HW_SET_MASTER_VOLUME,
179 AUDIO_HW_GET_ROUTING,
180 AUDIO_HW_SET_ROUTING,
181 AUDIO_HW_GET_MODE,
182 AUDIO_HW_SET_MODE,
183 AUDIO_HW_GET_MIC_MUTE,
184 AUDIO_HW_SET_MIC_MUTE,
185 AUDIO_SET_VOICE_VOLUME,
186 AUDIO_SET_PARAMETER,
187 };
188
189 // record interface
190 virtual sp<IAudioRecord> openRecord(
191 pid_t pid,
Eric Laurentddb78e72009-07-28 08:44:33 -0700192 int input,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700194 uint32_t format,
195 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196 int frameCount,
197 uint32_t flags,
Eric Laurent65b65452010-06-01 23:49:17 -0700198 int *sessionId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 status_t *status);
200
201 virtual status_t onTransact(
202 uint32_t code,
203 const Parcel& data,
204 Parcel* reply,
205 uint32_t flags);
206
Eric Laurent53334cd2010-06-23 17:38:20 -0700207 uint32_t getMode() { return mMode; }
208
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800209private:
210 AudioFlinger();
211 virtual ~AudioFlinger();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212
Dima Zavin2986f5b2011-04-19 19:04:32 -0700213 status_t initCheck() const;
214 virtual void onFirstRef();
Dima Zavin31f188892011-04-18 16:57:27 -0700215 audio_hw_device_t* findSuitableHwDev_l(uint32_t devices);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800216
217 // Internal dump utilites.
218 status_t dumpPermissionDenial(int fd, const Vector<String16>& args);
219 status_t dumpClients(int fd, const Vector<String16>& args);
220 status_t dumpInternals(int fd, const Vector<String16>& args);
221
222 // --- Client ---
223 class Client : public RefBase {
224 public:
225 Client(const sp<AudioFlinger>& audioFlinger, pid_t pid);
226 virtual ~Client();
227 const sp<MemoryDealer>& heap() const;
228 pid_t pid() const { return mPid; }
Eric Laurentb9481d82009-09-17 05:12:56 -0700229 sp<AudioFlinger> audioFlinger() { return mAudioFlinger; }
230
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231 private:
232 Client(const Client&);
233 Client& operator = (const Client&);
234 sp<AudioFlinger> mAudioFlinger;
235 sp<MemoryDealer> mMemoryDealer;
236 pid_t mPid;
237 };
238
Eric Laurent4f0f17d2010-05-12 02:05:53 -0700239 // --- Notification Client ---
240 class NotificationClient : public IBinder::DeathRecipient {
241 public:
242 NotificationClient(const sp<AudioFlinger>& audioFlinger,
243 const sp<IAudioFlingerClient>& client,
244 pid_t pid);
245 virtual ~NotificationClient();
246
247 sp<IAudioFlingerClient> client() { return mClient; }
248
249 // IBinder::DeathRecipient
250 virtual void binderDied(const wp<IBinder>& who);
251
252 private:
253 NotificationClient(const NotificationClient&);
254 NotificationClient& operator = (const NotificationClient&);
255
256 sp<AudioFlinger> mAudioFlinger;
257 pid_t mPid;
258 sp<IAudioFlingerClient> mClient;
259 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260
261 class TrackHandle;
262 class RecordHandle;
Eric Laurenta553c252009-07-17 12:17:14 -0700263 class RecordThread;
264 class PlaybackThread;
265 class MixerThread;
266 class DirectOutputThread;
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800267 class DuplicatingThread;
Eric Laurenta553c252009-07-17 12:17:14 -0700268 class Track;
269 class RecordTrack;
Eric Laurent65b65452010-06-01 23:49:17 -0700270 class EffectModule;
271 class EffectHandle;
272 class EffectChain;
Dima Zavin31f188892011-04-18 16:57:27 -0700273 struct AudioStreamOut;
274 struct AudioStreamIn;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275
Eric Laurenta553c252009-07-17 12:17:14 -0700276 class ThreadBase : public Thread {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 public:
Eric Laurent464d5b32011-06-17 21:29:58 -0700278 ThreadBase (const sp<AudioFlinger>& audioFlinger, int id, uint32_t device);
Eric Laurenta553c252009-07-17 12:17:14 -0700279 virtual ~ThreadBase();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280
Eric Laurent464d5b32011-06-17 21:29:58 -0700281
282 enum type {
283 MIXER, // Thread class is MixerThread
284 DIRECT, // Thread class is DirectOutputThread
285 DUPLICATING, // Thread class is DuplicatingThread
286 RECORD // Thread class is RecordThread
287 };
288
Eric Laurent3fdb1262009-11-07 00:01:32 -0800289 status_t dumpBase(int fd, const Vector<String16>& args);
Eric Laurent1345d332011-07-24 17:49:51 -0700290 status_t dumpEffectChains(int fd, const Vector<String16>& args);
Eric Laurent3fdb1262009-11-07 00:01:32 -0800291
Eric Laurent6dbdc402011-07-22 09:04:31 -0700292 void clearPowerManager();
293
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 // base for record and playback
295 class TrackBase : public AudioBufferProvider, public RefBase {
296
297 public:
298 enum track_state {
299 IDLE,
300 TERMINATED,
301 STOPPED,
302 RESUMING,
303 ACTIVE,
304 PAUSING,
305 PAUSED
306 };
307
308 enum track_flags {
309 STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex
310 SYSTEM_FLAGS_MASK = 0x0000ffffUL,
311 // The upper 16 bits are used for track-specific flags.
312 };
313
Eric Laurenta553c252009-07-17 12:17:14 -0700314 TrackBase(const wp<ThreadBase>& thread,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 const sp<Client>& client,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700317 uint32_t format,
318 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 int frameCount,
320 uint32_t flags,
Eric Laurent65b65452010-06-01 23:49:17 -0700321 const sp<IMemory>& sharedBuffer,
322 int sessionId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800323 ~TrackBase();
324
325 virtual status_t start() = 0;
326 virtual void stop() = 0;
327 sp<IMemory> getCblk() const;
Eric Laurent6c30a712009-08-10 23:22:32 -0700328 audio_track_cblk_t* cblk() const { return mCblk; }
Eric Laurent65b65452010-06-01 23:49:17 -0700329 int sessionId() { return mSessionId; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330
331 protected:
Eric Laurenta553c252009-07-17 12:17:14 -0700332 friend class ThreadBase;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800333 friend class RecordHandle;
Eric Laurent2c817f52009-07-23 13:17:39 -0700334 friend class PlaybackThread;
335 friend class RecordThread;
336 friend class MixerThread;
337 friend class DirectOutputThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338
339 TrackBase(const TrackBase&);
340 TrackBase& operator = (const TrackBase&);
341
342 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer) = 0;
343 virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
344
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700345 uint32_t format() const {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 return mFormat;
347 }
348
349 int channelCount() const ;
350
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700351 uint32_t channelMask() const;
352
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800353 int sampleRate() const;
354
355 void* getBuffer(uint32_t offset, uint32_t frames) const;
356
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 bool isStopped() const {
358 return mState == STOPPED;
359 }
360
361 bool isTerminated() const {
362 return mState == TERMINATED;
363 }
364
365 bool step();
366 void reset();
367
Eric Laurenta553c252009-07-17 12:17:14 -0700368 wp<ThreadBase> mThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 sp<Client> mClient;
370 sp<IMemory> mCblkMemory;
371 audio_track_cblk_t* mCblk;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372 void* mBuffer;
373 void* mBufferEnd;
374 uint32_t mFrameCount;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800375 // we don't really need a lock for these
376 int mState;
377 int mClientTid;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700378 uint32_t mFormat;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 uint32_t mFlags;
Eric Laurent65b65452010-06-01 23:49:17 -0700380 int mSessionId;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700381 uint8_t mChannelCount;
382 uint32_t mChannelMask;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800383 };
384
Eric Laurenta553c252009-07-17 12:17:14 -0700385 class ConfigEvent {
386 public:
387 ConfigEvent() : mEvent(0), mParam(0) {}
388
389 int mEvent;
390 int mParam;
391 };
392
Eric Laurent6dbdc402011-07-22 09:04:31 -0700393 class PMDeathRecipient : public IBinder::DeathRecipient {
394 public:
395 PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
396 virtual ~PMDeathRecipient() {}
397
398 // IBinder::DeathRecipient
399 virtual void binderDied(const wp<IBinder>& who);
400
401 private:
402 PMDeathRecipient(const PMDeathRecipient&);
403 PMDeathRecipient& operator = (const PMDeathRecipient&);
404
405 wp<ThreadBase> mThread;
406 };
407
Eric Laurent464d5b32011-06-17 21:29:58 -0700408 virtual status_t initCheck() const = 0;
409 int type() const { return mType; }
Eric Laurenta553c252009-07-17 12:17:14 -0700410 uint32_t sampleRate() const;
411 int channelCount() const;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700412 uint32_t format() const;
Eric Laurenta553c252009-07-17 12:17:14 -0700413 size_t frameCount() const;
414 void wakeUp() { mWaitWorkCV.broadcast(); }
415 void exit();
416 virtual bool checkForNewParameters_l() = 0;
417 virtual status_t setParameters(const String8& keyValuePairs);
418 virtual String8 getParameters(const String8& keys) = 0;
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700419 virtual void audioConfigChanged_l(int event, int param = 0) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -0700420 void sendConfigEvent(int event, int param = 0);
Eric Laurent8fce46a2009-08-04 09:45:33 -0700421 void sendConfigEvent_l(int event, int param = 0);
Eric Laurenta553c252009-07-17 12:17:14 -0700422 void processConfigEvents();
Eric Laurent49f02be2009-11-19 09:00:56 -0800423 int id() const { return mId;}
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800424 bool standby() { return mStandby; }
Eric Laurent464d5b32011-06-17 21:29:58 -0700425 uint32_t device() { return mDevice; }
426 virtual audio_stream_t* stream() = 0;
427
428 sp<EffectHandle> createEffect_l(
429 const sp<AudioFlinger::Client>& client,
430 const sp<IEffectClient>& effectClient,
431 int32_t priority,
432 int sessionId,
433 effect_descriptor_t *desc,
434 int *enabled,
435 status_t *status);
436 void disconnectEffect(const sp< EffectModule>& effect,
437 const wp<EffectHandle>& handle);
438
439 // return values for hasAudioSession (bit field)
440 enum effect_state {
441 EFFECT_SESSION = 0x1, // the audio session corresponds to at least one
442 // effect
443 TRACK_SESSION = 0x2 // the audio session corresponds to at least one
444 // track
445 };
446
447 // get effect chain corresponding to session Id.
448 sp<EffectChain> getEffectChain(int sessionId);
449 // same as getEffectChain() but must be called with ThreadBase mutex locked
450 sp<EffectChain> getEffectChain_l(int sessionId);
451 // add an effect chain to the chain list (mEffectChains)
452 virtual status_t addEffectChain_l(const sp<EffectChain>& chain) = 0;
453 // remove an effect chain from the chain list (mEffectChains)
454 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain) = 0;
455 // lock mall effect chains Mutexes. Must be called before releasing the
456 // ThreadBase mutex before processing the mixer and effects. This guarantees the
457 // integrity of the chains during the process.
458 void lockEffectChains_l(Vector<sp <EffectChain> >& effectChains);
459 // unlock effect chains after process
460 void unlockEffectChains(Vector<sp <EffectChain> >& effectChains);
461 // set audio mode to all effect chains
462 void setMode(uint32_t mode);
463 // get effect module with corresponding ID on specified audio session
464 sp<AudioFlinger::EffectModule> getEffect_l(int sessionId, int effectId);
465 // add and effect module. Also creates the effect chain is none exists for
466 // the effects audio session
467 status_t addEffect_l(const sp< EffectModule>& effect);
468 // remove and effect module. Also removes the effect chain is this was the last
469 // effect
470 void removeEffect_l(const sp< EffectModule>& effect);
471 // detach all tracks connected to an auxiliary effect
472 virtual void detachAuxEffect_l(int effectId) {}
473 // returns either EFFECT_SESSION if effects on this audio session exist in one
474 // chain, or TRACK_SESSION if tracks on this audio session exist, or both
475 virtual uint32_t hasAudioSession(int sessionId) = 0;
476 // the value returned by default implementation is not important as the
477 // strategy is only meaningful for PlaybackThread which implements this method
478 virtual uint32_t getStrategyForSession_l(int sessionId) { return 0; }
Eric Laurenta553c252009-07-17 12:17:14 -0700479
Eric Laurent2c817f52009-07-23 13:17:39 -0700480 mutable Mutex mLock;
481
Eric Laurenta553c252009-07-17 12:17:14 -0700482 protected:
483
Eric Laurent6dbdc402011-07-22 09:04:31 -0700484 void acquireWakeLock();
485 void acquireWakeLock_l();
486 void releaseWakeLock();
487 void releaseWakeLock_l();
488
Eric Laurenta553c252009-07-17 12:17:14 -0700489 friend class Track;
490 friend class TrackBase;
491 friend class PlaybackThread;
492 friend class MixerThread;
493 friend class DirectOutputThread;
494 friend class DuplicatingThread;
495 friend class RecordThread;
496 friend class RecordTrack;
497
Eric Laurent464d5b32011-06-17 21:29:58 -0700498 int mType;
Eric Laurenta553c252009-07-17 12:17:14 -0700499 Condition mWaitWorkCV;
500 sp<AudioFlinger> mAudioFlinger;
501 uint32_t mSampleRate;
502 size_t mFrameCount;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700503 uint32_t mChannelMask;
Eric Laurentb0a01472010-05-14 05:45:46 -0700504 uint16_t mChannelCount;
505 uint16_t mFrameSize;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700506 uint32_t mFormat;
Eric Laurenta553c252009-07-17 12:17:14 -0700507 Condition mParamCond;
Eric Laurent8fce46a2009-08-04 09:45:33 -0700508 Vector<String8> mNewParameters;
Eric Laurenta553c252009-07-17 12:17:14 -0700509 status_t mParamStatus;
510 Vector<ConfigEvent *> mConfigEvents;
511 bool mStandby;
Eric Laurent49f02be2009-11-19 09:00:56 -0800512 int mId;
513 bool mExiting;
Eric Laurent464d5b32011-06-17 21:29:58 -0700514 Vector< sp<EffectChain> > mEffectChains;
515 uint32_t mDevice; // output device for PlaybackThread
516 // input + output devices for RecordThread
Eric Laurent6dbdc402011-07-22 09:04:31 -0700517 static const int kNameLength = 32;
518 char mName[kNameLength];
519 sp<IPowerManager> mPowerManager;
520 sp<IBinder> mWakeLockToken;
521 sp<PMDeathRecipient> mDeathRecipient;
Eric Laurenta553c252009-07-17 12:17:14 -0700522 };
523
524 // --- PlaybackThread ---
525 class PlaybackThread : public ThreadBase {
526 public:
527
Eric Laurent059b4be2009-11-09 23:32:22 -0800528 enum mixer_state {
529 MIXER_IDLE,
530 MIXER_TRACKS_ENABLED,
531 MIXER_TRACKS_READY
532 };
533
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800534 // playback track
535 class Track : public TrackBase {
536 public:
Eric Laurenta553c252009-07-17 12:17:14 -0700537 Track( const wp<ThreadBase>& thread,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800538 const sp<Client>& client,
539 int streamType,
540 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700541 uint32_t format,
542 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 int frameCount,
Eric Laurent65b65452010-06-01 23:49:17 -0700544 const sp<IMemory>& sharedBuffer,
545 int sessionId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546 ~Track();
547
548 void dump(char* buffer, size_t size);
549 virtual status_t start();
550 virtual void stop();
551 void pause();
552
553 void flush();
554 void destroy();
555 void mute(bool);
556 void setVolume(float left, float right);
Eric Laurenta553c252009-07-17 12:17:14 -0700557 int name() const {
558 return mName;
559 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560
Eric Laurent4bc035a2009-05-22 09:18:15 -0700561 int type() const {
562 return mStreamType;
563 }
Eric Laurent65b65452010-06-01 23:49:17 -0700564 status_t attachAuxEffect(int EffectId);
565 void setAuxBuffer(int EffectId, int32_t *buffer);
566 int32_t *auxBuffer() { return mAuxBuffer; }
567 void setMainBuffer(int16_t *buffer) { mMainBuffer = buffer; }
568 int16_t *mainBuffer() { return mMainBuffer; }
569 int auxEffectId() { return mAuxEffectId; }
Eric Laurent4bc035a2009-05-22 09:18:15 -0700570
571
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 protected:
Eric Laurenta553c252009-07-17 12:17:14 -0700573 friend class ThreadBase;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 friend class AudioFlinger;
Eric Laurent2c817f52009-07-23 13:17:39 -0700575 friend class TrackHandle;
576 friend class PlaybackThread;
577 friend class MixerThread;
578 friend class DirectOutputThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800579
580 Track(const Track&);
581 Track& operator = (const Track&);
582
583 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
Eric Laurenta553c252009-07-17 12:17:14 -0700584 bool isMuted() { return mMute; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 bool isPausing() const {
586 return mState == PAUSING;
587 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800588 bool isPaused() const {
589 return mState == PAUSED;
590 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 bool isReady() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 void setPaused() { mState = PAUSED; }
593 void reset();
594
Eric Laurent49f02be2009-11-19 09:00:56 -0800595 bool isOutputTrack() const {
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700596 return (mStreamType == AUDIO_STREAM_CNT);
Eric Laurent49f02be2009-11-19 09:00:56 -0800597 }
598
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 // we don't really need a lock for these
600 float mVolume[2];
601 volatile bool mMute;
602 // FILLED state is used for suppressing volume ramp at begin of playing
603 enum {FS_FILLING, FS_FILLED, FS_ACTIVE};
604 mutable uint8_t mFillingUpStatus;
605 int8_t mRetryCount;
606 sp<IMemory> mSharedBuffer;
607 bool mResetDone;
Eric Laurent4bc035a2009-05-22 09:18:15 -0700608 int mStreamType;
Eric Laurenta553c252009-07-17 12:17:14 -0700609 int mName;
Eric Laurent65b65452010-06-01 23:49:17 -0700610 int16_t *mMainBuffer;
611 int32_t *mAuxBuffer;
612 int mAuxEffectId;
Eric Laurenta92ebfa2010-08-31 13:50:07 -0700613 bool mHasVolumeController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 }; // end of Track
615
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616
617 // playback track
618 class OutputTrack : public Track {
619 public:
Eric Laurenta553c252009-07-17 12:17:14 -0700620
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800621 class Buffer: public AudioBufferProvider::Buffer {
622 public:
623 int16_t *mBuffer;
624 };
Eric Laurenta553c252009-07-17 12:17:14 -0700625
626 OutputTrack( const wp<ThreadBase>& thread,
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800627 DuplicatingThread *sourceThread,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800628 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700629 uint32_t format,
630 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800631 int frameCount);
632 ~OutputTrack();
633
634 virtual status_t start();
635 virtual void stop();
Eric Laurenta553c252009-07-17 12:17:14 -0700636 bool write(int16_t* data, uint32_t frames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800637 bool bufferQueueEmpty() { return (mBufferQueue.size() == 0) ? true : false; }
Eric Laurenta553c252009-07-17 12:17:14 -0700638 bool isActive() { return mActive; }
639 wp<ThreadBase>& thread() { return mThread; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800640
641 private:
642
Eric Laurenta553c252009-07-17 12:17:14 -0700643 status_t obtainBuffer(AudioBufferProvider::Buffer* buffer, uint32_t waitTimeMs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800644 void clearBufferQueue();
Eric Laurenta553c252009-07-17 12:17:14 -0700645
646 // Maximum number of pending buffers allocated by OutputTrack::write()
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800647 static const uint8_t kMaxOverFlowBuffers = 10;
Eric Laurenta553c252009-07-17 12:17:14 -0700648
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800649 Vector < Buffer* > mBufferQueue;
650 AudioBufferProvider::Buffer mOutBuffer;
Eric Laurenta553c252009-07-17 12:17:14 -0700651 bool mActive;
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800652 DuplicatingThread* mSourceThread;
Eric Laurenta553c252009-07-17 12:17:14 -0700653 }; // end of OutputTrack
654
Dima Zavin31f188892011-04-18 16:57:27 -0700655 PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
Eric Laurenta553c252009-07-17 12:17:14 -0700656 virtual ~PlaybackThread();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800657
658 virtual status_t dump(int fd, const Vector<String16>& args);
659
660 // Thread virtuals
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800661 virtual status_t readyToRun();
662 virtual void onFirstRef();
663
Eric Laurent464d5b32011-06-17 21:29:58 -0700664 virtual status_t initCheck() const { return (mOutput == 0) ? NO_INIT : NO_ERROR; }
665
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800666 virtual uint32_t latency() const;
667
668 virtual status_t setMasterVolume(float value);
669 virtual status_t setMasterMute(bool muted);
670
671 virtual float masterVolume() const;
672 virtual bool masterMute() const;
673
674 virtual status_t setStreamVolume(int stream, float value);
675 virtual status_t setStreamMute(int stream, bool muted);
676
677 virtual float streamVolume(int stream) const;
678 virtual bool streamMute(int stream) const;
679
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -0700680 sp<Track> createTrack_l(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800681 const sp<AudioFlinger::Client>& client,
682 int streamType,
683 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700684 uint32_t format,
685 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800686 int frameCount,
687 const sp<IMemory>& sharedBuffer,
Eric Laurent65b65452010-06-01 23:49:17 -0700688 int sessionId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800689 status_t *status);
Eric Laurenta553c252009-07-17 12:17:14 -0700690
Eric Laurent828b9772011-08-07 16:32:26 -0700691 AudioStreamOut* getOutput();
692 AudioStreamOut* clearOutput();
693 virtual audio_stream_t* stream();
Eric Laurenta553c252009-07-17 12:17:14 -0700694
Eric Laurentd5603c12009-08-06 08:49:39 -0700695 void suspend() { mSuspended++; }
696 void restore() { if (mSuspended) mSuspended--; }
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800697 bool isSuspended() { return (mSuspended != 0); }
Eric Laurenta553c252009-07-17 12:17:14 -0700698 virtual String8 getParameters(const String8& keys);
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700699 virtual void audioConfigChanged_l(int event, int param = 0);
Eric Laurent0986e792010-01-19 17:37:09 -0800700 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
Eric Laurent65b65452010-06-01 23:49:17 -0700701 int16_t *mixBuffer() { return mMixBuffer; };
702
Eric Laurent464d5b32011-06-17 21:29:58 -0700703 virtual void detachAuxEffect_l(int effectId);
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700704 status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
705 int EffectId);
706 status_t attachAuxEffect_l(const sp<AudioFlinger::PlaybackThread::Track> track,
707 int EffectId);
Eric Laurenta553c252009-07-17 12:17:14 -0700708
Eric Laurent464d5b32011-06-17 21:29:58 -0700709 virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
710 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
711 virtual uint32_t hasAudioSession(int sessionId);
712 virtual uint32_t getStrategyForSession_l(int sessionId);
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700713
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800714 struct stream_type_t {
715 stream_type_t()
716 : volume(1.0f),
717 mute(false)
718 {
719 }
720 float volume;
721 bool mute;
722 };
723
Eric Laurent2c817f52009-07-23 13:17:39 -0700724 protected:
Eric Laurent2c817f52009-07-23 13:17:39 -0700725 int16_t* mMixBuffer;
Eric Laurentd5603c12009-08-06 08:49:39 -0700726 int mSuspended;
Eric Laurent2c817f52009-07-23 13:17:39 -0700727 int mBytesWritten;
728 bool mMasterMute;
729 SortedVector< wp<Track> > mActiveTracks;
730
Eric Laurent62443f52009-10-05 20:29:18 -0700731 virtual int getTrackName_l() = 0;
732 virtual void deleteTrackName_l(int name) = 0;
Eric Laurent059b4be2009-11-09 23:32:22 -0800733 virtual uint32_t activeSleepTimeUs() = 0;
734 virtual uint32_t idleSleepTimeUs() = 0;
Eric Laurent8448a792010-08-18 18:13:17 -0700735 virtual uint32_t suspendSleepTimeUs() = 0;
Eric Laurent62443f52009-10-05 20:29:18 -0700736
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 private:
738
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800739 friend class AudioFlinger;
Eric Laurent6c30a712009-08-10 23:22:32 -0700740 friend class OutputTrack;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800741 friend class Track;
742 friend class TrackBase;
Eric Laurenta553c252009-07-17 12:17:14 -0700743 friend class MixerThread;
744 friend class DirectOutputThread;
745 friend class DuplicatingThread;
746
747 PlaybackThread(const Client&);
748 PlaybackThread& operator = (const PlaybackThread&);
749
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -0700750 status_t addTrack_l(const sp<Track>& track);
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -0700751 void destroyTrack_l(const sp<Track>& track);
Eric Laurent90681d62011-05-09 12:09:06 -0700752 void removeTrack_l(const sp<Track>& track);
Eric Laurent62443f52009-10-05 20:29:18 -0700753
Eric Laurenta553c252009-07-17 12:17:14 -0700754 void readOutputParameters();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800755
Eric Laurenta553c252009-07-17 12:17:14 -0700756 virtual status_t dumpInternals(int fd, const Vector<String16>& args);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800757 status_t dumpTracks(int fd, const Vector<String16>& args);
Eric Laurenta553c252009-07-17 12:17:14 -0700758
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800759 SortedVector< sp<Track> > mTracks;
Eric Laurenta553c252009-07-17 12:17:14 -0700760 // mStreamTypes[] uses 1 additionnal stream type internally for the OutputTrack used by DuplicatingThread
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700761 stream_type_t mStreamTypes[AUDIO_STREAM_CNT + 1];
Dima Zavin31f188892011-04-18 16:57:27 -0700762 AudioStreamOut* mOutput;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800763 float mMasterVolume;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800764 nsecs_t mLastWriteTime;
765 int mNumWrites;
766 int mNumDelayedWrites;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800767 bool mInWrite;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800768 };
769
Eric Laurenta553c252009-07-17 12:17:14 -0700770 class MixerThread : public PlaybackThread {
771 public:
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700772 MixerThread (const sp<AudioFlinger>& audioFlinger,
Dima Zavin31f188892011-04-18 16:57:27 -0700773 AudioStreamOut* output,
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700774 int id,
775 uint32_t device);
Eric Laurenta553c252009-07-17 12:17:14 -0700776 virtual ~MixerThread();
777
778 // Thread virtuals
779 virtual bool threadLoop();
780
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700781 void invalidateTracks(int streamType);
Eric Laurenta553c252009-07-17 12:17:14 -0700782 virtual bool checkForNewParameters_l();
783 virtual status_t dumpInternals(int fd, const Vector<String16>& args);
784
785 protected:
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700786 uint32_t prepareTracks_l(const SortedVector< wp<Track> >& activeTracks,
787 Vector< sp<Track> > *tracksToRemove);
Eric Laurent62443f52009-10-05 20:29:18 -0700788 virtual int getTrackName_l();
789 virtual void deleteTrackName_l(int name);
Eric Laurent059b4be2009-11-09 23:32:22 -0800790 virtual uint32_t activeSleepTimeUs();
791 virtual uint32_t idleSleepTimeUs();
Eric Laurent8448a792010-08-18 18:13:17 -0700792 virtual uint32_t suspendSleepTimeUs();
Eric Laurenta553c252009-07-17 12:17:14 -0700793
794 AudioMixer* mAudioMixer;
795 };
796
797 class DirectOutputThread : public PlaybackThread {
798 public:
799
Dima Zavin31f188892011-04-18 16:57:27 -0700800 DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
Eric Laurenta553c252009-07-17 12:17:14 -0700801 ~DirectOutputThread();
802
803 // Thread virtuals
804 virtual bool threadLoop();
805
Eric Laurent62443f52009-10-05 20:29:18 -0700806 virtual bool checkForNewParameters_l();
807
808 protected:
Eric Laurenta553c252009-07-17 12:17:14 -0700809 virtual int getTrackName_l();
810 virtual void deleteTrackName_l(int name);
Eric Laurent059b4be2009-11-09 23:32:22 -0800811 virtual uint32_t activeSleepTimeUs();
812 virtual uint32_t idleSleepTimeUs();
Eric Laurent8448a792010-08-18 18:13:17 -0700813 virtual uint32_t suspendSleepTimeUs();
Eric Laurenta553c252009-07-17 12:17:14 -0700814
815 private:
Eric Laurent65b65452010-06-01 23:49:17 -0700816 void applyVolume(uint16_t leftVol, uint16_t rightVol, bool ramp);
817
818 float mLeftVolFloat;
819 float mRightVolFloat;
820 uint16_t mLeftVolShort;
821 uint16_t mRightVolShort;
Eric Laurenta553c252009-07-17 12:17:14 -0700822 };
823
824 class DuplicatingThread : public MixerThread {
825 public:
Eric Laurent49f02be2009-11-19 09:00:56 -0800826 DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread, int id);
Eric Laurenta553c252009-07-17 12:17:14 -0700827 ~DuplicatingThread();
828
829 // Thread virtuals
830 virtual bool threadLoop();
831 void addOutputTrack(MixerThread* thread);
832 void removeOutputTrack(MixerThread* thread);
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800833 uint32_t waitTimeMs() { return mWaitTimeMs; }
834 protected:
835 virtual uint32_t activeSleepTimeUs();
Eric Laurenta553c252009-07-17 12:17:14 -0700836
837 private:
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800838 bool outputsReady(SortedVector< sp<OutputTrack> > &outputTracks);
839 void updateWaitTime();
840
Eric Laurenta553c252009-07-17 12:17:14 -0700841 SortedVector < sp<OutputTrack> > mOutputTracks;
Eric Laurent8ac9f8d2009-12-18 05:47:48 -0800842 uint32_t mWaitTimeMs;
Eric Laurenta553c252009-07-17 12:17:14 -0700843 };
844
Eric Laurentddb78e72009-07-28 08:44:33 -0700845 PlaybackThread *checkPlaybackThread_l(int output) const;
846 MixerThread *checkMixerThread_l(int output) const;
847 RecordThread *checkRecordThread_l(int input) const;
Eric Laurenta553c252009-07-17 12:17:14 -0700848 float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; }
Eric Laurent49f02be2009-11-19 09:00:56 -0800849 void audioConfigChanged_l(int event, int ioHandle, void *param2);
Eric Laurenta553c252009-07-17 12:17:14 -0700850
Eric Laurent464d5b32011-06-17 21:29:58 -0700851 uint32_t nextUniqueId();
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700852 status_t moveEffectChain_l(int session,
853 AudioFlinger::PlaybackThread *srcThread,
Eric Laurent493941b2010-07-28 01:32:47 -0700854 AudioFlinger::PlaybackThread *dstThread,
855 bool reRegister);
Eric Laurent464d5b32011-06-17 21:29:58 -0700856 PlaybackThread *primaryPlaybackThread_l();
857 uint32_t primaryOutputDevice_l();
Eric Laurent65b65452010-06-01 23:49:17 -0700858
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800859 friend class AudioBuffer;
860
861 class TrackHandle : public android::BnAudioTrack {
862 public:
Eric Laurenta553c252009-07-17 12:17:14 -0700863 TrackHandle(const sp<PlaybackThread::Track>& track);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 virtual ~TrackHandle();
865 virtual status_t start();
866 virtual void stop();
867 virtual void flush();
868 virtual void mute(bool);
869 virtual void pause();
870 virtual void setVolume(float left, float right);
871 virtual sp<IMemory> getCblk() const;
Eric Laurent65b65452010-06-01 23:49:17 -0700872 virtual status_t attachAuxEffect(int effectId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800873 virtual status_t onTransact(
874 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
875 private:
Eric Laurenta553c252009-07-17 12:17:14 -0700876 sp<PlaybackThread::Track> mTrack;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800877 };
878
879 friend class Client;
Eric Laurenta553c252009-07-17 12:17:14 -0700880 friend class PlaybackThread::Track;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800881
882
Eric Laurentb9481d82009-09-17 05:12:56 -0700883 void removeClient_l(pid_t pid);
Eric Laurent4f0f17d2010-05-12 02:05:53 -0700884 void removeNotificationClient(pid_t pid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800885
886
Eric Laurenta553c252009-07-17 12:17:14 -0700887 // record thread
888 class RecordThread : public ThreadBase, public AudioBufferProvider
889 {
890 public:
891
892 // record track
893 class RecordTrack : public TrackBase {
894 public:
895 RecordTrack(const wp<ThreadBase>& thread,
896 const sp<Client>& client,
897 uint32_t sampleRate,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700898 uint32_t format,
899 uint32_t channelMask,
Eric Laurenta553c252009-07-17 12:17:14 -0700900 int frameCount,
Eric Laurent65b65452010-06-01 23:49:17 -0700901 uint32_t flags,
902 int sessionId);
Eric Laurenta553c252009-07-17 12:17:14 -0700903 ~RecordTrack();
904
905 virtual status_t start();
906 virtual void stop();
907
908 bool overflow() { bool tmp = mOverflow; mOverflow = false; return tmp; }
909 bool setOverflow() { bool tmp = mOverflow; mOverflow = true; return tmp; }
910
Eric Laurent3fdb1262009-11-07 00:01:32 -0800911 void dump(char* buffer, size_t size);
Eric Laurenta553c252009-07-17 12:17:14 -0700912 private:
913 friend class AudioFlinger;
Eric Laurent2c817f52009-07-23 13:17:39 -0700914 friend class RecordThread;
Eric Laurenta553c252009-07-17 12:17:14 -0700915
916 RecordTrack(const RecordTrack&);
917 RecordTrack& operator = (const RecordTrack&);
918
919 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
920
921 bool mOverflow;
922 };
923
924
925 RecordThread(const sp<AudioFlinger>& audioFlinger,
Dima Zavin31f188892011-04-18 16:57:27 -0700926 AudioStreamIn *input,
Eric Laurenta553c252009-07-17 12:17:14 -0700927 uint32_t sampleRate,
Eric Laurent49f02be2009-11-19 09:00:56 -0800928 uint32_t channels,
Eric Laurent464d5b32011-06-17 21:29:58 -0700929 int id,
930 uint32_t device);
Eric Laurenta553c252009-07-17 12:17:14 -0700931 ~RecordThread();
932
933 virtual bool threadLoop();
Eric Laurent828b9772011-08-07 16:32:26 -0700934 virtual status_t readyToRun();
Eric Laurenta553c252009-07-17 12:17:14 -0700935 virtual void onFirstRef();
936
Eric Laurent464d5b32011-06-17 21:29:58 -0700937 virtual status_t initCheck() const { return (mInput == 0) ? NO_INIT : NO_ERROR; }
938 sp<AudioFlinger::RecordThread::RecordTrack> createRecordTrack_l(
939 const sp<AudioFlinger::Client>& client,
940 uint32_t sampleRate,
941 int format,
942 int channelMask,
943 int frameCount,
944 uint32_t flags,
945 int sessionId,
946 status_t *status);
947
Eric Laurenta553c252009-07-17 12:17:14 -0700948 status_t start(RecordTrack* recordTrack);
949 void stop(RecordTrack* recordTrack);
950 status_t dump(int fd, const Vector<String16>& args);
Eric Laurent828b9772011-08-07 16:32:26 -0700951 AudioStreamIn* getInput();
952 AudioStreamIn* clearInput();
953 virtual audio_stream_t* stream();
Eric Laurenta553c252009-07-17 12:17:14 -0700954
Eric Laurent464d5b32011-06-17 21:29:58 -0700955
956 void setTrack(RecordTrack *recordTrack) { mTrack = recordTrack; }
Eric Laurenta553c252009-07-17 12:17:14 -0700957 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
958 virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
959 virtual bool checkForNewParameters_l();
960 virtual String8 getParameters(const String8& keys);
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700961 virtual void audioConfigChanged_l(int event, int param = 0);
Eric Laurenta553c252009-07-17 12:17:14 -0700962 void readInputParameters();
Eric Laurent47d0a922010-02-26 02:47:27 -0800963 virtual unsigned int getInputFramesLost();
Eric Laurenta553c252009-07-17 12:17:14 -0700964
Eric Laurent464d5b32011-06-17 21:29:58 -0700965 virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
966 virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
967 virtual uint32_t hasAudioSession(int sessionId);
968
Eric Laurenta553c252009-07-17 12:17:14 -0700969 private:
970 RecordThread();
Dima Zavin31f188892011-04-18 16:57:27 -0700971 AudioStreamIn *mInput;
Eric Laurent464d5b32011-06-17 21:29:58 -0700972 RecordTrack* mTrack;
Eric Laurenta553c252009-07-17 12:17:14 -0700973 sp<RecordTrack> mActiveTrack;
974 Condition mStartStopCond;
975 AudioResampler *mResampler;
976 int32_t *mRsmpOutBuffer;
977 int16_t *mRsmpInBuffer;
978 size_t mRsmpInIndex;
979 size_t mInputBytes;
980 int mReqChannelCount;
981 uint32_t mReqSampleRate;
Eric Laurent9cc489a22009-12-05 05:20:01 -0800982 ssize_t mBytesRead;
Eric Laurenta553c252009-07-17 12:17:14 -0700983 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984
985 class RecordHandle : public android::BnAudioRecord {
986 public:
Eric Laurenta553c252009-07-17 12:17:14 -0700987 RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800988 virtual ~RecordHandle();
989 virtual status_t start();
990 virtual void stop();
991 virtual sp<IMemory> getCblk() const;
992 virtual status_t onTransact(
993 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
994 private:
Eric Laurenta553c252009-07-17 12:17:14 -0700995 sp<RecordThread::RecordTrack> mRecordTrack;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800996 };
997
Eric Laurent65b65452010-06-01 23:49:17 -0700998 //--- Audio Effect Management
999
1000 // EffectModule and EffectChain classes both have their own mutex to protect
1001 // state changes or resource modifications. Always respect the following order
1002 // if multiple mutexes must be acquired to avoid cross deadlock:
1003 // AudioFlinger -> ThreadBase -> EffectChain -> EffectModule
1004
1005 // The EffectModule class is a wrapper object controlling the effect engine implementation
1006 // in the effect library. It prevents concurrent calls to process() and command() functions
1007 // from different client threads. It keeps a list of EffectHandle objects corresponding
1008 // to all client applications using this effect and notifies applications of effect state,
1009 // control or parameter changes. It manages the activation state machine to send appropriate
1010 // reset, enable, disable commands to effect engine and provide volume
1011 // ramping when effects are activated/deactivated.
1012 // When controlling an auxiliary effect, the EffectModule also provides an input buffer used by
1013 // the attached track(s) to accumulate their auxiliary channel.
1014 class EffectModule: public RefBase {
1015 public:
1016 EffectModule(const wp<ThreadBase>& wThread,
1017 const wp<AudioFlinger::EffectChain>& chain,
1018 effect_descriptor_t *desc,
1019 int id,
1020 int sessionId);
1021 ~EffectModule();
1022
1023 enum effect_state {
1024 IDLE,
Eric Laurent7d850f22010-07-09 13:34:17 -07001025 RESTART,
Eric Laurent65b65452010-06-01 23:49:17 -07001026 STARTING,
1027 ACTIVE,
1028 STOPPING,
Eric Laurent21b5c472011-07-26 20:54:46 -07001029 STOPPED,
1030 DESTROYED
Eric Laurent65b65452010-06-01 23:49:17 -07001031 };
1032
1033 int id() { return mId; }
1034 void process();
Eric Laurent7d850f22010-07-09 13:34:17 -07001035 void updateState();
Eric Laurenta4c72ac2010-07-28 05:40:18 -07001036 status_t command(uint32_t cmdCode,
1037 uint32_t cmdSize,
1038 void *pCmdData,
1039 uint32_t *replySize,
1040 void *pReplyData);
Eric Laurent65b65452010-06-01 23:49:17 -07001041
Eric Laurentdf9b81c2010-07-02 08:12:41 -07001042 void reset_l();
Eric Laurent65b65452010-06-01 23:49:17 -07001043 status_t configure();
1044 status_t init();
1045 uint32_t state() {
1046 return mState;
1047 }
1048 uint32_t status() {
1049 return mStatus;
1050 }
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001051 int sessionId() {
1052 return mSessionId;
1053 }
Eric Laurent65b65452010-06-01 23:49:17 -07001054 status_t setEnabled(bool enabled);
1055 bool isEnabled();
Eric Laurenta92ebfa2010-08-31 13:50:07 -07001056 bool isProcessEnabled();
Eric Laurent65b65452010-06-01 23:49:17 -07001057
1058 void setInBuffer(int16_t *buffer) { mConfig.inputCfg.buffer.s16 = buffer; }
1059 int16_t *inBuffer() { return mConfig.inputCfg.buffer.s16; }
1060 void setOutBuffer(int16_t *buffer) { mConfig.outputCfg.buffer.s16 = buffer; }
1061 int16_t *outBuffer() { return mConfig.outputCfg.buffer.s16; }
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001062 void setChain(const wp<EffectChain>& chain) { mChain = chain; }
1063 void setThread(const wp<ThreadBase>& thread) { mThread = thread; }
Eric Laurent65b65452010-06-01 23:49:17 -07001064
1065 status_t addHandle(sp<EffectHandle>& handle);
1066 void disconnect(const wp<EffectHandle>& handle);
1067 size_t removeHandle (const wp<EffectHandle>& handle);
1068
1069 effect_descriptor_t& desc() { return mDescriptor; }
Eric Laurent53334cd2010-06-23 17:38:20 -07001070 wp<EffectChain>& chain() { return mChain; }
Eric Laurent65b65452010-06-01 23:49:17 -07001071
1072 status_t setDevice(uint32_t device);
1073 status_t setVolume(uint32_t *left, uint32_t *right, bool controller);
Eric Laurent53334cd2010-06-23 17:38:20 -07001074 status_t setMode(uint32_t mode);
Eric Laurent21b5c472011-07-26 20:54:46 -07001075 status_t stop();
Eric Laurent65b65452010-06-01 23:49:17 -07001076
1077 status_t dump(int fd, const Vector<String16>& args);
1078
1079 protected:
1080
Eric Laurent7d850f22010-07-09 13:34:17 -07001081 // Maximum time allocated to effect engines to complete the turn off sequence
1082 static const uint32_t MAX_DISABLE_TIME_MS = 10000;
1083
Eric Laurent65b65452010-06-01 23:49:17 -07001084 EffectModule(const EffectModule&);
1085 EffectModule& operator = (const EffectModule&);
1086
Eric Laurentdf9b81c2010-07-02 08:12:41 -07001087 status_t start_l();
1088 status_t stop_l();
Eric Laurent65b65452010-06-01 23:49:17 -07001089
1090 Mutex mLock; // mutex for process, commands and handles list protection
1091 wp<ThreadBase> mThread; // parent thread
1092 wp<EffectChain> mChain; // parent effect chain
1093 int mId; // this instance unique ID
1094 int mSessionId; // audio session ID
1095 effect_descriptor_t mDescriptor;// effect descriptor received from effect engine
1096 effect_config_t mConfig; // input and output audio configuration
Eric Laurent0fb66c22011-05-17 19:16:02 -07001097 effect_handle_t mEffectInterface; // Effect module C API
Eric Laurent65b65452010-06-01 23:49:17 -07001098 status_t mStatus; // initialization status
1099 uint32_t mState; // current activation state (effect_state)
1100 Vector< wp<EffectHandle> > mHandles; // list of client handles
Eric Laurent7d850f22010-07-09 13:34:17 -07001101 uint32_t mMaxDisableWaitCnt; // maximum grace period before forcing an effect off after
1102 // sending disable command.
1103 uint32_t mDisableWaitCnt; // current process() calls count during disable period.
Eric Laurent65b65452010-06-01 23:49:17 -07001104 };
1105
1106 // The EffectHandle class implements the IEffect interface. It provides resources
1107 // to receive parameter updates, keeps track of effect control
1108 // ownership and state and has a pointer to the EffectModule object it is controlling.
1109 // There is one EffectHandle object for each application controlling (or using)
1110 // an effect module.
1111 // The EffectHandle is obtained by calling AudioFlinger::createEffect().
1112 class EffectHandle: public android::BnEffect {
1113 public:
1114
1115 EffectHandle(const sp<EffectModule>& effect,
1116 const sp<AudioFlinger::Client>& client,
1117 const sp<IEffectClient>& effectClient,
1118 int32_t priority);
1119 virtual ~EffectHandle();
1120
1121 // IEffect
1122 virtual status_t enable();
1123 virtual status_t disable();
Eric Laurenta4c72ac2010-07-28 05:40:18 -07001124 virtual status_t command(uint32_t cmdCode,
1125 uint32_t cmdSize,
1126 void *pCmdData,
1127 uint32_t *replySize,
1128 void *pReplyData);
Eric Laurent65b65452010-06-01 23:49:17 -07001129 virtual void disconnect();
1130 virtual sp<IMemory> getCblk() const;
1131 virtual status_t onTransact(uint32_t code, const Parcel& data,
1132 Parcel* reply, uint32_t flags);
1133
1134
1135 // Give or take control of effect module
1136 void setControl(bool hasControl, bool signal);
Eric Laurenta4c72ac2010-07-28 05:40:18 -07001137 void commandExecuted(uint32_t cmdCode,
1138 uint32_t cmdSize,
1139 void *pCmdData,
1140 uint32_t replySize,
1141 void *pReplyData);
Eric Laurent65b65452010-06-01 23:49:17 -07001142 void setEnabled(bool enabled);
1143
1144 // Getters
1145 int id() { return mEffect->id(); }
1146 int priority() { return mPriority; }
1147 bool hasControl() { return mHasControl; }
1148 sp<EffectModule> effect() { return mEffect; }
1149
1150 void dump(char* buffer, size_t size);
1151
1152 protected:
1153
1154 EffectHandle(const EffectHandle&);
1155 EffectHandle& operator =(const EffectHandle&);
1156
1157 sp<EffectModule> mEffect; // pointer to controlled EffectModule
1158 sp<IEffectClient> mEffectClient; // callback interface for client notifications
1159 sp<Client> mClient; // client for shared memory allocation
1160 sp<IMemory> mCblkMemory; // shared memory for control block
1161 effect_param_cblk_t* mCblk; // control block for deferred parameter setting via shared memory
1162 uint8_t* mBuffer; // pointer to parameter area in shared memory
1163 int mPriority; // client application priority to control the effect
1164 bool mHasControl; // true if this handle is controlling the effect
1165 };
1166
1167 // the EffectChain class represents a group of effects associated to one audio session.
1168 // There can be any number of EffectChain objects per output mixer thread (PlaybackThread).
1169 // The EffecChain with session ID 0 contains global effects applied to the output mix.
1170 // Effects in this chain can be insert or auxiliary. Effects in other chains (attached to tracks)
1171 // are insert only. The EffectChain maintains an ordered list of effect module, the order corresponding
1172 // in the effect process order. When attached to a track (session ID != 0), it also provide it's own
1173 // input buffer used by the track as accumulation buffer.
1174 class EffectChain: public RefBase {
1175 public:
1176 EffectChain(const wp<ThreadBase>& wThread, int sessionId);
1177 ~EffectChain();
1178
1179 void process_l();
1180
1181 void lock() {
1182 mLock.lock();
1183 }
1184 void unlock() {
1185 mLock.unlock();
1186 }
1187
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001188 status_t addEffect_l(const sp<EffectModule>& handle);
Eric Laurent76c40f72010-07-15 12:50:15 -07001189 size_t removeEffect_l(const sp<EffectModule>& handle);
Eric Laurent65b65452010-06-01 23:49:17 -07001190
Eric Laurent464d5b32011-06-17 21:29:58 -07001191 int sessionId() { return mSessionId; }
1192 void setSessionId(int sessionId) { mSessionId = sessionId; }
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001193
Eric Laurent76c40f72010-07-15 12:50:15 -07001194 sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
1195 sp<EffectModule> getEffectFromId_l(int id);
1196 bool setVolume_l(uint32_t *left, uint32_t *right);
1197 void setDevice_l(uint32_t device);
1198 void setMode_l(uint32_t mode);
Eric Laurent53334cd2010-06-23 17:38:20 -07001199
Eric Laurent65b65452010-06-01 23:49:17 -07001200 void setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
1201 mInBuffer = buffer;
1202 mOwnInBuffer = ownsBuffer;
1203 }
1204 int16_t *inBuffer() {
1205 return mInBuffer;
1206 }
1207 void setOutBuffer(int16_t *buffer) {
1208 mOutBuffer = buffer;
1209 }
1210 int16_t *outBuffer() {
1211 return mOutBuffer;
1212 }
1213
Eric Laurent90681d62011-05-09 12:09:06 -07001214 void incTrackCnt() { android_atomic_inc(&mTrackCnt); }
1215 void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
1216 int32_t trackCnt() { return mTrackCnt;}
1217
1218 void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt); }
1219 void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
1220 int32_t activeTrackCnt() { return mActiveTrackCnt;}
Eric Laurent65b65452010-06-01 23:49:17 -07001221
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001222 uint32_t strategy() { return mStrategy; }
1223 void setStrategy(uint32_t strategy)
1224 { mStrategy = strategy; }
1225
Eric Laurent65b65452010-06-01 23:49:17 -07001226 status_t dump(int fd, const Vector<String16>& args);
1227
1228 protected:
1229
1230 EffectChain(const EffectChain&);
1231 EffectChain& operator =(const EffectChain&);
1232
1233 wp<ThreadBase> mThread; // parent mixer thread
1234 Mutex mLock; // mutex protecting effect list
1235 Vector<sp<EffectModule> > mEffects; // list of effect modules
1236 int mSessionId; // audio session ID
1237 int16_t *mInBuffer; // chain input buffer
1238 int16_t *mOutBuffer; // chain output buffer
Eric Laurent90681d62011-05-09 12:09:06 -07001239 volatile int32_t mActiveTrackCnt; // number of active tracks connected
1240 volatile int32_t mTrackCnt; // number of tracks connected
Eric Laurent65b65452010-06-01 23:49:17 -07001241 bool mOwnInBuffer; // true if the chain owns its input buffer
Eric Laurent76c40f72010-07-15 12:50:15 -07001242 int mVolumeCtrlIdx; // index of insert effect having control over volume
1243 uint32_t mLeftVolume; // previous volume on left channel
1244 uint32_t mRightVolume; // previous volume on right channel
Eric Laurent0d7e0482010-07-19 06:24:46 -07001245 uint32_t mNewLeftVolume; // new volume on left channel
1246 uint32_t mNewRightVolume; // new volume on right channel
Eric Laurent8ed6ed02010-07-13 04:45:46 -07001247 uint32_t mStrategy; // strategy for this effect chain
Eric Laurent65b65452010-06-01 23:49:17 -07001248 };
1249
Dima Zavin31f188892011-04-18 16:57:27 -07001250 struct AudioStreamOut {
1251 audio_hw_device_t *hwDev;
1252 audio_stream_out_t *stream;
1253
1254 AudioStreamOut(audio_hw_device_t *dev, audio_stream_out_t *out) :
1255 hwDev(dev), stream(out) {}
1256 };
1257
1258 struct AudioStreamIn {
1259 audio_hw_device_t *hwDev;
1260 audio_stream_in_t *stream;
1261
1262 AudioStreamIn(audio_hw_device_t *dev, audio_stream_in_t *in) :
1263 hwDev(dev), stream(in) {}
1264 };
1265
Eric Laurenta553c252009-07-17 12:17:14 -07001266 friend class RecordThread;
1267 friend class PlaybackThread;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001268
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001269 mutable Mutex mLock;
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001270
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001271 DefaultKeyedVector< pid_t, wp<Client> > mClients;
1272
Eric Laurenta553c252009-07-17 12:17:14 -07001273 mutable Mutex mHardwareLock;
Dima Zavin31f188892011-04-18 16:57:27 -07001274 audio_hw_device_t* mPrimaryHardwareDev;
1275 Vector<audio_hw_device_t*> mAudioHwDevs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001276 mutable int mHardwareStatus;
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001277
Eric Laurenta553c252009-07-17 12:17:14 -07001278
Eric Laurentddb78e72009-07-28 08:44:33 -07001279 DefaultKeyedVector< int, sp<PlaybackThread> > mPlaybackThreads;
Dima Zavin24fc2fb2011-04-19 22:30:36 -07001280 PlaybackThread::stream_type_t mStreamTypes[AUDIO_STREAM_CNT];
Eric Laurenta553c252009-07-17 12:17:14 -07001281 float mMasterVolume;
1282 bool mMasterMute;
1283
Eric Laurentddb78e72009-07-28 08:44:33 -07001284 DefaultKeyedVector< int, sp<RecordThread> > mRecordThreads;
Eric Laurenta553c252009-07-17 12:17:14 -07001285
Eric Laurent4f0f17d2010-05-12 02:05:53 -07001286 DefaultKeyedVector< pid_t, sp<NotificationClient> > mNotificationClients;
Eric Laurent65b65452010-06-01 23:49:17 -07001287 volatile int32_t mNextUniqueId;
Eric Laurent53334cd2010-06-23 17:38:20 -07001288 uint32_t mMode;
1289
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001290};
1291
Dima Zavin31f188892011-04-18 16:57:27 -07001292
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001293// ----------------------------------------------------------------------------
1294
1295}; // namespace android
1296
1297#endif // ANDROID_AUDIO_FLINGER_H