Update error handling for some APIs 99/277599/2
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 11 Jul 2022 03:58:16 +0000 (12:58 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 13 Jul 2022 09:09:37 +0000 (18:09 +0900)
[Version] 0.4.83
[Issue Type] Error handling

Change-Id: I0ecc5e4c64cc8696591c98730f0f3f14abe87092
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-camera.spec
src/camera.c

index 2ee2852..a0a02fb 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.82
+Version:    0.4.83
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 5a5e4ac..4dbf71a 100644 (file)
@@ -2492,11 +2492,6 @@ int _camera_create_private(camera_device_e device, bool is_network, camera_h *ca
        int module_index = -1;
        int device_type = (int)device;
 
-       if (!camera) {
-               CAM_LOG_ERROR("NULL pointer");
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
        CAM_LOG_INFO("device %d, is_network %d", device, is_network);
 
        sock_fd = muse_client_new();
@@ -2592,6 +2587,12 @@ int _camera_create_private(camera_device_e device, bool is_network, camera_h *ca
                CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
                        preview_format, user_buffer_supported, g_camera_log_level);
 
+               if (!camera) {
+                       CAM_LOG_ERROR("NULL out handle");
+                       ret= CAMERA_ERROR_INVALID_PARAMETER;
+                       goto ErrorExit;
+               }
+
                *camera = (camera_h)pc;
 
                /* get display interface handle */
@@ -6644,8 +6645,15 @@ int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callbac
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info || !callback) {
-               CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
+
+       if (!camera_is_supported_extra_preview(camera)) {
+               CAM_LOG_ERROR("extra preview is not supported");
+               return CAMERA_ERROR_NOT_SUPPORTED;
+       }
+
+       if (!callback) {
+               CAM_LOG_ERROR("NULL callback");
                return CAMERA_ERROR_INVALID_PARAMETER;
        }
 
@@ -6676,6 +6684,11 @@ int camera_unset_extra_preview_cb(camera_h camera)
 
        CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
+       if (!camera_is_supported_extra_preview(camera)) {
+               CAM_LOG_ERROR("extra preview is not supported");
+               return CAMERA_ERROR_NOT_SUPPORTED;
+       }
+
        CAM_LOG_INFO("Enter");
 
        _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);