android: camera_stream: Add thread safety annotation

This applies clang thread safety annotation to CameraStream.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2021-12-01 16:53:45 +09:00 committed by Laurent Pinchart
parent 5e0d3a3517
commit 97ab0074ec
2 changed files with 6 additions and 4 deletions

View file

@ -275,7 +275,7 @@ void CameraStream::PostProcessorWorker::run()
MutexLocker locker(mutex_); MutexLocker locker(mutex_);
while (1) { while (1) {
cv_.wait(locker, [&] { cv_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(mutex_) {
return state_ != State::Running || !requests_.empty(); return state_ != State::Running || !requests_.empty();
}); });

View file

@ -155,8 +155,10 @@ private:
libcamera::Mutex mutex_; libcamera::Mutex mutex_;
libcamera::ConditionVariable cv_; libcamera::ConditionVariable cv_;
std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_; std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_
State state_ = State::Stopped; LIBCAMERA_TSA_GUARDED_BY(mutex_);
State state_ LIBCAMERA_TSA_GUARDED_BY(mutex_) = State::Stopped;
}; };
int waitFence(int fence); int waitFence(int fence);
@ -168,7 +170,7 @@ private:
const unsigned int index_; const unsigned int index_;
std::unique_ptr<libcamera::FrameBufferAllocator> allocator_; std::unique_ptr<libcamera::FrameBufferAllocator> allocator_;
std::vector<libcamera::FrameBuffer *> buffers_; std::vector<libcamera::FrameBuffer *> buffers_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
/* /*
* The class has to be MoveConstructible as instances are stored in * The class has to be MoveConstructible as instances are stored in
* an std::vector in CameraDevice. * an std::vector in CameraDevice.