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

Unified Diff: webrtc/api/android/java/src/org/webrtc/CameraCapturer.java

Issue 2357213002: Fix deadlock issue in CameraCapturer.stopCapture. (Closed)
Patch Set: Changes according to magjed's comments. Created 4 years, 3 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 | « webrtc/api/android/java/src/org/webrtc/Camera2Session.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/android/java/src/org/webrtc/CameraCapturer.java
diff --git a/webrtc/api/android/java/src/org/webrtc/CameraCapturer.java b/webrtc/api/android/java/src/org/webrtc/CameraCapturer.java
index e0ce19d42a005af694662bd67e985773a3b92660..2b0ffdcee798848d6d781cf2b9c9c6dc429ff940 100644
--- a/webrtc/api/android/java/src/org/webrtc/CameraCapturer.java
+++ b/webrtc/api/android/java/src/org/webrtc/CameraCapturer.java
@@ -40,8 +40,8 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
checkIsOnCameraThread();
Logging.d(TAG, "Create session done");
uiThreadHandler.removeCallbacks(openCameraTimeoutRunnable);
- capturerObserver.onCapturerStarted(true /* success */);
synchronized (stateLock) {
+ capturerObserver.onCapturerStarted(true /* success */);
sessionOpening = false;
currentSession = session;
cameraStatistics = new CameraStatistics(surfaceHelper, eventsHandler);
@@ -66,8 +66,8 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
public void onFailure(String error) {
checkIsOnCameraThread();
uiThreadHandler.removeCallbacks(openCameraTimeoutRunnable);
- capturerObserver.onCapturerStarted(false /* success */);
synchronized (stateLock) {
+ capturerObserver.onCapturerStarted(false /* success */);
openAttemptsRemaining--;
if (openAttemptsRemaining <= 0) {
@@ -284,11 +284,18 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
ThreadUtils.waitUninterruptibly(stateLock);
}
+
if (currentSession != null) {
- Logging.d(TAG, "Stop capture: Stopping session");
+ Logging.d(TAG, "Stop capture: Nulling session");
cameraStatistics.release();
cameraStatistics = null;
- currentSession.stop();
+ final CameraSession oldSession = currentSession;
+ cameraThreadHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ oldSession.stop();
+ }
+ });
currentSession = null;
capturerObserver.onCapturerStopped();
} else {
@@ -397,7 +404,13 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
Logging.d(TAG, "switchCamera: Stopping session");
cameraStatistics.release();
cameraStatistics = null;
- currentSession.stop();
+ final CameraSession oldSession = currentSession;
+ cameraThreadHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ oldSession.stop();
+ }
+ });
currentSession = null;
int cameraNameIndex = Arrays.asList(deviceNames).indexOf(cameraName);
« no previous file with comments | « webrtc/api/android/java/src/org/webrtc/Camera2Session.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698