VideoCaptureImpl::IncomingFrame(): avoid deadlock by acquiring _apiCs.

Since VCI::IF() fires a callback it risks a call back into VCI on the same
stack.  Failing to acquire _apiCs before _callbackCs means this is a lock
inversion and deadlock results.  By acquiring _apiCs first no lock inversion
occurs and the deadlock is removed.

BUG=3434
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/14629004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6353 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2014-06-06 18:28:28 +00:00
parent 91c910469f
commit 42694c5937

View File

@ -260,7 +260,8 @@ int32_t VideoCaptureImpl::IncomingFrame(
const VideoCaptureCapability& frameInfo,
int64_t captureTime/*=0*/)
{
CriticalSectionScoped cs(&_callBackCs);
CriticalSectionScoped cs(&_apiCs);
CriticalSectionScoped cs2(&_callBackCs);
const int32_t width = frameInfo.width;
const int32_t height = frameInfo.height;
@ -332,7 +333,8 @@ int32_t VideoCaptureImpl::IncomingFrame(
int32_t VideoCaptureImpl::IncomingI420VideoFrame(I420VideoFrame* video_frame,
int64_t captureTime) {
CriticalSectionScoped cs(&_callBackCs);
CriticalSectionScoped cs(&_apiCs);
CriticalSectionScoped cs2(&_callBackCs);
DeliverCapturedFrame(*video_frame, captureTime);
return 0;