Backed out changeset 6dc016256eba (bug 1378067) for bustage at dom/media/webaudio/WebAudioUtils.cpp:107. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 18 Jul 2017 11:51:22 +0200
changeset 369413 4da0547ae82c8b271bb38a9658e6ff25d186e870
parent 369412 6dc016256eba8c18f99ba2b3591239df27441846
child 369414 81f667d3a5049ce4ac54504f841d7c5dd1155236
push id32195
push userryanvm@gmail.com
push dateTue, 18 Jul 2017 16:15:01 +0000
treeherdermozilla-central@56c6c81993e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1378067
milestone56.0a1
backs out6dc016256eba8c18f99ba2b3591239df27441846
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
Backed out changeset 6dc016256eba (bug 1378067) for bustage at dom/media/webaudio/WebAudioUtils.cpp:107. r=backout on a CLOSED TREE
dom/media/CubebUtils.cpp
dom/media/DOMMediaStream.cpp
dom/media/GraphDriver.cpp
dom/media/webaudio/BiquadFilterNode.cpp
dom/media/webaudio/IIRFilterNode.cpp
dom/media/webaudio/WebAudioUtils.cpp
dom/media/webaudio/WebAudioUtils.h
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -420,17 +420,17 @@ Maybe<uint32_t> GetCubebMSGLatencyInFram
 void InitLibrary()
 {
   Preferences::RegisterCallbackAndCall(PrefChanged, PREF_VOLUME_SCALE);
   Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_LATENCY_PLAYBACK);
   Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_LATENCY_MSG);
   Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_BACKEND);
   Preferences::RegisterCallbackAndCall(PrefChanged, PREF_CUBEB_LOG_LEVEL);
 #ifndef MOZ_WIDGET_ANDROID
-  AbstractThread::MainThread()->Dispatch(
+  NS_DispatchToMainThread(
     NS_NewRunnableFunction("CubebUtils::InitLibrary", &InitBrandName));
 #endif
 }
 
 void ShutdownLibrary()
 {
   Preferences::UnregisterCallback(PrefChanged, PREF_VOLUME_SCALE);
   Preferences::UnregisterCallback(PrefChanged, PREF_CUBEB_BACKEND);
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -142,19 +142,18 @@ NS_IMPL_CYCLE_COLLECTION_0(MediaStreamTr
 class DOMMediaStream::OwnedStreamListener : public MediaStreamListener {
 public:
   explicit OwnedStreamListener(DOMMediaStream* aStream)
     : mStream(aStream)
   {}
 
   void Forget() { mStream = nullptr; }
 
-  void DoNotifyTrackCreated(MediaStreamGraph* aGraph, TrackID aTrackID,
-                            MediaSegment::Type aType, MediaStream* aInputStream,
-                            TrackID aInputTrackID)
+  void DoNotifyTrackCreated(TrackID aTrackID, MediaSegment::Type aType,
+                            MediaStream* aInputStream, TrackID aInputTrackID)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mStream) {
       return;
     }
 
     MediaStreamTrack* track =
@@ -182,72 +181,70 @@ public:
       nsPIDOMWindowInner* window = mStream->GetParentObject();
       nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
       nsIPrincipal* principal = doc ? doc->NodePrincipal() : nullptr;
       source = new BasicTrackSource(principal);
     }
 
     RefPtr<MediaStreamTrack> newTrack =
       mStream->CreateDOMTrack(aTrackID, aType, source);
-    aGraph->AbstractMainThread()->Dispatch(NewRunnableMethod<RefPtr<MediaStreamTrack>>(
+    NS_DispatchToMainThread(NewRunnableMethod<RefPtr<MediaStreamTrack>>(
       "DOMMediaStream::AddTrackInternal",
       mStream,
       &DOMMediaStream::AddTrackInternal,
       newTrack));
   }
 
-  void DoNotifyTrackEnded(MediaStreamGraph* aGraph, MediaStream* aInputStream,
-                          TrackID aInputTrackID, TrackID aTrackID)
+  void DoNotifyTrackEnded(MediaStream* aInputStream, TrackID aInputTrackID,
+                          TrackID aTrackID)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mStream) {
       return;
     }
 
     RefPtr<MediaStreamTrack> track =
       mStream->FindOwnedDOMTrack(aInputStream, aInputTrackID, aTrackID);
     NS_ASSERTION(track, "Owned MediaStreamTracks must be known by the DOMMediaStream");
     if (track) {
       LOG(LogLevel::Debug, ("DOMMediaStream %p MediaStreamTrack %p ended at the source. Marking it ended.",
                             mStream, track.get()));
-      aGraph->AbstractMainThread()->Dispatch(
+      NS_DispatchToMainThread(
         NewRunnableMethod("dom::MediaStreamTrack::OverrideEnded",
                           track,
                           &MediaStreamTrack::OverrideEnded));
     }
   }
 
   void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
                                 StreamTime aTrackOffset, TrackEventCommand aTrackEvents,
                                 const MediaSegment& aQueuedMedia,
                                 MediaStream* aInputStream,
                                 TrackID aInputTrackID) override
   {
     if (aTrackEvents & TrackEventCommand::TRACK_EVENT_CREATED) {
       aGraph->DispatchToMainThreadAfterStreamStateUpdate(
-        NewRunnableMethod<MediaStreamGraph*, TrackID,
+        NewRunnableMethod<TrackID,
                           MediaSegment::Type,
                           RefPtr<MediaStream>,
                           TrackID>(
           "DOMMediaStream::OwnedStreamListener::DoNotifyTrackCreated",
           this,
           &OwnedStreamListener::DoNotifyTrackCreated,
-          aGraph,
           aID,
           aQueuedMedia.GetType(),
           aInputStream,
           aInputTrackID));
     } else if (aTrackEvents & TrackEventCommand::TRACK_EVENT_ENDED) {
       aGraph->DispatchToMainThreadAfterStreamStateUpdate(
-        NewRunnableMethod<MediaStreamGraph*, RefPtr<MediaStream>, TrackID, TrackID>(
+        NewRunnableMethod<RefPtr<MediaStream>, TrackID, TrackID>(
           "DOMMediaStream::OwnedStreamListener::DoNotifyTrackEnded",
           this,
           &OwnedStreamListener::DoNotifyTrackEnded,
-          aGraph,
           aInputStream,
           aInputTrackID,
           aID));
     }
   }
 
 private:
   // These fields may only be accessed on the main thread
@@ -277,35 +274,33 @@ public:
 
     if (!mStream) {
       return;
     }
 
     // The owned stream listener adds its tracks after another main thread
     // dispatch. We have to do the same to notify of created tracks to stay
     // in sync. (Or NotifyTracksCreated is called before tracks are added).
-    MOZ_ASSERT(mStream->GetPlaybackStream());
-    mStream->GetPlaybackStream()->Graph()->AbstractMainThread()->Dispatch(
+    NS_DispatchToMainThread(
       NewRunnableMethod("DOMMediaStream::NotifyTracksCreated",
                         mStream,
                         &DOMMediaStream::NotifyTracksCreated));
   }
 
   void DoNotifyFinished()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mStream) {
       return;
     }
 
