From 030e1a5962195aa5914e76e3d071669869555a9f Mon Sep 17 00:00:00 2001 From: Tyler Luu Date: Wed, 26 Oct 2011 11:50:25 -0500 Subject: CameraHal: Check state in doAutoFocus Check the state in doAutoFocus and return if we are not in the AF_STATE. If user/monkey is pressing all over the screen, this will result in multiple autoFocus/cancelAutoFocus calls until the last autoFocus call comes when the user/monkey stop pressing preview window. This will result in multiple CAMERA_PERFORM_AUTOFOCUS commands being queued in OMXCameraAdapter's CommandHandler that will all eventually need to be serviced which will result in multiple doAutoFocus calls. This is the reason why we need to check the state in the beginning of the function and return if we are not focusing. Change-Id: If245751a296604bca511ad237b769be24175cbc6 Signed-off-by: Tyler Luu related-to-bug: 5472396 --- camera/OMXCameraAdapter/OMXFocus.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'camera') diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index 9daea44..102daeb 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -105,6 +105,11 @@ status_t OMXCameraAdapter::doAutoFocus() return NO_INIT; } + if( ((AF_ACTIVE & getState()) != AF_ACTIVE) && ((AF_ACTIVE & getNextState()) != AF_ACTIVE) ) { + CAMHAL_LOGDA("Auto focus got canceled before doAutoFocus could be called"); + return NO_ERROR; + } + // If the app calls autoFocus, the camera will stop sending face callbacks. pauseFaceDetection(true); -- cgit v1.1