예제 #1
0
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);
  }
}
예제 #2
0
int64_t AudioClock::GetPositionInFrames() const
{
    return (GetPositionUnlocked() * mInRate) / USECS_PER_S;
}
예제 #3
0
uint64_t AudioClock::GetPositionInFrames()
{
  return (GetPositionUnlocked() * mOutRate) / USECS_PER_S;
}