From patchwork Mon Mar 29 06:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11759 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 A749AC32EF for ; Mon, 29 Mar 2021 06:11:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 61C3C6877D; Mon, 29 Mar 2021 08:11:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jWwSpxw9"; dkim-atps=neutral Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4E54602D2 for ; Mon, 29 Mar 2021 08:11:38 +0200 (CEST) Received: by mail-pf1-x42d.google.com with SMTP id 11so9182297pfn.9 for ; Sun, 28 Mar 2021 23:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S0BbWN1J8xV7FErOAojsZ+fHvtyZlbls2qp4CgRYcQ4=; b=jWwSpxw90Kjo08Ou2TUbPCIq0bd0COdC+9xh76Hgung+cnjRCY9hA/gKI8hoTKqoQa GaMPKy600FaENYsYe8PeXJ86Avpj+Y1/d+kyzxDBQ5F3vPp64dVa4JuRLYcWKp+j8s1i 7tG3JAiQGgLoHiwqPg5hcbVSEP16cluJI/fkM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S0BbWN1J8xV7FErOAojsZ+fHvtyZlbls2qp4CgRYcQ4=; b=eS11pEWLNPxHpsS5xgSNALMB0heOjNPAdNLiHSgGOUqMUd7LaqGeFWpIAeDq9PEdqq xQtLjxWkZYTDmZOFnLe5V6qaJREqRSMgV7bzm9FCn/X5z2KOHn/A+bAJZIfXID/ZUvzD wrUXUqufN8dX2K1NilDairnoL+qrjLJ5Jyx9welWtRoPmTaYdwpffzPvTSYEjYrkvji6 cnO4s3E15Zz7/gUs4eBnuKwxhUAeODFLX9bXjsoFbZ0Bn3CyAJFxv1XwUZ3TqyZ4IBu4 C0Nqdlx5lkqYuKIqqDlrBSZruYeRjeYruSEz5Edf8UYgnJ7HFN3rZxvWd7UTAdU04d81 TArg== X-Gm-Message-State: AOAM530bgL6oM7Ihxzr6MsDPwZI+vBqCKq37IEBiykO/oA8w5EpcravY ZQpKy33wcW/RS5V3fEzD6hfXFPBQsYisDA== X-Google-Smtp-Source: ABdhPJwOpgZl0M8F6EAcKF4dayMie13R5+QQgBhxiROQhzXwr1mMQ44bbmAiYl3el/LDbE5M00fxng== X-Received: by 2002:aa7:9431:0:b029:1f1:52fd:5444 with SMTP id y17-20020aa794310000b02901f152fd5444mr23377479pfo.47.1616998288304; Sun, 28 Mar 2021 23:11:28 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id f2sm16445975pfq.129.2021.03.28.23.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 23:11:27 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 15:11:19 +0900 Message-Id: <20210329061119.135513-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210329061119.135513-1-hiroh@chromium.org> References: <20210329061119.135513-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/2] android: CameraDevice: Add stop() 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" This adds CameraDevice::stop(), which cleans up the member variables of CameraDevice. It is called in CameraDevice::close() and CameraDevice::configureStreams(). Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 17 +++++++++-------- src/android/camera_device.h | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 02d3bfb2..d5447d8e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -659,12 +659,17 @@ int CameraDevice::open(const hw_module_t *hardwareModule) void CameraDevice::close() { - streams_.clear(); + stop(); + + camera_->release(); +} +void CameraDevice::stop() +{ worker_.stop(); camera_->stop(); - camera_->release(); + descriptors_.clear(); running_ = false; } @@ -1547,12 +1552,8 @@ PixelFormat CameraDevice::toPixelFormat(int format) const */ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) { - /* Before any configuration attempt, stop the camera if it's running. */ - if (running_) { - worker_.stop(); - camera_->stop(); - running_ = false; - } + /* Before any configuration attempt, stop the camera. */ + stop(); /* * Generate an empty configuration, and construct a StreamConfiguration diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 5a2d22d6..cc12fe20 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -87,6 +87,8 @@ private: int androidFormat; }; + void stop(); + int initializeStreamConfigurations(); std::vector getYUVResolutions(libcamera::CameraConfiguration *cameraConfig,