summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-12 05:15:22 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-15 05:05:32 +0300
commit411987838ef6c141cc6e0ed2713cb06600855df8 (patch)
tree4e5b456c35025177097254e5a51cbadf996e05c7 /src
parent7e2948f5e106e7d3623134fb9f6c59347640c696 (diff)
cam: Drop frames once the capture limit is reached
The camera session keeps requeuing requests until the capture limit is reached. This causes more request than the limit to complete, as there's a queue of requests in flight. When capturing from multiple cameras concurrently, this results in the captureDone signal being emitted for every request completion after the limit is reached, instead of once per camera session when reaching the limit. Fix this by simply dropping any request that completes after the limit is reached. We could instead avoid requeuing more requests than needed to reach the limit, but that may cause request starvation in pipelines, which are currently not handled consistently (or correctly). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/cam/camera_session.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
index 60501827..1bf460fa 100644
--- a/src/cam/camera_session.cpp
+++ b/src/cam/camera_session.cpp
@@ -346,6 +346,16 @@ void CameraSession::requestComplete(Request *request)
void CameraSession::processRequest(Request *request)
{
+ /*
+ * If we've reached the capture limit, we're done. This doesn't
+ * duplicate the check below that emits the captureDone signal, as this
+ * function will be called for each request still in flight after the
+ * capture limit is reached and we don't want to emit the signal every
+ * single time.
+ */
+ if (captureLimit_ && captureCount_ >= captureLimit_)
+ return;
+
const Request::BufferMap &buffers = request->buffers();
/*
@@ -398,6 +408,10 @@ void CameraSession::processRequest(Request *request)
}
}
+ /*
+ * Notify the user that capture is complete if the limit has just been
+ * reached.
+ */
captureCount_++;
if (captureLimit_ && captureCount_ >= captureLimit_) {
captureDone.emit();
' href='#n197'>197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2018, Google Inc.
 *
 * utils.cpp - Miscellaneous utility tests
 */

#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>

#include <libcamera/base/span.h>
#include <libcamera/base/utils.h>

#include <libcamera/geometry.h>

#include "test.h"

using namespace std;
using namespace libcamera;
using namespace std::literals::chrono_literals;

class UtilsTest : public Test
{
protected:
	int testDirname()
	{
		static const std::vector<std::string> paths = {
			"",
			"///",
			"/bin",
			"/usr/bin",
			"//etc////",
			"//tmp//d//",
			"current_file",
			"./current_file",
			"./current_dir/",
			"current_dir/",
		};

		static const std::vector<std::string> expected = {
			".",
			"/",
			"/",
			"/usr",
			"/",
			"//tmp",
			".",
			".",
			".",