diff --git a/content/media/webaudio/AudioContext.cpp b/content/media/webaudio/AudioContext.cpp index 109d922a083..5b98b4a33c5 100644 --- a/content/media/webaudio/AudioContext.cpp +++ b/content/media/webaudio/AudioContext.cpp @@ -274,6 +274,20 @@ AudioContext::CurrentTime() const return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime()); } +void +AudioContext::Shutdown() +{ + Suspend(); + mDecoder.Shutdown(); + + // Stop all audio buffer source nodes, to make sure that they release + // their self-references. + for (uint32_t i = 0; i < mAudioBufferSourceNodes.Length(); ++i) { + ErrorResult rv; + mAudioBufferSourceNodes[i]->Stop(0.0, rv); + } +} + void AudioContext::Suspend() { diff --git a/content/media/webaudio/AudioContext.h b/content/media/webaudio/AudioContext.h index 1dc7fe611df..27f1c2d5f52 100644 --- a/content/media/webaudio/AudioContext.h +++ b/content/media/webaudio/AudioContext.h @@ -65,12 +65,7 @@ public: return mWindow; } - void Shutdown() - { - Suspend(); - mDecoder.Shutdown(); - } - + void Shutdown(); void Suspend(); void Resume();