diff options
author | Glenn Kasten <gkasten@google.com> | 2014-02-27 15:31:39 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2014-02-28 12:25:34 -0800 |
commit | 879707057cde0a83b5f6143c918c66b8f4a97581 (patch) | |
tree | c0dd80560309dc9fb878e467847fa108ed45c6cd /media/libmedia/AudioRecord.cpp | |
parent | 2c48f27be6b3ae58e451d9b56c1dfd00e606f345 (diff) | |
download | frameworks_av-879707057cde0a83b5f6143c918c66b8f4a97581.zip frameworks_av-879707057cde0a83b5f6143c918c66b8f4a97581.tar.gz frameworks_av-879707057cde0a83b5f6143c918c66b8f4a97581.tar.bz2 |
Make openRecord_l more like createTrack_l for fast tracks: part 3
Create the callback thread earlier, before creating the IAudioRecord,
so that the thread's tid is available as a parameter to openRecord().
Also move initialization of mCbf to same point as in AudioTrack.cpp.
Change-Id: I61ea4c5e2724ccfc691aaf51bc02a7c10d5a7495
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r-- | media/libmedia/AudioRecord.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index a8e1f5d..961b0a2 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -233,22 +233,27 @@ status_t AudioRecord::set( ALOGV("set(): mSessionId %d", mSessionId); mFlags = flags; + mCbf = cbf; + + if (cbf != NULL) { + mAudioRecordThread = new AudioRecordThread(*this, threadCanCallJava); + mAudioRecordThread->run("AudioRecord", ANDROID_PRIORITY_AUDIO); + } // create the IAudioRecord status = openRecord_l(0 /*epoch*/); + if (status != NO_ERROR) { + if (mAudioRecordThread != 0) { + mAudioRecordThread->requestExit(); // see comment in AudioRecord.h + mAudioRecordThread->requestExitAndWait(); + mAudioRecordThread.clear(); + } return status; } - if (cbf != NULL) { - mAudioRecordThread = new AudioRecordThread(*this, threadCanCallJava); - mAudioRecordThread->run("AudioRecord", ANDROID_PRIORITY_AUDIO); - } - mStatus = NO_ERROR; - mActive = false; - mCbf = cbf; mUserData = user; // TODO: add audio hardware input latency here mLatency = (1000*mFrameCount) / sampleRate; |