universal7580: camera: block notify callbacks during the cancel_auto_focus function...
authorDanny Wood <danwood76@gmail.com>
Sat, 25 May 2019 12:33:19 +0000 (13:33 +0100)
committerJan Altensen <info@stricted.net>
Fri, 16 Aug 2019 21:18:47 +0000 (23:18 +0200)
shorten the cancel_auto_focus blocking delay to 500mS to improve loading speed

Change-Id: I20cc5401bbc80bfd8f79d744d987f540206ce0c2

camera/Camera2Wrapper.cpp

index e105ae1a56c0f53de5278544029cc08c5668bf05..1eead7ce2be0539190b776cb7d12c34abb1be94d 100644 (file)
@@ -142,6 +142,19 @@ static int camera2_set_preview_window(struct camera_device * device,
     return rc;
 }
 
+uint8_t BlockNotifyCb = 0;
+camera_notify_callback UserNotifyCb = NULL;
+
+void WrappedNotifyCb (int32_t msg_type, int32_t ext1, int32_t ext2, void *user) {
+    ALOGV("%s->In", __FUNCTION__);
+
+    /* If the notify callback is valid and we are not blocking callbacks */
+    if((UserNotifyCb != NULL) && (BlockNotifyCb == 0)) {
+        ALOGV("%s->Calling UserNotifyCb", __FUNCTION__);
+        UserNotifyCb(msg_type, ext1, ext2, user);
+    }
+}
+
 static void camera2_set_callbacks(struct camera_device * device,
         camera_notify_callback notify_cb,
         camera_data_callback data_cb,
@@ -154,7 +167,11 @@ static void camera2_set_callbacks(struct camera_device * device,
     if(!device)
         return;
 
-    VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, get_memory, user);
+    /* Copy the notify_cb to our user pointer */
+    UserNotifyCb = notify_cb;
+
+    /* Call the set_callbacks function substituting the notify callback with our wrapper */
+    VENDOR_CALL(device, set_callbacks, WrappedNotifyCb, data_cb, data_cb_timestamp, get_memory, user);
 }
 
 static void camera2_enable_msg_type(struct camera_device * device, int32_t msg_type)
@@ -295,8 +312,8 @@ static int camera2_auto_focus(struct camera_device * device)
     /* Call the auto_focus function */
     Ret = VENDOR_CALL(device, auto_focus);
 
-    /* Set the cancel_auto_focus time guard to now plus 1 second */
-    CancelAFTimeGuard = current_timestamp() + 1000;
+    /* Set the cancel_auto_focus time guard to now plus 500mS */
+    CancelAFTimeGuard = current_timestamp() + 500;
 
     return Ret;
 }
@@ -317,9 +334,15 @@ static int camera2_cancel_auto_focus(struct camera_device * device)
         return 0;
     }
 
+    /* Block notify callbacks whilst we are in cancel_auto_focus */
+    BlockNotifyCb = 1;
+
     /* No active time guard so call the vendor function */
     Ret = VENDOR_CALL(device, cancel_auto_focus);
 
+    /* Clear the block flag */
+    BlockNotifyCb = 0;
+
     return Ret;
 }
 
@@ -436,6 +459,7 @@ static int camera2_device_close(hw_device_t* device)
 done:
     gPreviewWindow = 0;
     gPreviewStartDeferred = false;
+    UserNotifyCb = NULL;
     return ret;
 }