зеркало из https://github.com/mozilla/gecko-dev.git
Bug 974089 - Destroy WebAudio MediaStream when a source finishes. r=padenot
--HG-- extra : rebase_source : 1a6c80ebaf11cf52194774088399040fea4605cd
This commit is contained in:
Родитель
f8b1474d38
Коммит
70a1be5d33
|
@ -643,7 +643,9 @@ void
|
|||
AudioBufferSourceNode::SendBufferParameterToStream(JSContext* aCx)
|
||||
{
|
||||
AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
|
||||
MOZ_ASSERT(ns, "Why don't we have a stream here?");
|
||||
if (!mStream) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mBuffer) {
|
||||
float rate = mBuffer->SampleRate();
|
||||
|
@ -727,6 +729,8 @@ AudioBufferSourceNode::NotifyMainThreadStreamFinished()
|
|||
}
|
||||
|
||||
mNode->DispatchTrustedEvent(NS_LITERAL_STRING("ended"));
|
||||
// Release stream resources.
|
||||
mNode->DestroyMediaStream();
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
|
@ -744,6 +748,9 @@ void
|
|||
AudioBufferSourceNode::SendPlaybackRateToStream(AudioNode* aNode)
|
||||
{
|
||||
AudioBufferSourceNode* This = static_cast<AudioBufferSourceNode*>(aNode);
|
||||
if (!This->mStream) {
|
||||
return;
|
||||
}
|
||||
SendTimelineParameterToStream(This, PLAYBACKRATE, *This->mPlaybackRate);
|
||||
}
|
||||
|
||||
|
@ -757,12 +764,16 @@ AudioBufferSourceNode::SendDetuneToStream(AudioNode* aNode)
|
|||
void
|
||||
AudioBufferSourceNode::SendDopplerShiftToStream(double aDopplerShift)
|
||||
{
|
||||
MOZ_ASSERT(mStream, "Should have disconnected panner if no stream");
|
||||
SendDoubleParameterToStream(DOPPLERSHIFT, aDopplerShift);
|
||||
}
|
||||
|
||||
void
|
||||
AudioBufferSourceNode::SendLoopParametersToStream()
|
||||
{
|
||||
if (!mStream) {
|
||||
return;
|
||||
}
|
||||
// Don't compute and set the loop parameters unnecessarily
|
||||
if (mLoop && mBuffer) {
|
||||
float rate = mBuffer->SampleRate();
|
||||
|
|
|
@ -352,10 +352,12 @@ AudioNode::Disconnect(uint32_t aOutput, ErrorResult& aRv)
|
|||
// Remove one instance of 'dest' from mOutputNodes. There could be
|
||||
// others, and it's not correct to remove them all since some of them
|
||||
// could be for different output ports.
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new RunnableRelease(mOutputNodes[i].forget());
|
||||
nsRefPtr<AudioNode> output = mOutputNodes[i].forget();
|
||||
mOutputNodes.RemoveElementAt(i);
|
||||
mStream->RunAfterPendingUpdates(runnable.forget());
|
||||
if (mStream) {
|
||||
nsRefPtr<nsIRunnable> runnable = new RunnableRelease(output.forget());
|
||||
mStream->RunAfterPendingUpdates(runnable.forget());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ private:
|
|||
nsRefPtr<AudioContext> mContext;
|
||||
|
||||
protected:
|
||||
// Must be set in the constructor. Must not be null.
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -425,6 +425,9 @@ void
|
|||
OscillatorNode::SendFrequencyToStream(AudioNode* aNode)
|
||||
{
|
||||
OscillatorNode* This = static_cast<OscillatorNode*>(aNode);
|
||||
if (!This->mStream) {
|
||||
return;
|
||||
}
|
||||
SendTimelineParameterToStream(This, OscillatorNodeEngine::FREQUENCY, *This->mFrequency);
|
||||
}
|
||||
|
||||
|
@ -432,12 +435,18 @@ void
|
|||
OscillatorNode::SendDetuneToStream(AudioNode* aNode)
|
||||
{
|
||||
OscillatorNode* This = static_cast<OscillatorNode*>(aNode);
|
||||
if (!This->mStream) {
|
||||
return;
|
||||
}
|
||||
SendTimelineParameterToStream(This, OscillatorNodeEngine::DETUNE, *This->mDetune);
|
||||
}
|
||||
|
||||
void
|
||||
OscillatorNode::SendTypeToStream()
|
||||
{
|
||||
if (!mStream) {
|
||||
return;
|
||||
}
|
||||
if (mType == OscillatorType::Custom) {
|
||||
// The engine assumes we'll send the custom data before updating the type.
|
||||
SendPeriodicWaveToStream();
|
||||
|
@ -529,6 +538,8 @@ OscillatorNode::NotifyMainThreadStreamFinished()
|
|||
}
|
||||
|
||||
mNode->DispatchTrustedEvent(NS_LITERAL_STRING("ended"));
|
||||
// Release stream resources.
|
||||
mNode->DestroyMediaStream();
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче