[{"id":976,"web_url":"https://patchwork.libcamera.org/comment/976/","msgid":"<20190228224826.GO899@bigcity.dyn.berto.se>","date":"2019-02-28T22:48:26","subject":"Re: [libcamera-devel] [PATCH 08/10] libcamera: request: Add request\n\tcompletion status","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2019-02-28 18:29:11 +0200, Laurent Pinchart wrote:\n> Add a new field to the Request class to report its completion status,\n> and a new complete() method to update the status.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  include/libcamera/request.h | 12 +++++++++++\n>  src/libcamera/request.cpp   | 40 ++++++++++++++++++++++++++++++++++++-\n>  2 files changed, 51 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/request.h b/include/libcamera/request.h\n> index ef081177309f..0b75f9d9bd19 100644\n> --- a/include/libcamera/request.h\n> +++ b/include/libcamera/request.h\n> @@ -18,9 +18,16 @@ class Buffer;\n>  class Camera;\n>  class Stream;\n>  \n> +\n>  class Request\n>  {\n>  public:\n> +\tenum Status {\n> +\t\tRequestPending,\n> +\t\tRequestComplete,\n> +\t\tRequestCancelled,\n> +\t};\n> +\n>  \texplicit Request(Camera *camera);\n>  \tRequest(const Request &) = delete;\n>  \tRequest &operator=(const Request &) = delete;\n> @@ -28,15 +35,20 @@ public:\n>  \tint setBuffers(const std::map<Stream *, Buffer *> &streamMap);\n>  \tBuffer *findBuffer(Stream *stream) const;\n>  \n> +\tStatus status() const { return status_; }\n> +\n>  private:\n>  \tfriend class Camera;\n>  \n>  \tint prepare();\n> +\tvoid complete(Status status);\n>  \tvoid bufferCompleted(Buffer *buffer);\n>  \n>  \tCamera *camera_;\n>  \tstd::map<Stream *, Buffer *> bufferMap_;\n>  \tstd::unordered_set<Buffer *> pending_;\n> +\n> +\tStatus status_;\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index d76db24de0e2..cb170930fbb6 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -23,6 +23,17 @@ namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(Request)\n>  \n> +/**\n> + * \\enum Request::Status\n> + * Request completion status\n> + * \\var Request::RequestPending\n> + * The request hasn't completed yet\n> + * \\var Request::RequestComplete\n> + * The request has completed\n> + * \\var Request::RequestCancelled\n> + * The request has been cancelled due to capture stop\n> + */\n> +\n>  /**\n>   * \\class Request\n>   * \\brief A frame capture request\n> @@ -36,7 +47,7 @@ LOG_DEFINE_CATEGORY(Request)\n>   * \\param[in] camera The camera that creates the request\n>   */\n>  Request::Request(Camera *camera)\n> -\t: camera_(camera)\n> +\t: camera_(camera), status_(RequestPending)\n>  {\n>  }\n>  \n> @@ -82,6 +93,19 @@ Buffer *Request::findBuffer(Stream *stream) const\n>  \treturn it->second;\n>  }\n>  \n> +/**\n> + * \\fn Request::status()\n> + * \\brief Retrieve the request completion status\n> + *\n> + * The request status indicates whether the request has completed successfully\n> + * or with an error. When requests are created and before they complete the\n> + * request status is set to RequestPending, and is updated at completion time\n> + * to RequestComplete. If a request is cancelled at capture stop before it has\n> + * completed, its status is set to RequestCancelled.\n> + *\n> + * \\return The request completion status\n> + */\n> +\n>  /**\n>   * \\brief Prepare the resources for the completion handler\n>   */\n> @@ -96,6 +120,18 @@ int Request::prepare()\n>  \treturn 0;\n>  }\n>  \n> +/**\n> + * \\brief Complete a queued request\n> + * \\param[in] status The request completion status\n> + *\n> + * Mark the request as complete by updating its status to \\a status.\n> + */\n> +void Request::complete(Status status)\n> +{\n> +\tASSERT(pending_.empty());\n> +\tstatus_ = status;\n> +}\n> +\n>  /**\n>   * \\brief Slot for the buffer completed signal\n>   *\n> @@ -117,6 +153,8 @@ void Request::bufferCompleted(Buffer *buffer)\n>  \tif (!pending_.empty())\n>  \t\treturn;\n>  \n> +\tcomplete(RequestComplete);\n> +\n>  \tstd::map<Stream *, Buffer *> buffers(std::move(bufferMap_));\n>  \tcamera_->requestCompleted.emit(this, buffers);\n>  \tdelete this;\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5351B610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 23:48:28 +0100 (CET)","by mail-lf1-x143.google.com with SMTP id 131so7347849lfa.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 14:48:28 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tj16sm1178800lfh.81.2019.02.28.14.48.26\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tThu, 28 Feb 2019 14:48:27 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=OWeqyz/wqZyDIn4i0gaUABUnYbKnYG8ne5bmK8iXP7E=;\n\tb=GlTBQIxQrSxRaPs4DlE3Xg9sKHiBC2+E2fM1UYJvrUwg/SwhholXM7obW9rQncGvDN\n\tqqGgfJuDpb459X1LKRgSU88Sr8saArOxgbG/p2VbEwdJ9+MiX1yUIiM8DOZpVcUf8ho1\n\t4RqHIGk8wtf8TmL0d+ypQZpGr4Uef7iJIuntjNnzKLs1THb5WsCD2haENOIOuQYtYuK7\n\tr73wnmE3rZqbPlfptJpOuSz8zwVEbUlKNDc1Z5v36brWAa46HGb7ETsOtFJeEwsC2Dim\n\t4RCzjXqB8sxzU4zITkA6pghRCRY1AGfYYJTejmiQvrWfcVbxqc/IDuIn31tCylDWyy5V\n\tE0Vw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=OWeqyz/wqZyDIn4i0gaUABUnYbKnYG8ne5bmK8iXP7E=;\n\tb=VwfIKdQoH/VLBL5ws6DyprV07iYJ2b12/uJghp5Ogoojb64R9pS8gluHV2NSnKK1l2\n\t9DmEG6C5Ocq0Bm2mG4OC8HCl1WZIBA/xZO1DZa+xqa3dHrF5j24crqICq5NL/LvIAkEk\n\tAA1+KctCEqs1WDY/pAESKaDOeo9fgqeUHEFPG//0uMMKFhVj9HvLZPnHZ6ZNecW0ChkO\n\tQAf8vrHYG14sKo3W5mbFugpA1Ys+vBXcOWiAQZxaD+Q1OzwlgIsbQyBa2axquxHklw0Q\n\tN7iK91EMx3PCyJ9IH3jpEFoch3Zi0/4QBdMCeufvl92Hiut1U0ETBG15tCLp8YNABN7h\n\t8gAw==","X-Gm-Message-State":"APjAAAXL7J5JXnIXrnraeng7TybCVsgsAutXbmpEVJzed+iXrRN77h0o\n\tXin8fKxXAkvLeuBworoq/oH1LA==","X-Google-Smtp-Source":"APXvYqxltzKpoelwOogYo4t/mTi1/jIBUorZoGp/XRcnjMosBcyDaqsHrfnY4QdIhvGPv/3tLtkSMw==","X-Received":"by 2002:a19:2d57:: with SMTP id t23mr1153687lft.28.1551394107620;\n\tThu, 28 Feb 2019 14:48:27 -0800 (PST)","Date":"Thu, 28 Feb 2019 23:48:26 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190228224826.GO899@bigcity.dyn.berto.se>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>\n\t<20190228162913.6508-9-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190228162913.6508-9-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 08/10] libcamera: request: Add request\n\tcompletion status","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Thu, 28 Feb 2019 22:48:28 -0000"}}]