From e1b84a0b2b79be93ee0b0ca340e4f5e6e79d7bb3 Mon Sep 17 00:00:00 2001 From: "tommi@webrtc.org" Date: Sun, 1 Mar 2015 08:29:23 +0000 Subject: [PATCH] Fix a race reported by tsan. TSAN complains about this variable not having synchronized access, so I'm using atomic operations on it instead. There's no functional difference really though. R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/42539004 Cr-Commit-Position: refs/heads/master@{#8543} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8543 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/video_engine/vie_capturer.cc | 6 +++--- webrtc/video_engine/vie_capturer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webrtc/video_engine/vie_capturer.cc b/webrtc/video_engine/vie_capturer.cc index e777144bdb..a2f0fd5f75 100644 --- a/webrtc/video_engine/vie_capturer.cc +++ b/webrtc/video_engine/vie_capturer.cc @@ -79,7 +79,7 @@ ViECapturer::ViECapturer(int capture_id, "ViECaptureThread")), capture_event_(*EventWrapper::Create()), deliver_event_(*EventWrapper::Create()), - stop_(false), + stop_(0), effect_filter_(NULL), image_proc_module_(NULL), image_proc_module_ref_counter_(0), @@ -104,7 +104,7 @@ ViECapturer::~ViECapturer() { module_process_thread_.DeRegisterModule(overuse_detector_.get()); // Stop the thread. - stop_ = true; + rtc::AtomicOps::Increment(&stop_); capture_event_.Set(); // Stop the camera input. @@ -468,7 +468,7 @@ bool ViECapturer::ViECaptureThreadFunction(void* obj) { bool ViECapturer::ViECaptureProcess() { int64_t capture_time = -1; if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) { - if (stop_) + if (rtc::AtomicOps::Load(&stop_)) return false; overuse_detector_->FrameProcessingStarted(); diff --git a/webrtc/video_engine/vie_capturer.h b/webrtc/video_engine/vie_capturer.h index dcf67df0d1..4dfcfbf9ad 100644 --- a/webrtc/video_engine/vie_capturer.h +++ b/webrtc/video_engine/vie_capturer.h @@ -169,7 +169,7 @@ class ViECapturer EventWrapper& capture_event_; EventWrapper& deliver_event_; - bool stop_; + volatile int stop_; rtc::scoped_ptr captured_frame_; rtc::scoped_ptr deliver_frame_;