Bug 1185407. Part 3 - don't shutdown AudioStream prematurely. r=kinetik.
authorJW Wang <jwwang@mozilla.com>
Wed, 22 Jul 2015 09:54:15 +0800
changeset 254029 564e2565cf837b01ad8ca5e899472f2a335ca121
parent 254028 bd41024575c511d95fc8fb66f58eccc9e0270fc7
child 254030 35c6e7e9c205be0656c050909aaa3b42fa064c4f
push id62628
push userjwwang@mozilla.com
push dateWed, 22 Jul 2015 02:13:39 +0000
treeherdermozilla-inbound@564e2565cf83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1185407
milestone42.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 1185407. Part 3 - don't shutdown AudioStream prematurely. r=kinetik.
dom/media/AudioSink.cpp
--- a/dom/media/AudioSink.cpp
+++ b/dom/media/AudioSink.cpp
@@ -96,17 +96,20 @@ AudioSink::PrepareToShutdown()
   GetReentrantMonitor().NotifyAll();
 }
 
 void
 AudioSink::Shutdown()
 {
   mThread->Shutdown();
   mThread = nullptr;
-  MOZ_ASSERT(!mAudioStream);
+  if (mAudioStream) {
+    mAudioStream->Shutdown();
+    mAudioStream = nullptr;
+  }
 }
 
 void
 AudioSink::SetVolume(double aVolume)
 {
   AssertCurrentThreadInMonitor();
   mVolume = aVolume;
   mSetVolume = true;
@@ -230,22 +233,20 @@ AudioSink::Drain()
     mAudioStream->Drain();
   }
 }
 
 void
 AudioSink::Cleanup()
 {
   AssertCurrentThreadInMonitor();
-  nsRefPtr<AudioStream> audioStream;
-  audioStream.swap(mAudioStream);
   mEndPromise.Resolve(true, __func__);
-
-  ReentrantMonitorAutoExit exit(GetReentrantMonitor());
-  audioStream->Shutdown();
+  // Since the promise if resolved asynchronously, we don't shutdown
+  // AudioStream here so MDSM::ResyncAudioClock can get the correct
+  // audio position.
 }
 
 bool
 AudioSink::ExpectMoreAudioData()
 {
   return AudioQueue().GetSize() == 0 && !AudioQueue().IsFinished();
 }