[libcamera-devel] [PATCH] libcamera: Release all devices on shutdown

Umang Jain umang.jain at ideasonboard.com
Sat Oct 8 19:34:43 CEST 2022


Hi Christian

On 10/8/22 4:45 PM, Christian Rauch via libcamera-devel wrote:
> Some devices may not be released via their 'PipelineHandler'. This results

Can you explain better which are those devices / platform for which 
PipelineHandler does not release the devices? Do you have any particular 
case in mind?

It's the job of the pipeline handler to correctly release the device, 
since it's the one acquired it in the first place.
> in these devices still being acquired or busy on shutdown. Make sure that
> all devices are released when DeviceEnumerator is deconstructed.
>
> Signed-off-by: Christian Rauch <Rauch.Christian at gmx.de>
> ---
>   src/libcamera/device_enumerator.cpp | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
> index f2e055de..d0968a0a 100644
> --- a/src/libcamera/device_enumerator.cpp
> +++ b/src/libcamera/device_enumerator.cpp
> @@ -161,12 +161,8 @@ std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()
>
>   DeviceEnumerator::~DeviceEnumerator()
>   {
> -	for (const std::shared_ptr<MediaDevice> &media : devices_) {
> -		if (media->busy())
> -			LOG(DeviceEnumerator, Error)
> -				<< "Removing media device " << media->deviceNode()
> -				<< " while still in use";
> -	}
> +	for (const std::shared_ptr<MediaDevice> &media : devices_)
> +		media->release();

I believe this shadows  a bug and forcibly releases a device here, which 
should ideally be released by the pipeline handler in the first place. 
The Error log is present there to catch such instances I think!
>   }
>
>   /**
> --
> 2.34.1
>



More information about the libcamera-devel mailing list