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(); |
} |