Bug 1457427 - Change the assert in SetInputListener of GraphDriver to verify that the driver is not started. r=padenot
authorAlex Chronopoulos <achronop@gmail.com>
Mon, 07 May 2018 19:36:45 +0200
changeset 471470 c5e2684bc485bbcd323f5ce65c61edbc91e492e3
parent 471469 b3a339994f64d1a3269db8c1dc2f74cc32ef2c93
child 471471 47c2c71c14073f5ca3c6be3815058a6e3ae6cb12
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1457427
milestone62.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 1457427 - Change the assert in SetInputListener of GraphDriver to verify that the driver is not started. r=padenot With the updated OnThread method SetInputListener method cannot continue asserting for being in audio callback. This check is not realistic since it is used on a newly created driver before being started. MozReview-Commit-ID: 5gntuHm3fnr
dom/media/GraphDriver.cpp
dom/media/GraphDriver.h
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -1127,17 +1127,16 @@ AudioCallbackDriver::IterationDuration()
 {
   // The real fix would be to have an API in cubeb to give us the number. Short
   // of that, we approximate it here. bug 1019507
   return mIterationDurationMS;
 }
 
 bool
 AudioCallbackDriver::IsStarted() {
-  mGraphImpl->GetMonitor().AssertCurrentThreadOwns();
   return mStarted;
 }
 
 void
 AudioCallbackDriver::EnqueueStreamAndPromiseForOperation(MediaStream* aStream,
                                           void* aPromise,
                                           dom::AudioContextOperation aOperation)
 {
--- a/dom/media/GraphDriver.h
+++ b/dom/media/GraphDriver.h
@@ -420,17 +420,17 @@ public:
   void MixerCallback(AudioDataValue* aMixedBuffer,
                      AudioSampleFormat aFormat,
                      uint32_t aChannels,
                      uint32_t aFrames,
                      uint32_t aSampleRate) override;
 
   // These are invoked on the MSG thread (we don't call this if not LIFECYCLE_RUNNING)
   virtual void SetInputListener(AudioDataListener *aListener) {
-    MOZ_ASSERT(OnThread());
+    MOZ_ASSERT(!IsStarted());
     mAudioInput = aListener;
   }
   // XXX do we need the param?  probably no
   virtual void RemoveInputListener(AudioDataListener *aListener) {
     MOZ_ASSERT(OnThread());
     mAudioInput = nullptr;
   }
 
@@ -524,17 +524,17 @@ private:
    * and callbacks after the prefill never get called.
    * This is written on the previous driver's thread (if switching) or main
    * thread (if this driver is the first one).
    * This is read on previous driver's thread (during callbacks from
    * cubeb_stream_init) and the audio thread (when switching away from this
    * driver back to a SystemClockDriver).
    * This is synchronized by the Graph's monitor.
    * */
-  bool mStarted;
+  Atomic<bool> mStarted;
   /* Listener for mic input, if any. */
   RefPtr<AudioDataListener> mAudioInput;
 
   struct AutoInCallback
   {
     explicit AutoInCallback(AudioCallbackDriver* aDriver);
     ~AutoInCallback();
     AudioCallbackDriver* mDriver;