bug 1207003 fetch stream position once instead of three times r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 18 Sep 2015 14:27:03 +1200
changeset 263983 ade3b46614b0a8b3f96ab8440c0bcbf497e9edd4
parent 263982 b6ef4e4af23ad722085ea78d29c316d11efaa517
child 263984 2fe45d4590e580cabf0486c91c6e62a68b700164
push id29423
push userkwierso@gmail.com
push dateWed, 23 Sep 2015 20:13:47 +0000
treeherdermozilla-central@bcbfa80a0dc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1207003
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1207003 fetch stream position once instead of three times r=padenot
dom/media/webaudio/AudioBufferSourceNode.cpp
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -429,30 +429,30 @@ public:
     // Make sure the playback rate and the doppler shift are something
     // our resampler can work with.
     int32_t rate = WebAudioUtils::
       TruncateFloatToInt<int32_t>(mSource->SampleRate() /
                                   (computedPlaybackRate * mDopplerShift));
     return rate ? rate : mBufferSampleRate;
   }
 
-  void UpdateSampleRateIfNeeded(uint32_t aChannels)
+  void UpdateSampleRateIfNeeded(uint32_t aChannels, StreamTime aStreamPosition)
   {
     float playbackRate;
     float detune;
 
     if (mPlaybackRateTimeline.HasSimpleValue()) {
       playbackRate = mPlaybackRateTimeline.GetValue();
     } else {
-      playbackRate = mPlaybackRateTimeline.GetValueAtTime(mSource->GetCurrentPosition());
+      playbackRate = mPlaybackRateTimeline.GetValueAtTime(aStreamPosition);
     }
     if (mDetuneTimeline.HasSimpleValue()) {
       detune = mDetuneTimeline.GetValue();
     } else {
-      detune = mDetuneTimeline.GetValueAtTime(mSource->GetCurrentPosition());
+      detune = mDetuneTimeline.GetValueAtTime(aStreamPosition);
     }
     if (playbackRate <= 0 || mozilla::IsNaN(playbackRate)) {
       playbackRate = 1.0f;
     }
 
     detune = std::min(std::max(-1200.f, detune), 1200.f);
 
     int32_t outRate = ComputeFinalOutSampleRate(playbackRate, detune);
@@ -477,17 +477,17 @@ public:
         (!mLoop && mBufferPosition >= mBufferEnd && !mRemainingResamplerTail)) {
       *aFinished = true;
       aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
       return;
     }
 
     uint32_t channels = mBuffer ? mBuffer->GetChannels() : 0;
 
-    UpdateSampleRateIfNeeded(channels);
+    UpdateSampleRateIfNeeded(channels, streamPosition);
 
     uint32_t written = 0;
     while (written < WEBAUDIO_BLOCK_SIZE) {
       if (mStop != STREAM_TIME_MAX &&
           streamPosition >= mStop) {
         FillWithZeroes(aOutput, channels, &written, &streamPosition, STREAM_TIME_MAX);
         continue;
       }