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:
Laurent Pinchart
2019-07-14 16:00:56 +03:00
parent a2bcf6feee
commit 4e79b2ef31
10 changed files with 34 additions and 40 deletions
+13 -1
View File
@@ -1089,7 +1089,9 @@ int V4L2VideoDevice::streamOn()
* \brief Stop the video stream
*
* Buffers that are still queued when the video stream is stopped are
* implicitly dequeued, but no bufferReady signal is emitted for them.
* immediately dequeued with their status set to Buffer::BufferError,
* and the bufferReady signal is emitted for them. The order in which those
* buffers are dequeued is not specified.
*
* \return 0 on success or a negative error code otherwise
*/
@@ -1104,6 +1106,16 @@ int V4L2VideoDevice::streamOff()
return ret;
}
/* Send back all queued buffers. */
for (auto it : queuedBuffers_) {
unsigned int index = it.first;
Buffer *buffer = it.second;
buffer->index_ = index;
buffer->cancel();
bufferReady.emit(buffer);
}
queuedBuffers_.clear();
fdEvent_->setEnabled(false);