From patchwork Fri Feb 14 00:18:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2826 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C635600FB for ; Fri, 14 Feb 2020 01:18:14 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ABC619D3; Fri, 14 Feb 2020 01:18:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1581639493; bh=AzL5UoPbhR066r1KELklVWXAMFIrvOVlhJ+NTafcCcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOPz5fl8XByYPGGT+o/Szgcaqbtv95iLWAReZbWAHt+KlnMKu1/LVqHFiHA4ctp7L yKTxM9ogzYHS8yqJYC6mltvnY66znjarOaDzHwzfDRdxdp38VIM7WxXKd3k0Ls9tUF 48eqts29UFtbddE9uw29azmSge6I8XUR/YIcJ3vI= From: Kieran Bingham To: libcamera devel Date: Fri, 14 Feb 2020 00:18:04 +0000 Message-Id: <20200214001810.19302-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214001810.19302-1-kieran.bingham@ideasonboard.com> References: <20200214001810.19302-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/7] qcam: Tie FrameBufferAllocator to stream life 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: , X-List-Received-Date: Fri, 14 Feb 2020 00:18:14 -0000 The FrameBufferAllocator must be deleted and reconstructed before performing any reconfiguration of the stream. Construct the allocator at startCapture, and destroy it during stopCapture so that we can successfully stop and restart the stream. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - Remove unnecessary braces - Clean up in start_capture() error path. src/qcam/main_window.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 70a3e61c66d8..db14245d7f51 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -36,10 +36,8 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) adjustSize(); ret = openCamera(cm); - if (!ret) { - allocator_ = FrameBufferAllocator::create(camera_); + if (!ret) ret = startCapture(); - } if (ret < 0) QTimer::singleShot(0, QCoreApplication::instance(), @@ -50,7 +48,6 @@ MainWindow::~MainWindow() { if (camera_) { stopCapture(); - delete allocator_; camera_->release(); camera_.reset(); } @@ -171,6 +168,7 @@ int MainWindow::startCapture() adjustSize(); + allocator_ = FrameBufferAllocator::create(camera_); ret = allocator_->allocate(stream); if (ret < 0) { std::cerr << "Failed to allocate capture buffers" << std::endl; @@ -236,6 +234,9 @@ error: } mappedBuffers_.clear(); + delete allocator_; + allocator_ = nullptr; + return ret; } @@ -255,6 +256,8 @@ void MainWindow::stopCapture() } mappedBuffers_.clear(); + delete allocator_; + isCapturing_ = false; config_.reset();