<div dir="ltr"><div dir="ltr">Hi all,<div><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 7 Nov 2022 at 12:26, David Plowman via libcamera-devel <<a href="mailto:libcamera-devel@lists.libcamera.org">libcamera-devel@lists.libcamera.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi everyone<br>
<br>
Recently I've been working with multiple cameras and trying to make it<br>
possible to close them in one process and open them in another<br>
(without terminating the first process altogether). I'm still left<br>
with one problem and would like to get some suggestions as to how we<br>
should solve it.<br>
<br>
To illustrate the problem:<br>
<br>
Case 1 (works):<br>
<br>
In process 1, acquire the camera and then release it (but do not<br>
terminate the process).<br>
<br>
Process 2 can now acquire the camera and start it successfully. Hurray!<br>
<br>
Case 2 (broken):<br>
<br>
In process 1, acquire the camera, start it, then stop it and release<br>
it (again, do not terminate the process).<br>
<br>
Process 2 can acquire the camera but when you try to start it, it fails. :(<br>
<br>
The reason is that process 1 still holds file descriptors for all the<br>
devices in question (which is fair enough) but crucially it still has<br>
DMABUFs allocated, and this stops anyone else from doing so.<br>
<br>
Currently the CameraData (RPiCameraData in our case) gets no<br>
notification that the camera has been released - perhaps it should?<br>
The PipelineHandler could simply tell the CameraData that it's being<br>
released, and that would give us a place to free those buffers.<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Thoughts?<br></blockquote><div><br></div><div>Freeing buffer allocations on stopDevice() would resolve this issue, but we don't<br>want to do that. It is entirely reasonbale for an application to do a stop()<br>and start() without a configure(), so buffers do want to persist in this case.<br><br>Adding an acquire() and release() call into the individual pipeline handlers<br>seems like a reasonable approach to me. This would also provide a path to fix<br>the uvc pipeline handler bug [1] which looks to be related to leaving the device<br>open even if the camera has not yet been acquired.<br><br>Regards,<br>Naush</div><div><br>[1] <a href="https://bugs.libcamera.org/show_bug.cgi?id=168">https://bugs.libcamera.org/show_bug.cgi?id=168</a><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Thanks!<br>
David<br>
</blockquote></div></div>