blob: 01a9d05d49d0a6f06e5bb652798e9069ea706b4a [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_AUDIOTRACK_H
18#define ANDROID_AUDIOTRACK_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <media/IAudioFlinger.h>
24#include <media/IAudioTrack.h>
25#include <media/AudioSystem.h>
26
27#include <utils/RefBase.h>
28#include <utils/Errors.h>
Mathias Agopian07952722009-05-19 19:08:10 -070029#include <binder/IInterface.h>
30#include <binder/IMemory.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031#include <utils/threads.h>
32
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033namespace android {
34
35// ----------------------------------------------------------------------------
36
37class audio_track_cblk_t;
38
39// ----------------------------------------------------------------------------
40
Glenn Kasten9c151c52011-11-15 13:55:13 -080041class AudioTrack : virtual public RefBase
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042{
43public:
44 enum channel_index {
45 MONO = 0,
46 LEFT = 0,
47 RIGHT = 1
48 };
49
50 /* Events used by AudioTrack callback function (audio_track_cblk_t).
51 */
52 enum event_type {
53 EVENT_MORE_DATA = 0, // Request to write more data to PCM buffer.
54 EVENT_UNDERRUN = 1, // PCM buffer underrun occured.
55 EVENT_LOOP_END = 2, // Sample loop end was reached; playback restarted from loop start if loop count was not 0.
56 EVENT_MARKER = 3, // Playback head is at the specified marker position (See setMarkerPosition()).
57 EVENT_NEW_POS = 4, // Playback head is at a new position (See setPositionUpdatePeriod()).
58 EVENT_BUFFER_END = 5 // Playback head is at the end of the buffer.
59 };
60
61 /* Create Buffer on the stack and pass it to obtainBuffer()
62 * and releaseBuffer().
63 */
64
65 class Buffer
66 {
67 public:
68 enum {
69 MUTE = 0x00000001
70 };
71 uint32_t flags;
Glenn Kasten1c5a89d2012-01-04 09:36:37 -080072 audio_format_t format; // but AUDIO_FORMAT_PCM_8_BIT -> AUDIO_FORMAT_PCM_16_BIT
73 // accessed directly by WebKit ANP callback
Jean-Michel Trivi54392232011-05-24 15:53:33 -070074 int channelCount; // will be removed in the future, do not use
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075 size_t frameCount;
76 size_t size;
77 union {
78 void* raw;
Glenn Kastene5fb2632011-12-14 10:28:06 -080079 short* i16; // signed 16-bit
80 int8_t* i8; // unsigned 8-bit, offset by 0x80
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 };
82 };
83
84
85 /* As a convenience, if a callback is supplied, a handler thread
86 * is automatically created with the appropriate priority. This thread
Glenn Kastene5fb2632011-12-14 10:28:06 -080087 * invokes the callback when a new buffer becomes available or an underrun condition occurs.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 * Parameters:
89 *
90 * event: type of event notified (see enum AudioTrack::event_type).
91 * user: Pointer to context for use by the callback receiver.
92 * info: Pointer to optional parameter according to event type:
93 * - EVENT_MORE_DATA: pointer to AudioTrack::Buffer struct. The callback must not write
94 * more bytes than indicated by 'size' field and update 'size' if less bytes are
95 * written.
96 * - EVENT_UNDERRUN: unused.
97 * - EVENT_LOOP_END: pointer to an int indicating the number of loops remaining.
Glenn Kastene5fb2632011-12-14 10:28:06 -080098 * - EVENT_MARKER: pointer to an uint32_t containing the marker position in frames.
99 * - EVENT_NEW_POS: pointer to an uint32_t containing the new position in frames.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 * - EVENT_BUFFER_END: unused.
101 */
102
Glenn Kastene46a86f2011-06-01 15:20:35 -0700103 typedef void (*callback_t)(int event, void* user, void *info);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104
Chia-chi Yehbd240c22010-06-16 06:33:13 +0800105 /* Returns the minimum frame count required for the successful creation of
106 * an AudioTrack object.
107 * Returned status (from utils/Errors.h) can be:
108 * - NO_ERROR: successful operation
109 * - NO_INIT: audio server or audio hardware not initialized
110 */
111
112 static status_t getMinFrameCount(int* frameCount,
113 int streamType =-1,
114 uint32_t sampleRate = 0);
115
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116 /* Constructs an uninitialized AudioTrack. No connection with
117 * AudioFlinger takes place.
118 */
119 AudioTrack();
120
121 /* Creates an audio track and registers it with AudioFlinger.
122 * Once created, the track needs to be started before it can be used.
123 * Unspecified values are set to the audio hardware's current
124 * values.
125 *
126 * Parameters:
127 *
128 * streamType: Select the type of audio stream this track is attached to
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700129 * (e.g. AUDIO_STREAM_MUSIC).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130 * sampleRate: Track sampling rate in Hz.
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700131 * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 * 16 bits per sample).
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700133 * channelMask: Channel mask: see audio_channels_t.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 * frameCount: Total size of track PCM buffer in frames. This defines the
135 * latency of the track.
136 * flags: Reserved for future use.
137 * cbf: Callback function. If not null, this function is called periodically
138 * to request new PCM data.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800139 * user: Context for use by the callback receiver.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 * notificationFrames: The callback function is called each time notificationFrames PCM
Glenn Kastene5fb2632011-12-14 10:28:06 -0800141 * frames have been consumed from track input buffer.
142 * sessionId: Specific session ID, or zero to use default.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800143 */
144
145 AudioTrack( int streamType,
146 uint32_t sampleRate = 0,
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800147 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700148 int channelMask = 0,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149 int frameCount = 0,
150 uint32_t flags = 0,
151 callback_t cbf = 0,
152 void* user = 0,
Eric Laurent65b65452010-06-01 23:49:17 -0700153 int notificationFrames = 0,
154 int sessionId = 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155
156 /* Creates an audio track and registers it with AudioFlinger. With this constructor,
Glenn Kastene5fb2632011-12-14 10:28:06 -0800157 * the PCM data to be rendered by AudioTrack is passed in a shared memory buffer
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158 * identified by the argument sharedBuffer. This prototype is for static buffer playback.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800159 * PCM data must be present in memory before the AudioTrack is started.
160 * The write() and flush() methods are not supported in this case.
161 * It is recommended to pass a callback function to be notified of playback end by an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 * EVENT_UNDERRUN event.
163 */
164
165 AudioTrack( int streamType,
166 uint32_t sampleRate = 0,
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800167 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700168 int channelMask = 0,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 const sp<IMemory>& sharedBuffer = 0,
170 uint32_t flags = 0,
171 callback_t cbf = 0,
172 void* user = 0,
Eric Laurent65b65452010-06-01 23:49:17 -0700173 int notificationFrames = 0,
174 int sessionId = 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175
176 /* Terminates the AudioTrack and unregisters it from AudioFlinger.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800177 * Also destroys all resources associated with the AudioTrack.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178 */
179 ~AudioTrack();
180
181
182 /* Initialize an uninitialized AudioTrack.
183 * Returned status (from utils/Errors.h) can be:
Glenn Kastene5fb2632011-12-14 10:28:06 -0800184 * - NO_ERROR: successful initialization
185 * - INVALID_OPERATION: AudioTrack is already initialized
Eric Laurenta553c252009-07-17 12:17:14 -0700186 * - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 * - NO_INIT: audio server or audio hardware not initialized
188 * */
189 status_t set(int streamType =-1,
190 uint32_t sampleRate = 0,
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800191 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700192 int channelMask = 0,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 int frameCount = 0,
194 uint32_t flags = 0,
195 callback_t cbf = 0,
196 void* user = 0,
197 int notificationFrames = 0,
198 const sp<IMemory>& sharedBuffer = 0,
Eric Laurent65b65452010-06-01 23:49:17 -0700199 bool threadCanCallJava = false,
200 int sessionId = 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201
202
203 /* Result of constructing the AudioTrack. This must be checked
Glenn Kastene5fb2632011-12-14 10:28:06 -0800204 * before using any AudioTrack API (except for set()), because using
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 * an uninitialized AudioTrack produces undefined results.
206 * See set() method above for possible return codes.
207 */
208 status_t initCheck() const;
209
Glenn Kastene5fb2632011-12-14 10:28:06 -0800210 /* Returns this track's estimated latency in milliseconds.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 * This includes the latency due to AudioTrack buffer size, AudioMixer (if any)
212 * and audio hardware driver.
213 */
214 uint32_t latency() const;
215
216 /* getters, see constructor */
217
218 int streamType() const;
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800219 audio_format_t format() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800220 int channelCount() const;
221 uint32_t frameCount() const;
Glenn Kastenfaf354d2012-01-11 09:48:27 -0800222
223 /* Return channelCount * (bit depth per channel / 8).
224 * channelCount is determined from channelMask, and bit depth comes from format.
225 */
226 size_t frameSize() const;
227
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800228 sp<IMemory>& sharedBuffer();
229
230
231 /* After it's created the track is not active. Call start() to
232 * make it active. If set, the callback will start being called.
233 */
234 void start();
235
236 /* Stop a track. If set, the callback will cease being called and
237 * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
238 * and will fill up buffers until the pool is exhausted.
239 */
240 void stop();
241 bool stopped() const;
242
Glenn Kastene5fb2632011-12-14 10:28:06 -0800243 /* Flush a stopped track. All pending buffers are discarded.
244 * This function has no effect if the track is not stopped.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 */
246 void flush();
247
248 /* Pause a track. If set, the callback will cease being called and
249 * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
250 * and will fill up buffers until the pool is exhausted.
251 */
252 void pause();
253
Glenn Kastene5fb2632011-12-14 10:28:06 -0800254 /* Mute or unmute this track.
255 * While muted, the callback, if set, is still called.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800256 */
257 void mute(bool);
258 bool muted() const;
259
Glenn Kastene5fb2632011-12-14 10:28:06 -0800260 /* Set volume for this track, mostly used for games' sound effects
261 * left and right volumes. Levels must be >= 0.0 and <= 1.0.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 */
Eric Laurent65b65452010-06-01 23:49:17 -0700263 status_t setVolume(float left, float right);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800264 void getVolume(float* left, float* right);
265
Glenn Kastene5fb2632011-12-14 10:28:06 -0800266 /* Set the send level for this track. An auxiliary effect should be attached
267 * to the track with attachEffect(). Level must be >= 0.0 and <= 1.0.
Eric Laurent65b65452010-06-01 23:49:17 -0700268 */
Eric Laurent7070b362010-07-16 07:43:46 -0700269 status_t setAuxEffectSendLevel(float level);
270 void getAuxEffectSendLevel(float* level);
Eric Laurent65b65452010-06-01 23:49:17 -0700271
Glenn Kastene5fb2632011-12-14 10:28:06 -0800272 /* Set sample rate for this track, mostly used for games' sound effects
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 */
Eric Laurent88e209d2009-07-07 07:10:45 -0700274 status_t setSampleRate(int sampleRate);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275 uint32_t getSampleRate();
276
277 /* Enables looping and sets the start and end points of looping.
278 *
279 * Parameters:
280 *
281 * loopStart: loop start expressed as the number of PCM frames played since AudioTrack start.
282 * loopEnd: loop end expressed as the number of PCM frames played since AudioTrack start.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800283 * loopCount: number of loops to execute. Calling setLoop() with loopCount == 0 cancels any
284 * pending or active loop. loopCount = -1 means infinite looping.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 *
286 * For proper operation the following condition must be respected:
287 * (loopEnd-loopStart) <= framecount()
288 */
289 status_t setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount);
290 status_t getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount);
291
Glenn Kastene5fb2632011-12-14 10:28:06 -0800292 /* Sets marker position. When playback reaches the number of frames specified, a callback with
293 * event type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker
294 * notification callback.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295 * If the AudioTrack has been opened with no callback function associated, the operation will fail.
296 *
297 * Parameters:
298 *
299 * marker: marker position expressed in frames.
300 *
301 * Returned status (from utils/Errors.h) can be:
302 * - NO_ERROR: successful operation
303 * - INVALID_OPERATION: the AudioTrack has no callback installed.
304 */
305 status_t setMarkerPosition(uint32_t marker);
306 status_t getMarkerPosition(uint32_t *marker);
307
308
Glenn Kastene5fb2632011-12-14 10:28:06 -0800309 /* Sets position update period. Every time the number of frames specified has been played,
310 * a callback with event type EVENT_NEW_POS is called.
311 * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
312 * callback.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800313 * If the AudioTrack has been opened with no callback function associated, the operation will fail.
314 *
315 * Parameters:
316 *
317 * updatePeriod: position update notification period expressed in frames.
318 *
319 * Returned status (from utils/Errors.h) can be:
320 * - NO_ERROR: successful operation
321 * - INVALID_OPERATION: the AudioTrack has no callback installed.
322 */
323 status_t setPositionUpdatePeriod(uint32_t updatePeriod);
324 status_t getPositionUpdatePeriod(uint32_t *updatePeriod);
325
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800326 /* Sets playback head position within AudioTrack buffer. The new position is specified
Glenn Kastene5fb2632011-12-14 10:28:06 -0800327 * in number of frames.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 * This method must be called with the AudioTrack in paused or stopped state.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800329 * Note that the actual position set is <position> modulo the AudioTrack buffer size in frames.
330 * Therefore using this method makes sense only when playing a "static" audio buffer
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 * as opposed to streaming.
332 * The getPosition() method on the other hand returns the total number of frames played since
333 * playback start.
334 *
335 * Parameters:
336 *
337 * position: New playback head position within AudioTrack buffer.
338 *
339 * Returned status (from utils/Errors.h) can be:
340 * - NO_ERROR: successful operation
341 * - INVALID_OPERATION: the AudioTrack is not stopped.
Glenn Kastene5fb2632011-12-14 10:28:06 -0800342 * - BAD_VALUE: The specified position is beyond the number of frames present in AudioTrack buffer
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 */
344 status_t setPosition(uint32_t position);
345 status_t getPosition(uint32_t *position);
346
Glenn Kastene5fb2632011-12-14 10:28:06 -0800347 /* Forces AudioTrack buffer full condition. When playing a static buffer, this method avoids
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 * rewriting the buffer before restarting playback after a stop.
349 * This method must be called with the AudioTrack in paused or stopped state.
350 *
351 * Returned status (from utils/Errors.h) can be:
352 * - NO_ERROR: successful operation
353 * - INVALID_OPERATION: the AudioTrack is not stopped.
354 */
355 status_t reload();
356
Glenn Kastene5fb2632011-12-14 10:28:06 -0800357 /* Returns a handle on the audio output used by this AudioTrack.
Eric Laurenta553c252009-07-17 12:17:14 -0700358 *
359 * Parameters:
360 * none.
361 *
362 * Returned value:
363 * handle on audio hardware output
364 */
365 audio_io_handle_t getOutput();
366
Glenn Kastene5fb2632011-12-14 10:28:06 -0800367 /* Returns the unique session ID associated with this track.
Eric Laurent65b65452010-06-01 23:49:17 -0700368 *
369 * Parameters:
370 * none.
371 *
372 * Returned value:
Glenn Kastene5fb2632011-12-14 10:28:06 -0800373 * AudioTrack session ID.
Eric Laurent65b65452010-06-01 23:49:17 -0700374 */
375 int getSessionId();
376
Glenn Kastene5fb2632011-12-14 10:28:06 -0800377 /* Attach track auxiliary output to specified effect. Use effectId = 0
Eric Laurent65b65452010-06-01 23:49:17 -0700378 * to detach track from effect.
379 *
380 * Parameters:
381 *
382 * effectId: effectId obtained from AudioEffect::id().
383 *
384 * Returned status (from utils/Errors.h) can be:
385 * - NO_ERROR: successful operation
386 * - INVALID_OPERATION: the effect is not an auxiliary effect.
387 * - BAD_VALUE: The specified effect ID is invalid
388 */
389 status_t attachAuxEffect(int effectId);
390
Glenn Kastene5fb2632011-12-14 10:28:06 -0800391 /* Obtains a buffer of "frameCount" frames. The buffer must be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800392 * filled entirely. If the track is stopped, obtainBuffer() returns
Glenn Kastene5fb2632011-12-14 10:28:06 -0800393 * STOPPED instead of NO_ERROR as long as there are buffers available,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394 * at which point NO_MORE_BUFFERS is returned.
395 * Buffers will be returned until the pool (buffercount())
396 * is exhausted, at which point obtainBuffer() will either block
397 * or return WOULD_BLOCK depending on the value of the "blocking"
398 * parameter.
399 */
400
401 enum {
402 NO_MORE_BUFFERS = 0x80000001,
403 STOPPED = 1
404 };
405
406 status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
407 void releaseBuffer(Buffer* audioBuffer);
408
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 /* As a convenience we provide a write() interface to the audio buffer.
410 * This is implemented on top of lockBuffer/unlockBuffer. For best
Glenn Kastene5fb2632011-12-14 10:28:06 -0800411 * performance use callbacks. Return actual number of bytes written.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 *
413 */
414 ssize_t write(const void* buffer, size_t size);
415
416 /*
417 * Dumps the state of an audio track.
418 */
419 status_t dump(int fd, const Vector<String16>& args) const;
420
421private:
422 /* copying audio tracks is not allowed */
423 AudioTrack(const AudioTrack& other);
424 AudioTrack& operator = (const AudioTrack& other);
425
426 /* a small internal class to handle the callback */
427 class AudioTrackThread : public Thread
428 {
429 public:
430 AudioTrackThread(AudioTrack& receiver, bool bCanCallJava = false);
431 private:
432 friend class AudioTrack;
433 virtual bool threadLoop();
434 virtual status_t readyToRun();
435 virtual void onFirstRef();
436 AudioTrack& mReceiver;
437 Mutex mLock;
438 };
439
440 bool processAudioBuffer(const sp<AudioTrackThread>& thread);
Eric Laurent421ddc02011-03-07 14:52:59 -0800441 status_t createTrack_l(int streamType,
Eric Laurentbda74692009-11-04 08:27:26 -0800442 uint32_t sampleRate,
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800443 audio_format_t format,
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700444 uint32_t channelMask,
Eric Laurentbda74692009-11-04 08:27:26 -0800445 int frameCount,
446 uint32_t flags,
447 const sp<IMemory>& sharedBuffer,
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700448 audio_io_handle_t output,
449 bool enforceFrameCount);
Eric Laurent421ddc02011-03-07 14:52:59 -0800450 void flush_l();
451 status_t setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount);
452 audio_io_handle_t getOutput_l();
453 status_t restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart);
Glenn Kastene6810ff2012-01-03 09:42:47 -0800454 bool stopped_l() const { return !mActive; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800456 sp<IAudioTrack> mAudioTrack;
457 sp<IMemory> mCblkMemory;
458 sp<AudioTrackThread> mAudioTrackThread;
459
460 float mVolume[2];
Eric Laurent65b65452010-06-01 23:49:17 -0700461 float mSendLevel;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800462 uint32_t mFrameCount;
463
464 audio_track_cblk_t* mCblk;
Glenn Kasten1c5a89d2012-01-04 09:36:37 -0800465 audio_format_t mFormat;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800466 uint8_t mStreamType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467 uint8_t mChannelCount;
468 uint8_t mMuted;
Jean-Michel Trivi54392232011-05-24 15:53:33 -0700469 uint8_t mReserved;
470 uint32_t mChannelMask;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471 status_t mStatus;
472 uint32_t mLatency;
473
Glenn Kastene6810ff2012-01-03 09:42:47 -0800474 bool mActive; // protected by mLock
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800475
476 callback_t mCbf;
477 void* mUserData;
Eric Laurenteb8f850d2010-05-14 03:26:45 -0700478 uint32_t mNotificationFramesReq; // requested number of frames between each notification callback
479 uint32_t mNotificationFramesAct; // actual number of frames between each notification callback
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480 sp<IMemory> mSharedBuffer;
481 int mLoopCount;
482 uint32_t mRemainingFrames;
483 uint32_t mMarkerPosition;
Jean-Michel Trivi4a5c1a72009-03-24 18:11:07 -0700484 bool mMarkerReached;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800485 uint32_t mNewPosition;
486 uint32_t mUpdatePeriod;
Jean-Michel Trivi22cb2042011-08-25 16:47:23 -0700487 bool mFlushed; // FIXME will be made obsolete by making flush() synchronous
Eric Laurenta553c252009-07-17 12:17:14 -0700488 uint32_t mFlags;
Eric Laurent65b65452010-06-01 23:49:17 -0700489 int mSessionId;
Eric Laurent7070b362010-07-16 07:43:46 -0700490 int mAuxEffectId;
Glenn Kastene6810ff2012-01-03 09:42:47 -0800491 mutable Mutex mLock;
Eric Laurent7e8626f2011-09-13 15:04:17 -0700492 status_t mRestoreStatus;
Glenn Kasten99d54432011-06-22 16:15:25 -0700493 int mPreviousPriority; // before start()
494 int mPreviousSchedulingGroup;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495};
496
497
498}; // namespace android
499
500#endif // ANDROID_AUDIOTRACK_H