From 879707057cde0a83b5f6143c918c66b8f4a97581 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Thu, 27 Feb 2014 15:31:39 -0800 Subject: 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 --- media/libmedia/AudioRecord.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'media/libmedia/AudioRecord.cpp') 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; -- cgit v1.1