void AudioClock::SetPlaybackRateUnlocked(double aPlaybackRate) { // GetPositionInFramesUnlocked() asserts it owns the monitor int64_t position = mAudioStream->GetPositionInFramesUnlocked(); if (position > mPlaybackRateChangeOffset) { mOldBasePosition = mBasePosition; mBasePosition = GetPositionUnlocked(); mOldBaseOffset = mPlaybackRateChangeOffset; mBaseOffset = position; mPlaybackRateChangeOffset = mWritten; mOldOutRate = mOutRate; mOutRate = static_cast<int>(mInRate / aPlaybackRate); } else { // The playbackRate has been changed before the end of the latency // compensation phase. We don't update the mOld* variable. That way, the // last playbackRate set is taken into account. mBasePosition = GetPositionUnlocked(); mBaseOffset = position; mPlaybackRateChangeOffset = mWritten; mOutRate = static_cast<int>(mInRate / aPlaybackRate); } }
int64_t AudioClock::GetPositionInFrames() const { return (GetPositionUnlocked() * mInRate) / USECS_PER_S; }
uint64_t AudioClock::GetPositionInFrames() { return (GetPositionUnlocked() * mOutRate) / USECS_PER_S; }