diff options
author | Andy Hung <hunga@google.com> | 2014-10-16 17:54:34 -0700 |
---|---|---|
committer | Rachad Alao <rachad@google.com> | 2014-10-17 20:32:54 +0000 |
commit | c2813e568aa476e03d159529c0af28c99536db8d (patch) | |
tree | 95bf50e96fd0bd69d892b5bf629220b9fc874f94 | |
parent | 9d2189ffcf1142b2948ce3065c32521ed7d966c4 (diff) | |
download | frameworks_av-c2813e568aa476e03d159529c0af28c99536db8d.zip frameworks_av-c2813e568aa476e03d159529c0af28c99536db8d.tar.gz frameworks_av-c2813e568aa476e03d159529c0af28c99536db8d.tar.bz2 |
Fix AudioTrack retrograde getPosition when restoring tracks
mReleased represents the number of frames written to the
track, but was cleared on start() causing a mismatch if the
client wrote to the track before starting. Moved the clearing
to entering the STATE_STOPPED or STATE_FLUSHED state.
Bug: 18017947
Bug: 18022276
Change-Id: I3788c98c4c3c4d9cc004378432797b3f3138e22e
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 8e0704f..0a89fbb 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -464,7 +464,6 @@ status_t AudioTrack::start() if (previousState == STATE_STOPPED || previousState == STATE_FLUSHED) { // reset current position as seen by client to 0 mPosition = 0; - mReleased = 0; // For offloaded tracks, we don't know if the hardware counters are really zero here, // since the flush is asynchronous and stop may not fully drain. // We save the time when the track is started to later verify whether @@ -529,6 +528,7 @@ void AudioTrack::stop() mState = STATE_STOPPING; } else { mState = STATE_STOPPED; + mReleased = 0; } mProxy->interrupt(); @@ -585,6 +585,7 @@ void AudioTrack::flush_l() mRefreshRemaining = true; mState = STATE_FLUSHED; + mReleased = 0; if (isOffloaded_l()) { mProxy->interrupt(); } @@ -1625,6 +1626,7 @@ nsecs_t AudioTrack::processAudioBuffer() waitStreamEnd = mState == STATE_STOPPING; if (waitStreamEnd) { mState = STATE_STOPPED; + mReleased = 0; } } if (waitStreamEnd && status != DEAD_OBJECT) { @@ -1873,6 +1875,7 @@ status_t AudioTrack::restoreTrack_l(const char *from) if (result != NO_ERROR) { ALOGW("restoreTrack_l() failed status %d", result); mState = STATE_STOPPED; + mReleased = 0; } return result; |