[libcamera-devel,v3,7/8] android: Rename CameraDevice::mutex_
diff mbox series

Message ID 20210521154227.60186-8-jacopo@jmondi.org
State Superseded
Headers show
Series
  • Implement flush() camera operation
Related show

Commit Message

Jacopo Mondi May 21, 2021, 3:42 p.m. UTC
With the introduction of an additional mutex class member, the name of
the existing one is too generic.

Rename CameraDevice::mutex_ in CameraDevice::requestsMutex_ and use the
libcamera provided libcamera::Mutex type to align the style with the
rest of the code base.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/android/camera_device.cpp | 4 ++--
 src/android/camera_device.h   | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart May 23, 2021, 6:15 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, May 21, 2021 at 05:42:26PM +0200, Jacopo Mondi wrote:
> With the introduction of an additional mutex class member, the name of
> the existing one is too generic.
> 
> Rename CameraDevice::mutex_ in CameraDevice::requestsMutex_ and use the
> libcamera provided libcamera::Mutex type to align the style with the
> rest of the code base.

Ah, this is where you use libcamera::Mutex :-)

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> ---
>  src/android/camera_device.cpp | 4 ++--
>  src/android/camera_device.h   | 3 ++-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 6645c019410e..3fce14035718 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1953,7 +1953,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
>  	worker_.queueRequest(descriptor.request_.get());
>  
>  	{
> -		MutexLocker lock(mutex_);
> +		MutexLocker requestsLock(requestsMutex_);
>  		descriptors_[descriptor.request_->cookie()] = std::move(descriptor);
>  	}
>  
> @@ -1964,7 +1964,7 @@ void CameraDevice::requestComplete(Request *request)
>  {
>  	decltype(descriptors_)::node_type node;
>  	{
> -		MutexLocker lock(mutex_);
> +		MutexLocker requestsLock(requestsMutex_);
>  		auto it = descriptors_.find(request->cookie());
>  		if (it == descriptors_.end()) {
>  			/*
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 6fe5454c6535..7cf8e8370387 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -24,6 +24,7 @@
>  #include "libcamera/internal/buffer.h"
>  #include "libcamera/internal/log.h"
>  #include "libcamera/internal/message.h"
> +#include "libcamera/internal/thread.h"

I think you can drop #include <mutex>.

>  
>  #include "camera_metadata.h"
>  #include "camera_stream.h"
> @@ -133,7 +134,7 @@ private:
>  	std::map<int, libcamera::PixelFormat> formatsMap_;
>  	std::vector<CameraStream> streams_;
>  
> -	std::mutex mutex_; /* Protect descriptors_ */
> +	libcamera::Mutex requestsMutex_; /* Protects descriptors_. */

We could also name this descriptorsMutex_ (unless you expand its scope
in patch 8/8), up to you.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	std::map<uint64_t, Camera3RequestDescriptor> descriptors_;
>  
>  	std::string maker_;

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 6645c019410e..3fce14035718 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1953,7 +1953,7 @@  int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
 	worker_.queueRequest(descriptor.request_.get());
 
 	{
-		MutexLocker lock(mutex_);
+		MutexLocker requestsLock(requestsMutex_);
 		descriptors_[descriptor.request_->cookie()] = std::move(descriptor);
 	}
 
@@ -1964,7 +1964,7 @@  void CameraDevice::requestComplete(Request *request)
 {
 	decltype(descriptors_)::node_type node;
 	{
-		MutexLocker lock(mutex_);
+		MutexLocker requestsLock(requestsMutex_);
 		auto it = descriptors_.find(request->cookie());
 		if (it == descriptors_.end()) {
 			/*
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 6fe5454c6535..7cf8e8370387 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -24,6 +24,7 @@ 
 #include "libcamera/internal/buffer.h"
 #include "libcamera/internal/log.h"
 #include "libcamera/internal/message.h"
+#include "libcamera/internal/thread.h"
 
 #include "camera_metadata.h"
 #include "camera_stream.h"
@@ -133,7 +134,7 @@  private:
 	std::map<int, libcamera::PixelFormat> formatsMap_;
 	std::vector<CameraStream> streams_;
 
-	std::mutex mutex_; /* Protect descriptors_ */
+	libcamera::Mutex requestsMutex_; /* Protects descriptors_. */
 	std::map<uint64_t, Camera3RequestDescriptor> descriptors_;
 
 	std::string maker_;