-    mStream->GetPlaybackStream()->Graph()->AbstractMainThread()->Dispatch(
-        NewRunnableMethod("DOMMediaStream::NotifyFinished",
-                          mStream,
-                          &DOMMediaStream::NotifyFinished));
+    NS_DispatchToMainThread(NewRunnableMethod("DOMMediaStream::NotifyFinished",
+                                              mStream,
+                                              &DOMMediaStream::NotifyFinished));
   }
 
   // The methods below are called on the MediaStreamGraph thread.
 
   void NotifyFinishedTrackCreation(MediaStreamGraph* aGraph) override
   {
     aGraph->DispatchToMainThreadAfterStreamStateUpdate(
       NewRunnableMethod(
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -160,20 +160,19 @@ private:
   nsCOMPtr<nsIThread> mThread;
 };
 
 ThreadedDriver::~ThreadedDriver()
 {
   if (mThread) {
     nsCOMPtr<nsIRunnable> event =
       new MediaStreamGraphShutdownThreadRunnable(mThread.forget());
-    GraphImpl()->Dispatch(event.forget());
+    NS_DispatchToMainThread(event);
   }
 }
-
 class MediaStreamGraphInitThreadRunnable : public Runnable {
 public:
   explicit MediaStreamGraphInitThreadRunnable(ThreadedDriver* aDriver)
     : Runnable("MediaStreamGraphInitThreadRunnable")
     , mDriver(aDriver)
   {
   }
   NS_IMETHOD Run() override
@@ -489,21 +488,20 @@ AsyncCubebTask::EnsureThread()
   if (!sThreadPool) {
     nsCOMPtr<nsIThreadPool> threadPool =
       SharedThreadPool::Get(NS_LITERAL_CSTRING("CubebOperation"), 1);
     sThreadPool = threadPool;
     // Need to null this out before xpcom-shutdown-threads Observers run
     // since we don't know the order that the shutdown-threads observers
     // will run.  ClearOnShutdown guarantees it runs first.
     if (!NS_IsMainThread()) {
-      nsCOMPtr<nsIRunnable> runnable =
+      NS_DispatchToMainThread(
         NS_NewRunnableFunction("AsyncCubebTask::EnsureThread", []() -> void {
           ClearOnShutdown(&sThreadPool, ShutdownPhase::ShutdownThreads);
-        });
-      AbstractThread::MainThread()->Dispatch(runnable.forget());
+        }));
     } else {
       ClearOnShutdown(&sThreadPool, ShutdownPhase::ShutdownThreads);
     }
 
     const uint32_t kIdleThreadTimeoutMs = 2000;
 
     nsresult rv = sThreadPool->SetIdleThreadTimeout(PR_MillisecondsToInterval(kIdleThreadTimeoutMs));
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/dom/media/webaudio/BiquadFilterNode.cpp
+++ b/dom/media/webaudio/BiquadFilterNode.cpp
@@ -172,18 +172,17 @@ public:
     } else if(mBiquads.Length() != aInput.ChannelCount()){
       if (mBiquads.IsEmpty()) {
         RefPtr<PlayingRefChangeHandler> refchanged =
           new PlayingRefChangeHandler(aStream, PlayingRefChangeHandler::ADDREF);
         aStream->Graph()->DispatchToMainThreadAfterStreamStateUpdate(
           refchanged.forget());
       } else { // Help people diagnose bug 924718
         WebAudioUtils::LogToDeveloperConsole(mWindowID,
-                                             "BiquadFilterChannelCountChangeWarning",
-                                             aStream->Graph()->AbstractMainThread());
+                                             "BiquadFilterChannelCountChangeWarning");
       }
 
       // Adjust the number of biquads based on the number of channels
       mBiquads.SetLength(aInput.ChannelCount());
     }
 
     uint32_t numberOfChannels = mBiquads.Length();
     aOutput->AllocateChannels(numberOfChannels);
