libcamera: v4l2_videodevice: Signal buffer completion at streamoff time
When stopping the stream buffers have been queued, in which case their completion is never be notified to the user. This can lead to memory leaks. Fix it by notifying completion of all queued buffers with the status set to error. As a result the base PipelineHandler implementation can be simplified, as all requests complete as the result of stopping the stream. The stop() method that manually completes all queued requests isn't needed anymore. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -56,7 +56,7 @@ LOG_DEFINE_CATEGORY(Request)
|
||||
*/
|
||||
Request::Request(Camera *camera, uint64_t cookie)
|
||||
: camera_(camera), controls_(camera), cookie_(cookie),
|
||||
status_(RequestPending)
|
||||
status_(RequestPending), cancelled_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -199,14 +199,15 @@ int Request::prepare()
|
||||
|
||||
/**
|
||||
* \brief Complete a queued request
|
||||
* \param[in] status The request completion status
|
||||
*
|
||||
* Mark the request as complete by updating its status to \a status.
|
||||
* Mark the request as complete by updating its status to RequestComplete,
|
||||
* unless buffers have been cancelled in which case the status is set to
|
||||
* RequestCancelled.
|
||||
*/
|
||||
void Request::complete(Status status)
|
||||
void Request::complete()
|
||||
{
|
||||
ASSERT(!hasPendingBuffers());
|
||||
status_ = status;
|
||||
status_ = cancelled_ ? RequestCancelled : RequestComplete;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,6 +230,9 @@ bool Request::completeBuffer(Buffer *buffer)
|
||||
|
||||
buffer->setRequest(nullptr);
|
||||
|
||||
if (buffer->status() == Buffer::BufferCancelled)
|
||||
cancelled_ = true;
|
||||
|
||||
return !hasPendingBuffers();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user