@@ -9,7 +9,6 @@
#include <map>
#include <memory>
-#include <mutex>
#include <queue>
#include <vector>
@@ -8,7 +8,6 @@
#pragma once
#include <map>
-#include <mutex>
#include <stddef.h>
#include <tuple>
#include <vector>
@@ -18,6 +17,7 @@
#include <system/camera_metadata.h>
#include <libcamera/base/class.h>
+#include <libcamera/base/thread.h>
#include <libcamera/camera_manager.h>
@@ -44,9 +44,6 @@ public:
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraHalManager)
- using Mutex = std::mutex;
- using MutexLocker = std::unique_lock<std::mutex>;
-
static constexpr unsigned int firstExternalCameraId_ = 1000;
CameraHalManager();
@@ -64,7 +61,7 @@ private:
const camera_module_callbacks_t *callbacks_;
std::vector<std::unique_ptr<CameraDevice>> cameras_;
std::map<std::string, unsigned int> cameraIdsMap_;
- Mutex mutex_;
+ libcamera::Mutex mutex_;
unsigned int numInternalCameras_;
unsigned int nextExternalCameraId_;
@@ -9,10 +9,10 @@
#include <map>
#include <memory>
-#include <mutex>
#include <vector>
#include <libcamera/base/class.h>
+#include <libcamera/base/thread.h>
#include <libcamera/camera.h>
#include <libcamera/framebuffer.h>
@@ -58,7 +58,7 @@ public:
/* Keeps track of streams requiring post-processing. */
std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
- std::mutex streamsProcessMutex_;
+ libcamera::Mutex streamsProcessMutex_;
Camera3RequestDescriptor(libcamera::Camera *camera,
const camera3_capture_request_t *camera3Request);
@@ -119,7 +119,7 @@ int CameraStream::configure()
if (type_ == Type::Internal) {
allocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());
- mutex_ = std::make_unique<std::mutex>();
+ mutex_ = std::make_unique<Mutex>();
int ret = allocator_->allocate(stream());
if (ret < 0)
@@ -208,7 +208,7 @@ FrameBuffer *CameraStream::getBuffer()
if (!allocator_)
return nullptr;
- std::lock_guard<std::mutex> locker(*mutex_);
+ MutexLocker locker(*mutex_);
if (buffers_.empty()) {
LOG(HAL, Error) << "Buffer underrun";
@@ -226,7 +226,7 @@ void CameraStream::putBuffer(FrameBuffer *buffer)
if (!allocator_)
return;
- std::lock_guard<std::mutex> locker(*mutex_);
+ MutexLocker locker(*mutex_);
buffers_.push_back(buffer);
}
@@ -239,7 +239,7 @@ CameraStream::PostProcessorWorker::PostProcessorWorker(PostProcessor *postProces
CameraStream::PostProcessorWorker::~PostProcessorWorker()
{
{
- libcamera::MutexLocker lock(mutex_);
+ MutexLocker lock(mutex_);
state_ = State::Stopped;
}
@@ -250,7 +250,7 @@ CameraStream::PostProcessorWorker::~PostProcessorWorker()
void CameraStream::PostProcessorWorker::start()
{
{
- libcamera::MutexLocker lock(mutex_);
+ MutexLocker lock(mutex_);
ASSERT(state_ != State::Running);
state_ = State::Running;
}
@@ -308,7 +308,7 @@ void CameraStream::PostProcessorWorker::run()
void CameraStream::PostProcessorWorker::flush()
{
- libcamera::MutexLocker lock(mutex_);
+ MutexLocker lock(mutex_);
state_ = State::Flushing;
lock.unlock();
@@ -8,7 +8,6 @@
#pragma once
#include <memory>
-#include <mutex>
#include <queue>
#include <vector>
@@ -173,7 +172,7 @@ private:
* The class has to be MoveConstructible as instances are stored in
* an std::vector in CameraDevice.
*/
- std::unique_ptr<std::mutex> mutex_;
+ std::unique_ptr<libcamera::Mutex> mutex_;
std::unique_ptr<PostProcessor> postProcessor_;
std::unique_ptr<PostProcessorWorker> worker_;