summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-08-28 10:23:01 -0700
committerEric Laurent <elaurent@google.com>2013-08-28 10:30:08 -0700
commitec9a032c2e104ab1e3b5bf73e69dab1408ced0ad (patch)
treede4b71e9f43dc9a3a46aec43bc08f910ad5b8127
parent3bd3690fb0a423f9d0ba635e8db1c148ac9e93fc (diff)
downloadframeworks_av-ec9a032c2e104ab1e3b5bf73e69dab1408ced0ad.zip
frameworks_av-ec9a032c2e104ab1e3b5bf73e69dab1408ced0ad.tar.gz
frameworks_av-ec9a032c2e104ab1e3b5bf73e69dab1408ced0ad.tar.bz2
AudioTrack: fix unwanted underrun when restarting
When restarting an AudioTrack from stopped state, it is necessary to force refresh of mRemainingFrames by processAudioBuffer() as the last write 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: Id703f8dc092a6f07c905eee194054b4a978f979d
-rw-r--r--media/libmedia/AudioTrack.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index dd0ec73..214e789 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -387,6 +387,9 @@ status_t AudioTrack::start()
if (previousState == STATE_STOPPED || previousState == STATE_FLUSHED) {
// reset current position as seen by client to 0
mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition());
+ // force refresh of remaining frames by processAudioBuffer() as last
+ // write before stop could be partial.
+ mRefreshRemaining = true;
}
mNewPosition = mProxy->getPosition() + mUpdatePeriod;
int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->mFlags);