From d4dadbaff0acc18a5482325e148f7581b0118845 Mon Sep 17 00:00:00 2001 From: Demon000 Date: Tue, 5 Sep 2017 09:11:40 +0300 Subject: [PATCH] klte-common: CameraWrapper: Store user pointer and pass it when needed The new camera interface calls set_callbacks with a pointer to it's internal CameraDevice and expects following calls to the callbacks to use that pointer. Store the pointer in the camera wraper and intercept the callbacks calls to pass it along. Change-Id: I99f02484e12a3f72cf1be13f1c724f474a452d7f --- camera/CameraWrapper.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index 63bfcad..e0d183c 100644 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -44,6 +44,12 @@ using namespace android; static Mutex gCameraWrapperLock; static camera_module_t *gVendorModule = 0; +static camera_notify_callback gUserNotifyCb = NULL; +static camera_data_callback gUserDataCb = NULL; +static camera_data_timestamp_callback gUserDataCbTimestamp = NULL; +static camera_request_memory gUserGetMemory = NULL; +static void *gUserCameraDevice = NULL; + static char **fixed_set_params = NULL; static int camera_device_open(const hw_module_t *module, const char *name, @@ -233,6 +239,25 @@ static int camera_set_preview_window(struct camera_device *device, return VENDOR_CALL(device, set_preview_window, window); } +void camera_notify_cb(int32_t msg_type, int32_t ext1, int32_t ext2, void *user) { + gUserNotifyCb(msg_type, ext1, ext2, gUserCameraDevice); +} + +void camera_data_cb(int32_t msg_type, const camera_memory_t *data, unsigned int index, + camera_frame_metadata_t *metadata, void *user) { + gUserDataCb(msg_type, data, index, metadata, gUserCameraDevice); +} + +void camera_data_cb_timestamp(nsecs_t timestamp, int32_t msg_type, + const camera_memory_t *data, unsigned index, void *user) { + gUserDataCbTimestamp(timestamp, msg_type, data, index, gUserCameraDevice); +} + +camera_memory_t* camera_get_memory(int fd, size_t buf_size, + uint_t num_bufs, void *user) { + return gUserGetMemory(fd, buf_size, num_bufs, gUserCameraDevice); +} + static void camera_set_callbacks(struct camera_device *device, camera_notify_callback notify_cb, camera_data_callback data_cb, @@ -246,8 +271,14 @@ static void camera_set_callbacks(struct camera_device *device, ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); - VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, - get_memory, user); + gUserNotifyCb = notify_cb; + gUserDataCb = data_cb; + gUserDataCbTimestamp = data_cb_timestamp; + gUserGetMemory = get_memory; + gUserCameraDevice = user; + + VENDOR_CALL(device, set_callbacks, camera_notify_cb, camera_data_cb, + camera_data_cb_timestamp, camera_get_memory, user); } static void camera_enable_msg_type(struct camera_device *device,