diff options
author | Glenn Kasten <gkasten@google.com> | 2013-07-30 14:36:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-07-30 14:36:20 +0000 |
commit | a30e75897934da2ce7b1b03bcb4b58e139d3e81e (patch) | |
tree | 78a398fee8ff72494debd7284ce0b43115412ad0 /services/audioflinger/Tracks.cpp | |
parent | fa319e6d918b84f93fb5457af5d1cca6421ac517 (diff) | |
parent | 9fdcb0a9497ca290bcf364b10868587b6bde3a34 (diff) | |
download | frameworks_av-a30e75897934da2ce7b1b03bcb4b58e139d3e81e.zip frameworks_av-a30e75897934da2ce7b1b03bcb4b58e139d3e81e.tar.gz frameworks_av-a30e75897934da2ce7b1b03bcb4b58e139d3e81e.tar.bz2 |
Merge "Fix theoretical race using TrackBase::sampleRate()"
Diffstat (limited to 'services/audioflinger/Tracks.cpp')
-rw-r--r-- | services/audioflinger/Tracks.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index 4ea1355..3e184b4 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -1172,10 +1172,12 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer( } } + uint32_t sr = sampleRate(); + // adjust the head buffer's PTS to reflect the portion of the head buffer // that has already been consumed int64_t effectivePTS = headLocalPTS + - ((head.position() / mFrameSize) * mLocalTimeFreq / sampleRate()); + ((head.position() / mFrameSize) * mLocalTimeFreq / sr); // Calculate the delta in samples between the head of the input buffer // queue and the start of the next output buffer that will be written. @@ -1207,7 +1209,7 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer( // the current output position is within this threshold, then we will // concatenate the next input samples to the previous output const int64_t kSampleContinuityThreshold = - (static_cast<int64_t>(sampleRate()) << 32) / 250; + (static_cast<int64_t>(sr) << 32) / 250; // if this is the first buffer of audio that we're emitting from this track // then it should be almost exactly on time. |