Bug 1100803 - Avoid repeated deletion of media ports. r=roc
authorAlastor Wu <alwu@mozilla.com>
Thu, 11 Dec 2014 10:53:00 +0800
changeset 219747 333eda1b009985af71334f511e228acc66e8e715
parent 219746 6953b6a787ce2d501ca1b8ed3d5204c854ac432e
child 219748 19313a129f6d23239277251823a1d4ee131aae72
push id27968
push usernigelbabu@gmail.com
push dateTue, 16 Dec 2014 06:59:11 +0000
treeherdermozilla-central@b836016d82b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1100803
milestone37.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 1100803 - Avoid repeated deletion of media ports. r=roc
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -279,25 +279,29 @@ void MediaDecoder::DestroyDecodedStream(
   // need to be explicitly blocked again.
   for (int32_t i = mOutputStreams.Length() - 1; i >= 0; --i) {
     OutputStreamData& os = mOutputStreams[i];
     // During cycle collection, nsDOMMediaStream can be destroyed and send
     // its Destroy message before this decoder is destroyed. So we have to
     // be careful not to send any messages after the Destroy().
     if (os.mStream->IsDestroyed()) {
       // Probably the DOM MediaStream was GCed. Clean up.
-      os.mPort->Destroy();
+      if (os.mPort) {
+        os.mPort->Destroy();
+      }
       mOutputStreams.RemoveElementAt(i);
       continue;
     }
     os.mStream->ChangeExplicitBlockerCount(1);
     // Explicitly remove all existing ports. This is not strictly necessary but it's
     // good form.
-    os.mPort->Destroy();
-    os.mPort = nullptr;
+    if (os.mPort) {
+      os.mPort->Destroy();
+      os.mPort = nullptr;
+    }
   }
 
   mDecodedStream = nullptr;
 }
 
 void MediaDecoder::UpdateStreamBlockingForStateMachinePlaying()
 {
   GetReentrantMonitor().AssertCurrentThreadIn();
@@ -836,25 +840,29 @@ void MediaDecoder::PlaybackEnded()
 
   {
     ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
 
     for (int32_t i = mOutputStreams.Length() - 1; i >= 0; --i) {
       OutputStreamData& os = mOutputStreams[i];
       if (os.mStream->IsDestroyed()) {
         // Probably the DOM MediaStream was GCed. Clean up.
-        os.mPort->Destroy();
+        if (os.mPort) {
+          os.mPort->Destroy();
+        }
         mOutputStreams.RemoveElementAt(i);
         continue;
       }
       if (os.mFinishWhenEnded) {
         // Shouldn't really be needed since mDecodedStream should already have
         // finished, but doesn't hurt.
         os.mStream->Finish();
-        os.mPort->Destroy();
+        if (os.mPort) {
+          os.mPort->Destroy();
+        }
         // Not really needed but it keeps the invariant that a stream not
         // connected to mDecodedStream is explicity blocked.
         os.mStream->ChangeExplicitBlockerCount(1);
         mOutputStreams.RemoveElementAt(i);
       }
     }
   }