From c657073f8ebe84505613b593db4a41f30f86c970 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Sat, 29 Nov 2025 18:49:35 +0100 Subject: introduce sem_queue --- src/camera/veyeimx287m.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/camera/veyeimx287m.h') diff --git a/src/camera/veyeimx287m.h b/src/camera/veyeimx287m.h index 2b5c28c..a9311ba 100644 --- a/src/camera/veyeimx287m.h +++ b/src/camera/veyeimx287m.h @@ -15,6 +15,7 @@ #include "constants.h" #include "icamera.h" #include "image.h" +#include "utils/sem_queue.h" namespace veye { namespace imx287m { @@ -112,15 +113,20 @@ private: { Semaphore() { - rawBufferIndices.reserve(BUFFER_COUNT); + // rawBufferIndices.reserve(BUFFER_COUNT); rotatedBufferIndices.reserve(BUFFER_COUNT); } const uint8_t maxSize{BUFFER_COUNT}; - QQueue rawBufferIndices; - QSemaphore freeRawBuffers{BUFFER_COUNT}; - QSemaphore usedRawBuffers{}; + sem_queue rawSemQueue; + sem_queue rotSemQueue; + // std::mutex rawBufferMtx; + // QQueue rawBufferIndices; + // QSemaphore freeRawBuffers{BUFFER_COUNT}; + // QSemaphore usedRawBuffers{}; + + std::mutex rotatedBufferMtx; QQueue rotatedBufferIndices; QSemaphore freeRotatedBuffers{BUFFER_COUNT}; QSemaphore usedRotatedBuffers{}; @@ -141,7 +147,8 @@ private: // std::jthread m_getThreads[4]; // TODO: sync all loops somehow to guarantee frames order std::jthread m_rotateThreads[2]; - std::jthread m_calcPixelsThreads[1]; + std::jthread m_calcPixelsThreads[2]; + size_t m_lastProcessedIdx{std::numeric_limits::max()}; std::shared_ptr m_i2c; std::shared_ptr m_httpServer; -- cgit v1.2.3-70-g09d2