Bug 817141 - Call EndTrack()/Finish() from StopPreview() (as well) to prevent deadlock. r=kchen, a=blocking-basecamp
authorMike Habicher <mikeh@mozilla.com>
Tue, 04 Dec 2012 21:00:39 -0500
changeset 119100 c02926efc5faa6fc42bf18933ff34f9d32585f67
parent 119099 d6239ba4d40f984105916ae86ccc0ef719986c14
child 119101 28932b5006920b37c01ac00f97a251b57460147e
push id3054
push userryanvm@gmail.com
push dateMon, 24 Dec 2012 21:22:01 +0000
treeherdermozilla-aurora@c02926efc5fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskchen, blocking-basecamp
bugs817141
milestone19.0a2
Bug 817141 - Call EndTrack()/Finish() from StopPreview() (as well) to prevent deadlock. r=kchen, a=blocking-basecamp
dom/camera/DOMCameraPreview.cpp
--- a/dom/camera/DOMCameraPreview.cpp
+++ b/dom/camera/DOMCameraPreview.cpp
@@ -244,25 +244,30 @@ DOMCameraPreview::StopPreview()
   NS_ASSERTION(NS_IsMainThread(), "StopPreview() not called from main thread");
   if (mState != STARTED) {
     return;
   }
 
   DOM_CAMERA_LOGI("Stopping preview stream\n");
   DOM_CAMERA_SETSTATE(STOPPING);
   mCameraControl->StopPreview();
+  mInput->EndTrack(TRACK_VIDEO);
+  mInput->Finish();
 }
 
 void
 DOMCameraPreview::SetStateStopped()
 {
   NS_ASSERTION(NS_IsMainThread(), "SetStateStopped() not called from main thread");
 
-  mInput->EndTrack(TRACK_VIDEO);
-  mInput->Finish();
+  // see bug 809259 and bug 817367.
+  if (mState != STOPPING) {
+    mInput->EndTrack(TRACK_VIDEO);
+    mInput->Finish();
+  }
   DOM_CAMERA_SETSTATE(STOPPED);
   DOM_CAMERA_LOGI("Preview stream stopped\n");
 
   /**
    * Only remove the reference added in Start() once the preview
    * has stopped completely.
    */
   NS_RELEASE_THIS();