[RFC PATCH v3 20/21] apps: lc-compliance: Make `EventLoop` a member
Jacopo Mondi
jacopo.mondi at ideasonboard.com
Thu Feb 6 18:34:14 CET 2025
Hi Barnabás
On Thu, Jan 30, 2025 at 11:51:46AM +0000, Barnabás Pőcze wrote:
> Instead of creating an `EventLoop` in each `run()` invocation
> and setting a member pointer to the on-stack object, simply
> make it a member variable.
>
> Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
I wonder if this could be merged with 16/21
Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
Thanks
j
> ---
> src/apps/lc-compliance/helpers/capture.cpp | 11 ++++-------
> src/apps/lc-compliance/helpers/capture.h | 2 +-
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp
> index 5032470d9..13a5e3f33 100644
> --- a/src/apps/lc-compliance/helpers/capture.cpp
> +++ b/src/apps/lc-compliance/helpers/capture.cpp
> @@ -69,16 +69,13 @@ void Capture::run(unsigned int captureLimit, std::optional<unsigned int> queueLi
>
> captureCount_ = queueCount_ = 0;
>
> - EventLoop loop;
> - loop_ = &loop;
> -
> start();
> prepareRequests();
>
> for (const auto &request : requests_)
> queueRequest(request.get());
>
> - EXPECT_EQ(loop_->exec(), 0);
> + EXPECT_EQ(loop_.exec(), 0);
>
> stop();
>
> @@ -140,7 +137,7 @@ void Capture::requestComplete(Request *request)
> {
> captureCount_++;
> if (captureCount_ >= captureLimit_) {
> - loop_->exit(0);
> + loop_.exit(0);
> return;
> }
>
> @@ -170,7 +167,7 @@ void Capture::start()
> camera_->requestCompleted.connect(this, [this](libcamera::Request *request) {
> /* Runs in the CameraManager thread. */
>
> - loop_->callLater([this, request] {
> + loop_.callLater([this, request] {
> /* Run handler in the context of the event loop. */
> requestComplete(request);
> }, reinterpret_cast<std::uintptr_t>(this));
> @@ -190,7 +187,7 @@ void Capture::stop()
>
> requests_.clear();
>
> - loop_->cancelLater(reinterpret_cast<std::uintptr_t>(this));
> + loop_.cancelLater(reinterpret_cast<std::uintptr_t>(this));
>
> for (const auto &cfg : *config_) {
> int ret = allocator_.free(cfg.stream());
> diff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h
> index dacce1fe2..50dc37c28 100644
> --- a/src/apps/lc-compliance/helpers/capture.h
> +++ b/src/apps/lc-compliance/helpers/capture.h
> @@ -38,7 +38,7 @@ private:
> std::unique_ptr<libcamera::CameraConfiguration> config_;
> std::vector<std::unique_ptr<libcamera::Request>> requests_;
>
> - EventLoop *loop_ = nullptr;
> + EventLoop loop_;
> unsigned int captureLimit_ = 0;
> std::optional<unsigned int> queueLimit_;
> unsigned int captureCount_ = 0;
> --
> 2.48.1
>
>
More information about the libcamera-devel
mailing list