bug 1179662 specify AudioNode::mStream as AudioNodeStream r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 02 Jul 2015 17:36:07 +1200
changeset 251257 b6672a6212e3a916d3147251d4b06fb30cf35e94
parent 251256 950835c3c86f6be445f9709b8d92d71c3af63f8e
child 251258 23b96ee6b007160c5df487cf650c59765ea499ef
push id28991
push usercbook@mozilla.com
push dateFri, 03 Jul 2015 10:08:14 +0000
treeherdermozilla-central@b6a79816ee71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1179662
milestone42.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 1179662 specify AudioNode::mStream as AudioNodeStream r=padenot
dom/media/MediaRecorder.cpp
dom/media/webaudio/AudioBufferSourceNode.cpp
dom/media/webaudio/AudioDestinationNode.cpp
dom/media/webaudio/AudioNode.cpp
dom/media/webaudio/AudioNode.h
dom/media/webaudio/BiquadFilterNode.cpp
dom/media/webaudio/ConvolverNode.cpp
dom/media/webaudio/DelayNode.cpp
dom/media/webaudio/DynamicsCompressorNode.cpp
dom/media/webaudio/GainNode.cpp
dom/media/webaudio/OscillatorNode.cpp
dom/media/webaudio/ScriptProcessorNode.cpp
dom/media/webaudio/StereoPannerNode.cpp
dom/media/webaudio/WaveShaperNode.cpp
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1135,17 +1135,17 @@ MediaRecorder::NotifyOwnerDocumentActivi
 
 MediaStream*
 MediaRecorder::GetSourceMediaStream()
 {
   if (mDOMStream != nullptr) {
     return mDOMStream->GetStream();
   }
   MOZ_ASSERT(mAudioNode != nullptr);
-  return mPipeStream != nullptr ? mPipeStream : mAudioNode->Stream();
+  return mPipeStream != nullptr ? mPipeStream.get() : mAudioNode->Stream();
 }
 
 nsIPrincipal*
 MediaRecorder::GetSourcePrincipal()
 {
   if (mDOMStream != nullptr) {
     return mDOMStream->GetPrincipal();
   }
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -56,17 +56,17 @@ public:
     AudioNodeEngine(aNode),
     mStart(0.0), mBeginProcessing(0),
     mStop(STREAM_TIME_MAX),
     mResampler(nullptr), mRemainingResamplerTail(0),
     mBufferEnd(0),
     mLoopStart(0), mLoopEnd(0),
     mBufferSampleRate(0), mBufferPosition(0), mChannels(0),
     mDopplerShift(1.0f),
-    mDestination(static_cast<AudioNodeStream*>(aDestination->Stream())),
+    mDestination(aDestination->Stream()),
     mPlaybackRateTimeline(1.0f),
     mDetuneTimeline(0.0f),
     mLoop(false)
   {}
 
   ~AudioBufferSourceNodeEngine()
   {
     if (mResampler) {
@@ -555,17 +555,17 @@ AudioBufferSourceNode::AudioBufferSource
   // mOffset and mDuration are initialized in Start().
   , mPlaybackRate(new AudioParam(this, SendPlaybackRateToStream, 1.0f, "playbackRate"))
   , mDetune(new AudioParam(this, SendDetuneToStream, 0.0f, "detune"))
   , mLoop(false)
   , mStartCalled(false)
 {
   AudioBufferSourceNodeEngine* engine = new AudioBufferSourceNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::SOURCE_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*>(mStream.get()));
+  engine->SetSourceStream(mStream);
   mStream->AddMainThreadListener(this);
 }
 
 AudioBufferSourceNode::~AudioBufferSourceNode()
 {
 }
 
 void
@@ -616,17 +616,17 @@ AudioBufferSourceNode::Start(double aWhe
   }
 
   if (mStartCalled) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
   mStartCalled = true;
 
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
+  AudioNodeStream* ns = mStream;
   if (!ns) {
     // Nothing to play, or we're already dead for some reason
     return;
   }
 
   // Remember our arguments so that we can use them when we get a new buffer.
   mOffset = aOffset;
   mDuration = aDuration.WasPassed() ? aDuration.Value()
@@ -641,18 +641,18 @@ AudioBufferSourceNode::Start(double aWhe
   if (aWhen > 0.0) {
     ns->SetDoubleParameter(START, mContext->DOMTimeToStreamTime(aWhen));
   }
 }
 
 void
 AudioBufferSourceNode::SendBufferParameterToStream(JSContext* aCx)
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  if (!mStream) {
+  AudioNodeStream* ns = mStream;
+  if (!ns) {
     return;
   }
 
   if (mBuffer) {
     float rate = mBuffer->SampleRate();
     nsRefPtr<ThreadSharedFloatArrayBufferList> data =
       mBuffer->GetThreadSharedChannelsForRate(aCx);
     ns->SetBuffer(data.forget());
@@ -700,17 +700,17 @@ AudioBufferSourceNode::Stop(double aWhen
     return;
   }
 
   if (!mStartCalled) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
+  AudioNodeStream* ns = mStream;
   if (!ns || !Context()) {
     // We've already stopped and had our stream shut down
     return;
   }
 
   ns->SetStreamTimeParameter(STOP, Context(), std::max(0.0, aWhen));
 }
 
--- a/dom/media/webaudio/AudioDestinationNode.cpp
+++ b/dom/media/webaudio/AudioDestinationNode.cpp
@@ -364,17 +364,17 @@ AudioDestinationNode::AudioDestinationNo
                                                              aLength, aSampleRate) :
                             static_cast<AudioNodeEngine*>(new DestinationNodeEngine(this));
 
   mStream = graph->CreateAudioNodeStream(engine, MediaStreamGraph::EXTERNAL_STREAM);
   mStream->AddMainThreadListener(this);
   mStream->AddAudioOutput(&gWebAudioOutputKey);
 
   if (!aIsOffline) {
-    graph->NotifyWhenGraphStarted(mStream->AsAudioNodeStream());
+    graph->NotifyWhenGraphStarted(mStream);
   }
 
   if (aChannel != AudioChannel::Normal) {
     ErrorResult rv;
     SetMozAudioChannelType(aChannel, rv);
   }
 }
 
@@ -433,19 +433,18 @@ AudioDestinationNode::NotifyMainThreadSt
       NS_NewRunnableMethod(this, &AudioDestinationNode::FireOfflineCompletionEvent);
     NS_DispatchToCurrentThread(runnable);
   }
 }
 
 void
 AudioDestinationNode::FireOfflineCompletionEvent()
 {
-  AudioNodeStream* stream = static_cast<AudioNodeStream*>(Stream());
   OfflineDestinationNodeEngine* engine =
-    static_cast<OfflineDestinationNodeEngine*>(stream->Engine());
+    static_cast<OfflineDestinationNodeEngine*>(Stream()->Engine());
   engine->FireOfflineCompletionEvent(this);
 }
 
 void
 AudioDestinationNode::ResolvePromise(AudioBuffer* aRenderedBuffer)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mIsOffline);
