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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller.cc

Issue 7859018: Fix a couple of data races found by TSAN Race Verifier in VideoCaptureController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/video_capture_controller.h" 5 #include "content/browser/renderer_host/media/video_capture_controller.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "content/browser/browser_thread.h" 8 #include "content/browser/browser_thread.h"
9 #include "content/browser/renderer_host/media/media_stream_manager.h" 9 #include "content/browser/renderer_host/media/media_stream_manager.h"
10 #include "content/browser/renderer_host/media/video_capture_manager.h" 10 #include "content/browser/renderer_host/media/video_capture_manager.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 stopped_task)); 52 stopped_task));
53 } 53 }
54 54
55 void VideoCaptureController::ReturnBuffer(int buffer_id) { 55 void VideoCaptureController::ReturnBuffer(int buffer_id) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
57 57
58 bool ready_to_delete; 58 bool ready_to_delete;
59 { 59 {
60 base::AutoLock lock(lock_); 60 base::AutoLock lock(lock_);
61 free_dibs_.push_back(buffer_id); 61 free_dibs_.push_back(buffer_id);
62 ready_to_delete = (free_dibs_.size() == owned_dibs_.size()); 62 ready_to_delete = (free_dibs_.size() == owned_dibs_.size()) &&
63 report_ready_to_delete_;
63 } 64 }
64 if (report_ready_to_delete_ && ready_to_delete) { 65 if (ready_to_delete) {
65 event_handler_->OnReadyToDelete(id_); 66 event_handler_->OnReadyToDelete(id_);
66 } 67 }
67 } 68 }
68 69
69 /////////////////////////////////////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////////////
70 // Implements VideoCaptureDevice::EventHandler. 71 // Implements VideoCaptureDevice::EventHandler.
71 // OnIncomingCapturedFrame is called the thread running the capture device. 72 // OnIncomingCapturedFrame is called the thread running the capture device.
72 // I.e.- DirectShow thread on windows and v4l2_thread on Linux. 73 // I.e.- DirectShow thread on windows and v4l2_thread on Linux.
73 void VideoCaptureController::OnIncomingCapturedFrame(const uint8* data, 74 void VideoCaptureController::OnIncomingCapturedFrame(const uint8* data,
74 int length, 75 int length,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 event_handler_->OnFrameInfo(id_, info.width, info.height, info.frame_rate); 192 event_handler_->OnFrameInfo(id_, info.width, info.height, info.frame_rate);
192 } 193 }
193 194
194 /////////////////////////////////////////////////////////////////////////////// 195 ///////////////////////////////////////////////////////////////////////////////
195 // Called by VideoCaptureManager when a device have been stopped. 196 // Called by VideoCaptureManager when a device have been stopped.
196 // This will report to the event handler that this object is ready to be deleted 197 // This will report to the event handler that this object is ready to be deleted
197 // if all DIBS have been returned. 198 // if all DIBS have been returned.
198 void VideoCaptureController::OnDeviceStopped(Task* stopped_task) { 199 void VideoCaptureController::OnDeviceStopped(Task* stopped_task) {
199 bool ready_to_delete_now; 200 bool ready_to_delete_now;
200 201
201 // Set flag to indicate we need to report when all DIBs have been returned.
202 report_ready_to_delete_ = true;
203 { 202 {
204 base::AutoLock lock(lock_); 203 base::AutoLock lock(lock_);
204 // Set flag to indicate we need to report when all DIBs have been returned.
205 report_ready_to_delete_ = true;
205 ready_to_delete_now = (free_dibs_.size() == owned_dibs_.size()); 206 ready_to_delete_now = (free_dibs_.size() == owned_dibs_.size());
206 } 207 }
207 208
208 if (ready_to_delete_now) { 209 if (ready_to_delete_now) {
209 event_handler_->OnReadyToDelete(id_); 210 event_handler_->OnReadyToDelete(id_);
210 } 211 }
211 if (stopped_task) { 212 if (stopped_task) {
212 stopped_task->Run(); 213 stopped_task->Run();
213 delete stopped_task; 214 delete stopped_task;
214 } 215 }
215 } 216 }
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/tsan/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698