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
This commit is contained in:
tommi@webrtc.org 2015-03-01 08:29:23 +00:00
parent d68fa65d76
commit e1b84a0b2b
2 changed files with 4 additions and 4 deletions

View File

@ -79,7 +79,7 @@ ViECapturer::ViECapturer(int capture_id,
"ViECaptureThread")), "ViECaptureThread")),
capture_event_(*EventWrapper::Create()), capture_event_(*EventWrapper::Create()),
deliver_event_(*EventWrapper::Create()), deliver_event_(*EventWrapper::Create()),
stop_(false), stop_(0),
effect_filter_(NULL), effect_filter_(NULL),
image_proc_module_(NULL), image_proc_module_(NULL),
image_proc_module_ref_counter_(0), image_proc_module_ref_counter_(0),
@ -104,7 +104,7 @@ ViECapturer::~ViECapturer() {
module_process_thread_.DeRegisterModule(overuse_detector_.get()); module_process_thread_.DeRegisterModule(overuse_detector_.get());
// Stop the thread. // Stop the thread.
stop_ = true; rtc::AtomicOps::Increment(&stop_);
capture_event_.Set(); capture_event_.Set();
// Stop the camera input. // Stop the camera input.
@ -468,7 +468,7 @@ bool ViECapturer::ViECaptureThreadFunction(void* obj) {
bool ViECapturer::ViECaptureProcess() { bool ViECapturer::ViECaptureProcess() {
int64_t capture_time = -1; int64_t capture_time = -1;
if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) { if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) {
if (stop_) if (rtc::AtomicOps::Load(&stop_))
return false; return false;
overuse_detector_->FrameProcessingStarted(); overuse_detector_->FrameProcessingStarted();

View File

@ -169,7 +169,7 @@ class ViECapturer
EventWrapper& capture_event_; EventWrapper& capture_event_;
EventWrapper& deliver_event_; EventWrapper& deliver_event_;
bool stop_; volatile int stop_;
rtc::scoped_ptr<I420VideoFrame> captured_frame_; rtc::scoped_ptr<I420VideoFrame> captured_frame_;
rtc::scoped_ptr<I420VideoFrame> deliver_frame_; rtc::scoped_ptr<I420VideoFrame> deliver_frame_;