summaryrefslogtreecommitdiff
path: root/src/py/cam/cam_qt.py
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-08-08 18:30:41 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2024-09-12 11:12:28 +0200
commit33a49ce4a265c88ade6cc7e94d5124f5d6ebaea0 (patch)
tree6f483e9011ec37d4373d3cf9231a0b25220fdfee /src/py/cam/cam_qt.py
parent75fc9447382a22260e98a7950859e0adb379d595 (diff)
libcamera: v4l2_videodevice: Improve readability
The handling for the sequence number validation within V4L2VideoDevice::dequeueBuffer makes use of a std::optional, which can be used as a boolean in conditional statements. This has the impact in this use case that it can be mis-read to be interpretting the value for firstFrame_ which is assigned as the buf.sequence. Remove this potential for confusion by making it clear that the first frame handling is only performed when firstFrame_ does not have a value assigned. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Kieran: Rework commit message] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/py/cam/cam_qt.py')
0 files changed, 0 insertions, 0 deletions
::chrono_literals; class CaptureAsyncTest : public V4L2VideoDeviceTest { public: CaptureAsyncTest() : V4L2VideoDeviceTest("vimc", "Raw Capture 0"), frames(0) {} void receiveBuffer(FrameBuffer *buffer) { std::cout << "Buffer received" << std::endl; frames++; /* Requeue the buffer for further use. */ capture_->queueBuffer(buffer); } protected: int run() { const unsigned int bufferCount = 8; EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int ret; ret = capture_->allocateBuffers(bufferCount, &buffers_); if (ret < 0) { std::cout << "Failed to allocate buffers" << std::endl; return TestFail; } capture_->bufferReady.connect(this, &CaptureAsyncTest::receiveBuffer); for (const std::unique_ptr<FrameBuffer> &buffer : buffers_) { if (capture_->queueBuffer(buffer.get())) { std::cout << "Failed to queue buffer" << std::endl; return TestFail; } } ret = capture_->streamOn(); if (ret) return TestFail; timeout.start(10000ms); while (timeout.isRunning()) { dispatcher->processEvents(); if (frames > 30) break; } if (frames < 1) { std::cout << "Failed to capture any frames within timeout." << std::endl; return TestFail; } if (frames < 30) { std::cout << "Failed to capture 30 frames within timeout." << std::endl; return TestFail; } std::cout << "Processed " << frames << " frames" << std::endl;