Bug 864086 - Simplify AudioNode::DestroyMediaStream callers; r=padenot
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 22 Apr 2013 08:14:10 -0400
changeset 129479 0b45b14fd0c0c9bd01b6238b7d0b8bd3f6c9ce27
parent 129478 a4a6a7809457cb031b384189025e10a158f30582
child 129480 7ff57f0a926550c638c9cc6b9434712a549cabf5
push idunknown
push userunknown
push dateunknown
reviewerspadenot
bugs864086
milestone23.0a1
Bug 864086 - Simplify AudioNode::DestroyMediaStream callers; r=padenot
content/media/webaudio/AnalyserNode.cpp
content/media/webaudio/AnalyserNode.h
content/media/webaudio/AudioBufferSourceNode.cpp
content/media/webaudio/AudioNode.h
content/media/webaudio/BiquadFilterNode.cpp
content/media/webaudio/BiquadFilterNode.h
content/media/webaudio/DynamicsCompressorNode.cpp
content/media/webaudio/DynamicsCompressorNode.h
content/media/webaudio/GainNode.cpp
content/media/webaudio/GainNode.h
content/media/webaudio/PannerNode.cpp
content/media/webaudio/ScriptProcessorNode.cpp
content/media/webaudio/ScriptProcessorNode.h
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -72,21 +72,16 @@ AnalyserNode::AnalyserNode(AudioContext*
   , mSmoothingTimeConstant(.8)
   , mWriteIndex(0)
 {
   mStream = aContext->Graph()->CreateAudioNodeStream(new AnalyserNodeEngine(this),
                                                      MediaStreamGraph::INTERNAL_STREAM);
   AllocateBuffer();
 }
 
-AnalyserNode::~AnalyserNode()
-{
-  DestroyMediaStream();
-}
-
 JSObject*
 AnalyserNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return AnalyserNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AnalyserNode::SetFftSize(uint32_t aValue, ErrorResult& aRv)
@@ -238,22 +233,16 @@ AnalyserNode::ApplyBlackmanWindow(float*
 
   for (uint32_t i = 0; i < aSize; ++i) {
     double x = double(i) / aSize;
     double window = a0 - a1 * cos(2 * M_PI * x) + a2 * cos(4 * M_PI * x);
     aBuffer[i] *= window;
   }
 }
 
-void
-AnalyserNode::DestroyMediaStream()
-{
-  AudioNode::DestroyMediaStream();
-}
-
 bool
 AnalyserNode::AllocateBuffer()
 {
   bool result = true;
   if (mBuffer.Length() != mFFTSize) {
     result = mBuffer.SetLength(mFFTSize);
     if (result) {
       memset(mBuffer.Elements(), 0, sizeof(float) * mFFTSize);
--- a/content/media/webaudio/AnalyserNode.h
+++ b/content/media/webaudio/AnalyserNode.h
@@ -13,29 +13,26 @@ namespace mozilla {
 namespace dom {
 
 class AudioContext;
 
 class AnalyserNode : public AudioNode
 {
 public:
   explicit AnalyserNode(AudioContext* aContext);
-  virtual ~AnalyserNode();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
-  virtual void DestroyMediaStream() MOZ_OVERRIDE;
-
   void GetFloatFrequencyData(Float32Array& aArray);
   void GetByteFrequencyData(Uint8Array& aArray);
   void GetByteTimeDomainData(Uint8Array& aArray);
   uint32_t FftSize() const
   {
     return mFFTSize;
   }
   void SetFftSize(uint32_t aValue, ErrorResult& aRv);
--- a/content/media/webaudio/AudioBufferSourceNode.cpp
+++ b/content/media/webaudio/AudioBufferSourceNode.cpp
@@ -423,21 +423,19 @@ AudioBufferSourceNode::AudioBufferSource
   mStream = aContext->Graph()->CreateAudioNodeStream(
       new AudioBufferSourceNodeEngine(this, aContext->Destination()),
       MediaStreamGraph::INTERNAL_STREAM);
   mStream->AddMainThreadListener(this);
 }
 
 AudioBufferSourceNode::~AudioBufferSourceNode()
 {
-  // 
   if (Context()) {
     Context()->UnregisterAudioBufferSourceNode(this);
   }
-  DestroyMediaStream();
 }
 
 JSObject*
 AudioBufferSourceNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return AudioBufferSourceNodeBinding::Wrap(aCx, aScope, this);
 }
 
--- a/content/media/webaudio/AudioNode.h
+++ b/content/media/webaudio/AudioNode.h
@@ -73,18 +73,16 @@ private:
 class AudioNode : public nsDOMEventTargetHelper,
                   public EnableWebAudioCheck
 {
 public:
   explicit AudioNode(AudioContext* aContext);
   virtual ~AudioNode();
 
   // This should be idempotent (safe to call multiple times).
-  // This should be called in the destructor of every class that overrides
-  // this method.
   virtual void DestroyMediaStream()
   {
     if (mStream) {
       UnbindFromEngine();
       mStream->Destroy();
       mStream = nullptr;
     }
   }
--- a/content/media/webaudio/BiquadFilterNode.cpp
+++ b/content/media/webaudio/BiquadFilterNode.cpp
@@ -104,21 +104,16 @@ BiquadFilterNode::BiquadFilterNode(Audio
   , mQ(new AudioParam(this, SendQToStream, 1.f))
   , mGain(new AudioParam(this, SendGainToStream, 0.f))
 {
   BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
-BiquadFilterNode::~BiquadFilterNode()
-{
-  DestroyMediaStream();
-}
-
 JSObject*
 BiquadFilterNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return BiquadFilterNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 BiquadFilterNode::SetType(uint16_t aType, ErrorResult& aRv)
--- a/content/media/webaudio/BiquadFilterNode.h
+++ b/content/media/webaudio/BiquadFilterNode.h
@@ -28,17 +28,16 @@ MOZ_BEGIN_ENUM_CLASS(BiquadTypeEnum, uin
   ALLPASS = 7,
   Max = 7
 MOZ_END_ENUM_CLASS(BiquadTypeEnum)
 
 class BiquadFilterNode : public AudioNode
 {
 public:
   explicit BiquadFilterNode(AudioContext* aContext);
-  ~BiquadFilterNode();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BiquadFilterNode, AudioNode)
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
--- a/content/media/webaudio/DynamicsCompressorNode.cpp
+++ b/content/media/webaudio/DynamicsCompressorNode.cpp
@@ -122,21 +122,16 @@ DynamicsCompressorNode::DynamicsCompress
   , mAttack(new AudioParam(this, SendAttackToStream, 0.003f))
   , mRelease(new AudioParam(this, SendReleaseToStream, 0.25f))
 {
   DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
-DynamicsCompressorNode::~DynamicsCompressorNode()
-{
-  DestroyMediaStream();
-}
-
 JSObject*
 DynamicsCompressorNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return DynamicsCompressorNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 DynamicsCompressorNode::SendThresholdToStream(AudioNode* aNode)
--- a/content/media/webaudio/DynamicsCompressorNode.h
+++ b/content/media/webaudio/DynamicsCompressorNode.h
@@ -14,17 +14,16 @@ namespace mozilla {
 namespace dom {
 
 class AudioContext;
 
 class DynamicsCompressorNode : public AudioNode
 {
 public:
   explicit DynamicsCompressorNode(AudioContext* aContext);
-  ~DynamicsCompressorNode();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DynamicsCompressorNode, AudioNode)
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
--- a/content/media/webaudio/GainNode.cpp
+++ b/content/media/webaudio/GainNode.cpp
@@ -98,21 +98,16 @@ GainNode::GainNode(AudioContext* aContex
   : AudioNode(aContext)
   , mGain(new AudioParam(this, SendGainToStream, 1.0f))
 {
   GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
-GainNode::~GainNode()
-{
-  DestroyMediaStream();
-}
-
 JSObject*
 GainNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return GainNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 GainNode::SendGainToStream(AudioNode* aNode)
--- a/content/media/webaudio/GainNode.h
+++ b/content/media/webaudio/GainNode.h
@@ -14,17 +14,16 @@ namespace mozilla {
 namespace dom {
 
 class AudioContext;
 
 class GainNode : public AudioNode
 {
 public:
   explicit GainNode(AudioContext* aContext);
-  virtual ~GainNode();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GainNode, AudioNode)
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
 
   AudioParam* Gain() const
   {
--- a/content/media/webaudio/PannerNode.cpp
+++ b/content/media/webaudio/PannerNode.cpp
@@ -179,17 +179,16 @@ PannerNode::PannerNode(AudioContext* aCo
   Context()->Listener()->RegisterPannerNode(this);
 }
 
 PannerNode::~PannerNode()
 {
   if (Context()) {
     Context()->UnregisterPannerNode(this);
   }
-  DestroyMediaStream();
 }
 
 JSObject*
 PannerNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return PannerNodeBinding::Wrap(aCx, aScope, this);
 }
 
--- a/content/media/webaudio/ScriptProcessorNode.cpp
+++ b/content/media/webaudio/ScriptProcessorNode.cpp
@@ -352,21 +352,16 @@ ScriptProcessorNode::ScriptProcessorNode
                                   aContext->Destination(),
                                   BufferSize(),
                                   aNumberOfInputChannels);
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM,
                                                      aNumberOfInputChannels);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
-ScriptProcessorNode::~ScriptProcessorNode()
-{
-  DestroyMediaStream();
-}
-
 JSObject*
 ScriptProcessorNode::WrapObject(JSContext* aCx, JSObject* aScope)
 {
   return ScriptProcessorNodeBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
--- a/content/media/webaudio/ScriptProcessorNode.h
+++ b/content/media/webaudio/ScriptProcessorNode.h
@@ -22,17 +22,16 @@ class SharedBuffers;
 
 class ScriptProcessorNode : public AudioNode
 {
 public:
   ScriptProcessorNode(AudioContext* aContext,
                       uint32_t aBufferSize,
                       uint32_t aNumberOfInputChannels,
                       uint32_t aNumberOfOutputChannels);
-  virtual ~ScriptProcessorNode();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   IMPL_EVENT_HANDLER(audioprocess)
 
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE