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); |
} |
} |