diff options
author | Sai Kumar Sanagavarapu <ssanagav@codeaurora.org> | 2015-03-13 11:35:58 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-04-16 04:02:19 -0700 |
commit | 164a956d7aa04958df9043cc33bb0cca11bed29f (patch) | |
tree | 6ff3e1f8c6a45d532d7618ad51a68288132204b0 /src/com | |
parent | 0202eb424a9f8dfe472b6cfbf35b88f3fdacd025 (diff) | |
download | android_packages_apps_Snap-164a956d7aa04958df9043cc33bb0cca11bed29f.tar.gz android_packages_apps_Snap-164a956d7aa04958df9043cc33bb0cca11bed29f.tar.bz2 android_packages_apps_Snap-164a956d7aa04958df9043cc33bb0cca11bed29f.zip |
SnapdragonCamera: Fix preview window race condition.
There could be race condition between onPreviewUIReady() and start
preview thread leading to final null preview window being set to
camera device even though a valid surface is available at the time
of start preview.
Fix this by synchronizing these two threads.
Change-Id: I07654ee3c5d1c71530ef5b588f30d22c65f04e61
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index e2fc34b0c..cf1de18f3 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -584,12 +584,14 @@ public class PhotoModule if (mCameraState == PREVIEW_STOPPED) { startPreview(); } else { - SurfaceHolder sh = mUI.getSurfaceHolder(); - if (sh == null) { - Log.w(TAG, "startPreview: holder for preview are not ready."); - return; + synchronized (mCameraDevice) { + SurfaceHolder sh = mUI.getSurfaceHolder(); + if (sh == null) { + Log.w(TAG, "startPreview: holder for preview are not ready."); + return; + } + mCameraDevice.setPreviewDisplay(sh); } - mCameraDevice.setPreviewDisplay(sh); } } @@ -2617,15 +2619,16 @@ public class PhotoModule return; } - SurfaceHolder sh = null; - Log.v(TAG, "startPreview: SurfaceHolder (MDP path)"); - if (mUI != null) { - sh = mUI.getSurfaceHolder(); - } + synchronized (mCameraDevice) { + SurfaceHolder sh = null; + Log.v(TAG, "startPreview: SurfaceHolder (MDP path)"); + if (mUI != null) { + sh = mUI.getSurfaceHolder(); + } - setCameraParameters(UPDATE_PARAM_ALL); - // Let UI set its expected aspect ratio - mCameraDevice.setPreviewDisplay(sh); + // Let UI set its expected aspect ratio + mCameraDevice.setPreviewDisplay(sh); + } if (!mCameraPreviewParamsReady) { Log.w(TAG, "startPreview: parameters for preview are not ready."); |