Fix un-defined backend call accepted/tizen/7.0/unified/20231005.155627
authorKwanghoon Son <k.son@samsung.com>
Wed, 4 Oct 2023 04:19:40 +0000 (13:19 +0900)
committerKwanghoon Son <k.son@samsung.com>
Wed, 4 Oct 2023 10:40:18 +0000 (19:40 +0900)
[Issue type] Fix
[Version] 0.2.1

Change-Id: I142119f2ed1b58363081e57a20841bec9b63df07
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
packaging/vision-source.spec
src/vision_source.c
src/vision_source_private.h

index ab3113b..6703d98 100644 (file)
@@ -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
index 22c0022..5bdede6 100644 (file)
@@ -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
index 893f15d..c0b4815 100644 (file)
@@ -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