[libcamera-devel] [PATCH] libcamera: camera: Fix the isAcquired test

David Plowman david.plowman at raspberrypi.com
Mon Nov 7 11:09:36 CET 2022


Hi Laurent

Thanks for the quick confirmation on this one!

On Sat, 5 Nov 2022 at 12:44, Laurent Pinchart
<laurent.pinchart at ideasonboard.com> wrote:
>
> Hi David,
>
> Thank you for the patch.
>
> On Fri, Nov 04, 2022 at 05:45:09PM +0000, David Plowman via libcamera-devel wrote:
> > All states count as "acquired" except for "CameraAvailable".
>
> It should make no difference in practice given the current usage pattern
> of isAcquired(), but it's certainly right.

Actually I was having trouble with this in the Python world, where I
found that I couldn't properly "release" a camera (for another
process) without dropping all my handles to the camera manager. Shows
how dangerous Python is, users can just sit there and type in any old
stuff!!

Thanks
David

>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>
> > Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
> > ---
> >  src/libcamera/camera.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> > index 9fe29ca9..f0575c13 100644
> > --- a/src/libcamera/camera.cpp
> > +++ b/src/libcamera/camera.cpp
> > @@ -501,7 +501,7 @@ static const char *const camera_state_names[] = {
> >
> >  bool Camera::Private::isAcquired() const
> >  {
> > -     return state_.load(std::memory_order_acquire) == CameraRunning;
> > +     return state_.load(std::memory_order_acquire) != CameraAvailable;
> >  }
> >
> >  bool Camera::Private::isRunning() const
>
> --
> Regards,
>
> Laurent Pinchart


More information about the libcamera-devel mailing list