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-21 18:46:32 -0700
commit4016f84e0b68f94a9e9da8864b0c75de91cca64d (patch)
tree16295cf0c663b99268ecf234db812e9c9556c09e
parent1a726286b4be774a6b8c662e62f32e31768e6dd4 (diff)
downloadandroid_packages_apps_Snap-4016f84e0b68f94a9e9da8864b0c75de91cca64d.zip
android_packages_apps_Snap-4016f84e0b68f94a9e9da8864b0c75de91cca64d.tar.gz
android_packages_apps_Snap-4016f84e0b68f94a9e9da8864b0c75de91cca64d.tar.bz2
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 ba57630..5178d49 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);