Bug 1586387 - Don't append a device change message to a graph that is going away. r=padenot a=lizzard
authorAndreas Pehrson <apehrson@mozilla.com>
Tue, 08 Oct 2019 14:08:52 +0200
changeset 552362 2697830a6ab4c65617539ee8ef78154ada3a2194
parent 552361 fe97faa4dc3e04d3a8674eafac4686ffd1ca2c15
child 552363 5d88242a100d287b7559b420ea0fe5952c7be425
push id12154
push userarchaeopteryx@coole-files.de
push dateThu, 10 Oct 2019 13:07:55 +0000
treeherdermozilla-beta@2697830a6ab4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, lizzard
bugs1586387
milestone70.0
Bug 1586387 - Don't append a device change message to a graph that is going away. r=padenot a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D48553
dom/media/MediaStreamGraph.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -953,16 +953,25 @@ void MediaStreamGraphImpl::DeviceChanged
         : ControlMessage(nullptr),
           mGraphImpl(static_cast<MediaStreamGraphImpl*>(aGraph)) {}
     void Run() override { mGraphImpl->DeviceChangedImpl(); }
     // We know that this is valid, because the graph can't shutdown if it has
     // messages.
     MediaStreamGraphImpl* mGraphImpl;
   };
 
+  if (mMainThreadStreamCount == 0 && mMainThreadPortCount == 0) {
+    // This is a special case where the origin of this event cannot control the
+    // lifetime of the graph, because the graph is controling the lifetime of
+    // the AudioCallbackDriver where the event originated.
+    // We know the graph is soon going away, so there's no need to notify about
+    // this device change.
+    return;
+  }
+
   // Reset the latency, it will get fetched again next time it's queried.
   MOZ_ASSERT(NS_IsMainThread());
   mAudioOutputLatency = 0.0;
 
   AppendMessage(MakeUnique<Message>(this));
 }
 
 void MediaStreamGraphImpl::ReevaluateInputDevice() {