--- a/dom/media/webaudio/IIRFilterNode.cpp
+++ b/dom/media/webaudio/IIRFilterNode.cpp
@@ -68,18 +68,17 @@ public:
     } else if(mIIRFilters.Length() != aInput.ChannelCount()){
       if (mIIRFilters.IsEmpty()) {
         RefPtr<PlayingRefChangeHandler> refchanged =
           new PlayingRefChangeHandler(aStream, PlayingRefChangeHandler::ADDREF);
         aStream->Graph()->DispatchToMainThreadAfterStreamStateUpdate(
           refchanged.forget());
       } else {
         WebAudioUtils::LogToDeveloperConsole(mWindowID,
-                                             "IIRFilterChannelCountChangeWarning",
-                                             aStream->Graph()->AbstractMainThread());
+                                             "IIRFilterChannelCountChangeWarning");
       }
 
       // Adjust the number of filters based on the number of channels
       mIIRFilters.SetLength(aInput.ChannelCount());
       for (size_t i = 0; i < aInput.ChannelCount(); ++i) {
         mIIRFilters[i] = new blink::IIRFilter(&mFeedforward, &mFeedback);
       }
     }
--- a/dom/media/webaudio/WebAudioUtils.cpp
+++ b/dom/media/webaudio/WebAudioUtils.cpp
@@ -89,28 +89,27 @@ WebAudioUtils::SpeexResamplerProcess(Spe
   ConvertAudioSamples(aIn, tmp1.Elements(), *aInLen);
   int result = speex_resampler_process_float(aResampler, aChannel, tmp1.Elements(), aInLen, tmp2.Elements(), aOutLen);
   ConvertAudioSamples(tmp2.Elements(), aOut, *aOutLen);
   return result;
 #endif
 }
 
 void
-WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID, const char* aKey,
-                                     AbstractThread* aMainThread)
+WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID, const char* aKey)
 {
   // This implementation is derived from dom/media/VideoUtils.cpp, but we
   // use a windowID so that the message is delivered to the developer console.
   // It is similar to ContentUtils::ReportToConsole, but also works off main
   // thread.
   if (!NS_IsMainThread()) {
     nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
       "dom::WebAudioUtils::LogToDeveloperConsole",
-      [aWindowID, aKey, aMainThread]() { LogToDeveloperConsole(aWindowID, aKey, aMainThread); });
-    aMainThread->Dispatch(task.forget(), NS_DISPATCH_NORMAL);
+      [aWindowID, aKey]() { LogToDeveloperConsole(aWindowID, aKey); });
+    NS_DispatchToMainThread(task.forget(), NS_DISPATCH_NORMAL);
     return;
   }
 
   nsCOMPtr<nsIConsoleService> console(
     do_GetService("@mozilla.org/consoleservice;1"));
   if (!console) {
     NS_WARNING("Failed to log message to console.");
     return;
--- a/dom/media/webaudio/WebAudioUtils.h
+++ b/dom/media/webaudio/WebAudioUtils.h
@@ -224,18 +224,17 @@ namespace WebAudioUtils {
 
   int
   SpeexResamplerProcess(SpeexResamplerState* aResampler,
                         uint32_t aChannel,
                         const int16_t* aIn, uint32_t* aInLen,
                         int16_t* aOut, uint32_t* aOutLen);
 
   void
-  LogToDeveloperConsole(uint64_t aWindowID, const char* aKey,
-                        AbstractThread* aMainThread);
+  LogToDeveloperConsole(uint64_t aWindowID, const char* aKey);
 
   } // namespace WebAudioUtils
 
 } // namespace dom
 } // namespace mozilla
 
 #endif