summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmilian Peev <epeevs@codeaurora.org>2015-06-02 14:50:30 +0300
committerMichael Bestas <mikeioannina@gmail.com>2015-08-29 04:15:51 +0300
commita1ba573ab1524c967a45161e7d31ca41ec17d874 (patch)
tree3632bfb47896bfceb1be001144501888bbae921e /src
parentd7afbe38bc2d9cf4f4738378f93a37777cdcc18a (diff)
downloadandroid_packages_apps_Snap-a1ba573ab1524c967a45161e7d31ca41ec17d874.tar.gz
android_packages_apps_Snap-a1ba573ab1524c967a45161e7d31ca41ec17d874.tar.bz2
android_packages_apps_Snap-a1ba573ab1524c967a45161e7d31ca41ec17d874.zip
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
Diffstat (limited to 'src')
-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 da6278d08..2d2662eb3 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -640,6 +640,15 @@ public class PhotoModule
mPendingSwitchCameraId = -1;
setCameraId(mCameraId);
+ try {
+ if (mOpenCameraThread != null) {
+ mOpenCameraThread.join();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ mOpenCameraThread = null;
+
// from onPause
try {
if (mOpenCameraThread != null) {