From patchwork Wed Nov 27 09:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 22117 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 43C61C3213 for ; Wed, 27 Nov 2024 09:26:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 924A6660B9; Wed, 27 Nov 2024 10:26:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YYtWI9nA"; dkim-atps=neutral Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 314D3660C7 for ; Wed, 27 Nov 2024 10:26:48 +0100 (CET) Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-71d4d0516e6so1696532a34.2 for ; Wed, 27 Nov 2024 01:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1732699607; x=1733304407; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7qf7TjoxNHo5OLDoWBsF8q4aXijLrJm4Gl0VuJh1ic0=; b=YYtWI9nAgdyIEDo6UZU9eei0bgK9iPDVCTowryk1ztNoC8ZBuG8RENRpNTwS2h6i8i 4KIGJdBShV0AYpLdSmIcZevV+IeNdqnjr4A51HJBzb4l2Z4ArT+es+T/QnC9SCzWwGs4 GbmJgffafwjkbTwFzizGhnbmjXGm/+lh/ipWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732699607; x=1733304407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7qf7TjoxNHo5OLDoWBsF8q4aXijLrJm4Gl0VuJh1ic0=; b=QgehKqgbBZZf7Vx/R8i8vphYph/jTb7Zj0mKZi/OIMXsQvyfuoaDq9BLlCWysSO5lx ZAesw18X4HeRHLp9jb0B2veAEXboSSb24Xi2Z79rujcXEDyQuzzgzePG56pXZYERSnw1 qR0zn5vib00HveE1FP+wL6nrZNRF5CdOkqyjHRKZSInf3sE6/ZYJJiNH/HXZ9GMVqz5G YhRR8e0AD++itOpWp+9WYEQuvBh7vC1CZVqpLa3ztfj07rM5YlMHlXj41OD2gPBPMzl9 IgDu4oHOJ96mi86JYi1Vuw9w4/CQhRrHIx09lDSdTj+xWG8sAFZSqwy8hxTMRNpno4TL +3Pg== X-Gm-Message-State: AOJu0YyhlSLvZrLd0OF/+viwlY/DufV8QQ+m8LTk8JsxZogl4VRa1M6l 9dhhtfTVIqBk6dTi77QW7FFRlWxPqaAAO2j40tkr3yQDNP2gkqlEPE7wfRUh0kBjU6huUSaQLDc = X-Gm-Gg: ASbGnctXXC3VzdItL97FzqO5YdEEmDWL5+HPqZwtBwacjmgZZZZH3CvSByz7rv4g4g8 D38P7yP/yKKrq0Ems/B/aaRuUBPIYwMKFSfL1+Eb2QLiMD/lktBLNHste7wJFFZVAtqgyakKADX nBA/mKgksJm8FnSd+UTuXf7DSSARXai//Ze7OhaI2jLo1qb6dIy8j9IX0kjhaJ2TnU/qz6cvtGW G46GJeCpovFf2TQveg1FIAyHhr09isz2hvoIj7CGktSe3Gi3ekg8QzqaPuLIoFjXBDbMAl3wC2M oz581frw7j8vF3/rKqTPIOscnUE2dXxxLM7EZ++k3DOdt/PhkW3Msg== X-Google-Smtp-Source: AGHT+IErrD10G3jBi+mWN3Zjm+Ew7Cwjj1wFpafYaRzKTRTL+0s/QFh7z1QoDsMjCii7PQxoU/V0RQ== X-Received: by 2002:a05:6830:3805:b0:71d:4d88:2293 with SMTP id 46e09a7af769-71d65cf62c7mr2174243a34.23.1732699606734; Wed, 27 Nov 2024 01:26:46 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (27.247.221.35.bc.googleusercontent.com. [35.221.247.27]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fbcbfc41f9sm8693027a12.8.2024.11.27.01.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 01:26:46 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Han-Lin Chen Subject: [PATCH v2 6/9] android: Cleanup CAMERA3_MSG_ERROR_REQUEST Date: Wed, 27 Nov 2024 09:25:56 +0000 Message-ID: <20241127092632.3145984-7-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241127092632.3145984-1-chenghaoyang@chromium.org> References: <20241127092632.3145984-1-chenghaoyang@chromium.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When a request is completed with failure, CAMERA3_MSG_ERROR_RESULT should be used instead. This patch also cleans up aborting when flushing with sendCaptureResult(). Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- src/android/camera_device.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 0377cf215..3fb92268e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -868,6 +868,8 @@ void CameraDevice::abortRequest(Camera3RequestDescriptor *descriptor) const buffer.status = StreamBuffer::Status::Error; descriptor->status_ = Camera3RequestDescriptor::Status::Error; + + sendCaptureResult(descriptor); } bool CameraDevice::isValidRequest(camera3_capture_request_t *camera3Request) const @@ -1136,14 +1138,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques MutexLocker stateLock(stateMutex_); if (state_ == State::Flushing) { - Camera3RequestDescriptor *rawDescriptor = descriptor.get(); - { - MutexLocker descriptorsLock(descriptorsMutex_); - descriptors_.push(std::move(descriptor)); - } - abortRequest(rawDescriptor); - completeDescriptor(rawDescriptor); - + abortRequest(descriptor.get()); return 0; } @@ -1211,10 +1206,7 @@ void CameraDevice::requestComplete(Request *request) << " not successfully completed: " << request->status(); - abortRequest(descriptor); - completeDescriptor(descriptor); - - return; + descriptor->status_ = Camera3RequestDescriptor::Status::Error; } /* @@ -1239,7 +1231,7 @@ void CameraDevice::requestComplete(Request *request) */ descriptor->resultMetadata_ = getResultMetadata(*descriptor); if (!descriptor->resultMetadata_) { - notifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT); + descriptor->status_ = Camera3RequestDescriptor::Status::Error; /* * The camera framework expects an empty metadata pack on error. @@ -1325,6 +1317,16 @@ void CameraDevice::sendCaptureResults() descriptors_.pop(); sendCaptureResult(descriptor.get()); + + /* + * Call notify with CAMERA3_MSG_ERROR_RESULT to indicate some + * of the expected result metadata might not be available + * because the capture is cancelled by the camera. Only notify + * it when the final result is sent, since Android will ignore + * the following metadata. + */ + if (descriptor->status_ == Camera3RequestDescriptor::Status::Error) + notifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT); } }