summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-02-19 17:03:16 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-02-25 23:13:33 +0100
commit24cb5638533d19f77dd2f7f629f05eb07484ab97 (patch)
tree04a01521deae427ffd2a99c45187af664b704f4e
parent2090f8fdd8f903683349f650ac572c15cd8a224e (diff)
cam: free allocated buffers when done capturing
The allocated buffers needs to be freed once the application is done with them. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/cam/main.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 7c47ce65..0c66a98e 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -160,7 +160,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;
@@ -168,13 +169,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;
}
}
@@ -184,6 +185,9 @@ static int capture()
ret = loop->exec();
camera->stop();
+out:
+ camera->freeBuffers();
+
return ret;
}