[{"id":19630,"web_url":"https://patchwork.libcamera.org/comment/19630/","msgid":"<YT6pUusfauHHQl/A@pendragon.ideasonboard.com>","date":"2021-09-13T01:28:50","subject":"Re: [libcamera-devel] [PATCH v2 9/9] RFC: Stop PostProcessor when\n\tcamera is stopped","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Fri, Sep 10, 2021 at 12:36:38PM +0530, Umang Jain wrote:\n> Stopping the post-processor thread from CameraDevice is not ideal.\n\nWhy is so ? I think that explicit start() and stop() functions for\nCameraStream() could make sense.\n\n> But it temporarily avoids the crash on stopping the camera.\n\nWhat crash ?\n\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  src/android/camera_device.cpp | 8 ++++++++\n>  src/android/camera_stream.h   | 7 +++++++\n>  2 files changed, 15 insertions(+)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 73eb5758..fa2db72f 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -425,6 +425,14 @@ int CameraDevice::open(const hw_module_t *hardwareModule)\n>  \n>  void CameraDevice::close()\n>  {\n> +\tfor (CameraStream &cameraStream : streams_) {\n> +\t\t/* CameraStream doesn't have user defined destructor as\n> +\t\t * it is MoveConstructible. Stop the post-processor thread\n\nWhy does being move-constructible prevent having a user-defined\ndestructor ? Adding a user-defined destructor will prevent the compiler\nfrom adding an implicitly-declared move constructor, but you could add\nan explicit\n\n\tCameraStream(CameraStream &&other) = default;\n\nOr better,\n\n\tCameraStream(CameraStream &&other);\n\nin camera_device.h, and\n\nCameraStream::CameraStream(CameraStream &&other) = default;\n\nin camera_device.cpp to avoid making it inline.\n\n> +\t\t * from here before clearing streams_.\n> +\t\t */\n> +\t\tcameraStream.stopPostProcessorThread();\n> +\t}\n> +\n>  \tstreams_.clear();\n>  \n>  \tstop();\n> diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\n> index dbb7eee3..bd37473e 100644\n> --- a/src/android/camera_stream.h\n> +++ b/src/android/camera_stream.h\n> @@ -133,6 +133,13 @@ public:\n>  \t\t    const Camera3RequestDescriptor *context);\n>  \tlibcamera::FrameBuffer *getBuffer();\n>  \tvoid putBuffer(libcamera::FrameBuffer *buffer);\n> +\tvoid stopPostProcessorThread()\n> +\t{\n> +\t\tif (thread_) {\n> +\t\t\tthread_->exit();\n> +\t\t\tthread_->wait();\n> +\t\t}\n> +\t}\n>  \n>  \tenum ProcessStatus {\n>  \t\tSucceeded,","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 E3EC5BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Sep 2021 01:29:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5EDFE69185;\n\tMon, 13 Sep 2021 03:29:16 +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 9718B60250\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Sep 2021 03:29:14 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 04E899E;\n\tMon, 13 Sep 2021 03:29:13 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SQJ0cltI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631496554;\n\tbh=HVUuBTIYNCbemDU4GXmUWMJiY5d5ATDOY2JqI+V2vNE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SQJ0cltIw8Yh9u+y9+/e1GEkcdJ+i2i7MqmG0qc02DKlwIjoxU1eQ18wnHTArZPKD\n\tWJe28Kg65GcGm3CVurq42ROGm7O0dmXMc/wXbfpXU0/f5ygZDuGr5817cHmWo/yNq6\n\tq3UnoWSOgqRyWBV/fF2LYxRTtl/18OSkuQqdd6fc=","Date":"Mon, 13 Sep 2021 04:28:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YT6pUusfauHHQl/A@pendragon.ideasonboard.com>","References":"<20210910070638.467294-1-umang.jain@ideasonboard.com>\n\t<20210910070638.467294-10-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210910070638.467294-10-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 9/9] RFC: Stop PostProcessor when\n\tcamera is stopped","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]