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

Unified Diff: media/video/capture/mac/video_capture_device_mac.mm

Issue 10905134: use lock to make sure device will not deliver any frame after it's stopped. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/mac/video_capture_device_mac.mm
===================================================================
--- media/video/capture/mac/video_capture_device_mac.mm (revision 155213)
+++ media/video/capture/mac/video_capture_device_mac.mm (working copy)
@@ -49,6 +49,7 @@
void VideoCaptureDeviceMac::Allocate(int width, int height, int frame_rate,
EventHandler* observer) {
+ base::AutoLock auto_lock(lock_);
if (state_ != kIdle) {
return;
}
@@ -85,16 +86,19 @@
SetErrorState("Could not start capture device.");
return;
}
+ base::AutoLock auto_lock(lock_);
state_ = kCapturing;
}
void VideoCaptureDeviceMac::Stop() {
DCHECK_EQ(state_, kCapturing);
[capture_device_ stopCapture];
+ base::AutoLock auto_lock(lock_);
state_ = kAllocated;
}
void VideoCaptureDeviceMac::DeAllocate() {
+ base::AutoLock auto_lock(lock_);
if (state_ != kAllocated && state_ != kCapturing) {
return;
}
@@ -134,12 +138,16 @@
const uint8* video_frame,
int video_frame_length,
const VideoCaptureCapability& frame_info) {
- observer_->OnIncomingCapturedFrame(video_frame, video_frame_length,
- base::Time::Now());
+ base::AutoLock auto_lock(lock_);
+ if (state_ == kCapturing) {
+ observer_->OnIncomingCapturedFrame(video_frame, video_frame_length,
+ base::Time::Now());
+ }
}
void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) {
DLOG(ERROR) << reason;
+ base::AutoLock auto_lock(lock_);
state_ = kError;
observer_->OnError();
}
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698