Bug 1361336 - Part 2: Prevent AudioStream::ResetDefaultDevice() from being called before stream is started. r=cpearce, r=kinetik, a=lizzard
authorChun-Min Chang <chun.m.chang@gmail.com>
Fri, 21 Jul 2017 17:45:45 +0800
changeset 421655 7ffa5f4b3dde34ffb59a9e9b25072414f6202ced
parent 421654 4defb75014dfe3f8d77301ea89a7b43897696ca2
child 421656 de020e9792ff39cf66e6b5c43ce6b7c9cfbabf72
push id7736
push userryanvm@gmail.com
push dateMon, 11 Sep 2017 15:47:51 +0000
treeherdermozilla-beta@94cf7f1ee06b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, kinetik, lizzard
bugs1361336
milestone56.0
Bug 1361336 - Part 2: Prevent AudioStream::ResetDefaultDevice() from being called before stream is started. r=cpearce, r=kinetik, a=lizzard
dom/media/AudioStream.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -473,16 +473,21 @@ AudioStream::Shutdown()
 
   mState = SHUTDOWN;
 }
 
 void
 AudioStream::ResetDefaultDevice()
 {
   MonitorAutoLock mon(mMonitor);
+  if (mState != STARTED && mState != STOPPED) {
+    return;
+  }
+
+  MOZ_ASSERT(mCubebStream);
   auto r = InvokeCubeb(cubeb_stream_reset_default_device);
   if (!(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED)) {
     mState = ERRORED;
   }
 }
 
 int64_t
 AudioStream::GetPosition()