--- a/dom/media/webaudio/AudioNode.cpp
+++ b/dom/media/webaudio/AudioNode.cpp
@@ -268,51 +268,47 @@ AudioNode::Connect(AudioParam& aDestinat
   MOZ_ASSERT(aOutput <= UINT16_MAX, "Unexpected large output port number");
   input->mStreamPort = ps->AllocateInputPort(mStream, MediaInputPort::FLAG_BLOCK_INPUT,
                                              0, static_cast<uint16_t>(aOutput));
 }
 
 void
 AudioNode::SendDoubleParameterToStream(uint32_t aIndex, double aValue)
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "How come we don't have a stream here?");
-  ns->SetDoubleParameter(aIndex, aValue);
+  MOZ_ASSERT(mStream, "How come we don't have a stream here?");
+  mStream->SetDoubleParameter(aIndex, aValue);
 }
 
 void
 AudioNode::SendInt32ParameterToStream(uint32_t aIndex, int32_t aValue)
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "How come we don't have a stream here?");
-  ns->SetInt32Parameter(aIndex, aValue);
+  MOZ_ASSERT(mStream, "How come we don't have a stream here?");
+  mStream->SetInt32Parameter(aIndex, aValue);
 }
 
 void
 AudioNode::SendThreeDPointParameterToStream(uint32_t aIndex, const ThreeDPoint& aValue)
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "How come we don't have a stream here?");
-  ns->SetThreeDPointParameter(aIndex, aValue);
+  MOZ_ASSERT(mStream, "How come we don't have a stream here?");
+  mStream->SetThreeDPointParameter(aIndex, aValue);
 }
 
 void
 AudioNode::SendChannelMixingParametersToStream()
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "How come we don't have a stream here?");
-  ns->SetChannelMixingParameters(mChannelCount, mChannelCountMode,
+  MOZ_ASSERT(mStream, "How come we don't have a stream here?");
+  mStream->SetChannelMixingParameters(mChannelCount, mChannelCountMode,
                                  mChannelInterpretation);
 }
 
 void
 AudioNode::SendTimelineParameterToStream(AudioNode* aNode, uint32_t aIndex,
                                          const AudioParamTimeline& aValue)
 {
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(aNode->mStream.get());
+  AudioNodeStream* ns = aNode->mStream;
   MOZ_ASSERT(ns, "How come we don't have a stream here?");
   ns->SetTimelineParameter(aIndex, aValue);
 }
 
 void
 AudioNode::Disconnect(uint32_t aOutput, ErrorResult& aRv)
 {
   if (aOutput >= NumberOfOutputs()) {
@@ -386,17 +382,17 @@ void
 AudioNode::DestroyMediaStream()
 {
   if (mStream) {
     {
       // Remove the node reference on the engine, and take care to not
       // hold the lock when the stream gets destroyed, because that will
       // cause the engine to be destroyed as well, and we don't want to
       // be holding the lock as we're trying to destroy it!
-      AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
+      AudioNodeStream* ns = mStream;
       MutexAutoLock lock(ns->Engine()->NodeMutex());
       MOZ_ASSERT(ns, "How come we don't have a stream here?");
       MOZ_ASSERT(ns->Engine()->Node() == this, "Invalid node reference");
       ns->Engine()->ClearNode();
     }
 
     mStream->Destroy();
     mStream = nullptr;
@@ -426,15 +422,14 @@ AudioNode::PassThrough() const
   return mPassThrough;
 }
 
 void
 AudioNode::SetPassThrough(bool aPassThrough)
 {
   MOZ_ASSERT(NumberOfInputs() <= 1 && NumberOfOutputs() == 1);
   mPassThrough = aPassThrough;
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "How come we don't have a stream here?");
-  ns->SetPassThrough(mPassThrough);
+  MOZ_ASSERT(mStream, "How come we don't have a stream here?");
+  mStream->SetPassThrough(mPassThrough);
 }
 
 }
 }
