diff options
author | glaznev@webrtc.org <glaznev@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-07-14 17:01:53 +0000 |
---|---|---|
committer | glaznev@webrtc.org <glaznev@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-07-14 17:01:53 +0000 |
commit | 82383d9b14ff8e5fedf5a70229eb0ac6b512909a (patch) | |
tree | 5546ceaf1c4d7470424c58d73acea75529bf0d54 /modules/video_capture/android/video_capture_android.cc | |
parent | ccf0fef3741cbc1a499d9be260d3df142a2ec85d (diff) | |
download | webrtc-82383d9b14ff8e5fedf5a70229eb0ac6b512909a.tar.gz |
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/webrtc@6673 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'modules/video_capture/android/video_capture_android.cc')
-rw-r--r-- | modules/video_capture/android/video_capture_android.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/video_capture/android/video_capture_android.cc b/modules/video_capture/android/video_capture_android.cc index 6f0200e6..4bc14e5a 100644 --- a/modules/video_capture/android/video_capture_android.cc +++ b/modules/video_capture/android/video_capture_android.cc @@ -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"); |