summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorVijayashree Channiah Sondekoppa <vchann@codeaurora.org>2013-08-30 11:52:03 +0530
committerSteve Kondik <shade@chemlab.org>2013-10-01 03:32:39 -0700
commite19c1af861efbc00a524f8f61a23c97876af9f99 (patch)
treebdadef78d8eb4c44113c462bbd35c15bfb9c2f45 /src/com
parentfe3360ade4f9d48794a5adf759907123797eeb92 (diff)
downloadandroid_packages_apps_Gallery2-e19c1af861efbc00a524f8f61a23c97876af9f99.tar.gz
android_packages_apps_Gallery2-e19c1af861efbc00a524f8f61a23c97876af9f99.tar.bz2
android_packages_apps_Gallery2-e19c1af861efbc00a524f8f61a23c97876af9f99.zip
Camera App: return after synchronized block
For some boundary condition when surface allocated is null, due to return within synchronization block it is giving ANR. This change will ensure that return take place outside synchronization block. It will also ensure to notify an object if already in wait state before invoking wait on it. CRs-Fixed: 529666 Change-Id: I8532aa410840785923388a879701be9e98b0154f
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CameraScreenNail.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/com/android/camera/CameraScreenNail.java b/src/com/android/camera/CameraScreenNail.java
index b770a9a34..a03c103cc 100644
--- a/src/com/android/camera/CameraScreenNail.java
+++ b/src/com/android/camera/CameraScreenNail.java
@@ -67,6 +67,7 @@ public class CameraScreenNail extends SurfaceTextureScreenNail {
// sure some code are atomic. For example, requestRender and setting
// mAnimState.
private Object mLock = new Object();
+ private boolean mWaitFlag = false;
private OnFrameDrawnListener mOneTimeFrameDrawnListener;
private int mRenderWidth;
@@ -429,7 +430,10 @@ public class CameraScreenNail extends SurfaceTextureScreenNail {
// as the origin (0, 0).
canvas.translate(0, height);
canvas.scale(1, -1, 1);
- getSurfaceTexture().getTransformMatrix(mTextureTransformMatrix);
+ SurfaceTexture surfaceT = getSurfaceTexture();
+ if (surfaceT != null) {
+ surfaceT.getTransformMatrix(mTextureTransformMatrix);
+ }
updateTransformMatrix(mTextureTransformMatrix);
canvas.drawTexture(mExtTexture, mTextureTransformMatrix, 0, 0, width, height);
canvas.endRenderTarget();
@@ -488,18 +492,21 @@ public class CameraScreenNail extends SurfaceTextureScreenNail {
@Override
public SurfaceTexture getSurfaceTexture() {
+ SurfaceTexture surfaceTexture = null;
synchronized (mLock) {
- SurfaceTexture surfaceTexture = super.getSurfaceTexture();
+ surfaceTexture = super.getSurfaceTexture();
if (surfaceTexture == null && mAcquireTexture) {
try {
+ if (mWaitFlag) mLock.notifyAll();
+ mWaitFlag = true;
mLock.wait();
surfaceTexture = super.getSurfaceTexture();
} catch (InterruptedException e) {
Log.w(TAG, "unexpected interruption");
}
}
- return surfaceTexture;
}
+ return surfaceTexture;
}
private void allocateTextureIfRequested(GLCanvas canvas) {
@@ -508,6 +515,7 @@ public class CameraScreenNail extends SurfaceTextureScreenNail {
super.acquireSurfaceTexture(canvas);
mAcquireTexture = false;
mLock.notifyAll();
+ mWaitFlag = false;
}
}
}