Backed out changeset 27493ca82782 (bug 1353476) for bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 04 Apr 2017 18:57:40 -0400
changeset 355577 e8651b7e41c89a4a8354c2bfba6d10923a167ac3
parent 355576 d7d87adfe186580ae49e079a394d7f96eff751f2
child 355578 c66e2269ec31ba9d7ce4368b5e28b89e59fe3d90
push id7002
push userryanvm@gmail.com
push dateTue, 04 Apr 2017 22:57:47 +0000
treeherdermozilla-esr52@e8651b7e41c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1353476
milestone52.0.3
backs out27493ca827822bb6341444b0c5cdfb65511537c2
Backed out changeset 27493ca82782 (bug 1353476) for bustage.
dom/media/systemservices/CamerasParent.cpp
dom/media/systemservices/CamerasParent.h
--- a/dom/media/systemservices/CamerasParent.cpp
+++ b/dom/media/systemservices/CamerasParent.cpp
@@ -39,28 +39,26 @@ namespace camera {
 // - the main thread for some setups, and occassionally for video capture setup
 //   calls that don't work correctly elsewhere.
 // - the IPC thread on which PBackground is running and which receives and
 //   sends messages
 // - a thread which will execute the actual (possibly slow) camera access
 //   called "VideoCapture". On Windows this is a thread with an event loop
 //   suitable for UI access.
 
-// InputObserver is owned by CamerasParent, and it has a ref to CamerasParent
 void InputObserver::DeviceChange() {
   LOG((__PRETTY_FUNCTION__));
   MOZ_ASSERT(mParent);
 
-  RefPtr<InputObserver> self(this);
   RefPtr<nsIRunnable> ipc_runnable =
-    media::NewRunnableFrom([self]() -> nsresult {
-      if (self->mParent->IsShuttingDown()) {
+    media::NewRunnableFrom([this]() -> nsresult {
+      if (mParent->IsShuttingDown()) {
         return NS_ERROR_FAILURE;
       }
-      Unused << self->mParent->SendDeviceChange();
+      Unused << mParent->SendDeviceChange();
       return NS_OK;
     });
 
   nsIThread* thread = mParent->GetBackgroundThread();
   MOZ_ASSERT(thread != nullptr);
   thread->Dispatch(ipc_runnable, NS_DISPATCH_NORMAL);
 };
 
@@ -402,17 +400,16 @@ CamerasParent::SetupEngine(CaptureEngine
   helper->mConfig.Set<webrtc::CaptureDeviceInfo>(captureDeviceInfo);
   helper->mEngine = webrtc::VideoEngine::Create(helper->mConfig);
 
   if (!helper->mEngine) {
     LOG(("VideoEngine::Create failed"));
     return false;
   }
 
-<<<<<<< local
   helper->mPtrViEBase = webrtc::ViEBase::GetInterface(helper->mEngine);
   if (!helper->mPtrViEBase) {
     LOG(("ViEBase::GetInterface failed"));
     return false;
   }
 
   if (helper->mPtrViEBase->Init() < 0) {
     LOG(("ViEBase::Init failed"));
@@ -433,23 +430,16 @@ CamerasParent::SetupEngine(CaptureEngine
 #else
   helper->mPtrViECapture->RegisterInputObserver(*observer);
 #endif
 
   helper->mPtrViERender = webrtc::ViERender::GetInterface(helper->mEngine);
   if (!helper->mPtrViERender) {
     LOG(("ViERender::GetInterface failed"));
     return false;
-=======
-  RefPtr<InputObserver>* observer = mObservers.AppendElement(new InputObserver(this));
-  auto device_info = engine->get()->GetOrCreateVideoCaptureDeviceInfo();
-  MOZ_ASSERT(device_info);
-  if (device_info) {
-    device_info->RegisterVideoInputFeedBack(*(observer->get()));
->>>>>>> graft
   }
 
   return true;
 }
 
 void
 CamerasParent::CloseEngines()
 {
@@ -492,17 +482,19 @@ CamerasParent::CloseEngines()
     }
     if (mEngines[i].mEngine) {
       mEngines[i].mEngine->SetTraceCallback(nullptr);
       webrtc::VideoEngine::Delete(mEngines[i].mEngine);
       mEngines[i].mEngine = nullptr;
     }
   }
 
-  // the observers hold references to us
+  for (InputObserver* observer : mObservers) {
+    delete observer;
+  }
   mObservers.Clear();
 
   mWebRTCAlive = false;
 }
 
 bool
 CamerasParent::EnsureInitialized(int aEngine)
 {
--- a/dom/media/systemservices/CamerasParent.h
+++ b/dom/media/systemservices/CamerasParent.h
@@ -74,27 +74,23 @@ public:
 
   // Engine alive
   bool mEngineIsRunning;
 };
 
 class InputObserver :  public webrtc::ViEInputObserver
 {
 public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(InputObserver)
-
   explicit InputObserver(CamerasParent* aParent)
     : mParent(aParent) {};
   virtual void DeviceChange();
 
   friend CamerasParent;
 
 private:
-  ~InputObserver() {}
-
   RefPtr<CamerasParent> mParent;
 };
 
 class CamerasParent :  public PCamerasParent,
                        public nsIObserver
 {
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVER
@@ -171,17 +167,17 @@ protected:
   base::Thread* mVideoCaptureThread;
 
   // Shutdown handling
   bool mChildIsAlive;
   bool mDestroyed;
   // Above 2 are PBackground only, but this is potentially
   // read cross-thread.
   mozilla::Atomic<bool> mWebRTCAlive;
-  nsTArray<RefPtr<InputObserver>> mObservers;
+  nsTArray<InputObserver*> mObservers;
 };
 
 PCamerasParent* CreateCamerasParent();
 
 } // namespace camera
 } // namespace mozilla
 
 #endif  // mozilla_CameraParent_h