From 58cede9e3e8004f6be9731e9cb9a135238a2efd8 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Thu, 20 Oct 2011 12:42:22 -0700 Subject: Effects: shut down camera preview when unexpected graph closures occur. If the graph runner needs to shut down a graph due to an error, previously the surface texture connecting the camera to the processing graph would get released before camera was told to shut down preview. This led to various abandoned surfacetexture errors in the camera HAL, sometimes including native crashes. Now properly uses the SurfaceTextureSource callback to detect unexpected graph shutdown to clean up the camera before the SurfaceTexture is released. Bug: 5451833 Change-Id: Id130c1e5deb27cffab335affaa1ed55f04c260a5 --- src/com/android/camera/EffectsRecorder.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java index 7c81bf0..a9aa51b 100644 --- a/src/com/android/camera/EffectsRecorder.java +++ b/src/com/android/camera/EffectsRecorder.java @@ -554,12 +554,25 @@ public class EffectsRecorder { synchronized(EffectsRecorder.this) { mTextureSource = source; - // When shutting down a graph, we receive a null SurfaceTexture to - // indicate that. Don't want to connect up the camera in that case. - if (source == null) return; - if (mState == STATE_RELEASED) return; + if (source == null) { + if (mState == STATE_PREVIEW || + mState == STATE_RECORD) { + // A null source here means the graph is shutting down + // unexpectedly, so we need to turn off preview before + // the surface texture goes away. + mCameraDevice.stopPreview(); + try { + mCameraDevice.setPreviewTexture(null); + } catch(IOException e) { + throw new RuntimeException("Unable to disconnect " + + "camera from effect input", e); + } + } + return; + } + // Lock AE/AWB to reduce transition flicker tryEnable3ALocks(true); -- cgit v1.1