[libcamera-devel] Problems opening/closing camera in different processes

David Plowman david.plowman at raspberrypi.com
Mon Nov 7 13:26:22 CET 2022


Hi everyone

Recently I've been working with multiple cameras and trying to make it
possible to close them in one process and open them in another
(without terminating the first process altogether). I'm still left
with one problem and would like to get some suggestions as to how we
should solve it.

To illustrate the problem:

Case 1 (works):

In process 1, acquire the camera and then release it (but do not
terminate the process).

Process 2 can now acquire the camera and start it successfully. Hurray!

Case 2 (broken):

In process 1, acquire the camera, start it, then stop it and release
it (again, do not terminate the process).

Process 2 can acquire the camera but when you try to start it, it fails.  :(

The reason is that process 1 still holds file descriptors for all the
devices in question (which is fair enough) but crucially it still has
DMABUFs allocated, and this stops anyone else from doing so.

Currently the CameraData (RPiCameraData in our case) gets no
notification that the camera has been released - perhaps it should?
The PipelineHandler could simply tell the CameraData that it's being
released, and that would give us a place to free those buffers.

Thoughts?

Thanks!
David


More information about the libcamera-devel mailing list