Show a patch.

GET /api/1.1/patches/22273/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22273,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22273/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22273/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20241210142557.2886315-6-chenghaoyang@chromium.org>",
    "date": "2024-12-10T14:23:58",
    "name": "[v4,5/7] android: Drop notify CAMERA3_MSG_ERROR_REQUEST when a request fails",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "74eaf97dba3f5a1edeb8708a69eeef78a04091aa",
    "submitter": {
        "id": 117,
        "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22273/mbox/",
    "series": [
        {
            "id": 4870,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4870/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4870",
            "date": "2024-12-10T14:23:53",
            "name": "Refactor Android HAL before supporting partial result",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/4870/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22273/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22273/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CBA51C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Dec 2024 14:26:16 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F34367E9E;\n\tTue, 10 Dec 2024 15:26:16 +0100 (CET)",
            "from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com\n\t[IPv6:2607:f8b0:4864:20::102b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 943F167E99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Dec 2024 15:26:12 +0100 (CET)",
            "by mail-pj1-x102b.google.com with SMTP id\n\t98e67ed59e1d1-2ee397a82f6so4978189a91.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Dec 2024 06:26:12 -0800 (PST)",
            "from chenghaoyang-low.c.googlers.com.com\n\t(112.212.229.35.bc.googleusercontent.com. [35.229.212.112])\n\tby smtp.gmail.com with ESMTPSA id\n\t98e67ed59e1d1-2ef26ff97f2sm11812053a91.11.2024.12.10.06.26.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Dec 2024 06:26:08 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"eO/YnBEW\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1733840771; x=1734445571;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=6LRoqne7Vs2NH7WovLgxTUdHOeemlMfXK+jCzHW5XUQ=;\n\tb=eO/YnBEW8zRxBaf1ML8sL9mnyKKRdBKuEasvDbAliMp5yUNanuSQDHgFI5xHRyQwn9\n\tXPrm3bsGIimpaxlSCnmrp+dZX7UYRnsh7RDWgC4d27o0N6fFcfG1P9gAbICg+YW51oef\n\tLdjVpnM33CuasOAvKXtzUlbWl0VVYKbAMvw3c=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1733840771; x=1734445571;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=6LRoqne7Vs2NH7WovLgxTUdHOeemlMfXK+jCzHW5XUQ=;\n\tb=X0ZW6z482dZGa/esH4w0Rd1Zy4vLNlvK/5cONLdh3Jd8mUZKW8fqqZh7fQeepEjreU\n\twdL7mum8mBdhoRjPfjHkmGTSrIhDxEl1CUR2HQpEcwZ7KJjij5oqutobiSp06D4T2MRw\n\tgpwnJHHN3X23kYBWiyVS1m7+XOSJcOY8NMLFFvLOSx53fHGU7vLmickUS6VcHh/KkyDt\n\ttzmhxKT50ZS8r9rBOXJvjwybOsxYb4hbyagCoDYUjKym3M1RAXyDoBiOPB89tMiSWKZt\n\tRir8HMJ04MBFUIf/MTv5tlNip+jp2hl/neJdjUGmwyhPCY6Olc4kV/eu3Aue3Gux3Jno\n\tMT8g==",
        "X-Gm-Message-State": "AOJu0YzANEc56bODSAnHN4ui7UyIMnYjnRgGYQCH+FRACZnNnl7YOaNX\n\twKcsmAw+CV1J3FIM/4Q+OCEpQrza701b8HKJKMmhgwCKpgzvS2/WSV0Y1tA0vp1kDNbm4nlNxhc\n\t=",
        "X-Gm-Gg": "ASbGncujMk/o0Clc25IAc3o2AET1lBvmFsBm2Tku+hqQmLv7AFymim2wAvdVGM5zgiI\n\tk64laXpSxApnUCDhNpUQXR1fHptQ4ddYalt6tH6HqvJWbGMAENB6aMb7LZjqWJgY1VmduJwhtEB\n\t3XG7cwE9rSts4uxgNi43ypEaAP/LqzRGzuXw+etZsbOX0nBN1B3Tns/yKu88MtZ+mT8NYFciDvg\n\tqZ58ApGtSj7VMCl7LnLC5St7+NsKJuLw9ToDhUZMDVTxlTtNym3swq6etSEXjv6YSgkPvs9Clyy\n\tJHRlDOH+Vs+qmCIVdJqyEF55zKOr8NBTibAUobgL/zTczUu2DZawyPUpfSc6",
        "X-Google-Smtp-Source": "AGHT+IEz3EqGurLMOBF1f3prn9cEG8crqYMhj6EyIJLXA/MTzAtTS3anMPEQGNXFhmgTaiMI/ffGfg==",
        "X-Received": "by 2002:a17:90b:4a:b0:2ee:b4d4:69 with SMTP id\n\t98e67ed59e1d1-2efcf2c587fmr7783592a91.35.1733840769318; \n\tTue, 10 Dec 2024 06:26:09 -0800 (PST)",
        "From": "Harvey Yang <chenghaoyang@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Harvey Yang <chenghaoyang@chromium.org>,\n\tHan-Lin Chen <hanlinchen@chromium.org>",
        "Subject": "[PATCH v4 5/7] android: Drop notify CAMERA3_MSG_ERROR_REQUEST when a\n\trequest fails",
        "Date": "Tue, 10 Dec 2024 14:23:58 +0000",
        "Message-ID": "<20241210142557.2886315-6-chenghaoyang@chromium.org>",
        "X-Mailer": "git-send-email 2.47.0.338.g60cca15819-goog",
        "In-Reply-To": "<20241210142557.2886315-1-chenghaoyang@chromium.org>",
        "References": "<20241210142557.2886315-1-chenghaoyang@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "According to Android Camera API v3.2, CAMERA3_MSG_ERROR_REQUEST is used\nfor requests that have not done any processing. When a request is\ncompleted with failure, CAMERA3_MSG_ERROR_RESULT should be used instead.\n\nTo avoid code duplication, when CameraMetadata cannot be generated,\nCAMERA3_MSG_ERROR_RESULT is notified after process_capture_result.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/android/camera_device.cpp | 40 ++++++++++++++++++++++++++++-------\n 1 file changed, 32 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex f3f570544..3b10f207e 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1182,6 +1182,18 @@ void CameraDevice::requestComplete(Request *request)\n \t * post-processing/compression fails.\n \t */\n \tfor (auto &buffer : descriptor->buffers_) {\n+\t\tfor (auto &[_, frameBuffer] : request->buffers()) {\n+\t\t\tif (buffer.srcBuffer != frameBuffer &&\n+\t\t\t    buffer.frameBuffer.get() != frameBuffer)\n+\t\t\t\tcontinue;\n+\n+\t\t\tStreamBuffer::Status status = StreamBuffer::Status::Success;\n+\t\t\tif (frameBuffer->metadata().status != FrameMetadata::FrameSuccess) {\n+\t\t\t\tstatus = StreamBuffer::Status::Error;\n+\t\t\t}\n+\t\t\tsetBufferStatus(buffer, status);\n+\t\t}\n+\n \t\tCameraStream *stream = buffer.stream;\n \n \t\t/*\n@@ -1198,22 +1210,18 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\tif (fence)\n \t\t\t\tbuffer.fence = fence->release();\n \t\t}\n-\t\tbuffer.status = StreamBuffer::Status::Success;\n \t}\n \n \t/*\n-\t * If the Request has failed, abort the request by notifying the error\n-\t * and complete the request with all buffers in error state.\n+\t * If the Request has failed, complete the request with all buffers in\n+\t * error state and notify an error result.\n \t */\n \tif (request->status() != Request::RequestComplete) {\n \t\tLOG(HAL, Error) << \"Request \" << request->cookie()\n \t\t\t\t<< \" not successfully completed: \"\n \t\t\t\t<< request->status();\n \n-\t\tabortRequest(descriptor);\n-\t\tcompleteDescriptor(descriptor);\n-\n-\t\treturn;\n+\t\tdescriptor->status_ = Camera3RequestDescriptor::Status::Error;\n \t}\n \n \t/*\n@@ -1238,7 +1246,7 @@ void CameraDevice::requestComplete(Request *request)\n \t */\n \tdescriptor->resultMetadata_ = getResultMetadata(*descriptor);\n \tif (!descriptor->resultMetadata_) {\n-\t\tnotifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT);\n+\t\tdescriptor->status_ = Camera3RequestDescriptor::Status::Error;\n \n \t\t/*\n \t\t * The camera framework expects an empty metadata pack on error.\n@@ -1271,7 +1279,13 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\tcontinue;\n \t\t}\n \n+\t\tif (buffer->status == StreamBuffer::Status::Error) {\n+\t\t\titer = descriptor->pendingStreamsToProcess_.erase(iter);\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\t++iter;\n+\n \t\tint ret = stream->process(buffer);\n \t\tif (ret) {\n \t\t\tsetBufferStatus(*buffer, StreamBuffer::Status::Error);\n@@ -1324,6 +1338,16 @@ void CameraDevice::sendCaptureResults()\n \t\tdescriptors_.pop();\n \n \t\tsendCaptureResult(descriptor.get());\n+\n+\t\t/*\n+\t\t * Call notify with CAMERA3_MSG_ERROR_RESULT to indicate some\n+\t\t * of the expected result metadata might not be available\n+\t\t * because the capture is cancelled by the camera. Only notify\n+\t\t * it when the final result is sent, since Android will ignore\n+\t\t * the following metadata.\n+\t\t */\n+\t\tif (descriptor->status_ == Camera3RequestDescriptor::Status::Error)\n+\t\t\tnotifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT);\n \t}\n }\n \n",
    "prefixes": [
        "v4",
        "5/7"
    ]
}