Bug 1452048 - Read _captureStarted under lock on the camera thread. r=dminor
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 06 Apr 2018 15:50:31 +0200
changeset 412407 a83f3f831cabb7bacd03baadb2244f6bf34d242f
parent 412406 729193a3d03ae3d3ed5ef9fcbf005662f256f2eb
child 412408 b113a2f83d32dabb98498210d1ce34f16ba32d9a
push id33803
push userapavel@mozilla.com
push dateMon, 09 Apr 2018 21:54:49 +0000
treeherdermozilla-central@bbaa0e5f393c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1452048
milestone61.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 1452048 - Read _captureStarted under lock on the camera thread. r=dminor It is written under lock on the controlling thread (CamerasParent) in StartCapture/StopCapture. MozReview-Commit-ID: E7eq1YElhwt
media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
--- a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
@@ -111,17 +111,20 @@ rtc::scoped_refptr<VideoCaptureModule> V
   }
   return implementation;
 }
 
 int32_t VideoCaptureAndroid::OnIncomingFrame(uint8_t* videoFrame,
                                              size_t videoFrameLength,
                                              int32_t degrees,
                                              int64_t captureTime) {
-  if (!_captureStarted)
+  // _captureStarted is written on the controlling thread in
+  // StartCapture/StopCapture. This is the camera thread.
+  // CaptureStarted() will access it under a lock.
+  if (!CaptureStarted())
     return 0;
 
   VideoRotation current_rotation =
       (degrees <= 45 || degrees > 315) ? kVideoRotation_0 :
       (degrees > 45 && degrees <= 135) ? kVideoRotation_90 :
       (degrees > 135 && degrees <= 225) ? kVideoRotation_180 :
       (degrees > 225 && degrees <= 315) ? kVideoRotation_270 :
       kVideoRotation_0;  // Impossible.