summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline_handler.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-10-26 15:21:29 +0200
committerJacopo Mondi <jacopo@jmondi.org>2021-12-11 17:53:40 +0100
commitf6b6f15b54c27c144629fec0a880c4f870815011 (patch)
treecb491052bea30eec53eb62b5e37f15be652c13da /src/libcamera/pipeline_handler.cpp
parent6cd5c958b738dd7b06605adff915093f9fe0d513 (diff)
libcamera: pipeline: Introduce stopDevice()
Since a queue of waiting Requests has been introduced, not all Requests queued to the PipelineHandler are immediately queued to the device. As a Camera can be stopped at any time, it is required to complete the waiting requests after the ones queued to the device had been completed. Introduce a pure virtual PipelineHandler::stopDevice() function to be implemented by pipeline handlers and make the PipelineHandler::stop() function call it before completing pending requests. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline_handler.cpp')
-rw-r--r--src/libcamera/pipeline_handler.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 2374c289..92b5e3ab 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -267,8 +267,7 @@ void PipelineHandler::unlock()
*/
/**
- * \fn PipelineHandler::stop()
- * \brief Stop capturing from all running streams
+ * \brief Stop capturing from all running streams and cancel pending requests
* \param[in] camera The camera to stop
*
* This function stops capturing and processing requests immediately. All
@@ -276,6 +275,33 @@ void PipelineHandler::unlock()
*
* \context This function is called from the CameraManager thread.
*/
+void PipelineHandler::stop(Camera *camera)
+{
+ /* Stop the pipeline handler and let the queued requests complete. */
+ stopDevice(camera);
+
+ /* Cancel and signal as complete all waiting requests. */
+ while (!waitingRequests_.empty()) {
+ Request *request = waitingRequests_.front();
+ waitingRequests_.pop();
+
+ request->_d()->cancel();
+ completeRequest(request);
+ }
+
+ /* Make sure no requests are pending. */
+ Camera::Private *data = camera->_d();
+ ASSERT(data->queuedRequests_.empty());
+}
+
+/**
+ * \fn PipelineHandler::stopDevice()
+ * \brief Stop capturing from all running streams
+ * \param[in] camera The camera to stop
+ *
+ * This function stops capturing and processing requests immediately. All
+ * pending requests are cancelled and complete immediately in an error state.
+ */
/**
* \brief Determine if the camera has any requests pending