blob: 0ab26b89eeecd86aa976b96ffcdad13da9fd57bd [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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 AUDIORECORD_H_
18#define AUDIORECORD_H_
19
Mathias Agopian75624082009-05-19 19:08:10 -070020#include <binder/IMemory.h>
Glenn Kastena6364332012-04-19 09:35:04 -070021#include <cutils/sched_policy.h>
Eric Laurenta011e352012-03-29 15:51:43 -070022#include <media/AudioSystem.h>
Glenn Kasten868a6a32012-06-21 16:22:09 -070023#include <media/IAudioRecord.h>
24#include <system/audio.h>
25#include <utils/RefBase.h>
26#include <utils/Errors.h>
27#include <utils/threads.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080028
29namespace android {
30
Glenn Kastena3f1fa32012-01-18 14:54:46 -080031class audio_track_cblk_t;
32
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080033// ----------------------------------------------------------------------------
34
Eric Laurenta0a98ca2012-04-20 16:40:28 -070035class AudioRecord : virtual public RefBase
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080036{
37public:
38
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080039 static const int DEFAULT_SAMPLE_RATE = 8000;
40
41 /* Events used by AudioRecord callback function (callback_t).
Glenn Kasten02e84ea2012-06-25 13:45:12 -070042 * Keep in sync with frameworks/base/media/java/android/media/AudioRecord.java NATIVE_EVENT_*.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080043 */
44 enum event_type {
Glenn Kasten02e84ea2012-06-25 13:45:12 -070045 EVENT_MORE_DATA = 0, // Request to read more data from PCM buffer.
Glenn Kastenc28c03b2012-11-01 15:41:48 -070046 EVENT_OVERRUN = 1, // PCM buffer overrun occurred.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080047 EVENT_MARKER = 2, // Record head is at the specified marker position
48 // (See setMarkerPosition()).
Eric Laurentc2f1f072009-07-17 12:17:14 -070049 EVENT_NEW_POS = 3, // Record head is at a new position
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080050 // (See setPositionUpdatePeriod()).
51 };
52
Glenn Kastenc28c03b2012-11-01 15:41:48 -070053 /* Client should declare Buffer on the stack and pass address to obtainBuffer()
54 * and releaseBuffer(). See also callback_t for EVENT_MORE_DATA.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080055 */
56
57 class Buffer
58 {
59 public:
Glenn Kastenc28c03b2012-11-01 15:41:48 -070060 size_t frameCount; // number of sample frames corresponding to size;
61 // on input it is the number of frames available,
62 // on output is the number of frames actually drained
63
Glenn Kasten02e84ea2012-06-25 13:45:12 -070064 size_t size; // total size in bytes == frameCount * frameSize
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080065 union {
66 void* raw;
Glenn Kastenc28c03b2012-11-01 15:41:48 -070067 short* i16; // signed 16-bit
68 int8_t* i8; // unsigned 8-bit, offset by 0x80
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080069 };
70 };
71
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080072 /* As a convenience, if a callback is supplied, a handler thread
73 * is automatically created with the appropriate priority. This thread
Glenn Kastenc28c03b2012-11-01 15:41:48 -070074 * invokes the callback when a new buffer becomes ready or various conditions occur.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080075 * Parameters:
76 *
77 * event: type of event notified (see enum AudioRecord::event_type).
78 * user: Pointer to context for use by the callback receiver.
79 * info: Pointer to optional parameter according to event type:
80 * - EVENT_MORE_DATA: pointer to AudioRecord::Buffer struct. The callback must not read
Glenn Kastenc28c03b2012-11-01 15:41:48 -070081 * more bytes than indicated by 'size' field and update 'size' if fewer bytes are
82 * consumed.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080083 * - EVENT_OVERRUN: unused.
Glenn Kasten955e7812012-02-21 10:32:45 -080084 * - EVENT_MARKER: pointer to const uint32_t containing the marker position in frames.
85 * - EVENT_NEW_POS: pointer to const uint32_t containing the new position in frames.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080086 */
87
88 typedef void (*callback_t)(int event, void* user, void *info);
89
Chia-chi Yeh15304d62010-06-22 08:01:13 +080090 /* Returns the minimum frame count required for the successful creation of
91 * an AudioRecord object.
92 * Returned status (from utils/Errors.h) can be:
93 * - NO_ERROR: successful operation
94 * - NO_INIT: audio server or audio hardware not initialized
95 * - BAD_VALUE: unsupported configuration
96 */
97
98 static status_t getMinFrameCount(int* frameCount,
99 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800100 audio_format_t format,
Glenn Kastendd8104c2012-07-02 12:42:44 -0700101 audio_channel_mask_t channelMask);
Chia-chi Yeh15304d62010-06-22 08:01:13 +0800102
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800103 /* Constructs an uninitialized AudioRecord. No connection with
104 * AudioFlinger takes place.
105 */
106 AudioRecord();
107
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700108 /* Creates an AudioRecord object and registers it with AudioFlinger.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800109 * Once created, the track needs to be started before it can be used.
110 * Unspecified values are set to the audio hardware's current
111 * values.
112 *
113 * Parameters:
114 *
Eric Laurentc2f1f072009-07-17 12:17:14 -0700115 * inputSource: Select the audio input to record to (e.g. AUDIO_SOURCE_DEFAULT).
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800116 * sampleRate: Track sampling rate in Hz.
Dima Zavinfce7a472011-04-19 22:30:36 -0700117 * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800118 * 16 bits per sample).
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700119 * channelMask: Channel mask.
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700120 * frameCount: Minimum size of track PCM buffer in frames. This defines the
121 * application's contribution to the
122 * latency of the track. The actual size selected by the AudioRecord could
123 * be larger if the requested size is not compatible with current audio HAL
124 * latency. Zero means to use a default value.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800125 * cbf: Callback function. If not null, this function is called periodically
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700126 * to consume new PCM data.
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700127 * user: Context for use by the callback receiver.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800128 * notificationFrames: The callback function is called each time notificationFrames PCM
129 * frames are ready in record track output buffer.
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700130 * sessionId: Not yet supported.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800131 */
132
Glenn Kasteneba51fb2012-01-23 13:58:49 -0800133 AudioRecord(audio_source_t inputSource,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800134 uint32_t sampleRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -0800135 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten624a7fc2012-06-21 16:24:00 -0700136 audio_channel_mask_t channelMask = AUDIO_CHANNEL_IN_MONO,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800137 int frameCount = 0,
Glenn Kastena0d68332012-01-27 16:47:15 -0800138 callback_t cbf = NULL,
139 void* user = NULL,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700140 int notificationFrames = 0,
141 int sessionId = 0);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800142
143
144 /* Terminates the AudioRecord and unregisters it from AudioFlinger.
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700145 * Also destroys all resources associated with the AudioRecord.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800146 */
147 ~AudioRecord();
148
149
150 /* Initialize an uninitialized AudioRecord.
151 * Returned status (from utils/Errors.h) can be:
152 * - NO_ERROR: successful intialization
153 * - INVALID_OPERATION: AudioRecord is already intitialized or record device is already in use
Eric Laurentc2f1f072009-07-17 12:17:14 -0700154 * - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800155 * - NO_INIT: audio server or audio hardware not initialized
156 * - PERMISSION_DENIED: recording is not allowed for the requesting process
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700157 */
Glenn Kasteneba51fb2012-01-23 13:58:49 -0800158 status_t set(audio_source_t inputSource = AUDIO_SOURCE_DEFAULT,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800159 uint32_t sampleRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -0800160 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten624a7fc2012-06-21 16:24:00 -0700161 audio_channel_mask_t channelMask = AUDIO_CHANNEL_IN_MONO,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800162 int frameCount = 0,
Glenn Kastena0d68332012-01-27 16:47:15 -0800163 callback_t cbf = NULL,
164 void* user = NULL,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800165 int notificationFrames = 0,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700166 bool threadCanCallJava = false,
167 int sessionId = 0);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800168
169
170 /* Result of constructing the AudioRecord. This must be checked
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700171 * before using any AudioRecord API (except for set()), because using
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800172 * an uninitialized AudioRecord produces undefined results.
173 * See set() method above for possible return codes.
174 */
175 status_t initCheck() const;
176
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700177 /* Returns this track's estimated latency in milliseconds.
178 * This includes the latency due to AudioRecord buffer size,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800179 * and audio hardware driver.
180 */
181 uint32_t latency() const;
182
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700183 /* getters, see constructor and set() */
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800184
Glenn Kasten58f30212012-01-12 12:27:51 -0800185 audio_format_t format() const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800186 int channelCount() const;
187 uint32_t frameCount() const;
Glenn Kastenb9980652012-01-11 09:48:27 -0800188 size_t frameSize() const;
Glenn Kasteneba51fb2012-01-23 13:58:49 -0800189 audio_source_t inputSource() const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800190
191
192 /* After it's created the track is not active. Call start() to
193 * make it active. If set, the callback will start being called.
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700194 * If event is not AudioSystem::SYNC_EVENT_NONE, the capture start will be delayed until
Eric Laurenta011e352012-03-29 15:51:43 -0700195 * the specified event occurs on the specified trigger session.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800196 */
Eric Laurenta011e352012-03-29 15:51:43 -0700197 status_t start(AudioSystem::sync_event_t event = AudioSystem::SYNC_EVENT_NONE,
198 int triggerSession = 0);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800199
200 /* Stop a track. If set, the callback will cease being called and
201 * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700202 * and will drain buffers until the pool is exhausted.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800203 */
Glenn Kastend64cd232012-02-21 10:21:23 -0800204 void stop();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800205 bool stopped() const;
206
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700207 /* Get sample rate for this record track in Hz.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800208 */
Glenn Kasten606ee612012-02-24 16:33:14 -0800209 uint32_t getSampleRate() const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800210
211 /* Sets marker position. When record reaches the number of frames specified,
212 * a callback with event type EVENT_MARKER is called. Calling setMarkerPosition
Eric Laurentc2f1f072009-07-17 12:17:14 -0700213 * with marker == 0 cancels marker notification callback.
214 * If the AudioRecord has been opened with no callback function associated,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800215 * the operation will fail.
216 *
217 * Parameters:
218 *
219 * marker: marker position expressed in frames.
220 *
221 * Returned status (from utils/Errors.h) can be:
222 * - NO_ERROR: successful operation
223 * - INVALID_OPERATION: the AudioRecord has no callback installed.
224 */
225 status_t setMarkerPosition(uint32_t marker);
Glenn Kasten606ee612012-02-24 16:33:14 -0800226 status_t getMarkerPosition(uint32_t *marker) const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800227
228
Eric Laurentc2f1f072009-07-17 12:17:14 -0700229 /* Sets position update period. Every time the number of frames specified has been recorded,
230 * a callback with event type EVENT_NEW_POS is called.
231 * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
232 * callback.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800233 * If the AudioRecord has been opened with no callback function associated,
234 * the operation will fail.
235 *
236 * Parameters:
237 *
238 * updatePeriod: position update notification period expressed in frames.
239 *
240 * Returned status (from utils/Errors.h) can be:
241 * - NO_ERROR: successful operation
242 * - INVALID_OPERATION: the AudioRecord has no callback installed.
243 */
244 status_t setPositionUpdatePeriod(uint32_t updatePeriod);
Glenn Kasten606ee612012-02-24 16:33:14 -0800245 status_t getPositionUpdatePeriod(uint32_t *updatePeriod) const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800246
247
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700248 /* Gets record head position. The position is the total number of frames
Eric Laurentc2f1f072009-07-17 12:17:14 -0700249 * recorded since record start.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800250 *
251 * Parameters:
252 *
253 * position: Address where to return record head position within AudioRecord buffer.
254 *
255 * Returned status (from utils/Errors.h) can be:
256 * - NO_ERROR: successful operation
257 * - BAD_VALUE: position is NULL
258 */
Glenn Kasten606ee612012-02-24 16:33:14 -0800259 status_t getPosition(uint32_t *position) const;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800260
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700261 /* Returns a handle on the audio input used by this AudioRecord.
Eric Laurentc2f1f072009-07-17 12:17:14 -0700262 *
263 * Parameters:
264 * none.
265 *
266 * Returned value:
267 * handle on audio hardware input
268 */
Glenn Kasten606ee612012-02-24 16:33:14 -0800269 audio_io_handle_t getInput() const;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700270
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700271 /* Returns the audio session ID associated with this AudioRecord.
Eric Laurentbe916aa2010-06-01 23:49:17 -0700272 *
273 * Parameters:
274 * none.
275 *
276 * Returned value:
277 * AudioRecord session ID.
278 */
Glenn Kasten606ee612012-02-24 16:33:14 -0800279 int getSessionId() const;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700280
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700281 /* Obtains a buffer of "frameCount" frames. The buffer must be
282 * drained entirely, and then released with releaseBuffer().
283 * If the track is stopped, obtainBuffer() returns
Glenn Kasten417c2732012-02-24 13:00:45 -0800284 * STOPPED instead of NO_ERROR as long as there are buffers available,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800285 * at which point NO_MORE_BUFFERS is returned.
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700286 * Buffers will be returned until the pool
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800287 * is exhausted, at which point obtainBuffer() will either block
288 * or return WOULD_BLOCK depending on the value of the "blocking"
289 * parameter.
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700290 *
291 * Interpretation of waitCount:
292 * +n limits wait time to n * WAIT_PERIOD_MS,
293 * -1 causes an (almost) infinite wait time,
294 * 0 non-blocking.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800295 */
296
297 enum {
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700298 NO_MORE_BUFFERS = 0x80000001, // same name in AudioFlinger.h, ok to be different value
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800299 STOPPED = 1
300 };
301
302 status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700303
304 /* Release an emptied buffer of "frameCount" frames for AudioFlinger to re-fill. */
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800305 void releaseBuffer(Buffer* audioBuffer);
306
307
308 /* As a convenience we provide a read() interface to the audio buffer.
Glenn Kasten417c2732012-02-24 13:00:45 -0800309 * This is implemented on top of obtainBuffer/releaseBuffer.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800310 */
311 ssize_t read(void* buffer, size_t size);
312
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700313 /* Return the number of input frames lost in the audio driver since the last call of this
Glenn Kasten417c2732012-02-24 13:00:45 -0800314 * function. Audio driver is expected to reset the value to 0 and restart counting upon
315 * returning the current value by this function call. Such loss typically occurs when the
316 * user space process is blocked longer than the capacity of audio driver buffers.
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700317 * Units: the number of input audio frames.
Eric Laurent05bca2f2010-02-26 02:47:27 -0800318 */
Glenn Kasten606ee612012-02-24 16:33:14 -0800319 unsigned int getInputFramesLost() const;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800320
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800321private:
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700322 /* copying audio record objects is not allowed */
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800323 AudioRecord(const AudioRecord& other);
324 AudioRecord& operator = (const AudioRecord& other);
325
326 /* a small internal class to handle the callback */
Glenn Kasten68337ed2012-07-12 09:05:58 -0700327 class AudioRecordThread : public Thread
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800328 {
329 public:
Glenn Kasten68337ed2012-07-12 09:05:58 -0700330 AudioRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
331
332 // Do not call Thread::requestExitAndWait() without first calling requestExit().
333 // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough.
334 virtual void requestExit();
335
336 void pause(); // suspend thread from execution at next loop boundary
337 void resume(); // allow thread to execute, if not requested to exit
338
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800339 private:
340 friend class AudioRecord;
341 virtual bool threadLoop();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800342 AudioRecord& mReceiver;
Glenn Kasten68337ed2012-07-12 09:05:58 -0700343 virtual ~AudioRecordThread();
344 Mutex mMyLock; // Thread::mLock is private
345 Condition mMyCond; // Thread::mThreadExitedCondition is private
346 bool mPaused; // whether thread is currently paused
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800347 };
348
Glenn Kasten68337ed2012-07-12 09:05:58 -0700349 // body of AudioRecordThread::threadLoop()
350 bool processAudioBuffer(const sp<AudioRecordThread>& thread);
351
Eric Laurent1703cdf2011-03-07 14:52:59 -0800352 status_t openRecord_l(uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800353 audio_format_t format,
Glenn Kasten624a7fc2012-06-21 16:24:00 -0700354 audio_channel_mask_t channelMask,
Eric Laurent34f1d8e2009-11-04 08:27:26 -0800355 int frameCount,
Eric Laurent6100d2d2009-11-19 09:00:56 -0800356 audio_io_handle_t input);
Eric Laurent1703cdf2011-03-07 14:52:59 -0800357 audio_io_handle_t getInput_l();
358 status_t restoreRecord_l(audio_track_cblk_t*& cblk);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800359
Glenn Kasten68337ed2012-07-12 09:05:58 -0700360 sp<AudioRecordThread> mAudioRecordThread;
Glenn Kasten606ee612012-02-24 16:33:14 -0800361 mutable Mutex mLock;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800362
Glenn Kasten68337ed2012-07-12 09:05:58 -0700363 bool mActive; // protected by mLock
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800364
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700365 // for client callback handler
Glenn Kastenc28c03b2012-11-01 15:41:48 -0700366 callback_t mCbf; // callback handler for events, or NULL
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700367 void* mUserData;
368
369 // for notification APIs
370 uint32_t mNotificationFrames;
371 uint32_t mRemainingFrames;
372 uint32_t mMarkerPosition; // in frames
373 bool mMarkerReached;
374 uint32_t mNewPosition; // in frames
375 uint32_t mUpdatePeriod; // in ms
376
377 // constant after constructor or set()
378 uint32_t mFrameCount;
Glenn Kasten58f30212012-01-12 12:27:51 -0800379 audio_format_t mFormat;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800380 uint8_t mChannelCount;
Glenn Kasteneba51fb2012-01-23 13:58:49 -0800381 audio_source_t mInputSource;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800382 status_t mStatus;
383 uint32_t mLatency;
Glenn Kasten624a7fc2012-06-21 16:24:00 -0700384 audio_channel_mask_t mChannelMask;
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700385 audio_io_handle_t mInput; // returned by AudioSystem::getInput()
Eric Laurentbe916aa2010-06-01 23:49:17 -0700386 int mSessionId;
Glenn Kasten02e84ea2012-06-25 13:45:12 -0700387
388 // may be changed if IAudioRecord object is re-created
389 sp<IAudioRecord> mAudioRecord;
390 sp<IMemory> mCblkMemory;
391 audio_track_cblk_t* mCblk;
392
Glenn Kasten87913512011-06-22 16:15:25 -0700393 int mPreviousPriority; // before start()
Glenn Kastena6364332012-04-19 09:35:04 -0700394 SchedPolicy mPreviousSchedulingGroup;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800395};
396
397}; // namespace android
398
399#endif /*AUDIORECORD_H_*/