--- a/dom/media/webaudio/AudioNode.h
+++ b/dom/media/webaudio/AudioNode.h
@@ -162,17 +162,17 @@ public:
     nsRefPtr<MediaInputPort> mStreamPort;
     // The index of the input port this node feeds into.
     // This is not used for connections to AudioParams.
     uint32_t mInputPort;
     // The index of the output port this node comes out of.
     uint32_t mOutputPort;
   };
 
-  MediaStream* Stream() { return mStream; }
+  AudioNodeStream* Stream() { return mStream; }
 
   const nsTArray<InputNode>& InputNodes() const
   {
     return mInputNodes;
   }
   const nsTArray<nsRefPtr<AudioNode> >& OutputNodes() const
   {
     return mOutputNodes;
@@ -216,18 +216,17 @@ protected:
   static void SendTimelineParameterToStream(AudioNode* aNode, uint32_t aIndex,
                                             const AudioParamTimeline& aValue);
 
 private:
   nsRefPtr<AudioContext> mContext;
 
 protected:
   // Must be set in the constructor. Must not be null unless finished.
-  // If MaxNumberOfInputs() is > 0, then mStream must be a ProcessedMediaStream.
-  nsRefPtr<MediaStream> mStream;
+  nsRefPtr<AudioNodeStream> mStream;
 
 private:
   // For every InputNode, there is a corresponding entry in mOutputNodes of the
   // InputNode's mInputNode.
   nsTArray<InputNode> mInputNodes;
   // For every mOutputNode entry, there is a corresponding entry in mInputNodes
   // of the mOutputNode entry. We won't necessarily be able to identify the
   // exact matching entry, since mOutputNodes doesn't include the port
--- a/dom/media/webaudio/BiquadFilterNode.cpp
+++ b/dom/media/webaudio/BiquadFilterNode.cpp
@@ -74,17 +74,17 @@ SetParamsOnBiquad(WebCore::Biquad& aBiqu
 }
 
 class BiquadFilterNodeEngine final : public AudioNodeEngine
 {
 public:
   BiquadFilterNodeEngine(AudioNode* aNode, AudioDestinationNode* aDestination)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     // Keep the default values in sync with the default values in
     // BiquadFilterNode::BiquadFilterNode
     , mType(BiquadFilterType::Lowpass)
     , mFrequency(350.f)
     , mDetune(0.f)
     , mQ(1.f)
     , mGain(0.f)
   {
@@ -246,17 +246,17 @@ BiquadFilterNode::BiquadFilterNode(Audio
   , mType(BiquadFilterType::Lowpass)
   , mFrequency(new AudioParam(this, SendFrequencyToStream, 350.f, "frequency"))
   , mDetune(new AudioParam(this, SendDetuneToStream, 0.f, "detune"))
   , mQ(new AudioParam(this, SendQToStream, 1.f, "Q"))
   , mGain(new AudioParam(this, SendGainToStream, 0.f, "gain"))
 {
   BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 BiquadFilterNode::~BiquadFilterNode()
 {
 }
 
 size_t
 BiquadFilterNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/ConvolverNode.cpp
+++ b/dom/media/webaudio/ConvolverNode.cpp
@@ -236,17 +236,17 @@ ConvolverNode::SetBuffer(JSContext* aCx,
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return;
     }
   }
 
   mBuffer = aBuffer;
 
   // Send the buffer to the stream
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
+  AudioNodeStream* ns = mStream;
   MOZ_ASSERT(ns, "Why don't we have a stream here?");
   if (mBuffer) {
     uint32_t length = mBuffer->Length();
     nsRefPtr<ThreadSharedFloatArrayBufferList> data =
       mBuffer->GetThreadSharedChannelsForRate(aCx);
     if (data && length < WEBAUDIO_BLOCK_SIZE) {
       // For very small impulse response buffers, we need to pad the
       // buffer with 0 to make sure that the Reverb implementation
--- a/dom/media/webaudio/DelayNode.cpp
+++ b/dom/media/webaudio/DelayNode.cpp
@@ -28,17 +28,17 @@ NS_IMPL_RELEASE_INHERITED(DelayNode, Aud
 class DelayNodeEngine final : public AudioNodeEngine
 {
   typedef PlayingRefChangeHandler PlayingRefChanged;
 public:
   DelayNodeEngine(AudioNode* aNode, AudioDestinationNode* aDestination,
                   double aMaxDelayTicks)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     // Keep the default value in sync with the default value in DelayNode::DelayNode.
     , mDelay(0.f)
     // Use a smoothing range of 20ms
     , mBuffer(std::max(aMaxDelayTicks,
                        static_cast<double>(WEBAUDIO_BLOCK_SIZE)),
               WebAudioUtils::ComputeSmoothingRate(0.02,
                                                   mDestination->SampleRate()))
     , mMaxDelay(aMaxDelayTicks)
@@ -194,17 +194,17 @@ DelayNode::DelayNode(AudioContext* aCont
               ChannelCountMode::Max,
               ChannelInterpretation::Speakers)
   , mDelay(new AudioParam(this, SendDelayToStream, 0.0f, "delayTime"))
 {
   DelayNodeEngine* engine =
     new DelayNodeEngine(this, aContext->Destination(),
                         aContext->SampleRate() * aMaxDelay);
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 DelayNode::~DelayNode()
 {
 }
 
 size_t
 DelayNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/DynamicsCompressorNode.cpp
+++ b/dom/media/webaudio/DynamicsCompressorNode.cpp
@@ -32,17 +32,17 @@ NS_IMPL_RELEASE_INHERITED(DynamicsCompre
 
 class DynamicsCompressorNodeEngine final : public AudioNodeEngine
 {
 public:
   explicit DynamicsCompressorNodeEngine(AudioNode* aNode,
                                         AudioDestinationNode* aDestination)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     // Keep the default value in sync with the default value in
     // DynamicsCompressorNode::DynamicsCompressorNode.
     , mThreshold(-24.f)
     , mKnee(30.f)
     , mRatio(12.f)
     , mAttack(0.003f)
     , mRelease(0.25f)
     , mCompressor(new DynamicsCompressor(mDestination->SampleRate(), 2))
@@ -205,17 +205,17 @@ DynamicsCompressorNode::DynamicsCompress
   , mKnee(new AudioParam(this, SendKneeToStream, 30.f, "knee"))
   , mRatio(new AudioParam(this, SendRatioToStream, 12.f, "ratio"))
   , mReduction(0)
   , mAttack(new AudioParam(this, SendAttackToStream, 0.003f, "attack"))
   , mRelease(new AudioParam(this, SendReleaseToStream, 0.25f, "release"))
 {
   DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 DynamicsCompressorNode::~DynamicsCompressorNode()
 {
 }
 
 size_t
 DynamicsCompressorNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/GainNode.cpp
+++ b/dom/media/webaudio/GainNode.cpp
@@ -24,17 +24,17 @@ NS_IMPL_ADDREF_INHERITED(GainNode, Audio
 NS_IMPL_RELEASE_INHERITED(GainNode, AudioNode)
 
 class GainNodeEngine final : public AudioNodeEngine
 {
 public:
   GainNodeEngine(AudioNode* aNode, AudioDestinationNode* aDestination)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     // Keep the default value in sync with the default value in GainNode::GainNode.
     , mGain(1.f)
   {
   }
 
   void SetSourceStream(AudioNodeStream* aSource)
   {
     mSource = aSource;
@@ -125,17 +125,17 @@ GainNode::GainNode(AudioContext* aContex
   : AudioNode(aContext,
               2,
               ChannelCountMode::Max,
               ChannelInterpretation::Speakers)
   , mGain(new AudioParam(this, SendGainToStream, 1.0f, "gain"))
 {
   GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 GainNode::~GainNode()
 {
 }
 
 size_t
 GainNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/OscillatorNode.cpp
+++ b/dom/media/webaudio/OscillatorNode.cpp
@@ -24,17 +24,17 @@ NS_IMPL_ADDREF_INHERITED(OscillatorNode,
 NS_IMPL_RELEASE_INHERITED(OscillatorNode, AudioNode)
 
 class OscillatorNodeEngine final : public AudioNodeEngine
 {
 public:
   OscillatorNodeEngine(AudioNode* aNode, AudioDestinationNode* aDestination)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     , mStart(-1)
     , mStop(STREAM_TIME_MAX)
     // Keep the default values in sync with OscillatorNode::OscillatorNode.
     , mFrequency(440.f)
     , mDetune(0.f)
     , mType(OscillatorType::Sine)
     , mPhase(0.)
     , mRecomputeParameters(true)
@@ -382,17 +382,17 @@ OscillatorNode::OscillatorNode(AudioCont
               ChannelInterpretation::Speakers)
   , mType(OscillatorType::Sine)
   , mFrequency(new AudioParam(this, SendFrequencyToStream, 440.0f, "frequency"))
   , mDetune(new AudioParam(this, SendDetuneToStream, 0.0f, "detune"))
   , mStartCalled(false)
 {
   OscillatorNodeEngine* engine = new OscillatorNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::SOURCE_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
   mStream->AddMainThreadListener(this);
 }
 
 OscillatorNode::~OscillatorNode()
 {
 }
 
 size_t
@@ -462,49 +462,47 @@ OscillatorNode::SendTypeToStream()
   }
   SendInt32ParameterToStream(OscillatorNodeEngine::TYPE, static_cast<int32_t>(mType));
 }
 
 void OscillatorNode::SendPeriodicWaveToStream()
 {
   NS_ASSERTION(mType == OscillatorType::Custom,
                "Sending custom waveform to engine thread with non-custom type");
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  MOZ_ASSERT(ns, "Missing node stream.");
+  MOZ_ASSERT(mStream, "Missing node stream.");
   MOZ_ASSERT(mPeriodicWave, "Send called without PeriodicWave object.");
   SendInt32ParameterToStream(OscillatorNodeEngine::PERIODICWAVE,
                              mPeriodicWave->DataLength());
   nsRefPtr<ThreadSharedFloatArrayBufferList> data =
     mPeriodicWave->GetThreadSharedBuffer();
-  ns->SetBuffer(data.forget());
+  mStream->SetBuffer(data.forget());
 }
 
 void
 OscillatorNode::Start(double aWhen, ErrorResult& aRv)
 {
   if (!WebAudioUtils::IsTimeValid(aWhen)) {
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return;
   }
 
   if (mStartCalled) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
   mStartCalled = true;
 
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  if (!ns) {
+  if (!mStream) {
     // Nothing to play, or we're already dead for some reason
     return;
   }
 
   // TODO: Perhaps we need to do more here.
-  ns->SetStreamTimeParameter(OscillatorNodeEngine::START,
-                             Context(), aWhen);
+  mStream->SetStreamTimeParameter(OscillatorNodeEngine::START,
+                                  Context(), aWhen);
 
   MarkActive();
 }
 
 void
 OscillatorNode::Stop(double aWhen, ErrorResult& aRv)
 {
   if (!WebAudioUtils::IsTimeValid(aWhen)) {
@@ -512,25 +510,24 @@ OscillatorNode::Stop(double aWhen, Error
     return;
   }
 
   if (!mStartCalled) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
-  if (!ns || !Context()) {
+  if (!mStream || !Context()) {
     // We've already stopped and had our stream shut down
     return;
   }
 
   // TODO: Perhaps we need to do more here.
-  ns->SetStreamTimeParameter(OscillatorNodeEngine::STOP,
-                             Context(), std::max(0.0, aWhen));
+  mStream->SetStreamTimeParameter(OscillatorNodeEngine::STOP,
+                                  Context(), std::max(0.0, aWhen));
 }
 
 void
 OscillatorNode::NotifyMainThreadStreamFinished()
 {
   MOZ_ASSERT(mStream->IsFinished());
 
   class EndedEventDispatcher final : public nsRunnable
--- a/dom/media/webaudio/ScriptProcessorNode.cpp
+++ b/dom/media/webaudio/ScriptProcessorNode.cpp
@@ -244,17 +244,17 @@ public:
 
   ScriptProcessorNodeEngine(ScriptProcessorNode* aNode,
                             AudioDestinationNode* aDestination,
                             uint32_t aBufferSize,
                             uint32_t aNumberOfInputChannels)
     : AudioNodeEngine(aNode)
     , mSharedBuffers(aNode->GetSharedBuffers())
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     , mBufferSize(aBufferSize)
     , mInputWriteIndex(0)
     , mSeenNonSilenceInput(false)
   {
     mInputChannels.SetLength(aNumberOfInputChannels);
     AllocateInputBlock();
   }
 
@@ -485,17 +485,17 @@ ScriptProcessorNode::ScriptProcessorNode
 {
   MOZ_ASSERT(BufferSize() % WEBAUDIO_BLOCK_SIZE == 0, "Invalid buffer size");
   ScriptProcessorNodeEngine* engine =
     new ScriptProcessorNodeEngine(this,
                                   aContext->Destination(),
                                   BufferSize(),
                                   aNumberOfInputChannels);
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 ScriptProcessorNode::~ScriptProcessorNode()
 {
 }
 
 size_t
 ScriptProcessorNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/StereoPannerNode.cpp
+++ b/dom/media/webaudio/StereoPannerNode.cpp
@@ -29,17 +29,17 @@ NS_IMPL_RELEASE_INHERITED(StereoPannerNo
 
 class StereoPannerNodeEngine final : public AudioNodeEngine
 {
 public:
   StereoPannerNodeEngine(AudioNode* aNode,
                          AudioDestinationNode* aDestination)
     : AudioNodeEngine(aNode)
     , mSource(nullptr)
-    , mDestination(static_cast<AudioNodeStream*>(aDestination->Stream()))
+    , mDestination(aDestination->Stream())
     // Keep the default value in sync with the default value in
     // StereoPannerNode::StereoPannerNode.
     , mPan(0.f)
   {
   }
 
   void SetSourceStream(AudioNodeStream* aSource)
   {
@@ -178,17 +178,17 @@ StereoPannerNode::StereoPannerNode(Audio
               2,
               ChannelCountMode::Clamped_max,
               ChannelInterpretation::Speakers)
   , mPan(new AudioParam(this, SendPanToStream, 0.f, "pan"))
 {
   StereoPannerNodeEngine* engine = new StereoPannerNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine,
                                                      MediaStreamGraph::INTERNAL_STREAM);
-  engine->SetSourceStream(static_cast<AudioNodeStream*>(mStream.get()));
+  engine->SetSourceStream(mStream);
 }
 
 StereoPannerNode::~StereoPannerNode()
 {
 }
 
 size_t
 StereoPannerNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
--- a/dom/media/webaudio/WaveShaperNode.cpp
+++ b/dom/media/webaudio/WaveShaperNode.cpp
@@ -321,17 +321,17 @@ WaveShaperNode::SetCurve(const Nullable<
     floats.ComputeLengthAndData();
 
     curve.SetLength(floats.Length());
     PodCopy(curve.Elements(), floats.Data(), floats.Length());
   } else {
     mCurve = nullptr;
   }
 
-  AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
+  AudioNodeStream* ns = mStream;
   MOZ_ASSERT(ns, "Why don't we have a stream here?");
   ns->SetRawArrayData(curve);
 }
 
 void
 WaveShaperNode::SetOversample(OverSampleType aType)
 {
   mType = aType;