[{"id":2157,"web_url":"https://patchwork.libcamera.org/comment/2157/","msgid":"<20190704134126.GK6569@pendragon.ideasonboard.com>","date":"2019-07-04T13:41:26","subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: Move static timestamp to\n\tMainWindow","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Thu, Jul 04, 2019 at 02:03:45PM +0100, Kieran Bingham wrote:\n> The 'last' buffer timestamp is stored as a static. Rename the variable\n> to a more descritive 'lastBufferTime' and move it to the class instance.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/qcam/main_window.cpp | 10 +++++-----\n>  src/qcam/main_window.h   |  2 ++\n>  2 files changed, 7 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 16b123132dd9..0f737d852960 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -144,6 +144,8 @@ int MainWindow::startCapture()\n>  \t\trequests.push_back(request);\n>  \t}\n>  \n> +\tlastBufferTime_ = 0;\n> +\n>  \tret = camera_->start();\n>  \tif (ret) {\n>  \t\tstd::cout << \"Failed to start capture\" << std::endl;\n> @@ -187,16 +189,14 @@ void MainWindow::stopCapture()\n>  void MainWindow::requestComplete(Request *request,\n>  \t\t\t\t const std::map<Stream *, Buffer *> &buffers)\n>  {\n> -\tstatic uint64_t last = 0;\n> -\n>  \tif (request->status() == Request::RequestCancelled)\n>  \t\treturn;\n>  \n>  \tBuffer *buffer = buffers.begin()->second;\n>  \n> -\tdouble fps = buffer->timestamp() - last;\n> -\tfps = last && fps ? 1000000000.0 / fps : 0.0;\n> -\tlast = buffer->timestamp();\n> +\tdouble fps = buffer->timestamp() - lastBufferTime_;\n> +\tfps = lastBufferTime_ && fps ? 1000000000.0 / fps : 0.0;\n> +\tlastBufferTime_ = buffer->timestamp();\n>  \n>  \tstd::cout << \"seq: \" << std::setw(6) << std::setfill('0') << buffer->sequence()\n>  \t\t  << \" buf: \" << buffer->index()\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index fe565cbcb460..345bdaaed354 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -48,6 +48,8 @@ private:\n>  \tbool isCapturing_;\n>  \tstd::unique_ptr<CameraConfiguration> config_;\n>  \n> +\tuint64_t lastBufferTime_;\n> +\n>  \tViewFinder *viewfinder_;\n>  };\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61D3B61569\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jul 2019 15:41:47 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EF67624B;\n\tThu,  4 Jul 2019 15:41:46 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562247707;\n\tbh=LvWo+ei9uN9H1jBqcenpJ2kqIvIvQ92uQLAL6E8Bn6M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bVj8HLsJ8HW53ogdxxHp6hZn/OmJUtpfk58MUStF1KGQ+M96mtQW9Y4ZMWJaeVBER\n\tGckcouekGUk56ruWlrabcLNFMhZRoAgj8IxLv2/s3Vt5Sd7LpaBaix1A1PP+kTTcCC\n\tTHfrwCkN1SnIDKVFQpN5rqgcoLRKtczvcrKtIpfE=","Date":"Thu, 4 Jul 2019 16:41:26 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20190704134126.GK6569@pendragon.ideasonboard.com>","References":"<20190704130347.9372-1-kieran.bingham@ideasonboard.com>\n\t<20190704130347.9372-8-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190704130347.9372-8-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: Move static timestamp to\n\tMainWindow","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 04 Jul 2019 13:41:47 -0000"}}]