Bug 864083 - Cleanup AudioBuffer::GetThreadSharedChannelsForRate; r=padenot
☠☠ backed out by 8a76117e496c ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 22 Apr 2013 08:12:45 -0400
changeset 129472 ab61f99fb584d059d5133edf639662dc80b40ce0
parent 129471 e2f4b1c75ff6da7d390a278418177c692e2c68f9
child 129473 3b8fdfefcf5ea2c621d2642bcadb56c79f56717f
push idunknown
push userunknown
push dateunknown
reviewerspadenot
bugs864083
milestone23.0a1
Bug 864083 - Cleanup AudioBuffer::GetThreadSharedChannelsForRate; r=padenot
content/media/webaudio/AudioBuffer.cpp
content/media/webaudio/AudioBuffer.h
content/media/webaudio/AudioBufferSourceNode.cpp
content/media/webaudio/ScriptProcessorNode.cpp
--- a/content/media/webaudio/AudioBuffer.cpp
+++ b/content/media/webaudio/AudioBuffer.cpp
@@ -160,24 +160,21 @@ StealJSArrayDataIntoThreadSharedFloatArr
       result->Clear();
       return result.forget();
     }
   }
   return result.forget();
 }
 
 ThreadSharedFloatArrayBufferList*
-AudioBuffer::GetThreadSharedChannelsForRate(JSContext* aJSContext, uint32_t* aRate,
-                                            uint32_t* aLength)
+AudioBuffer::GetThreadSharedChannelsForRate(JSContext* aJSContext)
 {
   if (!mSharedChannels) {
     // Steal JS data
     mSharedChannels =
       StealJSArrayDataIntoThreadSharedFloatArrayBufferList(aJSContext, mJSChannels);
   }
 
-  *aLength = mLength;
-  *aRate = mSampleRate;
   return mSharedChannels;
 }
 
 }
 }
--- a/content/media/webaudio/AudioBuffer.h
+++ b/content/media/webaudio/AudioBuffer.h
@@ -84,22 +84,19 @@ public:
 
   JSObject* GetChannelData(uint32_t aChannel) const {
     // Doesn't perform bounds checking
     MOZ_ASSERT(aChannel < mJSChannels.Length());
     return mJSChannels[aChannel];
   }
 
   /**
-   * Returns a ThreadSharedFloatArrayBufferList containing the sample data
-   * at aRate. Sets *aLength to the number of samples per channel.
+   * Returns a ThreadSharedFloatArrayBufferList containing the sample data.
    */
-  ThreadSharedFloatArrayBufferList* GetThreadSharedChannelsForRate(JSContext* aContext,
-                                                                   uint32_t* aRate,
-                                                                   uint32_t* aLength);
+  ThreadSharedFloatArrayBufferList* GetThreadSharedChannelsForRate(JSContext* aContext);
 
   // aContents should either come from JS_AllocateArrayBufferContents or
   // JS_StealArrayBufferContents.
   void SetChannelDataFromArrayBufferContents(JSContext* aJSContext,
                                              uint32_t aChannel,
                                              void* aContents);
 
   // This replaces the contents of the JS array for the given channel.
--- a/content/media/webaudio/AudioBufferSourceNode.cpp
+++ b/content/media/webaudio/AudioBufferSourceNode.cpp
@@ -452,20 +452,20 @@ AudioBufferSourceNode::Start(JSContext* 
   mStartCalled = true;
 
   AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
   if (!mBuffer || !ns) {
     // Nothing to play, or we're already dead for some reason
     return;
   }
 
-  uint32_t rate;
-  uint32_t lengthSamples;
+  float rate = mBuffer->SampleRate();
+  int32_t lengthSamples = mBuffer->Length();
   nsRefPtr<ThreadSharedFloatArrayBufferList> data =
-    mBuffer->GetThreadSharedChannelsForRate(aCx, &rate, &lengthSamples);
+    mBuffer->GetThreadSharedChannelsForRate(aCx);
   double length = double(lengthSamples) / rate;
   double offset = std::max(0.0, aOffset);
   double endOffset = aDuration.WasPassed() ?
       std::min(aOffset + aDuration.Value(), length) : length;
 
   if (offset >= endOffset) {
     return;
   }
--- a/content/media/webaudio/ScriptProcessorNode.cpp
+++ b/content/media/webaudio/ScriptProcessorNode.cpp
@@ -8,17 +8,16 @@
 #include "mozilla/dom/ScriptProcessorNodeBinding.h"
 #include "AudioBuffer.h"
 #include "AudioDestinationNode.h"
 #include "AudioNodeEngine.h"
 #include "AudioNodeStream.h"
 #include "AudioProcessingEvent.h"
 #include "WebAudioUtils.h"
 #include "mozilla/Mutex.h"
-#include "mozilla/unused.h"
 #include "mozilla/PodOperations.h"
 #include <deque>
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ScriptProcessorNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
@@ -299,20 +298,17 @@ private:
           event->InitEvent(inputBuffer,
                            mInputChannels.Length(),
                            mPlaybackTime);
           node->DispatchTrustedEvent(event);
 
           // Steal the output buffers
           nsRefPtr<ThreadSharedFloatArrayBufferList> output;
           if (event->HasOutputBuffer()) {
-            uint32_t rate, length;
-            output = event->OutputBuffer()->GetThreadSharedChannelsForRate(cx, &rate, &length);
-            unused << rate;
-            unused << length;
+            output = event->OutputBuffer()->GetThreadSharedChannelsForRate(cx);
           }
 
           // Append it to our output buffer queue
           node->GetSharedBuffers()->FinishProducingOutputBuffer(output, node->BufferSize());
         }
         return NS_OK;
       }
     private: