From 439dc8eb2a7505fca9aa4e55865059cbf5878e23 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 21 Sep 2021 14:44:20 +0200 Subject: [PATCH] libcamera: disconnect camera in spa_libcamera_stream_off() The camera is connected in the spa_libcamera_stream_on() function but the disconnect happen in LibCamera::stop(). It makes more sense to have this two operations separated as it's done for the connection and start, since the camera then can be stopped/started without needing to do a reconnect. Move the camera disconnect to spa_libcamera_stream_off() for the reason mentioned above but also to make the code more consistent and symmetric. --- spa/plugins/libcamera/libcamera-utils.c | 4 ++++ spa/plugins/libcamera/libcamera_wrapper.cpp | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-utils.c b/spa/plugins/libcamera/libcamera-utils.c index 4a57c6774..87be87e91 100644 --- a/spa/plugins/libcamera/libcamera-utils.c +++ b/spa/plugins/libcamera/libcamera-utils.c @@ -912,6 +912,10 @@ static int spa_libcamera_stream_off(struct impl *this) libcamera_stop_capture(dev->camera); + spa_log_info(this->log, "disconnecting camera"); + + libcamera_disconnect(dev->camera); + spa_loop_invoke(this->data_loop, do_remove_source, 0, NULL, 0, true, port); spa_list_init(&port->queue); diff --git a/spa/plugins/libcamera/libcamera_wrapper.cpp b/spa/plugins/libcamera/libcamera_wrapper.cpp index 4e0a461c8..dfc224812 100644 --- a/spa/plugins/libcamera/libcamera_wrapper.cpp +++ b/spa/plugins/libcamera/libcamera_wrapper.cpp @@ -518,8 +518,6 @@ extern "C" { } void LibCamera::stop() { - this->disconnect(); - StreamConfiguration &cfg = this->config_->at(0); Stream *stream = cfg.stream(); uint32_t nbuffers = this->allocator_->buffers(stream).size();