aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDemon000 <demonsingur@gmail.com>2017-09-05 09:11:40 +0300
committerShreps <shr3ps@gmail.com>2017-09-13 10:12:46 +0200
commitc931d9cad46b97924d18d2d30cd79077502eda6d (patch)
treef4003453f0324d905d00d0602a44405df75892b9
parentead79a6d019d66eb32b53b8cce8ecaab9c620356 (diff)
A6020: 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
-rw-r--r--camera/CameraWrapper.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp
index 254615a..7a19b10 100644
--- a/camera/CameraWrapper.cpp
+++ b/camera/CameraWrapper.cpp
@@ -45,6 +45,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,
@@ -178,6 +184,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,
@@ -191,8 +216,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,