Bug 1418917. P2 - NotifyClientSuspended() should check mClosed. draft
authorJW Wang <jwwang@mozilla.com>
Mon, 20 Nov 2017 14:21:22 +0800
changeset 703048 016e630c64d7c2d71c1db6954d4703cbac6214db
parent 703047 65f032e8dda5875f65c6ff3b5efecdd2e746f5af
child 741643 14303b9050f2f165e10ce3e8f7ecca4dc918699f
push id90681
push userjwwang@mozilla.com
push dateFri, 24 Nov 2017 08:20:36 +0000
bugs1418917
milestone59.0a1
Bug 1418917. P2 - NotifyClientSuspended() should check mClosed. MozReview-Commit-ID: 9mBPwfyfWCV
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -2251,20 +2251,20 @@ MediaCacheStream::NotifyDataEnded(uint32
 void
 MediaCacheStream::NotifyClientSuspended(bool aSuspended)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<ChannelMediaResource> client = mClient;
   nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
     "MediaCacheStream::NotifyClientSuspended", [client, this, aSuspended]() {
-      if (mClientSuspended != aSuspended) {
+      ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
+      if (!mClosed && mClientSuspended != aSuspended) {
         mClientSuspended = aSuspended;
         // mClientSuspended changes the decision of reading streams.
-        ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
         mMediaCache->QueueUpdate();
       }
     });
   OwnerThread()->Dispatch(r.forget());
 }
 
 MediaCacheStream::~MediaCacheStream()
 {