From 4549ad573f74cb4827adc9590f657f7765fe5f92 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Mon, 11 Jul 2022 12:58:16 +0900 Subject: [PATCH] Update error handling for some APIs [Version] 0.4.83 [Issue Type] Error handling Change-Id: I0ecc5e4c64cc8696591c98730f0f3f14abe87092 Signed-off-by: Jeongmo Yang --- packaging/capi-media-camera.spec | 2 +- src/camera.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 2ee2852..a0a02fb 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -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 diff --git a/src/camera.c b/src/camera.c index 5a5e4ac..4dbf71a 100644 --- a/src/camera.c +++ b/src/camera.c @@ -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); -- 2.7.4