summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-06-21 12:34:16 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-25 21:55:20 -0700
commitf92a4ca9f22e3bbc497768c2683d44c8ca3f53f0 (patch)
treed778f7e644fd52ed57c209dc0e74cd66123a68e7
parent8e40b3b86c8ca767bd02043674e8dc51762101ff (diff)
downloadandroid_packages_apps_Snap-f92a4ca9f22e3bbc497768c2683d44c8ca3f53f0.tar.gz
android_packages_apps_Snap-f92a4ca9f22e3bbc497768c2683d44c8ca3f53f0.tar.bz2
android_packages_apps_Snap-f92a4ca9f22e3bbc497768c2683d44c8ca3f53f0.zip
SnapdragonCamera: Reorder logic when closing cameras
Re-order calls to unlink all cameras and close sessions before closing any devices. CRs-Fixed: 993611 Change-Id: I0e753a5286799ff59637333cc00231c96709a3e7
-rw-r--r--src/com/android/camera/CaptureModule.java64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index ba576306c..5178d49d2 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1185,46 +1185,50 @@ public class CaptureModule implements CameraModule, PhotoController,
*/
private void closeCamera() {
Log.d(TAG, "closeCamera");
- try {
- mCameraOpenCloseLock.acquire();
- if(mPostProcessor != null) {
- mPostProcessor.onClose();
- }
- if(mFrameProcessor != null) {
- mFrameProcessor.onClose();
- }
- for (int i = 0; i < MAX_NUM_CAM; i++) {
- if (null != mCaptureSession[i]) {
- if (mIsLinked) {
- unLinkBayerMono(i);
- try {
- mCaptureSession[i].capture(mPreviewRequestBuilder[i].build(), null,
- mCameraHandler);
- } catch (CameraAccessException e) {
- e.printStackTrace();
- }
+ if(mPostProcessor != null) {
+ mPostProcessor.onClose();
+ }
+
+ if(mFrameProcessor != null) {
+ mFrameProcessor.onClose();
+ }
+
+ for (int i = 0; i < MAX_NUM_CAM; i++) {
+ if (null != mCaptureSession[i]) {
+ if (mIsLinked) {
+ unLinkBayerMono(i);
+ try {
+ mCaptureSession[i].capture(mPreviewRequestBuilder[i].build(), null,
+ mCameraHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
}
- mCaptureSession[i].close();
- mCaptureSession[i] = null;
}
+ mCaptureSession[i].close();
+ mCaptureSession[i] = null;
+ }
- if (null != mImageReader[i]) {
- mImageReader[i].close();
- mImageReader[i] = null;
- }
+ if (null != mImageReader[i]) {
+ mImageReader[i].close();
+ mImageReader[i] = null;
+ }
+ }
+ /* no need to set this in the callback and handle asynchronously. This is the same
+ reason as why we release the semaphore here, not in camera close callback function
+ as we don't have to protect the case where camera open() gets called during camera
+ close(). The low level framework/HAL handles the synchronization for open()
+ happens after close() */
+ mIsLinked = false;
+ try {
+ mCameraOpenCloseLock.acquire();
+ for (int i = 0; i < MAX_NUM_CAM; i++) {
if (null != mCameraDevice[i]) {
mCameraDevice[i].close();
mCameraDevice[i] = null;
mCameraOpened[i] = false;
}
}
- /* no need to set this in the callback and handle asynchronously. This is the same
- reason as why we release the semaphore here, not in camera close callback function
- as we don't have to protect the case where camera open() gets called during camera
- close(). The low level framework/HAL handles the synchronization for open()
- happens after close() */
- mIsLinked = false;
} catch (InterruptedException e) {
mCameraOpenCloseLock.release();
throw new RuntimeException("Interrupted while trying to lock camera closing.", e);