Bug 1286041 - Assert audio callback is not called in initialized state. r=jwwang
☠☠ backed out by 83c6065c6f64 ☠ ☠
authorAlex Chronopoulos <achronop@gmail.com>
Tue, 12 Jul 2016 16:53:58 +0200
changeset 312824 71b9d48efac6b0034ee7a653eb73f99ebb077055
parent 312823 0bb0f5bef1a61dca5203831e322b13cb051b4463
child 312825 232069c626269a71a3c2c0cd5d9cc3d4f2327338
push id30661
push userkwierso@gmail.com
push dateWed, 07 Sep 2016 00:28:11 +0000
treeherdermozilla-central@3ba67e3bb588 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1286041
milestone51.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 1286041 - Assert audio callback is not called in initialized state. r=jwwang MozReview-Commit-ID: 3epBfvUHYFo
dom/media/AudioStream.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -395,19 +395,22 @@ AudioStream::SetVolume(double aVolume)
   }
 }
 
 void
 AudioStream::Start()
 {
   MonitorAutoLock mon(mMonitor);
   MOZ_ASSERT(mState == INITIALIZED);
+  mState = STARTED;
   auto r = InvokeCubeb(cubeb_stream_start);
-  mState = r == CUBEB_OK ? STARTED : ERRORED;
-  LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
+  if (r != CUBEB_OK) {
+    mState = ERRORED;
+  }
+  LOG("started, state %s", mState == STARTED ? "STARTED" : mState == DRAINED ? "DRAINED" : "ERRORED");
 }
 
 void
 AudioStream::Pause()
 {
   MonitorAutoLock mon(mMonitor);
   MOZ_ASSERT(mState != INITIALIZED, "Must be Start()ed.");
   MOZ_ASSERT(mState != STOPPED, "Already Pause()ed.");
@@ -588,23 +591,17 @@ long
 AudioStream::DataCallback(void* aBuffer, long aFrames)
 {
   MonitorAutoLock mon(mMonitor);
   MOZ_ASSERT(mState != SHUTDOWN, "No data callback after shutdown");
 
   auto writer = AudioBufferWriter(
     reinterpret_cast<AudioDataValue*>(aBuffer), mOutChannels, aFrames);
 
-  // FIXME: cubeb_pulse sometimes calls us before cubeb_stream_start() is called.
-  // We don't want to consume audio data until Start() is called by the client.
-  if (mState == INITIALIZED) {
-    NS_WARNING("data callback fires before cubeb_stream_start() is called");
-    mAudioClock.UpdateFrameHistory(0, aFrames);
-    return writer.WriteZeros(aFrames);
-  }
+  MOZ_ASSERT(mState != INITIALIZED);
 
   // NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
   // Bug 996162
 
   if (mAudioClock.GetInputRate() == mAudioClock.GetOutputRate()) {
     GetUnprocessed(writer);
   } else {
     GetTimeStretched(writer);