From: Jean-Michel Trivi Date: Thu, 13 Sep 2012 18:44:00 +0000 (-0700) Subject: Handle audio HAL returning 0 bytes in record thread X-Git-Tag: android-x86-4.4-r1~662^2^2~160 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4362f5300162ed55f56cf167eccf7f2e5b89d435;p=android-x86%2Fframeworks-av.git Handle audio HAL returning 0 bytes in record thread Enter standby when HAL returns an error, but also consider 0 bytes returned as NOT_ENOUGH_DATA. Change-Id: Ica83142310e9c176f936e0440571a6034cbc575f --- diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index a44fb3e1d3..582ab65fbd 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -5984,7 +5984,7 @@ bool AudioFlinger::RecordThread::threadLoop() inputStandBy(); acquireWakeLock(); - // used to verify we've read at least one before evaluating how many bytes were read + // used to verify we've read at least once before evaluating how many bytes were read bool readOnce = false; // start recording @@ -6499,9 +6499,9 @@ status_t AudioFlinger::RecordThread::getNextBuffer(AudioBufferProvider::Buffer* if (framesReady == 0) { mBytesRead = mInput->stream->read(mInput->stream, mRsmpInBuffer, mInputBytes); - if (mBytesRead < 0) { - ALOGE("RecordThread::getNextBuffer() Error reading audio input"); - if (mActiveTrack->mState == TrackBase::ACTIVE) { + if (mBytesRead <= 0) { + if ((mBytesRead < 0) && (mActiveTrack->mState == TrackBase::ACTIVE)) { + ALOGE("RecordThread::getNextBuffer() Error reading audio input"); // Force input into standby so that it tries to // recover at next read attempt inputStandBy();