summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline_handler.cpp
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2022-11-11 13:30:24 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-11-14 11:03:32 +0000
commita5fdf63e90d8e9559f53f7bf5b0504f30ce69656 (patch)
treeb39331cad47bbf63bdba9bafdc6b282fea81a41d /src/libcamera/pipeline_handler.cpp
parent75e7befb1667f620410f0f15a10eccb32d7df66d (diff)
libcamera: Add a PipelineHandler::releaseDevice method
This notifies pipeline handlers when a camera is released, in case they want to free any resources or memory buffers. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline_handler.cpp')
-rw-r--r--src/libcamera/pipeline_handler.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 825aff5a..cfade490 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -183,6 +183,7 @@ bool PipelineHandler::acquire()
/**
* \brief Release exclusive access to the pipeline handler
+ * \param[in] camera The camera for which to release data
*
* This function releases access to the pipeline handler previously acquired by
* a call to acquire(). Every release() call shall match a previous successful
@@ -196,7 +197,7 @@ bool PipelineHandler::acquire()
*
* \sa acquire()
*/
-void PipelineHandler::release()
+void PipelineHandler::release(Camera *camera)
{
MutexLocker locker(lock_);
@@ -204,9 +205,22 @@ void PipelineHandler::release()
unlockMediaDevices();
+ releaseDevice(camera);
+
--useCount_;
}
+/**
+ * \brief Release resources associated with this camera
+ * \param[in] camera The camera for which to release resources
+ *
+ * Pipeline handlers may override this in order to perform cleanup operations
+ * when a camera is released, such as freeing memory.
+ */
+void PipelineHandler::releaseDevice([[maybe_unused]] Camera *camera)
+{
+}
+
void PipelineHandler::unlockMediaDevices()
{
for (std::shared_ptr<MediaDevice> &media : mediaDevices_)