summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-23 02:41:16 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-03 23:05:08 +0300
commit33dd4fab9d39726be4fcbd300a27f2640be1cd6f (patch)
treee00ded173f5ac92fb28821ed1fff56b227a72305 /src/android
parent49334e1f24b1a99456615d76061812eab9e45b0b (diff)
libcamera: base: class: Don't pass Extensible pointer to Private constructor
The Extensible and Extensible::Private classes contain pointers to each other. These pointers are initialized in the respective class's constructor, by passing a pointer to the other class to each constructor. This particular construct reduces the flexibility of the Extensible pattern, as the Private class instance has to be allocated and constructed in the members initializer list of the Extensible class's constructor. It is thus impossible to perform any operation on the Private class between its construction and the construction of the Extensible class, or to subclass the Private class without subclassing the Extensible class. To make the design pattern more flexible, don't pass the pointer to the Extensible class to the Private class's constructor, but initialize the pointer manually in the Extensible class's constructor. This requires a const_cast as the o_ member of the Private class is const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_hal_config.cpp7
-rw-r--r--src/android/mm/cros_camera_buffer.cpp4
-rw-r--r--src/android/mm/generic_camera_buffer.cpp3
3 files changed, 6 insertions, 8 deletions
diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp
index 833cf4ba..bbbb1410 100644
--- a/src/android/camera_hal_config.cpp
+++ b/src/android/camera_hal_config.cpp
@@ -32,7 +32,7 @@ class CameraHalConfig::Private : public Extensible::Private
LIBCAMERA_DECLARE_PUBLIC(CameraHalConfig)
public:
- Private(CameraHalConfig *halConfig);
+ Private();
int parseConfigFile(FILE *fh, std::map<std::string, CameraConfigData> *cameras);
@@ -50,8 +50,7 @@ private:
std::map<std::string, CameraConfigData> *cameras_;
};
-CameraHalConfig::Private::Private(CameraHalConfig *halConfig)
- : Extensible::Private(halConfig)
+CameraHalConfig::Private::Private()
{
}
@@ -344,7 +343,7 @@ int CameraHalConfig::Private::parseConfigFile(FILE *fh,
}
CameraHalConfig::CameraHalConfig()
- : Extensible(new Private(this)), exists_(false), valid_(false)
+ : Extensible(new Private()), exists_(false), valid_(false)
{
parseConfigurationFile();
}
diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp
index bb55b95e..437502fb 100644
--- a/src/android/mm/cros_camera_buffer.cpp
+++ b/src/android/mm/cros_camera_buffer.cpp
@@ -47,8 +47,8 @@ private:
CameraBuffer::Private::Private(CameraBuffer *cameraBuffer,
buffer_handle_t camera3Buffer,
[[maybe_unused]] int flags)
- : Extensible::Private(cameraBuffer), handle_(camera3Buffer),
- numPlanes_(0), valid_(false), registered_(false)
+ : handle_(camera3Buffer), numPlanes_(0), valid_(false),
+ registered_(false)
{
bufferManager_ = cros::CameraBufferManager::GetInstance();
diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
index 166be36e..2a4b77ea 100644
--- a/src/android/mm/generic_camera_buffer.cpp
+++ b/src/android/mm/generic_camera_buffer.cpp
@@ -34,9 +34,8 @@ public:
size_t jpegBufferSize(size_t maxJpegBufferSize) const;
};
-CameraBuffer::Private::Private(CameraBuffer *cameraBuffer,
+CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer,
buffer_handle_t camera3Buffer, int flags)
- : Extensible::Private(cameraBuffer)
{
maps_.reserve(camera3Buffer->numFds);
error_ = 0;