From patchwork Thu Apr 4 10:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19839 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 CF754BD16B for ; Thu, 4 Apr 2024 10:18:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0FA1B6337D; Thu, 4 Apr 2024 12:18:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rR0Lg7SW"; 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 EDD8C63339 for ; Thu, 4 Apr 2024 12:18:36 +0200 (CEST) Received: from localhost.localdomain (unknown [IPv6:2001:b07:5d2e:52c9:cc1e:e404:491f:e6ea]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EE05F1A2; Thu, 4 Apr 2024 12:17:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712225879; bh=8+RThJFYSLZ4+ulflUpxfmY4nyVnJni7WzofqivoEJs=; h=From:To:Cc:Subject:Date:From; b=rR0Lg7SW1268Owhg1ny4lk65wsH1SW93YPSzHw7NCN5nW2k2Ii9CLHcNWcJ00pBjU 2A97OU41vOJsYbPebKPfbMzI1l/DLPhEm0lw7ahAdL2Xd2Kb5QJgIObLo3ONkjaBpp WCJlesN3DxDTgUHmf/KC1422TG8j8OMHxye3Uqyg= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Anle Pan , Umang Jain , Jacopo Mondi Subject: [PATCH] android: camera_device: Always clear descriptors_ in stop() Date: Thu, 4 Apr 2024 12:18:14 +0200 Message-ID: <20240404101818.21484-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 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" From: Anle Pan When flush() is called and then a new stream configuration is set, the descriptors_ queue might have a chance to be not cleared in stop(), as the Camera is already in Stopped state. This will prevent further requests from being completed in sendCaptureResults() as the descriptors_ queue is not empty. To fix the issue, clear the descriptors_ even if the Camera State is Stopped. As a drawback the libcamera::Camera::stop() function might be called twice, but this is allowed by the Camera state machine, and the second call is guaranteed to be a nop. Signed-off-by: Anle Pan Signed-off-by: Fang Hui Tested-by: Jacopo Mondi Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- CTS shows no regressions compared to v0.2.0 --- src/android/camera_device.cpp | 2 -- 1 file changed, 2 deletions(-) -- 2.44.0 diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d2679a9722e2..1b6f3f3a2b29 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -433,8 +433,6 @@ void CameraDevice::flush() void CameraDevice::stop() { MutexLocker stateLock(stateMutex_); - if (state_ == State::Stopped) - return; camera_->stop();