From 5e1f79baa5c7355effbd2c9183787d6604487908 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Tue, 14 Jan 2014 15:45:21 -0800 Subject: AudioRecord: fix unwanted overrun when restarting Apply the same fix to AudioRecord as this CL did for AudioTrack: > Change-Id: Id703f8dc092a6f07c905eee194054b4a978f979d Details: When restarting an AudioRecord from stopped state, it is necessary to force refresh of mRemainingFrames by processAudioBuffer() as the last read before stop() could be partial. No doing so will lead into unnecessary sleep before filling the non contiguous part of the buffer returned by obtainBuffer() when processAudioBuffer() is executed for the first time after start(). Change-Id: I0ff04648e990e97bad5ea3db5be0c4151250d5e1 --- media/libmedia/AudioRecord.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'media/libmedia/AudioRecord.cpp') diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index e39a475..3a0f222 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -289,6 +289,9 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, int triggerSession) // reset current position as seen by client to 0 mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition()); + // force refresh of remaining frames by processAudioBuffer() as last + // read before stop could be partial. + mRefreshRemaining = true; mNewPosition = mProxy->getPosition() + mUpdatePeriod; int32_t flags = android_atomic_acquire_load(&mCblk->mFlags); -- cgit v1.1