From 07b77037f2f5aa28d6d3188f78588dc7f2d49398 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Mon, 24 Oct 2011 10:46:00 -0700 Subject: Add missing state check in EffectsRecorder startup path. When starting up, the EffectsRecorder gets a callback when the effect filter graph provides an input SurfaceTexture. This callback was not checking the EffectsRecorder state correctly, and if stopPreview was called on the EffectsRecorder between startup and before the callback fires, the callback would improperly reset the recorder state, resulting in NPEs down the line. Bug: 5493458 Change-Id: If552b7c0ea82e1506f0b22eb5fa0447c1ca4adf8 --- src/com/android/camera/EffectsRecorder.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java index d3b277d..a561011 100644 --- a/src/com/android/camera/EffectsRecorder.java +++ b/src/com/android/camera/EffectsRecorder.java @@ -562,8 +562,19 @@ public class EffectsRecorder { synchronized(EffectsRecorder.this) { mTextureSource = source; - if (mState == STATE_RELEASED) return; - + if (mState == STATE_CONFIGURE) { + // Stop preview happened while the runner was doing startup tasks + // Since we haven't started anything up, don't do anything + // Rest of cleanup will happen in onRunnerDone + if (mLogVerbose) Log.v(TAG, "Ready callback: Already stopped, skipping."); + return; + } + if (mState == STATE_RELEASED) { + // EffectsRecorder has been released, so don't touch the camera device + // or anything else + if (mLogVerbose) Log.v(TAG, "Ready callback: Already released, skipping."); + return; + } if (source == null) { if (mState == STATE_PREVIEW || mState == STATE_STARTING_PREVIEW || -- cgit v1.1