diff options
author | Andy Hung <hunga@google.com> | 2015-03-18 23:26:55 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-03-18 23:33:44 -0700 |
commit | 803b3e558022c6d0eb069308339dc84e6e8035dc (patch) | |
tree | ffae05f0ba870ac1f7b704a7309542444db623a4 /media/libmedia/AudioRecord.cpp | |
parent | 377165c24968b044faccaf366a2377fa32143e2f (diff) | |
download | frameworks_av-803b3e558022c6d0eb069308339dc84e6e8035dc.zip frameworks_av-803b3e558022c6d0eb069308339dc84e6e8035dc.tar.gz frameworks_av-803b3e558022c6d0eb069308339dc84e6e8035dc.tar.bz2 |
Event driven wake for AudioRecordThread notification changes
Used for setMarkerPosition and setPositionUpdatePeriod.
Change-Id: Iedd1be8725dea32bdba6908b78c5166780a66fec
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r-- | media/libmedia/AudioRecord.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 48abb96..84077ec 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -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; } @@ -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; } @@ -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); @@ -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); |