Fix deadlock in Android stopCapture() call.

BUG=3467
R=braveyao@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6673 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
glaznev@webrtc.org 2014-07-14 17:01:53 +00:00
parent 5f43ce6784
commit a4da771914

View File

@ -130,6 +130,8 @@ VideoCaptureModule* VideoCaptureImpl::Create(
int32_t VideoCaptureAndroid::OnIncomingFrame(uint8_t* videoFrame,
int32_t videoFrameLength,
int64_t captureTime) {
if (!_captureStarted)
return 0;
return IncomingFrame(
videoFrame, videoFrameLength, _captureCapability, captureTime);
}
@ -209,13 +211,16 @@ int32_t VideoCaptureAndroid::StartCapture(
}
int32_t VideoCaptureAndroid::StopCapture() {
CriticalSectionScoped cs(&_apiCs);
_apiCs.Enter();
AttachThreadScoped ats(g_jvm);
JNIEnv* env = ats.env();
memset(&_requestedCapability, 0, sizeof(_requestedCapability));
memset(&_captureCapability, 0, sizeof(_captureCapability));
_captureStarted = false;
// Exit critical section to avoid blocking camera thread inside
// onIncomingFrame() call.
_apiCs.Leave();
jmethodID j_stop =
env->GetMethodID(g_java_capturer_class, "stopCapture", "()Z");