Bug 873553 - Part 3: Rename AudioBufferSourceNodeEngine::mSampleRate to mBufferSampleRate; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 24 May 2013 13:09:51 -0400
changeset 132923 34b39b3d4773ee12206b8c2cb34cd9da339897f2
parent 132922 738b82a250374580068213fd122f0a54af1e5a33
child 132924 59f25c1db41453d11620888b9499ebce5eb0512a
push id24727
push userphilringnalda@gmail.com
push dateSun, 26 May 2013 04:02:45 +0000
treeherdermozilla-central@0fed3377c839 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs873553
milestone24.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 873553 - Part 3: Rename AudioBufferSourceNodeEngine::mSampleRate to mBufferSampleRate; r=roc
content/media/webaudio/AudioBufferSourceNode.cpp
--- a/content/media/webaudio/AudioBufferSourceNode.cpp
+++ b/content/media/webaudio/AudioBufferSourceNode.cpp
@@ -49,17 +49,17 @@ public:
   explicit AudioBufferSourceNodeEngine(AudioNode* aNode,
                                        AudioDestinationNode* aDestination) :
     AudioNodeEngine(aNode),
     GainProcessor(aDestination),
     mStart(0), mStop(TRACK_TICKS_MAX),
     mResampler(nullptr),
     mOffset(0), mDuration(0),
     mLoopStart(0), mLoopEnd(0),
-    mSampleRate(0), mPosition(0), mChannels(0), mPlaybackRate(1.0f),
+    mBufferSampleRate(0), mPosition(0), mChannels(0), mPlaybackRate(1.0f),
     mDopplerShift(1.0f),
     mPlaybackRateTimeline(1.0f), mLoop(false)
   {}
 
   ~AudioBufferSourceNodeEngine()
   {
     if (mResampler) {
       speex_resampler_destroy(mResampler);
@@ -71,17 +71,17 @@ public:
     switch (aIndex) {
     case AudioBufferSourceNode::PLAYBACKRATE:
       mPlaybackRateTimeline = aValue;
       // If we have a simple value that is 1.0 (i.e. intrinsic speed), and our
       // input buffer is already at the ideal audio rate, and we have a
       // resampler, we can release it.
       if (mResampler && mPlaybackRateTimeline.HasSimpleValue() &&
           mPlaybackRateTimeline.GetValue() == 1.0 &&
-          mSampleRate == IdealAudioRate()) {
+          mBufferSampleRate == IdealAudioRate()) {
         speex_resampler_destroy(mResampler);
         mResampler = nullptr;
       }
       WebAudioUtils::ConvertAudioParamToTicks(mPlaybackRateTimeline, nullptr, mDestination);
       break;
     case AudioBufferSourceNode::GAIN:
       SetGainParameter(aValue);
       break;
@@ -106,17 +106,17 @@ public:
         break;
       default:
         NS_ERROR("Bad AudioBufferSourceNodeEngine double parameter.");
     };
   }
   virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam)
   {
     switch (aIndex) {
-    case AudioBufferSourceNode::SAMPLE_RATE: mSampleRate = aParam; break;
+    case AudioBufferSourceNode::SAMPLE_RATE: mBufferSampleRate = aParam; break;
     case AudioBufferSourceNode::OFFSET: mOffset = aParam; break;
     case AudioBufferSourceNode::DURATION: mDuration = aParam; break;
     case AudioBufferSourceNode::LOOP: mLoop = !!aParam; break;
     case AudioBufferSourceNode::LOOPSTART: mLoopStart = aParam; break;
     case AudioBufferSourceNode::LOOPEND: mLoopEnd = aParam; break;
     default:
       NS_ERROR("Bad AudioBufferSourceNodeEngine Int32Parameter");
     }
@@ -130,17 +130,17 @@ public:
   {
     if (aChannels != mChannels && mResampler) {
       speex_resampler_destroy(mResampler);
       mResampler = nullptr;
     }
 
     if (!mResampler) {
       mChannels = aChannels;
-      mResampler = speex_resampler_init(mChannels, mSampleRate,
+      mResampler = speex_resampler_init(mChannels, mBufferSampleRate,
                                         ComputeFinalOutSampleRate(),
                                         SPEEX_RESAMPLER_QUALITY_DEFAULT,
                                         nullptr);
     }
     return mResampler;
   }
 
   // Borrow a full buffer of size WEBAUDIO_BLOCK_SIZE from the source buffer
@@ -169,29 +169,29 @@ public:
     for (uint32_t i = 0; i < aChannels; ++i) {
       float* baseChannelData = static_cast<float*>(const_cast<void*>(aOutput->mChannelData[i]));
       memcpy(baseChannelData + aBufferOffset,
              mBuffer->GetData(i) + aSourceOffset,
              aNumberOfFrames * sizeof(float));
     }
   }
 
-  // Resamples input data to an output buffer, according to |mSampleRate| and
+  // Resamples input data to an output buffer, according to |mBufferSampleRate| and
   // the playbackRate.
   // The number of frames consumed/produced depends on the amount of space
   // remaining in both the input and output buffer, and the playback rate (that
   // is, the ratio between the output samplerate and the input samplerate).
   void CopyFromInputBufferWithResampling(AudioChunk* aOutput,
                                          uint32_t aChannels,
                                          uintptr_t aSourceOffset,
                                          uintptr_t aBufferOffset,
                                          uint32_t aAvailableInInputBuffer,
                                          uint32_t& aFramesRead,
                                          uint32_t& aFramesWritten) {
-    double finalPlaybackRate = static_cast<double>(mSampleRate) / ComputeFinalOutSampleRate();
+    double finalPlaybackRate = static_cast<double>(mBufferSampleRate) / ComputeFinalOutSampleRate();
     uint32_t availableInOuputBuffer = WEBAUDIO_BLOCK_SIZE - aBufferOffset;
     uint32_t inputSamples, outputSamples;
 
     // Check if we are short on input or output buffer.
     if (aAvailableInInputBuffer < availableInOuputBuffer * finalPlaybackRate) {
       outputSamples = ceil(aAvailableInInputBuffer / finalPlaybackRate);
       inputSamples = aAvailableInInputBuffer;
     } else {
@@ -313,17 +313,17 @@ public:
     return WebAudioUtils::TruncateFloatToInt<uint32_t>(IdealAudioRate() /
                                                        (mPlaybackRate * mDopplerShift));
   }
 
   bool ShouldResample() const
   {
     return !(mPlaybackRate == 1.0 &&
              mDopplerShift == 1.0 &&
-             mSampleRate == IdealAudioRate());
+             mBufferSampleRate == IdealAudioRate());
   }
 
   void UpdateSampleRateIfNeeded(AudioNodeStream* aStream, uint32_t aChannels)
   {
     if (mPlaybackRateTimeline.HasSimpleValue()) {
       mPlaybackRate = mPlaybackRateTimeline.GetValue();
     } else {
       mPlaybackRate = mPlaybackRateTimeline.GetValueAtTime(aStream->GetCurrentPosition());
@@ -422,17 +422,17 @@ public:
   TrackTicks mStart;
   TrackTicks mStop;
   nsRefPtr<ThreadSharedFloatArrayBufferList> mBuffer;
   SpeexResamplerState* mResampler;
   int32_t mOffset;
   int32_t mDuration;
   int32_t mLoopStart;
   int32_t mLoopEnd;
-  int32_t mSampleRate;
+  int32_t mBufferSampleRate;
   uint32_t mPosition;
   uint32_t mChannels;
   float mPlaybackRate;
   float mDopplerShift;
   AudioParamTimeline mPlaybackRateTimeline;
   bool mLoop;
 };