[libcamera-devel] [PATCH v2 1/4] cam: free allocated buffers when done capturing
Niklas Söderlund
niklas.soderlund at ragnatech.se
Sun Feb 24 18:14:04 CET 2019
The allocated buffers needs to be freed once the application is done
with them.
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/cam/main.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 9b67ab75a6a1663e..b034eb25429abeb3 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -163,7 +163,8 @@ static int capture()
Request *request = camera->createRequest();
if (!request) {
std::cerr << "Can't create request" << std::endl;
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out;
}
std::map<Stream *, Buffer *> map;
@@ -171,13 +172,13 @@ static int capture()
ret = request->setBuffers(map);
if (ret < 0) {
std::cerr << "Can't set buffers for request" << std::endl;
- return ret;
+ goto out;
}
ret = camera->queueRequest(request);
if (ret < 0) {
std::cerr << "Can't queue request" << std::endl;
- return ret;
+ goto out;
}
}
@@ -187,6 +188,9 @@ static int capture()
ret = loop->exec();
camera->stop();
+out:
+ camera->freeBuffers();
+
return ret;
}
--
2.20.1
More information about the libcamera-devel
mailing list