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

Unified Diff: webrtc/api/android/java/src/org/webrtc/Camera1Session.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 | « no previous file | webrtc/api/android/java/src/org/webrtc/Camera2Session.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/Camera1Session.java
diff --git a/webrtc/api/android/java/src/org/webrtc/Camera1Session.java b/webrtc/api/android/java/src/org/webrtc/Camera1Session.java
index 2d897e3ed1de617e2b84af84c866ba891bd23731..9081999641aaebff713139c321a77288f791aba2 100644
--- a/webrtc/api/android/java/src/org/webrtc/Camera1Session.java
+++ b/webrtc/api/android/java/src/org/webrtc/Camera1Session.java
@@ -22,7 +22,6 @@ import android.view.WindowManager;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@SuppressWarnings("deprecation")
@@ -181,40 +180,15 @@ public class Camera1Session implements CameraSession {
@Override
public void stop() {
- final long stopStartTime = System.nanoTime();
Logging.d(TAG, "Stop camera1 session on camera " + cameraId);
- if (Thread.currentThread() == cameraThreadHandler.getLooper().getThread()) {
- if (state != SessionState.STOPPED) {
- state = SessionState.STOPPED;
- // Post the stopInternal to return earlier.
- cameraThreadHandler.post(new Runnable() {
- @Override
- public void run() {
- stopInternal();
- final int stopTimeMs =
- (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - stopStartTime);
- camera1StopTimeMsHistogram.addSample(stopTimeMs);
- }
- });
- }
- } else {
- final CountDownLatch stopLatch = new CountDownLatch(1);
-
- cameraThreadHandler.post(new Runnable() {
- @Override
- public void run() {
- if (state != SessionState.STOPPED) {
- state = SessionState.STOPPED;
- stopLatch.countDown();
- stopInternal();
- final int stopTimeMs =
- (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - stopStartTime);
- camera1StopTimeMsHistogram.addSample(stopTimeMs);
- }
- }
- });
-
- ThreadUtils.awaitUninterruptibly(stopLatch);
+ checkIsOnCameraThread();
+ if (state != SessionState.STOPPED) {
+ final long stopStartTime = System.nanoTime();
+ state = SessionState.STOPPED;
+ stopInternal();
+ final int stopTimeMs =
+ (int) TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - stopStartTime);
+ camera1StopTimeMsHistogram.addSample(stopTimeMs);
}
}
« no previous file with comments | « no previous file | webrtc/api/android/java/src/org/webrtc/Camera2Session.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698