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

Unified Diff: webrtc/api/java/jni/androidvideocapturer_jni.cc

Issue 2033943004: Handle Android stop capturer race. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/jni/androidvideocapturer_jni.cc
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.cc b/webrtc/api/java/jni/androidvideocapturer_jni.cc
index 0abc9c0d51b9c987df660924b8b9a2a6f1006288..3ebf3464fb7c2f2d8322487ecdb8b3128132777c 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.cc
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.cc
@@ -89,6 +89,10 @@ void AndroidVideoCapturerJni::Stop() {
LOG(LS_INFO) << "AndroidVideoCapturerJni stop";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
{
+ // TODO(nisse): Consider moving this block until *after* the call to
+ // stopCapturer. stopCapturer should ensure that we get no
+ // more frames, and then we shouldn't need the if (!capturer_)
+ // checks in OnMemoryBufferFrame and OnTextureFrame.
rtc::CritScope cs(&capturer_lock_);
// Destroying |invoker_| will cancel all pending calls to |capturer_|.
invoker_ = nullptr;
@@ -172,7 +176,10 @@ void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
rotation == 270);
rtc::CritScope cs(&capturer_lock_);
-
+ if (!capturer_) {
+ LOG(LS_WARNING) << "OnMemoryBufferFrame() called for closed capturer.";
+ return;
+ }
int adapted_width;
int adapted_height;
int crop_width;
@@ -252,7 +259,10 @@ void AndroidVideoCapturerJni::OnTextureFrame(int width,
RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
rotation == 270);
rtc::CritScope cs(&capturer_lock_);
-
+ if (!capturer_) {
+ LOG(LS_WARNING) << "OnTextureFrame() called for closed capturer.";
+ return;
+ }
int adapted_width;
int adapted_height;
int crop_width;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698