[libcamera-devel] Request and Pipeline::Stop() behavior

Naushir Patuck naush at raspberrypi.com
Thu Feb 27 11:00:58 CET 2020


Hi Kieran,


On Wed, 26 Feb 2020 at 15:13, Naushir Patuck <naush at raspberrypi.com> wrote:
>
> Hi Kieran,
>
>
> On Wed, 26 Feb 2020 at 14:24, Kieran Bingham
> <kieran.bingham at ideasonboard.com> wrote:
> >

 <snip>

>
> Yes, but I thought that mechanism was only to mark the buffers
> FrameMetadata::FrameCancelled, and causes Request::complete() to set
> the appropriate stats
>
> void Request::complete()
> {
>    ASSERT(!hasPendingBuffers());
>    status_ = cancelled_ ? RequestCancelled : RequestComplete;
> }
>
> >
> > And once all buffers have completed (with their status as cancelled) the
> > Request will (I think) automatically be cancelled too.
> >
>
> I did not see where this might be happening.  From my brief
> investigation, CameraData::queuedRequests_ maintains an internal list
> of pending requests.  The only place this list gets cleared is in
> PipelineHandler::completeRequest.  So I was under the impression that
> my pipeline handler should also maintain a list of Requests queued,
> and call PipelineHandler::completeReques() on all those elements
> during a Stop().  By the way, I noticed the UVC pipeline handler does
> not do this, so I could be completely wrong about this!
>

So after looking at the  UVC pipeline handler, I think I understand
better.  In V4L2VideoDevice::streamOff(), we call
bufferReady.emit(buffer) - the UVC pipeline handler does an explicit
completeBuffer and completeRequest call and the queue are emptied and
all is good.

The reason I am seeing these problems is, unlike the UVC pipeline
handler, when I get a request in (via
PipelineHandlerRPi::queueRequestDevice()), I do not queue the stream
buffer immediately.  Rather, I was holding onto the request (and any
subsequent requests) until I can action them appropriately one-by-one.
The reason for this was to synchronise the Request (and associated
buffers) with the Controls applied for the Request, and Metadata
returned back for the Request.  Since my Request buffers were not
queued, I never got the bufferReady.emit(buffer) signal for them.

I suppose there is no harm in queueing my buffers as soon as the
Request arrives and still maintaining my existing Request list to sync
the Controls and Metadata.

Thanks!

Naush


More information about the libcamera-devel mailing list