From patchwork Tue Mar 30 05:46:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11785 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 1B7E6C32EA for ; Tue, 30 Mar 2021 05:46:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7657768787; Tue, 30 Mar 2021 07:46:51 +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="QYxXcr1Z"; 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 B3D0A602D7 for ; Tue, 30 Mar 2021 07:46:49 +0200 (CEST) Received: by mail-pf1-x42d.google.com with SMTP id x26so11443283pfn.0 for ; Mon, 29 Mar 2021 22:46:49 -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:mime-version :content-transfer-encoding; bh=WDMIGvMK3UhEG/R2ElSVU98haTf20PV55Gz9xXNyv/M=; b=QYxXcr1Z0aIaixY6yo8J2P0x7YPuiD2w1B15jmagUkyvrDkUZ7RijPIUr1uXD3G3Kp I43TMHDOKzQq713iyVqsPx4+kPyIVIsRiiI+hpGdLfXOMYSeHXOclTEIzLYhEfnNIr1L PUlTiJEsxH3qNtC0ZiOEMRg+kVpzT4udE83ws= 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:mime-version :content-transfer-encoding; bh=WDMIGvMK3UhEG/R2ElSVU98haTf20PV55Gz9xXNyv/M=; b=DotSO+kTJ1W+6yBXNZ4v8z6VFHmv+sdKiWNNDqZx7Zf84UY2z6Wc5M94ySsfNBl+1Q OcNMblMQhVD9Pd5y8J2Lj+qWEJASX8e6aN/1hHCFwJ/i6sw17ogzM4JHV9swlOgQ66ji XXUwdpln+RPdsKpishRIePk7yWKaZJsTSScqoVZoTR0Ebcu7CxJgqKeAuioCQ49H1Wd8 02pBFZeDbEG+ZIZILIetmbWzg6gtc9LaTq/ylOqFCjXGd1nhsVUaxIpaf77Oq5+Alhvy H6mMNBKWhldghTbLE3wuVGqlmqTc21PWV+s5eSylTiZFH9mO6ufL2mgJibhV7gy6baev EZHg== X-Gm-Message-State: AOAM533YjzJyLEZvcKdtchSQfI16DhxPTcEjw55WEe6/Vs4NwkmxGt1A AJo1K/o0MoALg0HkOE70NtDyAH4pel4rBw== X-Google-Smtp-Source: ABdhPJyr27oDahMs6gF2fq9GpP4NUS0XH43fQr7BR5rIpk4GyDjC8ljoXsNHaTH0z4rEGbx2uTaglA== X-Received: by 2002:a05:6a00:852:b029:211:d819:7f57 with SMTP id q18-20020a056a000852b0290211d8197f57mr27857443pfk.17.1617083207977; Mon, 29 Mar 2021 22:46:47 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:c112:2822:484f:486]) by smtp.gmail.com with ESMTPSA id y22sm18679396pfn.32.2021.03.29.22.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 22:46:47 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Mar 2021 14:46:41 +0900 Message-Id: <20210330054642.387562-1-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- src/android/camera_device.cpp | 19 +++++++++++-------- src/android/camera_device.h | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..14299429 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -657,11 +657,18 @@ int CameraDevice::open(const hw_module_t *hardwareModule) void CameraDevice::close() { - streams_.clear(); + stop(); + + camera_->release(); +} + +void CameraDevice::stop() +{ + if (!running_) + return; worker_.stop(); camera_->stop(); - camera_->release(); running_ = false; } @@ -1545,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 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,