diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2024-07-09 18:59:54 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2024-07-18 10:00:10 +0900 |
commit | cde64310caab30c3087d91a1613c1dad51489a8a (patch) | |
tree | d813ff532493bbd42348934fbe41562c279762b0 | |
parent | 8012f74269bd8bb31c48e2f601dcc9a9a903a328 (diff) | |
download | camera-v4l2-cde64310caab30c3087d91a1613c1dad51489a8a.tar.gz camera-v4l2-cde64310caab30c3087d91a1613c1dad51489a8a.tar.bz2 camera-v4l2-cde64310caab30c3087d91a1613c1dad51489a8a.zip |
Update for multi-HAL interfaceaccepted/tizen/unified/x/asan/20240813.231907accepted/tizen/unified/x/20240806.012806accepted/tizen/unified/toolchain/20240812.133424accepted/tizen/unified/dev/20240807.093103accepted/tizen/unified/20240805.114554
[Version] 1.0.0
[Issue Type] New feature
Change-Id: I8974c03d46f1b916a9ba93f82f32c7d35ca8d426
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | packaging/hal-backend-camera-v4l2.spec | 2 | ||||
-rw-r--r-- | src/hal_backend_camera_v4l2.c | 42 |
2 files changed, 36 insertions, 8 deletions
diff --git a/packaging/hal-backend-camera-v4l2.spec b/packaging/hal-backend-camera-v4l2.spec index beafe87..4df07fd 100644 --- a/packaging/hal-backend-camera-v4l2.spec +++ b/packaging/hal-backend-camera-v4l2.spec @@ -8,7 +8,7 @@ Name: hal-backend-camera-v4l2 Summary: Tizen Camera Hal using generic V4L2 interface -Version: 0.0.8 +Version: 1.0.0 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/hal_backend_camera_v4l2.c b/src/hal_backend_camera_v4l2.c index 16d35dd..ac799a8 100644 --- a/src/hal_backend_camera_v4l2.c +++ b/src/hal_backend_camera_v4l2.c @@ -53,6 +53,7 @@ (fourcc >> 24) & 0xff +static gboolean g_free_funcs_on_exit; static gboolean g_is_virtual_camera_mode; static uint32_t g_virtual_camera_bytesused; static gulong g_virtual_camera_frame_delay; @@ -2748,11 +2749,34 @@ int camera_v4l2_set_batch_command(void *camera_handle, camera_batch_command_cont static int camera_v4l2_backend_init(void **data) { - hal_backend_camera_funcs *funcs; + hal_backend_camera_funcs *funcs = NULL; - funcs = calloc(1, sizeof(hal_backend_camera_funcs)); - if (!funcs) - return CAMERA_ERROR_OUT_OF_MEMORY; + if (!data) { + LOGE("NULL data"); + return -1; + } + + if (*data) { + g_free_funcs_on_exit = FALSE; + + LOGI("use data for funcs"); + + funcs = (hal_backend_camera_funcs *)*data; + } else { + g_free_funcs_on_exit = TRUE; + + LOGI("allocate new one for funcs"); + + funcs = calloc(1, sizeof(hal_backend_camera_funcs)); + if (!funcs) { + LOGE("funcs[size:%zu] failed", sizeof(hal_backend_camera_funcs)); + return -1; + } + + *data = (void *)funcs; + } + + LOGI("camera HAL funcs[%p]", funcs); funcs->init = camera_v4l2_init; funcs->deinit = camera_v4l2_deinit; @@ -2790,8 +2814,6 @@ static int camera_v4l2_backend_init(void **data) funcs->set_extra_preview_gop_interval = camera_v4l2_set_extra_preview_gop_interval; funcs->get_extra_preview_gop_interval = camera_v4l2_get_extra_preview_gop_interval; - *data = (void *)funcs; - g_is_virtual_camera_mode = getenv(ENV_VIRTUAL_CAMERA) ? TRUE : FALSE; LOGW("VIRTUAL CAMERA mode[%d]", g_is_virtual_camera_mode); @@ -2805,7 +2827,13 @@ static int camera_v4l2_backend_exit(void *data) if (!data) return 0; - free(data); + if (g_free_funcs_on_exit) { + LOGI("release funcs[%p]", data); + free(data); + } else { + LOGI("clear function pointer set by backend"); + memset(data, 0x0, sizeof(hal_backend_camera_funcs)); + } return 0; } |