Patch Detail
Show a patch.
GET /api/patches/9959/?format=api
{ "id": 9959, "url": "https://patchwork.libcamera.org/api/patches/9959/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9959/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20201005104649.10812-13-laurent.pinchart@ideasonboard.com>", "date": "2020-10-05T10:46:46", "name": "[libcamera-devel,12/15] android: camera_stream: Add methods to get/put buffers", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "9794d1578a5de4b6c45f61ca0244e7baf44be659", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/9959/mbox/", "series": [ { "id": 1349, "url": "https://patchwork.libcamera.org/api/series/1349/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1349", "date": "2020-10-05T10:46:34", "name": "CameraStream refactoring", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1349/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9959/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9959/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 DDF1AC3B5D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 5 Oct 2020 10:47:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A817063C23;\n\tMon, 5 Oct 2020 12:47:43 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B0B063B27\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 5 Oct 2020 12:47:38 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DEFB63B;\n\tMon, 5 Oct 2020 12:47:37 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DSE2W315\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1601894858;\n\tbh=QTpINhxG3ul3V118LYtzIO7Rg0RhyTjI+kD3k6IdYqU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DSE2W315MY5Qve0yqx3I8fyQ6VXyGr3EpgjzF2CU3yL6UuI6WEX067HN9jlCBdEut\n\tsZH2fR+tRM7emfnck6CJeQhrpDuK92wkoxqb+Xj/BbFTzRcrXhq58HlKXCAMryE9Oc\n\t89TYgGkvhiSWlJClOorq3IaqAEI9mn28tk/5dT+M=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 5 Oct 2020 13:46:46 +0300", "Message-Id": "<20201005104649.10812-13-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>", "References": "<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 12/15] android: camera_stream: Add methods\n\tto get/put buffers", "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": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nAdd two methods to the CameraStream class to get and put FrameBuffer\npointers from the pool of allocated buffers.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_stream.cpp | 35 +++++++++++++++++++++++++++++++++--\n src/android/camera_stream.h | 4 ++++\n 2 files changed, 37 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex dbde1e786300..c4b727eee63e 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -19,21 +19,24 @@ LOG_DECLARE_CATEGORY(HAL);\n CameraStream::CameraStream(CameraDevice *cameraDev, Type type,\n \t\t\t camera3_stream_t *androidStream, unsigned int index)\n \t: cameraDevice_(cameraDev), type_(type), androidStream_(androidStream),\n-\t index_(index), encoder_(nullptr), allocator_(nullptr)\n+\t index_(index), encoder_(nullptr), allocator_(nullptr), mutex_(nullptr)\n {\n \tconfig_ = cameraDevice_->cameraConfiguration();\n \n \tif (type_ == Type::Internal || type_ == Type::Mapped)\n \t\tencoder_ = new EncoderLibJpeg();\n \n-\tif (type == Type::Internal)\n+\tif (type == Type::Internal) {\n \t\tallocator_ = new FrameBufferAllocator(cameraDevice_->camera());\n+\t\tmutex_ = new std::mutex();\n+\t}\n }\n \n CameraStream::~CameraStream()\n {\n \tdelete encoder_;\n \tdelete allocator_;\n+\tdelete mutex_;\n }\n \n const StreamConfiguration &CameraStream::streamConfiguration() const\n@@ -135,3 +138,31 @@ int CameraStream::process(libcamera::FrameBuffer *source, MappedCamera3Buffer *d\n \n \treturn 0;\n }\n+\n+FrameBuffer *CameraStream::getBuffer()\n+{\n+\tif (!allocator_)\n+\t\treturn nullptr;\n+\n+\tstd::lock_guard<std::mutex> locker(*mutex_);\n+\n+\tif (buffers_.empty()) {\n+\t\tLOG(HAL, Error) << \"Buffer underrun\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tFrameBuffer *buffer = buffers_.back();\n+\tbuffers_.pop_back();\n+\n+\treturn buffer;\n+}\n+\n+void CameraStream::putBuffer(libcamera::FrameBuffer *buffer)\n+{\n+\tif (!allocator_)\n+\t\treturn;\n+\n+\tstd::lock_guard<std::mutex> locker(*mutex_);\n+\n+\tbuffers_.push_back(buffer);\n+}\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex c6ff79230b7e..b79a97606c60 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -8,6 +8,7 @@\n #define __ANDROID_CAMERA_STREAM_H__\n \n #include <memory>\n+#include <mutex>\n #include <vector>\n \n #include <hardware/camera3.h>\n@@ -127,6 +128,8 @@ public:\n \tint process(libcamera::FrameBuffer *source,\n \t\t MappedCamera3Buffer *dest,\n \t\t CameraMetadata *metadata);\n+\tlibcamera::FrameBuffer *getBuffer();\n+\tvoid putBuffer(libcamera::FrameBuffer *buffer);\n \n private:\n \tCameraDevice *cameraDevice_;\n@@ -143,6 +146,7 @@ private:\n \tEncoder *encoder_;\n \tlibcamera::FrameBufferAllocator *allocator_;\n \tstd::vector<libcamera::FrameBuffer *> buffers_;\n+\tstd::mutex *mutex_;\n };\n \n #endif /* __ANDROID_CAMERA_STREAM__ */\n", "prefixes": [ "libcamera-devel", "12/15" ] }