diff options
author | Glenn Kasten <gkasten@google.com> | 2014-09-30 01:44:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-30 01:44:18 +0000 |
commit | 955e24d3a8e218d4711cabc6558781e095011132 (patch) | |
tree | 1b27aa45a2224cbdc9e247935c811e8ab62af40a /services/audioflinger/Tracks.cpp | |
parent | 6c7ae72f0eccf456744474785afd25f9e205881c (diff) | |
parent | 54464ba861aaafd11ee5645f5d1ecd1171c6e9fe (diff) | |
download | frameworks_av-955e24d3a8e218d4711cabc6558781e095011132.zip frameworks_av-955e24d3a8e218d4711cabc6558781e095011132.tar.gz frameworks_av-955e24d3a8e218d4711cabc6558781e095011132.tar.bz2 |
Merge "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp" into lmp-dev
Diffstat (limited to 'services/audioflinger/Tracks.cpp')
-rw-r--r-- | services/audioflinger/Tracks.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index 75190f3..b2d53cf 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -898,7 +898,15 @@ status_t AudioFlinger::PlaybackThread::Track::getTimestamp(AudioTimestamp& times uint32_t unpresentedFrames = ((int64_t) playbackThread->mLatchQ.mUnpresentedFrames * mSampleRate) / playbackThread->mSampleRate; - uint32_t framesWritten = mAudioTrackServerProxy->framesReleased(); + // FIXME Since we're using a raw pointer as the key, it is theoretically possible + // for a brand new track to share the same address as a recently destroyed + // track, and thus for us to get the frames released of the wrong track. + // It is unlikely that we would be able to call getTimestamp() so quickly + // right after creating a new track. Nevertheless, the index here should + // be changed to something that is unique. Or use a completely different strategy. + ssize_t i = playbackThread->mLatchQ.mFramesReleased.indexOfKey(this); + uint32_t framesWritten = i >= 0 ? + playbackThread->mLatchQ.mFramesReleased[i] : mAudioTrackServerProxy->framesReleased(); bool checkPreviousTimestamp = mPreviousValid && framesWritten >= mPreviousFramesWritten; if (framesWritten < unpresentedFrames) { mPreviousValid = false; |