From patchwork Wed Sep 30 13:27:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9876 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 53302C3B5B for ; Wed, 30 Sep 2020 13:23:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F3DB6239C; Wed, 30 Sep 2020 15:23:25 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E73B60364 for ; Wed, 30 Sep 2020 15:23:23 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id E9AE9C0016; Wed, 30 Sep 2020 13:23:21 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 30 Sep 2020 15:27:02 +0200 Message-Id: <20200930132707.19367-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930132707.19367-1-jacopo@jmondi.org> References: <20200930132707.19367-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/9] android: camera_device: Clear allocator 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: , Cc: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Clear all the allocated buffers at camera close() time and before configuring the camera streams at configureStream() time as the configureStream operation could be called by the Android framework in two successive capture sessions without going through a close(). Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d8587647f831..d73d10d9d449 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -534,6 +534,8 @@ int CameraDevice::open(const hw_module_t *hardwareModule) void CameraDevice::close() { + allocator_.freeAll(); + camera_->stop(); camera_->release(); @@ -1181,12 +1183,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) } /* - * Clear and remove any existing configuration from previous calls, and - * ensure the required entries are available without further - * reallocation. + * Clear and remove any existing configuration and memory allocated from + * previous calls, and ensure the required entries are available without + * further reallocation. */ streams_.clear(); streams_.reserve(stream_list->num_streams); + allocator_.freeAll(); /* First handle all non-MJPEG streams. */ camera3_stream_t *jpegStream = nullptr;