Fix thread safety in VcmCapturer.

Makes VcmCapturer::Stop() blocking so that no frames can be in delivery
while the camera has stopped.

BUG=
R=mflodman@webrtc.org

Review URL: https://codereview.webrtc.org/1411813004 .

Cr-Original-Commit-Position: refs/heads/master@{#10385}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 1e737c6f2cf835a5b38dab0fc989ab52a749c87a
diff --git a/test/vcm_capturer.cc b/test/vcm_capturer.cc
index c37140f..1c6b919 100644
--- a/test/vcm_capturer.cc
+++ b/test/vcm_capturer.cc
@@ -58,19 +58,25 @@
                                  size_t width,
                                  size_t height,
                                  size_t target_fps) {
-  VcmCapturer* vcm__capturer = new VcmCapturer(input);
-  if (!vcm__capturer->Init(width, height, target_fps)) {
+  VcmCapturer* vcm_capturer = new VcmCapturer(input);
+  if (!vcm_capturer->Init(width, height, target_fps)) {
     // TODO(pbos): Log a warning that this failed.
-    delete vcm__capturer;
+    delete vcm_capturer;
     return NULL;
   }
-  return vcm__capturer;
+  return vcm_capturer;
 }
 
 
-void VcmCapturer::Start() { started_ = true; }
+void VcmCapturer::Start() {
+  rtc::CritScope lock(&crit_);
+  started_ = true;
+}
 
-void VcmCapturer::Stop() { started_ = false; }
+void VcmCapturer::Stop() {
+  rtc::CritScope lock(&crit_);
+  started_ = false;
+}
 
 void VcmCapturer::Destroy() {
   if (vcm_ == NULL) {
@@ -90,6 +96,7 @@
 
 void VcmCapturer::OnIncomingCapturedFrame(const int32_t id,
                                           const VideoFrame& frame) {
+  rtc::CritScope lock(&crit_);
   if (started_)
     input_->IncomingCapturedFrame(frame);
 }