{"id":10040,"url":"https://patchwork.libcamera.org/api/patches/10040/?format=json","web_url":"https://patchwork.libcamera.org/patch/10040/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201009133956.77396-3-jacopo@jmondi.org>","date":"2020-10-09T13:39:56","name":"[libcamera-devel,2/2] android: camera_device: Queue request to Worker","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"72cf45b03bf8e0cadd94a44613ec610cd7d54f46","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/10040/mbox/","series":[{"id":1371,"url":"https://patchwork.libcamera.org/api/series/1371/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1371","date":"2020-10-09T13:39:54","name":"android: Introduce CameraWorker","version":1,"mbox":"https://patchwork.libcamera.org/series/1371/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10040/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10040/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 DAF57BEEE0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  9 Oct 2020 13:36:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B83136073B;\n\tFri,  9 Oct 2020 15:36:31 +0200 (CEST)","from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C39FA6081E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  9 Oct 2020 15:36:29 +0200 (CEST)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 47EEEFF817;\n\tFri,  9 Oct 2020 13:36:29 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  9 Oct 2020 15:39:56 +0200","Message-Id":"<20201009133956.77396-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.28.0","In-Reply-To":"<20201009133956.77396-1-jacopo@jmondi.org>","References":"<20201009133956.77396-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 2/2] android: camera_device: Queue request\n\tto Worker","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a CameraWorker class member to the CameraDevice class and\nqueue capture requests to it to delegate fence handling and capture\nrequests queueing to the camera.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 19 +++++++++----------\n src/android/camera_device.h   |  3 +++\n 2 files changed, 12 insertions(+), 10 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 0a94c1ae17ac..0e42e2e194d8 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -194,8 +194,8 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()\n  */\n \n CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)\n-\t: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),\n-\t  facing_(CAMERA_FACING_FRONT), orientation_(0)\n+\t: id_(id), worker_(camera), running_(false), camera_(camera),\n+\t  staticMetadata_(nullptr), facing_(CAMERA_FACING_FRONT), orientation_(0)\n {\n \tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n \n@@ -519,6 +519,7 @@ void CameraDevice::close()\n {\n \tstreams_.clear();\n \n+\tworker_.stop();\n \tcamera_->stop();\n \tcamera_->release();\n \n@@ -1356,6 +1357,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \t\t\treturn ret;\n \t\t}\n \n+\t\tworker_.start();\n+\n \t\trunning_ = true;\n \t}\n \n@@ -1377,6 +1380,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \n \tRequest *request =\n \t\tcamera_->createRequest(reinterpret_cast<uint64_t>(descriptor));\n+\tstd::unique_ptr<CaptureRequest> captureRequest = std::make_unique<CaptureRequest>(request);\n \n \tLOG(HAL, Debug) << \"Queueing Request to libcamera with \"\n \t\t\t<< descriptor->numBuffers << \" HAL streams\";\n@@ -1445,16 +1449,11 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \t\t\treturn -ENOMEM;\n \t\t}\n \n-\t\trequest->addBuffer(cameraStream->stream(), buffer);\n+\t\tcaptureRequest->addBuffer(cameraStream->stream(), buffer,\n+\t\t\t\t\t  camera3Buffers[i].acquire_fence);\n \t}\n \n-\tint ret = camera_->queueRequest(request);\n-\tif (ret) {\n-\t\tLOG(HAL, Error) << \"Failed to queue request\";\n-\t\tdelete request;\n-\t\tdelete descriptor;\n-\t\treturn ret;\n-\t}\n+\tworker_.queueRequest(std::move(captureRequest));\n \n \treturn 0;\n }\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 777d1a35e801..b4b32f77a29a 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -25,6 +25,7 @@\n #include \"libcamera/internal/message.h\"\n \n #include \"camera_stream.h\"\n+#include \"camera_worker.h\"\n #include \"jpeg/encoder.h\"\n \n class CameraMetadata;\n@@ -108,6 +109,8 @@ private:\n \tunsigned int id_;\n \tcamera3_device_t camera3Device_;\n \n+\tCameraWorker worker_;\n+\n \tbool running_;\n \tstd::shared_ptr<libcamera::Camera> camera_;\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n","prefixes":["libcamera-devel","2/2"]}