Bug 1549041 - Destroy the AudioChannelAgent in CloseInternal instead of Close. r=karlt
authorPaul Adenot <paul@paul.cx>
Fri, 17 May 2019 09:46:25 +0000
changeset 533144 baa019d214ce6e9e89d1d7129479c7f2faa3a925
parent 533143 4bcfd40cc3a89763d88abafcf71f8bdacd765f67
child 533145 6d0bd72a59672bf12d7f0248644c7c708fb74d74
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1549041
milestone68.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 1549041 - Destroy the AudioChannelAgent in CloseInternal instead of Close. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D30638
dom/media/webaudio/AudioContext.cpp
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -1112,33 +1112,31 @@ already_AddRefed<Promise> AudioContext::
     return promise.forget();
   }
 
   if (mAudioContextState == AudioContextState::Closed) {
     promise->MaybeResolve(NS_ERROR_DOM_INVALID_STATE_ERR);
     return promise.forget();
   }
 
-  if (Destination()) {
-    Destination()->DestroyAudioChannelAgent();
-  }
-
   mPromiseGripArray.AppendElement(promise);
 
   CloseInternal(promise, AudioContextOperationFlags::SendStateChange);
 
   return promise.forget();
 }
 
 void AudioContext::CloseInternal(void* aPromise,
                                  AudioContextOperationFlags aFlags) {
   // This can be called when freeing a document, and the streams are dead at
   // this point, so we need extra null-checks.
   AudioNodeStream* ds = DestinationStream();
   if (ds) {
+    Destination()->DestroyAudioChannelAgent();
+
     nsTArray<MediaStream*> streams;
     // If mSuspendCalled or mCloseCalled are true then we already suspended
     // all our streams, so don't suspend them again. But we still need to do
     // ApplyAudioContextOperation to ensure our new promise is resolved.
     if (!mSuspendCalled && !mCloseCalled) {
       streams = GetAllStreams();
     }
     Graph()->ApplyAudioContextOperation(