From 38ab196e3d57e3c58cde4b1997f724dc2cb3572a Mon Sep 17 00:00:00 2001 From: zhangchao Date: Tue, 10 Jun 2025 19:55:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=91=8A=E8=AD=A6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangchao --- .../js/camera_napi/src/input/camera_input_napi.cpp | 7 +++---- .../camera_napi/src/session/camera_session_napi.cpp | 13 +++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/frameworks/js/camera_napi/src/input/camera_input_napi.cpp b/frameworks/js/camera_napi/src/input/camera_input_napi.cpp index d882b8289..75cf5d463 100644 --- a/frameworks/js/camera_napi/src/input/camera_input_napi.cpp +++ b/frameworks/js/camera_napi/src/input/camera_input_napi.cpp @@ -298,12 +298,10 @@ void ConsumeWorkerQueueTask(CameraInputAsyncContext* context) void CameraInputNapi::OpenCameraAsync(uv_work_t* work) { - if (!work) { - MEDIA_ERR_LOG("OpenCameraAsync null work"); - return; - } + CHECK_ERROR_RETURN_LOG(work == nullptr, "OpenCameraAsync null work"); MEDIA_INFO_LOG("OpenCameraAsync running on worker"); auto context = static_cast(work->data); + CHECK_ERROR_RETURN_LOG(context == nullptr, "OpenCameraAsync context is null"); CHECK_ERROR_RETURN_LOG(context->objectInfo == nullptr, "OpenCameraAsync async info is nullptr"); CAMERA_START_ASYNC_TRACE(context->funcName, context->taskId); ConsumeWorkerQueueTask(context); @@ -311,6 +309,7 @@ void CameraInputNapi::OpenCameraAsync(uv_work_t* work) void CameraInputNapi::UvWorkAsyncCompleted(uv_work_t* work, int status) { + CHECK_ERROR_RETURN_LOG(work == nullptr, "UvWorkAsyncCompleted null work"); auto context = static_cast(work->data); CHECK_ERROR_RETURN_LOG(context == nullptr, "UvWorkAsyncCompleted context is null"); MEDIA_INFO_LOG("UvWorkAsyncCompleted %{public}s, status = %{public}d", context->funcName.c_str(), diff --git a/frameworks/js/camera_napi/src/session/camera_session_napi.cpp b/frameworks/js/camera_napi/src/session/camera_session_napi.cpp index 5e8630656..9213d50fb 100644 --- a/frameworks/js/camera_napi/src/session/camera_session_napi.cpp +++ b/frameworks/js/camera_napi/src/session/camera_session_napi.cpp @@ -970,12 +970,10 @@ napi_value CameraSessionNapi::BeginConfig(napi_env env, napi_callback_info info) void CameraSessionNapi::CommitConfigAsync(uv_work_t* work) { - if (!work) { - MEDIA_ERR_LOG("CommitConfigAsync null work"); - return; - } + CHECK_ERROR_RETURN_LOG(work == nullptr, "CommitConfigAsync null work"); MEDIA_INFO_LOG("CommitConfigAsync running on worker"); auto context = static_cast(work->data); + CHECK_ERROR_RETURN_LOG(context == nullptr, "CommitConfigAsync context is null"); CHECK_ERROR_RETURN_LOG( context->objectInfo == nullptr, "CommitConfigAsync async info is nullptr"); CAMERA_START_ASYNC_TRACE(context->funcName, context->taskId); @@ -988,6 +986,7 @@ void CameraSessionNapi::CommitConfigAsync(uv_work_t* work) void CameraSessionNapi::UvWorkAsyncCompleted(uv_work_t* work, int status) { + CHECK_ERROR_RETURN_LOG(work == nullptr, "UvWorkAsyncCompleted null work"); auto context = static_cast(work->data); CHECK_ERROR_RETURN_LOG(context == nullptr, "UvWorkAsyncCompleted context is null"); MEDIA_INFO_LOG("UvWorkAsyncCompleted %{public}s, status = %{public}d", context->funcName.c_str(), @@ -1337,12 +1336,10 @@ napi_value CameraSessionNapi::RemoveOutput(napi_env env, napi_callback_info info void CameraSessionNapi::StartAsync(uv_work_t* work) { - if (!work) { - MEDIA_ERR_LOG("StartAsync null work"); - return; - } + CHECK_ERROR_RETURN_LOG(work == nullptr, "StartAsync null work"); MEDIA_INFO_LOG("StartAsync running on worker"); auto context = static_cast(work->data); + CHECK_ERROR_RETURN_LOG(context == nullptr, "StartAsync context is null"); CHECK_ERROR_RETURN_LOG(context->objectInfo == nullptr, "StartAsync async info is nullptr"); CAMERA_START_ASYNC_TRACE(context->funcName, context->taskId); CameraNapiWorkerQueueKeeper::GetInstance()->ConsumeWorkerQueueTask(context->queueTask, [&context]() { -- Gitee