From patchwork Thu Oct 28 17:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 14408 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 BD98EBDB1C for ; Thu, 28 Oct 2021 17:05:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15B6C600BA; Thu, 28 Oct 2021 19:05:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fKLZdJ91"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3530D600B5 for ; Thu, 28 Oct 2021 19:05:05 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [152.57.66.23]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 51D7D93; Thu, 28 Oct 2021 19:05:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1635440704; bh=BQcu1x+bYOLYYR1d3iUq+RCFU2jVLSJtqt2RWoQivjo=; h=From:To:Cc:Subject:Date:From; b=fKLZdJ916fElrTgIACL6FoRAjMCYtJSccOUfs09jYGIJlSWNBudf9D2Fplz38vNmF gu+CPBHR/+OkDVB8UdCRgqSQpl4wX2oNgwRiNGtWs0LJIZjxIXMRdPvkF5KZQysh5/ UpphDy9NKy/kr0jh5wQ0nbRjxJsq8eKDiDdFvsHs= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 22:32:54 +0530 Message-Id: <20211028170254.502151-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3] android: Camera3RequestDescriptor: Provide a constructor for StreamBuffer 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" Provide a constructor for StreamBuffer and use that while populating Camera3RequestDescriptor::buffers_ vector. Also provide the default move-constructor (required as StreamBuffer is stored in a vector in Camera3RequestDescriptor) and destructor for the StreamBuffer struct. Also declare a default move assignment operator and disable the copy constructor and move operator explicitly with LIBCAMERA_DISABLE_COPY(). While at it, initialize pointers members in the StreamBuffer struct to nullptr, with StreamBuffer::status set to Status::Success by default. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/android/camera_request.cpp | 19 ++++++++++++++++--- src/android/camera_request.h | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp index 5bac1b8f..8eced51d 100644 --- a/src/android/camera_request.cpp +++ b/src/android/camera_request.cpp @@ -37,9 +37,7 @@ Camera3RequestDescriptor::Camera3RequestDescriptor( CameraStream *stream = static_cast(buffer.stream->priv); - buffers_.push_back({ stream, buffer.buffer, nullptr, - buffer.acquire_fence, Status::Success, - nullptr, nullptr, nullptr, this }); + buffers_.emplace_back(stream, buffer, this); } /* Clone the controls associated with the camera3 request. */ @@ -54,3 +52,18 @@ Camera3RequestDescriptor::Camera3RequestDescriptor( } Camera3RequestDescriptor::~Camera3RequestDescriptor() = default; + +Camera3RequestDescriptor::StreamBuffer::StreamBuffer( + CameraStream *stream, const camera3_stream_buffer_t &buffer, + Camera3RequestDescriptor *request) + : camera3Buffer(buffer.buffer), fence(buffer.acquire_fence), + stream(stream), request(request) +{ +} + +Camera3RequestDescriptor::StreamBuffer::~StreamBuffer() = default; + +Camera3RequestDescriptor::StreamBuffer::StreamBuffer(StreamBuffer &&other) = default; + +Camera3RequestDescriptor::StreamBuffer & +Camera3RequestDescriptor::StreamBuffer::operator=(Camera3RequestDescriptor::StreamBuffer &&) = default; diff --git a/src/android/camera_request.h b/src/android/camera_request.h index cfafa445..d2935c99 100644 --- a/src/android/camera_request.h +++ b/src/android/camera_request.h @@ -34,15 +34,26 @@ public: }; struct StreamBuffer { + StreamBuffer(CameraStream *stream, + const camera3_stream_buffer_t &buffer, + Camera3RequestDescriptor *request); + ~StreamBuffer(); + + StreamBuffer(StreamBuffer &&other); + StreamBuffer &operator=(StreamBuffer &&); + CameraStream *stream; buffer_handle_t *camera3Buffer; std::unique_ptr frameBuffer; int fence; - Status status; - libcamera::FrameBuffer *internalBuffer; - const libcamera::FrameBuffer *srcBuffer; + Status status = Status::Success; + libcamera::FrameBuffer *internalBuffer = nullptr; + const libcamera::FrameBuffer *srcBuffer = nullptr; std::unique_ptr dstBuffer; Camera3RequestDescriptor *request; + + private: + LIBCAMERA_DISABLE_COPY(StreamBuffer) }; /* Keeps track of streams requiring post-processing. */