Loading include/media/AudioRecord.h +4 −1 Original line number Diff line number Diff line Loading @@ -417,6 +417,7 @@ private: void pause(); // suspend thread from execution at next loop boundary void resume(); // allow thread to execute, if not requested to exit void wake(); // wake to handle changed notification conditions. private: void pauseInternal(nsecs_t ns = 0LL); Loading @@ -431,7 +432,9 @@ private: bool mPaused; // whether thread is requested to pause at next loop entry bool mPausedInt; // whether thread internally requests pause nsecs_t mPausedNs; // if mPausedInt then associated timeout, otherwise ignored bool mIgnoreNextPausedInt; // whether to ignore next mPausedInt request bool mIgnoreNextPausedInt; // skip any internal pause and go immediately // to processAudioBuffer() as state may have changed // since pause time calculated. }; // body of AudioRecordThread::threadLoop() Loading media/libmedia/AudioRecord.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -352,6 +352,10 @@ status_t AudioRecord::setMarkerPosition(uint32_t marker) mMarkerPosition = marker; mMarkerReached = false; sp<AudioRecordThread> t = mAudioRecordThread; if (t != 0) { t->wake(); } return NO_ERROR; } Loading @@ -378,6 +382,10 @@ status_t AudioRecord::setPositionUpdatePeriod(uint32_t updatePeriod) mNewPosition = mProxy->getPosition() + updatePeriod; mUpdatePeriod = updatePeriod; sp<AudioRecordThread> t = mAudioRecordThread; if (t != 0) { t->wake(); } return NO_ERROR; } Loading Loading @@ -1072,8 +1080,8 @@ bool AudioRecord::AudioRecordThread::threadLoop() case NS_NEVER: return false; case NS_WHENEVER: // FIXME increase poll interval, or make event-driven ns = 1000000000LL; // Event driven: call wake() when callback notifications conditions change. ns = INT64_MAX; // fall through default: LOG_ALWAYS_FATAL_IF(ns < 0, "processAudioBuffer() returned %" PRId64, ns); Loading Loading @@ -1106,6 +1114,17 @@ void AudioRecord::AudioRecordThread::resume() } } void AudioRecord::AudioRecordThread::wake() { AutoMutex _l(mMyLock); if (!mPaused && mPausedInt && mPausedNs > 0) { // audio record is active and internally paused with timeout. mIgnoreNextPausedInt = true; mPausedInt = false; mMyCond.signal(); } } void AudioRecord::AudioRecordThread::pauseInternal(nsecs_t ns) { AutoMutex _l(mMyLock); Loading Loading
include/media/AudioRecord.h +4 −1 Original line number Diff line number Diff line Loading @@ -417,6 +417,7 @@ private: void pause(); // suspend thread from execution at next loop boundary void resume(); // allow thread to execute, if not requested to exit void wake(); // wake to handle changed notification conditions. private: void pauseInternal(nsecs_t ns = 0LL); Loading @@ -431,7 +432,9 @@ private: bool mPaused; // whether thread is requested to pause at next loop entry bool mPausedInt; // whether thread internally requests pause nsecs_t mPausedNs; // if mPausedInt then associated timeout, otherwise ignored bool mIgnoreNextPausedInt; // whether to ignore next mPausedInt request bool mIgnoreNextPausedInt; // skip any internal pause and go immediately // to processAudioBuffer() as state may have changed // since pause time calculated. }; // body of AudioRecordThread::threadLoop() Loading
media/libmedia/AudioRecord.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -352,6 +352,10 @@ status_t AudioRecord::setMarkerPosition(uint32_t marker) mMarkerPosition = marker; mMarkerReached = false; sp<AudioRecordThread> t = mAudioRecordThread; if (t != 0) { t->wake(); } return NO_ERROR; } Loading @@ -378,6 +382,10 @@ status_t AudioRecord::setPositionUpdatePeriod(uint32_t updatePeriod) mNewPosition = mProxy->getPosition() + updatePeriod; mUpdatePeriod = updatePeriod; sp<AudioRecordThread> t = mAudioRecordThread; if (t != 0) { t->wake(); } return NO_ERROR; } Loading Loading @@ -1072,8 +1080,8 @@ bool AudioRecord::AudioRecordThread::threadLoop() case NS_NEVER: return false; case NS_WHENEVER: // FIXME increase poll interval, or make event-driven ns = 1000000000LL; // Event driven: call wake() when callback notifications conditions change. ns = INT64_MAX; // fall through default: LOG_ALWAYS_FATAL_IF(ns < 0, "processAudioBuffer() returned %" PRId64, ns); Loading Loading @@ -1106,6 +1114,17 @@ void AudioRecord::AudioRecordThread::resume() } } void AudioRecord::AudioRecordThread::wake() { AutoMutex _l(mMyLock); if (!mPaused && mPausedInt && mPausedNs > 0) { // audio record is active and internally paused with timeout. mIgnoreNextPausedInt = true; mPausedInt = false; mMyCond.signal(); } } void AudioRecord::AudioRecordThread::pauseInternal(nsecs_t ns) { AutoMutex _l(mMyLock); Loading