summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-01-14 15:45:21 -0800
committerGlenn Kasten <gkasten@google.com>2014-01-16 11:53:03 -0800
commit5e1f79baa5c7355effbd2c9183787d6604487908 (patch)
treebec5fbb865e9c840a092ab18e0872f72ac787288 /media/libmedia/AudioRecord.cpp
parenta238b9b43a2b8dac60e0fd8700daa6cd4f644547 (diff)
downloadframeworks_av-5e1f79baa5c7355effbd2c9183787d6604487908.zip
frameworks_av-5e1f79baa5c7355effbd2c9183787d6604487908.tar.gz
frameworks_av-5e1f79baa5c7355effbd2c9183787d6604487908.tar.bz2
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
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r--media/libmedia/AudioRecord.cpp3
1 files changed, 3 insertions, 0 deletions
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);