From patchwork Fri Apr 2 02:12:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11821 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 0D8FBBD695 for ; Fri, 2 Apr 2021 02:12:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2EB568784; Fri, 2 Apr 2021 04:12:50 +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="NQ5XB7rQ"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F39568787 for ; Fri, 2 Apr 2021 04:12:48 +0200 (CEST) Received: by mail-pj1-x102a.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so3991209pjc.2 for ; Thu, 01 Apr 2021 19:12:48 -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=jC4N0/Et8TUJoGMkmrWzN7SBuUhrsqMvZodN8cLruMw=; b=NQ5XB7rQj0vp/JnJY/t90jGkPZFt/dJLgq9NnAxrkyd0zEFK/clfznpNn26REkwDaA 6z6RN8nAYExACeZQ/3lcm4/fpOVKibUBhs+PZu9sWdlqRM1HX4Gtj9hTWVjQCKl8ixWO GyvgQLsotrGa7TqGSAB4x/+aiX7ocUo3GQ/54= 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=jC4N0/Et8TUJoGMkmrWzN7SBuUhrsqMvZodN8cLruMw=; b=CvKVGPHfwDssajXUNILI5AuYQZz9IdwvxSsz3dPrWxs0foUT1b8V5qqRbTiuZ9/tDC zKg8pqSP8rdUoZ/uyERzuLthTw3vPHci/nuEu4pbUgUfFbjc3LOcrEHZ0rmDmTmYaprC AVNKd6sMvKxg8j/iX0/O3Qq1SISFhahaLB3fF34bYhTFjVdr2FAe64HVG4zVwloASXwh HlLajuh1lpi2ed+I0tJwm6kS7OYInvMUZqZezi7WgfkTjuzeykpzEakiUZHiWOVWZlBW AFaxMk/0dC+NvdN1aMimxuP+SKuQcjghB2cRF7YkN2YKQKX3H7wpwM7gDsvF9tE/FoKw GMdg== X-Gm-Message-State: AOAM53250U0tXPBLP9G3qhF3myaZaJ5m0lsTHXC7/EeQNKCrq5sndt9s zxrqDOui0FzB9AiKXMbqT61ZXy/ciLHvLQ== X-Google-Smtp-Source: ABdhPJztvCvzA6QM+FaIvT4Etl47zkYEwj+mxY4O5V5mi1+infiIq4S0vrgxKZydEEhIdMFb6KisQQ== X-Received: by 2002:a17:902:b494:b029:e7:36be:9ce7 with SMTP id y20-20020a170902b494b02900e736be9ce7mr10583120plr.43.1617329566872; Thu, 01 Apr 2021 19:12:46 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:908:1da:b07c:32bc]) by smtp.gmail.com with ESMTPSA id p4sm86902pjk.57.2021.04.01.19.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 19:12:46 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Apr 2021 11:12:37 +0900 Message-Id: <20210402021238.1297591-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210402021238.1297591-1-hiroh@chromium.org> References: <20210402021238.1297591-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/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 Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 19 ++++++++++++------- src/android/camera_device.h | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index eb327978..b45d3a54 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -659,9 +659,18 @@ void CameraDevice::close() { streams_.clear(); + stop(); + + camera_->release(); +} + +void CameraDevice::stop() +{ + if (!running_) + return; + worker_.stop(); camera_->stop(); - camera_->release(); running_ = false; } @@ -1547,12 +1556,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 11bdfec8..39cf95ad 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -85,6 +85,8 @@ private: int androidFormat; }; + void stop(); + int initializeStreamConfigurations(); std::vector getYUVResolutions(libcamera::CameraConfiguration *cameraConfig,