libcamera: request: Add Request::cancel()
Add a cancel() function to the Request class that allows to forcefully complete the request and its associated buffers in error state. Only pending requests can be forcefully cancelled. Enforce that by asserting the request state to be RequestPending. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -66,6 +66,14 @@ TRACEPOINT_EVENT_INSTANCE(
|
||||
)
|
||||
)
|
||||
|
||||
TRACEPOINT_EVENT_INSTANCE(
|
||||
libcamera,
|
||||
request,
|
||||
request_cancel,
|
||||
TP_ARGS(
|
||||
libcamera::Request *, req
|
||||
)
|
||||
)
|
||||
|
||||
TRACEPOINT_EVENT(
|
||||
libcamera,
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
friend class PipelineHandler;
|
||||
|
||||
void complete();
|
||||
void cancel();
|
||||
|
||||
bool completeBuffer(FrameBuffer *buffer);
|
||||
|
||||
|
||||
@@ -292,6 +292,29 @@ void Request::complete()
|
||||
LIBCAMERA_TRACEPOINT(request_complete, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Cancel a queued request
|
||||
*
|
||||
* Mark the request and its associated buffers as cancelled and complete it.
|
||||
*
|
||||
* Set each pending buffer in error state and emit the buffer completion signal
|
||||
* before completing the Request.
|
||||
*/
|
||||
void Request::cancel()
|
||||
{
|
||||
LIBCAMERA_TRACEPOINT(request_cancel, this);
|
||||
|
||||
ASSERT(status_ == RequestPending);
|
||||
|
||||
for (FrameBuffer *buffer : pending_) {
|
||||
buffer->cancel();
|
||||
camera_->bufferCompleted.emit(this, buffer);
|
||||
}
|
||||
|
||||
pending_.clear();
|
||||
cancelled_ = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Complete a buffer for the request
|
||||
* \param[in] buffer The buffer that has completed
|
||||
|
||||
Reference in New Issue
Block a user