Bug 1517711 - Guard other uses of SetPullingEnabled too. r=padenot
authorAndreas Pehrson <apehrson@mozilla.com>
Tue, 08 Jan 2019 10:06:08 +0000
changeset 509976 c2de6f3221df754e9ee2430b4ae269e8aa5e4c62
parent 509975 f134e4af88f7ff8dc90160f1e2858767cfe8f751
child 509977 b5ae2787288ee433c71da4afcb64613d010e6307
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1517711
milestone66.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 1517711 - Guard other uses of SetPullingEnabled too. r=padenot Depends on D15892 Differential Revision: https://phabricator.services.mozilla.com/D15896
dom/media/MediaManager.cpp
dom/media/webrtc/MediaEngineDefault.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -4188,17 +4188,18 @@ SourceListener::InitializeAsync() {
                  MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
                  MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
                  MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
 
                  state->mDeviceEnabled = true;
                  state->mTrackEnabled = true;
                  state->mTrackEnabledTime = TimeStamp::Now();
 
-                 if (state == mVideoDeviceState.get()) {
+                 if (state == mVideoDeviceState.get() &&
+                     !mStream->IsDestroyed()) {
                    mStream->SetPullingEnabled(kVideoTrack, true);
                  }
                }
                return SourceListenerPromise::CreateAndResolve(true, __func__);
              },
              [self = RefPtr<SourceListener>(this),
               this](RefPtr<MediaMgrError>&& aResult) {
                if (mStopped) {
--- a/dom/media/webrtc/MediaEngineDefault.cpp
+++ b/dom/media/webrtc/MediaEngineDefault.cpp
@@ -456,16 +456,19 @@ nsresult MediaEngineDefaultAudioSource::
 
   {
     MutexAutoLock lock(mMutex);
     mState = kStarted;
   }
 
   NS_DispatchToMainThread(
       NS_NewRunnableFunction(__func__, [stream = mStream, track = mTrackID]() {
+        if (stream->IsDestroyed()) {
+          return;
+        }
         stream->SetPullingEnabled(track, true);
       }));
 
   return NS_OK;
 }
 
 nsresult MediaEngineDefaultAudioSource::Stop(
     const RefPtr<const AllocationHandle>& aHandle) {
@@ -479,16 +482,19 @@ nsresult MediaEngineDefaultAudioSource::
 
   {
     MutexAutoLock lock(mMutex);
     mState = kStopped;
   }
 
   NS_DispatchToMainThread(
       NS_NewRunnableFunction(__func__, [stream = mStream, track = mTrackID]() {
+        if (stream->IsDestroyed()) {
+          return;
+        }
         stream->SetPullingEnabled(track, false);
       }));
   return NS_OK;
 }
 
 nsresult MediaEngineDefaultAudioSource::Reconfigure(
     const RefPtr<AllocationHandle>& aHandle,
     const dom::MediaTrackConstraints& aConstraints,
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -1470,26 +1470,32 @@ class GenericReceiveListener : public Me
             ("GenericReceiveListener added %s track %d (%p) to stream %p",
              mTrack->AsAudioStreamTrack() ? "audio" : "video", mTrackId,
              mTrack.get(), mSource.get()));
 
     mSource->AddTrackListener(this, mTrackId);
   }
 
   void AddSelf() {
-    if (!mListening) {
-      mListening = true;
+    if (mListening) {
+      return;
+    }
+    mListening = true;
+    mMaybeTrackNeedsUnmute = true;
+    if (!mSource->IsDestroyed()) {
       mSource->SetPullingEnabled(mTrackId, true);
-      mMaybeTrackNeedsUnmute = true;
     }
   }
 
   void RemoveSelf() {
-    if (mListening) {
-      mListening = false;
+    if (!mListening) {
+      return;
+    }
+    mListening = false;
+    if (!mSource->IsDestroyed()) {
       mSource->SetPullingEnabled(mTrackId, false);
     }
   }
 
   void OnRtpReceived() {
     if (mMaybeTrackNeedsUnmute) {
       mMaybeTrackNeedsUnmute = false;
       NS_DispatchToMainThread(