From patchwork Wed Nov 4 08:27:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10334 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 12A31BDB89 for ; Wed, 4 Nov 2020 08:28:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D8E660346; Wed, 4 Nov 2020 09:28:12 +0100 (CET) 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="JdDBFyuy"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC68760344 for ; Wed, 4 Nov 2020 09:28:10 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4D1D2563; Wed, 4 Nov 2020 09:28:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1604478490; bh=HerGvADrPRahOums1qspvtzop0yYXU9NmbgNVUlQrPM=; h=From:To:Cc:Subject:Date:From; b=JdDBFyuyfh3YocYuq1FGVDzWd5srBf+6mfr57+7vnLxgVZNjFk2y+K8iP+LW6VUcJ a5CayRH4lINlSbis6qaGg14WdNz+hUaHRuAOkQwhDRHsnOGkfpgbdH6Vx5/mCHWV8D l+bmrT3LrTqmwFZSOxnVyWZuhL3rjHC3XoYhcV0E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 4 Nov 2020 10:27:19 +0200 Message-Id: <20201104082719.25190-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] gstreamer: libcamerasrc: Delete configuration before stopping camera manager 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: Nicolas Dufresne Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When closing the libcamerasrc, the reference to camera is released and the camera manager is stopped. However, the camera configuration still exists at that point, and holds a reference to the camera. This leads to a warning from the device enumerator complaining that the media devices are still in use: [1:53:48.792327560] [408] ERROR DeviceEnumerator device_enumerator.cpp:165 Removing media device /dev/media1 while still in use [1:53:48.792354022] [408] ERROR DeviceEnumerator device_enumerator.cpp:165 Removing media device /dev/media0 while still in use A crash follows when the libcamerasrc is finalized, as deleting the camera configuration will then release the last reference to the camera, which attempts to delete the camera object with deleteLater() without an event dispatcher. Fix it by deleting the camera configuration before stopping the camera manager. Signed-off-by: Laurent Pinchart Reviewed-by: Nicolas Dufresne --- src/gstreamer/gstlibcamerasrc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index a099508c122a..636c14dff64e 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -499,6 +499,8 @@ gst_libcamera_src_close(GstLibcameraSrc *self) GST_DEBUG_OBJECT(self, "Releasing resources"); + state->config_.reset(); + ret = state->cam_->release(); if (ret) { GST_ELEMENT_WARNING(self, RESOURCE, BUSY,