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

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

Issue 2238263002: Make CameraCapturer.switchCamera try again if session is still opening. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changes according to magjed's comments. Created 4 years, 4 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 | webrtc/api/android/java/src/org/webrtc/CameraCapturer.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/android/java/src/org/webrtc/Camera2Session.java
diff --git a/webrtc/api/android/java/src/org/webrtc/Camera2Session.java b/webrtc/api/android/java/src/org/webrtc/Camera2Session.java
index 5e32c27102f95dc01dcf1b678a5e346aa61c5c82..9bcdfafa204c55907b72af1a789ba900b0ced421 100644
--- a/webrtc/api/android/java/src/org/webrtc/Camera2Session.java
+++ b/webrtc/api/android/java/src/org/webrtc/Camera2Session.java
@@ -318,21 +318,35 @@ public class Camera2Session implements CameraSession {
@Override
public void stop() {
Logging.d(TAG, "Stop camera2 session on camera " + cameraId);
- final CountDownLatch stopLatch = new CountDownLatch(1);
-
- cameraThreadHandler.post(new Runnable() {
- @Override
- public void run() {
- if (state != SessionState.STOPPED) {
- state = SessionState.STOPPED;
- capturerObserver.onCapturerStopped();
- stopLatch.countDown();
- stopInternal();
- }
+ if (Thread.currentThread() == cameraThreadHandler.getLooper().getThread()) {
+ if (state != SessionState.STOPPED) {
+ state = SessionState.STOPPED;
+ capturerObserver.onCapturerStopped();
+ // Post the stopInternal to return earlier.
+ cameraThreadHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ stopInternal();
+ }
+ });
}
- });
+ } else {
+ final CountDownLatch stopLatch = new CountDownLatch(1);
+
+ cameraThreadHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (state != SessionState.STOPPED) {
+ state = SessionState.STOPPED;
+ capturerObserver.onCapturerStopped();
+ stopLatch.countDown();
+ stopInternal();
+ }
+ }
+ });
- ThreadUtils.awaitUninterruptibly(stopLatch);
+ ThreadUtils.awaitUninterruptibly(stopLatch);
+ }
}
private void stopInternal() {
« no previous file with comments | « no previous file | webrtc/api/android/java/src/org/webrtc/CameraCapturer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698