AudioRecord.h revision 4cb668392ee0433462251afbee109405c6efacc8
1/*
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 ANDROID_AUDIORECORD_H
18#define ANDROID_AUDIORECORD_H
19
20#include <cutils/sched_policy.h>
21#include <media/AudioSystem.h>
22#include <media/IAudioRecord.h>
23#include <utils/threads.h>
24
25namespace android {
26
27// ----------------------------------------------------------------------------
28
29struct audio_track_cblk_t;
30class AudioRecordClientProxy;
31
32// ----------------------------------------------------------------------------
33
34class AudioRecord : public RefBase
35{
36public:
37
38    /* Events used by AudioRecord callback function (callback_t).
39     * Keep in sync with frameworks/base/media/java/android/media/AudioRecord.java NATIVE_EVENT_*.
40     */
41    enum event_type {
42        EVENT_MORE_DATA = 0,        // Request to read available data from buffer.
43                                    // If this event is delivered but the callback handler
44                                    // does not want to read the available data, the handler must
45                                    // explicitly ignore the event by setting frameCount to zero.
46        EVENT_OVERRUN = 1,          // Buffer overrun occurred.
47        EVENT_MARKER = 2,           // Record head is at the specified marker position
48                                    // (See setMarkerPosition()).
49        EVENT_NEW_POS = 3,          // Record head is at a new position
50                                    // (See setPositionUpdatePeriod()).
51        EVENT_NEW_IAUDIORECORD = 4, // IAudioRecord was re-created, either due to re-routing and
52                                    // voluntary invalidation by mediaserver, or mediaserver crash.
53    };
54
55    /* Client should declare a Buffer and pass address to obtainBuffer()
56     * and releaseBuffer().  See also callback_t for EVENT_MORE_DATA.
57     */
58
59    class Buffer
60    {
61    public:
62        // FIXME use m prefix
63        size_t      frameCount;     // number of sample frames corresponding to size;
64                                    // on input to obtainBuffer() it is the number of frames desired
65                                    // on output from obtainBuffer() it is the number of available
66                                    //    frames to be read
67                                    // on input to releaseBuffer() it is currently ignored
68
69        size_t      size;           // input/output in bytes == frameCount * frameSize
70                                    // on input to obtainBuffer() it is ignored
71                                    // on output from obtainBuffer() it is the number of available
72                                    //    bytes to be read, which is frameCount * frameSize
73                                    // on input to releaseBuffer() it is the number of bytes to
74                                    //    release
75                                    // FIXME This is redundant with respect to frameCount.  Consider
76                                    //    removing size and making frameCount the primary field.
77
78        union {
79            void*       raw;
80            short*      i16;        // signed 16-bit
81            int8_t*     i8;         // unsigned 8-bit, offset by 0x80
82                                    // input to obtainBuffer(): unused, output: pointer to buffer
83        };
84    };
85
86    /* As a convenience, if a callback is supplied, a handler thread
87     * is automatically created with the appropriate priority. This thread
88     * invokes the callback when a new buffer becomes available or various conditions occur.
89     * Parameters:
90     *
91     * event:   type of event notified (see enum AudioRecord::event_type).
92     * user:    Pointer to context for use by the callback receiver.
93     * info:    Pointer to optional parameter according to event type:
94     *          - EVENT_MORE_DATA: pointer to AudioRecord::Buffer struct. The callback must not read
95     *                             more bytes than indicated by 'size' field and update 'size' if
96     *                             fewer bytes are consumed.
97     *          - EVENT_OVERRUN: unused.
98     *          - EVENT_MARKER: pointer to const uint32_t containing the marker position in frames.
99     *          - EVENT_NEW_POS: pointer to const uint32_t containing the new position in frames.
100     *          - EVENT_NEW_IAUDIORECORD: unused.
101     */
102
103    typedef void (*callback_t)(int event, void* user, void *info);
104
105    /* Returns the minimum frame count required for the successful creation of
106     * an AudioRecord 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     *  - BAD_VALUE: unsupported configuration
111     * frameCount is guaranteed to be non-zero if status is NO_ERROR,
112     * and is undefined otherwise.
113     * FIXME This API assumes a route, and so should be deprecated.
114     */
115
116     static status_t getMinFrameCount(size_t* frameCount,
117                                      uint32_t sampleRate,
118                                      audio_format_t format,
119                                      audio_channel_mask_t channelMask);
120
121    /* How data is transferred from AudioRecord
122     */
123    enum transfer_type {
124        TRANSFER_DEFAULT,   // not specified explicitly; determine from the other parameters
125        TRANSFER_CALLBACK,  // callback EVENT_MORE_DATA
126        TRANSFER_OBTAIN,    // call obtainBuffer() and releaseBuffer()
127        TRANSFER_SYNC,      // synchronous read()
128    };
129
130    /* Constructs an uninitialized AudioRecord. No connection with
131     * AudioFlinger takes place.  Use set() after this.
132     *
133     * Parameters:
134     *
135     * opPackageName:      The package name used for app ops.
136     */
137                        AudioRecord(const String16& opPackageName);
138
139    /* Creates an AudioRecord object and registers it with AudioFlinger.
140     * Once created, the track needs to be started before it can be used.
141     * Unspecified values are set to appropriate default values.
142     *
143     * Parameters:
144     *
145     * inputSource:        Select the audio input to record from (e.g. AUDIO_SOURCE_DEFAULT).
146     * sampleRate:         Data sink sampling rate in Hz.
147     * format:             Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
148     *                     16 bits per sample).
149     * channelMask:        Channel mask, such that audio_is_input_channel(channelMask) is true.
150     * opPackageName:      The package name used for app ops.
151     * frameCount:         Minimum size of track PCM buffer in frames. This defines the
152     *                     application's contribution to the
153     *                     latency of the track.  The actual size selected by the AudioRecord could
154     *                     be larger if the requested size is not compatible with current audio HAL
155     *                     latency.  Zero means to use a default value.
156     * cbf:                Callback function. If not null, this function is called periodically
157     *                     to consume new data in TRANSFER_CALLBACK mode
158     *                     and inform of marker, position updates, etc.
159     * user:               Context for use by the callback receiver.
160     * notificationFrames: The callback function is called each time notificationFrames PCM
161     *                     frames are ready in record track output buffer.
162     * sessionId:          Not yet supported.
163     * transferType:       How data is transferred from AudioRecord.
164     * flags:              See comments on audio_input_flags_t in <system/audio.h>
165     * pAttributes:        If not NULL, supersedes inputSource for use case selection.
166     * threadCanCallJava:  Not present in parameter list, and so is fixed at false.
167     */
168
169                        AudioRecord(audio_source_t inputSource,
170                                    uint32_t sampleRate,
171                                    audio_format_t format,
172                                    audio_channel_mask_t channelMask,
173                                    const String16& opPackageName,
174                                    size_t frameCount = 0,
175                                    callback_t cbf = NULL,
176                                    void* user = NULL,
177                                    uint32_t notificationFrames = 0,
178                                    int sessionId = AUDIO_SESSION_ALLOCATE,
179                                    transfer_type transferType = TRANSFER_DEFAULT,
180                                    audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE,
181                                    int uid = -1,
182                                    pid_t pid = -1,
183                                    const audio_attributes_t* pAttributes = NULL);
184
185    /* Terminates the AudioRecord and unregisters it from AudioFlinger.
186     * Also destroys all resources associated with the AudioRecord.
187     */
188protected:
189                        virtual ~AudioRecord();
190public:
191
192    /* Initialize an AudioRecord that was created using the AudioRecord() constructor.
193     * Don't call set() more than once, or after an AudioRecord() constructor that takes parameters.
194     * set() is not multi-thread safe.
195     * Returned status (from utils/Errors.h) can be:
196     *  - NO_ERROR: successful intialization
197     *  - INVALID_OPERATION: AudioRecord is already initialized or record device is already in use
198     *  - BAD_VALUE: invalid parameter (channelMask, format, sampleRate...)
199     *  - NO_INIT: audio server or audio hardware not initialized
200     *  - PERMISSION_DENIED: recording is not allowed for the requesting process
201     * If status is not equal to NO_ERROR, don't call any other APIs on this AudioRecord.
202     *
203     * Parameters not listed in the AudioRecord constructors above:
204     *
205     * threadCanCallJava:  Whether callbacks are made from an attached thread and thus can call JNI.
206     */
207            status_t    set(audio_source_t inputSource,
208                            uint32_t sampleRate,
209                            audio_format_t format,
210                            audio_channel_mask_t channelMask,
211                            size_t frameCount = 0,
212                            callback_t cbf = NULL,
213                            void* user = NULL,
214                            uint32_t notificationFrames = 0,
215                            bool threadCanCallJava = false,
216                            int sessionId = AUDIO_SESSION_ALLOCATE,
217                            transfer_type transferType = TRANSFER_DEFAULT,
218                            audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE,
219                            int uid = -1,
220                            pid_t pid = -1,
221                            const audio_attributes_t* pAttributes = NULL);
222
223    /* Result of constructing the AudioRecord. This must be checked for successful initialization
224     * before using any AudioRecord API (except for set()), because using
225     * an uninitialized AudioRecord produces undefined results.
226     * See set() method above for possible return codes.
227     */
228            status_t    initCheck() const   { return mStatus; }
229
230    /* Returns this track's estimated latency in milliseconds.
231     * This includes the latency due to AudioRecord buffer size, resampling if applicable,
232     * and audio hardware driver.
233     */
234            uint32_t    latency() const     { return mLatency; }
235
236   /* getters, see constructor and set() */
237
238            audio_format_t format() const   { return mFormat; }
239            uint32_t    channelCount() const    { return mChannelCount; }
240            size_t      frameCount() const  { return mFrameCount; }
241            size_t      frameSize() const   { return mFrameSize; }
242            audio_source_t inputSource() const  { return mAttributes.source; }
243
244    /* After it's created the track is not active. Call start() to
245     * make it active. If set, the callback will start being called.
246     * If event is not AudioSystem::SYNC_EVENT_NONE, the capture start will be delayed until
247     * the specified event occurs on the specified trigger session.
248     */
249            status_t    start(AudioSystem::sync_event_t event = AudioSystem::SYNC_EVENT_NONE,
250                              int triggerSession = 0);
251
252    /* Stop a track.  The callback will cease being called.  Note that obtainBuffer() still
253     * works and will drain buffers until the pool is exhausted, and then will return WOULD_BLOCK.
254     */
255            void        stop();
256            bool        stopped() const;
257
258    /* Return the sink sample rate for this record track in Hz.
259     * Unlike AudioTrack, the sample rate is const after initialization, so doesn't need a lock.
260     */
261            uint32_t    getSampleRate() const   { return mSampleRate; }
262
263    /* Sets marker position. When record reaches the number of frames specified,
264     * a callback with event type EVENT_MARKER is called. Calling setMarkerPosition
265     * with marker == 0 cancels marker notification callback.
266     * To set a marker at a position which would compute as 0,
267     * a workaround is to set the marker at a nearby position such as ~0 or 1.
268     * If the AudioRecord has been opened with no callback function associated,
269     * the operation will fail.
270     *
271     * Parameters:
272     *
273     * marker:   marker position expressed in wrapping (overflow) frame units,
274     *           like the return value of getPosition().
275     *
276     * Returned status (from utils/Errors.h) can be:
277     *  - NO_ERROR: successful operation
278     *  - INVALID_OPERATION: the AudioRecord has no callback installed.
279     */
280            status_t    setMarkerPosition(uint32_t marker);
281            status_t    getMarkerPosition(uint32_t *marker) const;
282
283    /* Sets position update period. Every time the number of frames specified has been recorded,
284     * a callback with event type EVENT_NEW_POS is called.
285     * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
286     * callback.
287     * If the AudioRecord has been opened with no callback function associated,
288     * the operation will fail.
289     * Extremely small values may be rounded up to a value the implementation can support.
290     *
291     * Parameters:
292     *
293     * updatePeriod:  position update notification period expressed in frames.
294     *
295     * Returned status (from utils/Errors.h) can be:
296     *  - NO_ERROR: successful operation
297     *  - INVALID_OPERATION: the AudioRecord has no callback installed.
298     */
299            status_t    setPositionUpdatePeriod(uint32_t updatePeriod);
300            status_t    getPositionUpdatePeriod(uint32_t *updatePeriod) const;
301
302    /* Return the total number of frames recorded since recording started.
303     * The counter will wrap (overflow) periodically, e.g. every ~27 hours at 44.1 kHz.
304     * It is reset to zero by stop().
305     *
306     * Parameters:
307     *
308     *  position:  Address where to return record head position.
309     *
310     * Returned status (from utils/Errors.h) can be:
311     *  - NO_ERROR: successful operation
312     *  - BAD_VALUE:  position is NULL
313     */
314            status_t    getPosition(uint32_t *position) const;
315
316    /* Returns a handle on the audio input used by this AudioRecord.
317     *
318     * Parameters:
319     *  none.
320     *
321     * Returned value:
322     *  handle on audio hardware input
323     */
324// FIXME The only known public caller is frameworks/opt/net/voip/src/jni/rtp/AudioGroup.cpp
325            audio_io_handle_t    getInput() const __attribute__((__deprecated__))
326                                                { return getInputPrivate(); }
327private:
328            audio_io_handle_t    getInputPrivate() const;
329public:
330
331    /* Returns the audio session ID associated with this AudioRecord.
332     *
333     * Parameters:
334     *  none.
335     *
336     * Returned value:
337     *  AudioRecord session ID.
338     *
339     * No lock needed because session ID doesn't change after first set().
340     */
341            int    getSessionId() const { return mSessionId; }
342
343    /* Public API for TRANSFER_OBTAIN mode.
344     * Obtains a buffer of up to "audioBuffer->frameCount" full frames.
345     * After draining these frames of data, the caller should release them with releaseBuffer().
346     * If the track buffer is not empty, obtainBuffer() returns as many contiguous
347     * full frames as are available immediately.
348     *
349     * If nonContig is non-NULL, it is an output parameter that will be set to the number of
350     * additional non-contiguous frames that are predicted to be available immediately,
351     * if the client were to release the first frames and then call obtainBuffer() again.
352     * This value is only a prediction, and needs to be confirmed.
353     * It will be set to zero for an error return.
354     *
355     * If the track buffer is empty and track is stopped, obtainBuffer() returns WOULD_BLOCK
356     * regardless of the value of waitCount.
357     * If the track buffer is empty and track is not stopped, obtainBuffer() blocks with a
358     * maximum timeout based on waitCount; see chart below.
359     * Buffers will be returned until the pool
360     * is exhausted, at which point obtainBuffer() will either block
361     * or return WOULD_BLOCK depending on the value of the "waitCount"
362     * parameter.
363     *
364     * Interpretation of waitCount:
365     *  +n  limits wait time to n * WAIT_PERIOD_MS,
366     *  -1  causes an (almost) infinite wait time,
367     *   0  non-blocking.
368     *
369     * Buffer fields
370     * On entry:
371     *  frameCount  number of frames requested
372     *  size        ignored
373     *  raw         ignored
374     * After error return:
375     *  frameCount  0
376     *  size        0
377     *  raw         undefined
378     * After successful return:
379     *  frameCount  actual number of frames available, <= number requested
380     *  size        actual number of bytes available
381     *  raw         pointer to the buffer
382     */
383
384            status_t    obtainBuffer(Buffer* audioBuffer, int32_t waitCount,
385                                size_t *nonContig = NULL);
386
387            // Explicit Routing
388    /**
389     * TODO Document this method.
390     */
391            status_t setInputDevice(audio_port_handle_t deviceId);
392
393    /**
394     * TODO Document this method.
395     */
396            audio_port_handle_t getInputDevice();
397private:
398    /* If nonContig is non-NULL, it is an output parameter that will be set to the number of
399     * additional non-contiguous frames that are predicted to be available immediately,
400     * if the client were to release the first frames and then call obtainBuffer() again.
401     * This value is only a prediction, and needs to be confirmed.
402     * It will be set to zero for an error return.
403     * FIXME We could pass an array of Buffers instead of only one Buffer to obtainBuffer(),
404     * in case the requested amount of frames is in two or more non-contiguous regions.
405     * FIXME requested and elapsed are both relative times.  Consider changing to absolute time.
406     */
407            status_t    obtainBuffer(Buffer* audioBuffer, const struct timespec *requested,
408                                     struct timespec *elapsed = NULL, size_t *nonContig = NULL);
409public:
410
411    /* Public API for TRANSFER_OBTAIN mode.
412     * Release an emptied buffer of "audioBuffer->frameCount" frames for AudioFlinger to re-fill.
413     *
414     * Buffer fields:
415     *  frameCount  currently ignored but recommend to set to actual number of frames consumed
416     *  size        actual number of bytes consumed, must be multiple of frameSize
417     *  raw         ignored
418     */
419            void        releaseBuffer(const Buffer* audioBuffer);
420
421    /* As a convenience we provide a read() interface to the audio buffer.
422     * Input parameter 'size' is in byte units.
423     * This is implemented on top of obtainBuffer/releaseBuffer. For best
424     * performance use callbacks. Returns actual number of bytes read >= 0,
425     * or one of the following negative status codes:
426     *      INVALID_OPERATION   AudioRecord is configured for streaming mode
427     *      BAD_VALUE           size is invalid
428     *      WOULD_BLOCK         when obtainBuffer() returns same, or
429     *                          AudioRecord was stopped during the read
430     *      or any other error code returned by IAudioRecord::start() or restoreRecord_l().
431     * Default behavior is to only return when all data has been transferred. Set 'blocking' to
432     * false for the method to return immediately without waiting to try multiple times to read
433     * the full content of the buffer.
434     */
435            ssize_t     read(void* buffer, size_t size, bool blocking = true);
436
437    /* Return the number of input frames lost in the audio driver since the last call of this
438     * function.  Audio driver is expected to reset the value to 0 and restart counting upon
439     * returning the current value by this function call.  Such loss typically occurs when the
440     * user space process is blocked longer than the capacity of audio driver buffers.
441     * Units: the number of input audio frames.
442     * FIXME The side-effect of resetting the counter may be incompatible with multi-client.
443     * Consider making it more like AudioTrack::getUnderrunFrames which doesn't have side effects.
444     */
445            uint32_t    getInputFramesLost() const;
446
447private:
448    /* copying audio record objects is not allowed */
449                        AudioRecord(const AudioRecord& other);
450            AudioRecord& operator = (const AudioRecord& other);
451
452    /* a small internal class to handle the callback */
453    class AudioRecordThread : public Thread
454    {
455    public:
456        AudioRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
457
458        // Do not call Thread::requestExitAndWait() without first calling requestExit().
459        // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough.
460        virtual void        requestExit();
461
462                void        pause();    // suspend thread from execution at next loop boundary
463                void        resume();   // allow thread to execute, if not requested to exit
464                void        wake();     // wake to handle changed notification conditions.
465
466    private:
467                void        pauseInternal(nsecs_t ns = 0LL);
468                                        // like pause(), but only used internally within thread
469
470        friend class AudioRecord;
471        virtual bool        threadLoop();
472        AudioRecord&        mReceiver;
473        virtual ~AudioRecordThread();
474        Mutex               mMyLock;    // Thread::mLock is private
475        Condition           mMyCond;    // Thread::mThreadExitedCondition is private
476        bool                mPaused;    // whether thread is requested to pause at next loop entry
477        bool                mPausedInt; // whether thread internally requests pause
478        nsecs_t             mPausedNs;  // if mPausedInt then associated timeout, otherwise ignored
479        bool                mIgnoreNextPausedInt;   // skip any internal pause and go immediately
480                                        // to processAudioBuffer() as state may have changed
481                                        // since pause time calculated.
482    };
483
484            // body of AudioRecordThread::threadLoop()
485            // returns the maximum amount of time before we would like to run again, where:
486            //      0           immediately
487            //      > 0         no later than this many nanoseconds from now
488            //      NS_WHENEVER still active but no particular deadline
489            //      NS_INACTIVE inactive so don't run again until re-started
490            //      NS_NEVER    never again
491            static const nsecs_t NS_WHENEVER = -1, NS_INACTIVE = -2, NS_NEVER = -3;
492            nsecs_t processAudioBuffer();
493
494            // caller must hold lock on mLock for all _l methods
495
496            status_t openRecord_l(size_t epoch, const String16& opPackageName);
497
498            // FIXME enum is faster than strcmp() for parameter 'from'
499            status_t restoreRecord_l(const char *from);
500
501    sp<AudioRecordThread>   mAudioRecordThread;
502    mutable Mutex           mLock;
503
504    // Current client state:  false = stopped, true = active.  Protected by mLock.  If more states
505    // are added, consider changing this to enum State { ... } mState as in AudioTrack.
506    bool                    mActive;
507
508    // for client callback handler
509    callback_t              mCbf;                   // callback handler for events, or NULL
510    void*                   mUserData;
511
512    // for notification APIs
513    uint32_t                mNotificationFramesReq; // requested number of frames between each
514                                                    // notification callback
515                                                    // as specified in constructor or set()
516    uint32_t                mNotificationFramesAct; // actual number of frames between each
517                                                    // notification callback
518    bool                    mRefreshRemaining;      // processAudioBuffer() should refresh
519                                                    // mRemainingFrames and mRetryOnPartialBuffer
520
521    // These are private to processAudioBuffer(), and are not protected by a lock
522    uint32_t                mRemainingFrames;       // number of frames to request in obtainBuffer()
523    bool                    mRetryOnPartialBuffer;  // sleep and retry after partial obtainBuffer()
524    uint32_t                mObservedSequence;      // last observed value of mSequence
525
526    uint32_t                mMarkerPosition;        // in wrapping (overflow) frame units
527    bool                    mMarkerReached;
528    uint32_t                mNewPosition;           // in frames
529    uint32_t                mUpdatePeriod;          // in frames, zero means no EVENT_NEW_POS
530
531    status_t                mStatus;
532
533    String16                mOpPackageName;         // The package name used for app ops.
534
535    size_t                  mFrameCount;            // corresponds to current IAudioRecord, value is
536                                                    // reported back by AudioFlinger to the client
537    size_t                  mReqFrameCount;         // frame count to request the first or next time
538                                                    // a new IAudioRecord is needed, non-decreasing
539
540    // constant after constructor or set()
541    uint32_t                mSampleRate;
542    audio_format_t          mFormat;
543    uint32_t                mChannelCount;
544    size_t                  mFrameSize;         // app-level frame size == AudioFlinger frame size
545    uint32_t                mLatency;           // in ms
546    audio_channel_mask_t    mChannelMask;
547    audio_input_flags_t     mFlags;
548    int                     mSessionId;
549    transfer_type           mTransfer;
550
551    // Next 5 fields may be changed if IAudioRecord is re-created, but always != 0
552    // provided the initial set() was successful
553    sp<IAudioRecord>        mAudioRecord;
554    sp<IMemory>             mCblkMemory;
555    audio_track_cblk_t*     mCblk;              // re-load after mLock.unlock()
556    sp<IMemory>             mBufferMemory;
557    audio_io_handle_t       mInput;             // returned by AudioSystem::getInput()
558
559    int                     mPreviousPriority;  // before start()
560    SchedPolicy             mPreviousSchedulingGroup;
561    bool                    mAwaitBoost;    // thread should wait for priority boost before running
562
563    // The proxy should only be referenced while a lock is held because the proxy isn't
564    // multi-thread safe.
565    // An exception is that a blocking ClientProxy::obtainBuffer() may be called without a lock,
566    // provided that the caller also holds an extra reference to the proxy and shared memory to keep
567    // them around in case they are replaced during the obtainBuffer().
568    sp<AudioRecordClientProxy> mProxy;
569
570    bool                    mInOverrun;         // whether recorder is currently in overrun state
571
572private:
573    class DeathNotifier : public IBinder::DeathRecipient {
574    public:
575        DeathNotifier(AudioRecord* audioRecord) : mAudioRecord(audioRecord) { }
576    protected:
577        virtual void        binderDied(const wp<IBinder>& who);
578    private:
579        const wp<AudioRecord> mAudioRecord;
580    };
581
582    sp<DeathNotifier>       mDeathNotifier;
583    uint32_t                mSequence;              // incremented for each new IAudioRecord attempt
584    int                     mClientUid;
585    pid_t                   mClientPid;
586    audio_attributes_t      mAttributes;
587
588    // For Device Selection API
589    //  a value of AUDIO_PORT_HANDLE_NONE indicated default (AudioPolicyManager) routing.
590    audio_port_handle_t    mSelectedDeviceId;
591};
592
593}; // namespace android
594
595#endif // ANDROID_AUDIORECORD_H
596