Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: webrtc/video/video_capture_input.cc

Issue 1246073002: Implement store as an explicit atomic operation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: gcc/clang builtin atomics Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/system_wrappers/source/trace_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 stats_proxy)) { 56 stats_proxy)) {
57 capture_thread_->Start(); 57 capture_thread_->Start();
58 capture_thread_->SetPriority(kHighPriority); 58 capture_thread_->SetPriority(kHighPriority);
59 module_process_thread_->RegisterModule(overuse_detector_.get()); 59 module_process_thread_->RegisterModule(overuse_detector_.get());
60 } 60 }
61 61
62 VideoCaptureInput::~VideoCaptureInput() { 62 VideoCaptureInput::~VideoCaptureInput() {
63 module_process_thread_->DeRegisterModule(overuse_detector_.get()); 63 module_process_thread_->DeRegisterModule(overuse_detector_.get());
64 64
65 // Stop the thread. 65 // Stop the thread.
66 rtc::AtomicOps::Increment(&stop_); 66 rtc::AtomicOps::Increment(&stop_);
Alexander Potapenko 2015/07/22 13:43:00 Isn't rtc::AtomicOps::ReleaseStore(&stop, 1) enoug
pbos-webrtc 2015/07/22 13:51:04 Done.
67 capture_event_.Set(); 67 capture_event_.Set();
68 68
69 // Stop the camera input. 69 // Stop the camera input.
70 capture_thread_->Stop(); 70 capture_thread_->Stop();
71 delete &capture_event_; 71 delete &capture_event_;
72 delete &deliver_event_; 72 delete &deliver_event_;
73 } 73 }
74 74
75 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) { 75 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
76 // TODO(pbos): Remove local rendering, it should be handled by the client code 76 // TODO(pbos): Remove local rendering, it should be handled by the client code
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 bool VideoCaptureInput::CaptureThreadFunction(void* obj) { 123 bool VideoCaptureInput::CaptureThreadFunction(void* obj) {
124 return static_cast<VideoCaptureInput*>(obj)->CaptureProcess(); 124 return static_cast<VideoCaptureInput*>(obj)->CaptureProcess();
125 } 125 }
126 126
127 bool VideoCaptureInput::CaptureProcess() { 127 bool VideoCaptureInput::CaptureProcess() {
128 static const int kThreadWaitTimeMs = 100; 128 static const int kThreadWaitTimeMs = 100;
129 int64_t capture_time = -1; 129 int64_t capture_time = -1;
130 if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) { 130 if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) {
131 if (rtc::AtomicOps::Load(&stop_)) 131 if (rtc::AtomicOps::AcquireLoad(&stop_))
132 return false; 132 return false;
133 133
134 int64_t encode_start_time = -1; 134 int64_t encode_start_time = -1;
135 VideoFrame deliver_frame; 135 VideoFrame deliver_frame;
136 { 136 {
137 CriticalSectionScoped cs(capture_cs_.get()); 137 CriticalSectionScoped cs(capture_cs_.get());
138 if (!captured_frame_.IsZeroSize()) { 138 if (!captured_frame_.IsZeroSize()) {
139 deliver_frame = captured_frame_; 139 deliver_frame = captured_frame_;
140 captured_frame_.Reset(); 140 captured_frame_.Reset();
141 } 141 }
(...skipping 11 matching lines...) Expand all
153 } 153 }
154 // We're done! 154 // We're done!
155 if (capture_time != -1) { 155 if (capture_time != -1) {
156 overuse_detector_->FrameSent(capture_time); 156 overuse_detector_->FrameSent(capture_time);
157 } 157 }
158 return true; 158 return true;
159 } 159 }
160 160
161 } // namespace internal 161 } // namespace internal
162 } // namespace webrtc 162 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/source/trace_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698