[libcamera-devel] [PATCH 1/3] qcam: Queue requests only through MainWindow::queueRequest()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sun Jun 19 02:36:43 CEST 2022
Hi Utkarsh,
Thank you for the patch.
On Mon, Jun 13, 2022 at 11:33:43AM +0530, Utkarsh Tiwari via libcamera-devel wrote:
> Currently whenever we want to queue a request we use the camera directly
>
> Centralize all the queuing to a single function
Even more importantly than explaining what the patch does, the commit
message should explain why.
> Signed-off-by: Utkarsh Tiwari <utkarsh02t at gmail.com>
> ---
> src/qcam/main_window.cpp | 14 +++++++++-----
> src/qcam/main_window.h | 3 ++-
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index dd0e51f5..5ac31d9a 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -119,14 +119,14 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
> if (renderType == "qt") {
> ViewFinderQt *viewfinder = new ViewFinderQt(this);
> connect(viewfinder, &ViewFinderQt::renderComplete,
> - this, &MainWindow::queueRequest);
> + this, &MainWindow::refillRequest);
> viewfinder_ = viewfinder;
> setCentralWidget(viewfinder);
> #ifndef QT_NO_OPENGL
> } else if (renderType == "gles") {
> ViewFinderGL *viewfinder = new ViewFinderGL(this);
> connect(viewfinder, &ViewFinderGL::renderComplete,
> - this, &MainWindow::queueRequest);
> + this, &MainWindow::refillRequest);
> viewfinder_ = viewfinder;
> setCentralWidget(viewfinder);
> #endif
> @@ -521,7 +521,7 @@ int MainWindow::startCapture()
>
> /* Queue all requests. */
> for (std::unique_ptr<Request> &request : requests_) {
> - ret = camera_->queueRequest(request.get());
> + ret = queueRequest(request.get());
> if (ret < 0) {
> qWarning() << "Can't queue request";
> goto error_disconnect;
> @@ -755,7 +755,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)
> viewfinder_->render(buffer, mappedBuffers_[buffer].get());
> }
>
> -void MainWindow::queueRequest(FrameBuffer *buffer)
> +void MainWindow::refillRequest(FrameBuffer *buffer)
> {
> Request *request;
> {
> @@ -784,6 +784,10 @@ void MainWindow::queueRequest(FrameBuffer *buffer)
> qWarning() << "No free buffer available for RAW capture";
> }
> }
> + queueRequest(request);
> +}
>
> - camera_->queueRequest(request);
> +int MainWindow::queueRequest(Request *request)
> +{
> + return camera_->queueRequest(request);
> }
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 3fbe872c..251b8335 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -66,7 +66,7 @@ private Q_SLOTS:
> void processRaw(libcamera::FrameBuffer *buffer,
> const libcamera::ControlList &metadata);
>
> - void queueRequest(libcamera::FrameBuffer *buffer);
> + void refillRequest(libcamera::FrameBuffer *buffer);
I'd name the function either requeueRequest(), to emphasize that it also
queues the request, or possibly better renderComplete(), as it's the
slot that handles the rendering completion.
>
> private:
> int createToolbars();
> @@ -80,6 +80,7 @@ private:
> void addCamera(std::shared_ptr<libcamera::Camera> camera);
> void removeCamera(std::shared_ptr<libcamera::Camera> camera);
>
> + int queueRequest(libcamera::Request* request);
> void requestComplete(libcamera::Request *request);
> void processCapture();
> void processHotplug(HotplugEvent *e);
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list