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

Unified Diff: webrtc/sdk/android/api/org/webrtc/Camera1Session.java

Issue 2640093003: Camera1Session: Fix camera sometimes getting stopped twice. (Closed)
Patch Set: Switch if-statement around Created 3 years, 11 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/sdk/android/api/org/webrtc/Camera1Session.java
diff --git a/webrtc/sdk/android/api/org/webrtc/Camera1Session.java b/webrtc/sdk/android/api/org/webrtc/Camera1Session.java
index 8f2988642f9dab4a772511c7a11cd9a824eff76c..af67658a7c4cacc73ffa9ea74c9045e9a0820e1a 100644
--- a/webrtc/sdk/android/api/org/webrtc/Camera1Session.java
+++ b/webrtc/sdk/android/api/org/webrtc/Camera1Session.java
@@ -177,7 +177,6 @@ public class Camera1Session implements CameraSession {
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);
@@ -200,7 +199,6 @@ public class Camera1Session implements CameraSession {
errorMessage = "Camera error: " + error;
}
Logging.e(TAG, errorMessage);
- state = SessionState.STOPPED;
stopInternal();
if (error == android.hardware.Camera.CAMERA_ERROR_EVICTED) {
events.onCameraDisconnected(Camera1Session.this);
@@ -218,7 +216,6 @@ public class Camera1Session implements CameraSession {
try {
camera.startPreview();
} catch (RuntimeException e) {
- state = SessionState.STOPPED;
stopInternal();
events.onCameraError(this, e.getMessage());
}
@@ -227,16 +224,19 @@ public class Camera1Session implements CameraSession {
private void stopInternal() {
Logging.d(TAG, "Stop internal");
checkIsOnCameraThread();
+ if (state == SessionState.STOPPED) {
+ Logging.d(TAG, "Camera is already stopped");
+ return;
+ }
+ state = SessionState.STOPPED;
surfaceTextureHelper.stopListening();
-
// Note: stopPreview or other driver code might deadlock. Deadlock in
// android.hardware.Camera._stopPreview(Native Method) has been observed on
// Nexus 5 (hammerhead), OS version LMY48I.
camera.stopPreview();
camera.release();
events.onCameraClosed(this);
-
Logging.d(TAG, "Stop done");
}
« 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