libcamera: Request: validate state on complete

Requests should only be completed from the RequestPending state.

Requests which are completed from the RequestCancelled, or RequestComplete
state, will indicate that a double-complete has been called on the Request,
or that it has been used internally after it has been given back to the
application.

Ensure that this can be caught early if it occurs by enforcing the state
required with an assert.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2021-03-02 12:23:40 +00:00
parent de1b994bba
commit 2cf0c87511

View file

@ -262,7 +262,9 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const
*/ */
void Request::complete() void Request::complete()
{ {
ASSERT(status_ == RequestPending);
ASSERT(!hasPendingBuffers()); ASSERT(!hasPendingBuffers());
status_ = cancelled_ ? RequestCancelled : RequestComplete; status_ = cancelled_ ? RequestCancelled : RequestComplete;
LOG(Request, Debug) LOG(Request, Debug)