summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilian Peev <epeevs@codeaurora.org>2015-06-02 14:50:30 +0300
committerArne Coucheron <arco68@gmail.com>2018-01-27 00:41:42 +0100
commit2351f5b56a3571b0bb9f75dc4b355a86ceef5709 (patch)
tree8094ad3c063e9317c96ccb084a013256c41721ae
parentcc4130a5923c70ba11c00146ec18c8766cb4e18e (diff)
downloadandroid_packages_apps_Snap-2351f5b56a3571b0bb9f75dc4b355a86ceef5709.zip
android_packages_apps_Snap-2351f5b56a3571b0bb9f75dc4b355a86ceef5709.tar.gz
android_packages_apps_Snap-2351f5b56a3571b0bb9f75dc4b355a86ceef5709.tar.bz2
Snapdragon Camera: Avoid possible race condition
Camera open and preview start are currently executed in a separate thread different from the main handler thread. If the main thread tries to switch the camera immediately after the open camera thread starts a race condition is possible. This race condition can lead to a failing assert in CameraHolder which can receive two camera open requests one after another. To resolve this the main handler thread needs to check whether an open camera thread got initialized and started previously. If the check is positive, it needs to wait until the separate thread finishes before proceeding with the camera switch sequence. Change-Id: I409e3158bc976120de31540351ea8e55fddbca46
-rw-r--r--src/com/android/camera/PhotoModule.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index f48dca8..9056d87 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -762,6 +762,15 @@ public class PhotoModule
mSnapshotOnIdle = false;
setCameraId(mCameraId);
+ try {
+ if (mOpenCameraThread != null) {
+ mOpenCameraThread.join();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ mOpenCameraThread = null;
+
// from onPause
try {
if (mOpenCameraThread != null) {