Skip to content

Commit

Permalink
klte-common: CameraWrapper: Store user pointer and pass it when needed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Demon000 authored and haggertk committed Dec 22, 2017
1 parent e2db03e commit d4dadba
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions camera/CameraWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit d4dadba

Please sign in to comment.