From: Kwanghoon Son Date: Wed, 4 Oct 2023 04:19:40 +0000 (+0900) Subject: Fix un-defined backend call X-Git-Tag: accepted/tizen/7.0/unified/20231005.155627^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7196d4fa4012f186355d25f221a70feaf6898814;p=platform%2Fcore%2Fmultimedia%2Fvision-source.git Fix un-defined backend call [Issue type] Fix [Version] 0.2.1 Change-Id: I142119f2ed1b58363081e57a20841bec9b63df07 Signed-off-by: Kwanghoon Son --- diff --git a/packaging/vision-source.spec b/packaging/vision-source.spec index ab3113b..6703d98 100644 --- a/packaging/vision-source.spec +++ b/packaging/vision-source.spec @@ -1,6 +1,6 @@ Name: vision-source Summary: vision source -Version: 0.2.0 +Version: 0.2.1 Release: 0 Group: Multimedia/Framework License: Apache-2.0 diff --git a/src/vision_source.c b/src/vision_source.c index 22c0022..5bdede6 100644 --- a/src/vision_source.c +++ b/src/vision_source.c @@ -40,11 +40,12 @@ int _vision_source_dlsym(vision_source_internal_s *handle) dlsym(handle->dl_handle, "attach_backend"); char *error = dlerror(); - if (error != NULL) { + if (error) { LOGE("Failed dlsym : %s", error); return VISION_SOURCE_ERROR_INTERNAL; } attach_backend(&(handle->funcs)); + VISION_SOURCE_IMPLEMENT_CHECK(handle->funcs.init); int ret = handle->funcs.init(&(handle->backend_handle)); if (ret != VISION_SOURCE_ERROR_NONE) { @@ -89,7 +90,7 @@ int _vision_source_get_backend(char *name) const char *backend_name = iniparser_getstring(ini, "common:name", NULL); - if (backend_name == NULL) { + if (!backend_name) { iniparser_freedict(ini); return VISION_SOURCE_ERROR_INVALID_PARAMETER; } @@ -114,7 +115,7 @@ int vision_source_init(vision_source_h *handle) return ret; } - source_handle = malloc(sizeof(vision_source_internal_s)); + source_handle = calloc(1, sizeof(vision_source_internal_s)); VISION_SOURCE_NULL_ARG_CHECK(source_handle); const char *backend_name = backend_tmp; @@ -135,6 +136,7 @@ int vision_source_exit(vision_source_h handle) VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.exit); int ret = source_handle->funcs.exit(source_handle->backend_handle); if (ret != VISION_SOURCE_ERROR_NONE) { @@ -143,7 +145,7 @@ int vision_source_exit(vision_source_h handle) VISION_SOURCE_NULL_ARG_CHECK(source_handle->dl_handle); ret = dlclose(source_handle->dl_handle); - if (ret) { + if (ret != 0) { LOGE("Failed to close shared object : %s", dlerror()); return VISION_SOURCE_ERROR_INTERNAL; } @@ -158,6 +160,7 @@ int vision_source_open_device(vision_source_h handle, int device_index) VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.open_device); return source_handle->funcs.open_device(source_handle->backend_handle, device_index); } @@ -166,6 +169,7 @@ int vision_source_close_device(vision_source_h handle) VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.close_device); return source_handle->funcs.close_device(source_handle->backend_handle); } int vision_source_start_stream(vision_source_h handle, stream_cb callback, @@ -174,6 +178,7 @@ int vision_source_start_stream(vision_source_h handle, stream_cb callback, VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.start_stream); return source_handle->funcs.start_stream(source_handle->backend_handle, callback, user_data); } @@ -182,6 +187,7 @@ int vision_source_stop_stream(vision_source_h handle) VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.stop_stream); return source_handle->funcs.stop_stream(source_handle->backend_handle); } @@ -191,6 +197,7 @@ int vision_source_enumerate_devices(vision_source_h handle, VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.enumerate_devices); return source_handle->funcs.enumerate_devices(source_handle->backend_handle, info_list); } @@ -201,6 +208,7 @@ int vision_source_set_stream_format(vision_source_h handle, VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.set_stream_format); return source_handle->funcs.set_stream_format(source_handle->backend_handle, format); } @@ -210,6 +218,7 @@ int vision_source_get_capture_frame(vision_source_h handle, VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.get_capture_frame); return source_handle->funcs.get_capture_frame(source_handle->backend_handle, buffer); } @@ -220,6 +229,7 @@ int vision_source_release_capture_frame(vision_source_h handle, VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.release_capture_frame); return source_handle->funcs.release_capture_frame( source_handle->backend_handle, buffer_index); } @@ -229,6 +239,7 @@ int vision_source_ioctl(vision_source_h handle, int request, void *arg) VISION_SOURCE_NULL_ARG_CHECK(handle); vision_source_internal_s *source_handle = (vision_source_internal_s *) handle; + VISION_SOURCE_IMPLEMENT_CHECK(source_handle->funcs.ioctl); return source_handle->funcs.ioctl(source_handle->backend_handle, request, arg); } \ No newline at end of file diff --git a/src/vision_source_private.h b/src/vision_source_private.h index 893f15d..c0b4815 100644 --- a/src/vision_source_private.h +++ b/src/vision_source_private.h @@ -38,4 +38,8 @@ VISION_SOURCE_ERROR_INVALID_PARAMETER, \ "VISION_SOURCE_ERROR_INVALID_PARAMETER") +#define VISION_SOURCE_IMPLEMENT_CHECK(arg) \ + VISION_SOURCE_CHECK_CONDITION(arg != NULL, \ + VISION_SOURCE_ERROR_NOT_IMPLEMENTED, \ + "VISION_SOURCE_ERROR_NOT_IMPLEMENTED") #endif /* __VISION_SOURCE_INTERFACE__ */ \ No newline at end of file