// go to sleep
mWaitWorkCV.wait(mLock);
ALOGV("RecordThread: loop starting");
- acquireWakeLock_l();
+ acquireWakeLock_l(mClientUid);
continue;
}
- if (mActiveTrack != 0) {
- if (mActiveTrack->isTerminated()) {
- removeTrack_l(mActiveTrack);
- mActiveTrack.clear();
- } else if (mActiveTrack->mState == TrackBase::PAUSING) {
- standby();
+
+ if (activeTrack->isTerminated()) {
+ removeTrack_l(activeTrack);
+ mActiveTrack.clear();
+ continue;
+ }
+
+ activeTrackState = activeTrack->mState;
+ switch (activeTrackState) {
+ case TrackBase::PAUSING:
+ standby();
+ mActiveTrack.clear();
+ mStartStopCond.broadcast();
+ doSleep = true;
+ continue;
+
+ case TrackBase::RESUMING:
+ mStandby = false;
+ if (mReqChannelCount != activeTrack->channelCount()) {
mActiveTrack.clear();
mStartStopCond.broadcast();
- } else if (mActiveTrack->mState == TrackBase::RESUMING) {
- if (mReqChannelCount != mActiveTrack->channelCount()) {
+ continue;
+ }
+ if (readOnce) {
+ mStartStopCond.broadcast();
+ // record start succeeds only if first read from audio input succeeds
+ if (mBytesRead < 0) {
mActiveTrack.clear();
- mStartStopCond.broadcast();
- } else if (readOnce) {
- // record start succeeds only if first read from audio input
- // succeeds
- if (mBytesRead >= 0) {
- mActiveTrack->mState = TrackBase::ACTIVE;
- } else {
- mActiveTrack.clear();
- }
- mStartStopCond.broadcast();
+ continue;
}
- mStandby = false;
+ activeTrack->mState = TrackBase::ACTIVE;
}
+ break;
+
+ case TrackBase::ACTIVE:
+ break;
+
+ case TrackBase::IDLE:
+ doSleep = true;
+ continue;
+
+ default:
+ LOG_FATAL("Unexpected activeTrackState %d", activeTrackState);
}
lockEffectChains_l(effectChains);