libcamera: Drop the LIBCAMERA_D_PTR macro in favour of the _d() function
Now that all Extensible classes expose a _d() function that performs appropriate casts, the LIBCAMERA_D_PTR brings no real additional value. Replace it with direct calls to the _d() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
a81ccba6a2
commit
689811d87a
6 changed files with 34 additions and 65 deletions
|
@ -49,16 +49,12 @@ public: \
|
||||||
friend class klass; \
|
friend class klass; \
|
||||||
using Public = klass;
|
using Public = klass;
|
||||||
|
|
||||||
#define LIBCAMERA_D_PTR() \
|
|
||||||
_d();
|
|
||||||
|
|
||||||
#define LIBCAMERA_O_PTR() \
|
#define LIBCAMERA_O_PTR() \
|
||||||
_o<Public>();
|
_o<Public>();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define LIBCAMERA_DECLARE_PRIVATE()
|
#define LIBCAMERA_DECLARE_PRIVATE()
|
||||||
#define LIBCAMERA_DECLARE_PUBLIC(klass)
|
#define LIBCAMERA_DECLARE_PUBLIC(klass)
|
||||||
#define LIBCAMERA_D_PTR()
|
|
||||||
#define LIBCAMERA_O_PTR()
|
#define LIBCAMERA_O_PTR()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -40,27 +40,22 @@ CameraBuffer::~CameraBuffer() \
|
||||||
} \
|
} \
|
||||||
bool CameraBuffer::isValid() const \
|
bool CameraBuffer::isValid() const \
|
||||||
{ \
|
{ \
|
||||||
const Private *const d = LIBCAMERA_D_PTR(); \
|
return _d()->isValid(); \
|
||||||
return d->isValid(); \
|
|
||||||
} \
|
} \
|
||||||
unsigned int CameraBuffer::numPlanes() const \
|
unsigned int CameraBuffer::numPlanes() const \
|
||||||
{ \
|
{ \
|
||||||
const Private *const d = LIBCAMERA_D_PTR(); \
|
return _d()->numPlanes(); \
|
||||||
return d->numPlanes(); \
|
|
||||||
} \
|
} \
|
||||||
Span<const uint8_t> CameraBuffer::plane(unsigned int plane) const \
|
Span<const uint8_t> CameraBuffer::plane(unsigned int plane) const \
|
||||||
{ \
|
{ \
|
||||||
const Private *const d = LIBCAMERA_D_PTR(); \
|
return const_cast<Private *>(_d())->plane(plane); \
|
||||||
return const_cast<Private *>(d)->plane(plane); \
|
|
||||||
} \
|
} \
|
||||||
Span<uint8_t> CameraBuffer::plane(unsigned int plane) \
|
Span<uint8_t> CameraBuffer::plane(unsigned int plane) \
|
||||||
{ \
|
{ \
|
||||||
Private *const d = LIBCAMERA_D_PTR(); \
|
return _d()->plane(plane); \
|
||||||
return d->plane(plane); \
|
|
||||||
} \
|
} \
|
||||||
size_t CameraBuffer::jpegBufferSize(size_t maxJpegBufferSize) const \
|
size_t CameraBuffer::jpegBufferSize(size_t maxJpegBufferSize) const \
|
||||||
{ \
|
{ \
|
||||||
const Private *const d = LIBCAMERA_D_PTR(); \
|
return _d()->jpegBufferSize(maxJpegBufferSize); \
|
||||||
return d->jpegBufferSize(maxJpegBufferSize); \
|
|
||||||
}
|
}
|
||||||
#endif /* __ANDROID_CAMERA_BUFFER_H__ */
|
#endif /* __ANDROID_CAMERA_BUFFER_H__ */
|
||||||
|
|
|
@ -375,8 +375,7 @@ int CameraHalConfig::parseConfigurationFile()
|
||||||
|
|
||||||
exists_ = true;
|
exists_ = true;
|
||||||
|
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
int ret = _d()->parseConfigFile(fh, &cameras_);
|
||||||
int ret = d->parseConfigFile(fh, &cameras_);
|
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
if (ret)
|
if (ret)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -94,23 +94,12 @@ namespace libcamera {
|
||||||
* name passed as the \a klass parameter.
|
* name passed as the \a klass parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* \def LIBCAMERA_D_PTR()
|
|
||||||
* \brief Retrieve the private data pointer
|
|
||||||
*
|
|
||||||
* This macro can be used in any member function of a class that inherits,
|
|
||||||
* directly or indirectly, from the Extensible class, to create a local
|
|
||||||
* variable named 'd' that points to the class' private data instance.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def LIBCAMERA_O_PTR()
|
* \def LIBCAMERA_O_PTR()
|
||||||
* \brief Retrieve the public instance corresponding to the private data
|
* \brief Retrieve the public instance corresponding to the private data
|
||||||
*
|
*
|
||||||
* This macro is the counterpart of LIBCAMERA_D_PTR() for private data classes.
|
* This macro is used in any member function of the private data class to access
|
||||||
* It can be used in any member function of the private data class to create a
|
* the public class instance corresponding to the private data.
|
||||||
* local variable named 'o' that points to the public class instance
|
|
||||||
* corresponding to the private data.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,6 +137,8 @@ namespace libcamera {
|
||||||
* class need to be qualified with appropriate access specifiers. The
|
* class need to be qualified with appropriate access specifiers. The
|
||||||
* PublicClass and Private classes always have full access to each other's
|
* PublicClass and Private classes always have full access to each other's
|
||||||
* protected and private members.
|
* protected and private members.
|
||||||
|
*
|
||||||
|
* The PublicClass exposes its Private data pointer through the _d() function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -604,8 +604,7 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,
|
||||||
*/
|
*/
|
||||||
const std::string &Camera::id() const
|
const std::string &Camera::id() const
|
||||||
{
|
{
|
||||||
const Private *const d = LIBCAMERA_D_PTR();
|
return _d()->id_;
|
||||||
return d->id_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -655,18 +654,16 @@ Camera::~Camera()
|
||||||
*/
|
*/
|
||||||
void Camera::disconnect()
|
void Camera::disconnect()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
|
||||||
|
|
||||||
LOG(Camera, Debug) << "Disconnecting camera " << id();
|
LOG(Camera, Debug) << "Disconnecting camera " << id();
|
||||||
|
|
||||||
d->disconnect();
|
_d()->disconnect();
|
||||||
disconnected.emit(this);
|
disconnected.emit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Camera::exportFrameBuffers(Stream *stream,
|
int Camera::exportFrameBuffers(Stream *stream,
|
||||||
std::vector<std::unique_ptr<FrameBuffer>> *buffers)
|
std::vector<std::unique_ptr<FrameBuffer>> *buffers)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraConfigured);
|
int ret = d->isAccessAllowed(Private::CameraConfigured);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -709,7 +706,7 @@ int Camera::exportFrameBuffers(Stream *stream,
|
||||||
*/
|
*/
|
||||||
int Camera::acquire()
|
int Camera::acquire()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No manual locking is required as PipelineHandler::lock() is
|
* No manual locking is required as PipelineHandler::lock() is
|
||||||
|
@ -746,7 +743,7 @@ int Camera::acquire()
|
||||||
*/
|
*/
|
||||||
int Camera::release()
|
int Camera::release()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraAvailable,
|
int ret = d->isAccessAllowed(Private::CameraAvailable,
|
||||||
Private::CameraConfigured, true);
|
Private::CameraConfigured, true);
|
||||||
|
@ -772,8 +769,7 @@ int Camera::release()
|
||||||
*/
|
*/
|
||||||
const ControlInfoMap &Camera::controls() const
|
const ControlInfoMap &Camera::controls() const
|
||||||
{
|
{
|
||||||
const Private *const d = LIBCAMERA_D_PTR();
|
return _d()->pipe_->controls(this);
|
||||||
return d->pipe_->controls(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -786,8 +782,7 @@ const ControlInfoMap &Camera::controls() const
|
||||||
*/
|
*/
|
||||||
const ControlList &Camera::properties() const
|
const ControlList &Camera::properties() const
|
||||||
{
|
{
|
||||||
const Private *const d = LIBCAMERA_D_PTR();
|
return _d()->pipe_->properties(this);
|
||||||
return d->pipe_->properties(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -803,8 +798,7 @@ const ControlList &Camera::properties() const
|
||||||
*/
|
*/
|
||||||
const std::set<Stream *> &Camera::streams() const
|
const std::set<Stream *> &Camera::streams() const
|
||||||
{
|
{
|
||||||
const Private *const d = LIBCAMERA_D_PTR();
|
return _d()->streams_;
|
||||||
return d->streams_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -825,7 +819,7 @@ const std::set<Stream *> &Camera::streams() const
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamRoles &roles)
|
std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamRoles &roles)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraAvailable,
|
int ret = d->isAccessAllowed(Private::CameraAvailable,
|
||||||
Private::CameraRunning);
|
Private::CameraRunning);
|
||||||
|
@ -886,7 +880,7 @@ std::unique_ptr<CameraConfiguration> Camera::generateConfiguration(const StreamR
|
||||||
*/
|
*/
|
||||||
int Camera::configure(CameraConfiguration *config)
|
int Camera::configure(CameraConfiguration *config)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraAcquired,
|
int ret = d->isAccessAllowed(Private::CameraAcquired,
|
||||||
Private::CameraConfigured);
|
Private::CameraConfigured);
|
||||||
|
@ -958,9 +952,7 @@ int Camera::configure(CameraConfiguration *config)
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)
|
std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
int ret = _d()->isAccessAllowed(Private::CameraConfigured,
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraConfigured,
|
|
||||||
Private::CameraRunning);
|
Private::CameraRunning);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -992,7 +984,7 @@ std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)
|
||||||
*/
|
*/
|
||||||
int Camera::queueRequest(Request *request)
|
int Camera::queueRequest(Request *request)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraRunning);
|
int ret = d->isAccessAllowed(Private::CameraRunning);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -1044,7 +1036,7 @@ int Camera::queueRequest(Request *request)
|
||||||
*/
|
*/
|
||||||
int Camera::start(const ControlList *controls)
|
int Camera::start(const ControlList *controls)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
int ret = d->isAccessAllowed(Private::CameraConfigured);
|
int ret = d->isAccessAllowed(Private::CameraConfigured);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -1079,7 +1071,7 @@ int Camera::start(const ControlList *controls)
|
||||||
*/
|
*/
|
||||||
int Camera::stop()
|
int Camera::stop()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \todo Make calling stop() when not in 'Running' part of the state
|
* \todo Make calling stop() when not in 'Running' part of the state
|
||||||
|
@ -1115,10 +1107,8 @@ int Camera::stop()
|
||||||
*/
|
*/
|
||||||
void Camera::requestComplete(Request *request)
|
void Camera::requestComplete(Request *request)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
|
||||||
|
|
||||||
/* Disconnected cameras are still able to complete requests. */
|
/* Disconnected cameras are still able to complete requests. */
|
||||||
if (d->isAccessAllowed(Private::CameraStopping, Private::CameraRunning,
|
if (_d()->isAccessAllowed(Private::CameraStopping, Private::CameraRunning,
|
||||||
true))
|
true))
|
||||||
LOG(Camera, Fatal) << "Trying to complete a request when stopped";
|
LOG(Camera, Fatal) << "Trying to complete a request when stopped";
|
||||||
|
|
||||||
|
|
|
@ -291,11 +291,9 @@ CameraManager::~CameraManager()
|
||||||
*/
|
*/
|
||||||
int CameraManager::start()
|
int CameraManager::start()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
|
||||||
|
|
||||||
LOG(Camera, Info) << "libcamera " << version_;
|
LOG(Camera, Info) << "libcamera " << version_;
|
||||||
|
|
||||||
int ret = d->start();
|
int ret = _d()->start();
|
||||||
if (ret)
|
if (ret)
|
||||||
LOG(Camera, Error) << "Failed to start camera manager: "
|
LOG(Camera, Error) << "Failed to start camera manager: "
|
||||||
<< strerror(-ret);
|
<< strerror(-ret);
|
||||||
|
@ -315,7 +313,7 @@ int CameraManager::start()
|
||||||
*/
|
*/
|
||||||
void CameraManager::stop()
|
void CameraManager::stop()
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
d->exit();
|
d->exit();
|
||||||
d->wait();
|
d->wait();
|
||||||
}
|
}
|
||||||
|
@ -333,7 +331,7 @@ void CameraManager::stop()
|
||||||
*/
|
*/
|
||||||
std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const
|
std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const
|
||||||
{
|
{
|
||||||
const Private *const d = LIBCAMERA_D_PTR();
|
const Private *const d = _d();
|
||||||
|
|
||||||
MutexLocker locker(d->mutex_);
|
MutexLocker locker(d->mutex_);
|
||||||
|
|
||||||
|
@ -353,7 +351,7 @@ std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<Camera> CameraManager::get(const std::string &id)
|
std::shared_ptr<Camera> CameraManager::get(const std::string &id)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
MutexLocker locker(d->mutex_);
|
MutexLocker locker(d->mutex_);
|
||||||
|
|
||||||
|
@ -383,7 +381,7 @@ std::shared_ptr<Camera> CameraManager::get(const std::string &id)
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<Camera> CameraManager::get(dev_t devnum)
|
std::shared_ptr<Camera> CameraManager::get(dev_t devnum)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
MutexLocker locker(d->mutex_);
|
MutexLocker locker(d->mutex_);
|
||||||
|
|
||||||
|
@ -439,7 +437,7 @@ std::shared_ptr<Camera> CameraManager::get(dev_t devnum)
|
||||||
void CameraManager::addCamera(std::shared_ptr<Camera> camera,
|
void CameraManager::addCamera(std::shared_ptr<Camera> camera,
|
||||||
const std::vector<dev_t> &devnums)
|
const std::vector<dev_t> &devnums)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
ASSERT(Thread::current() == d);
|
ASSERT(Thread::current() == d);
|
||||||
|
|
||||||
|
@ -459,7 +457,7 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera,
|
||||||
*/
|
*/
|
||||||
void CameraManager::removeCamera(std::shared_ptr<Camera> camera)
|
void CameraManager::removeCamera(std::shared_ptr<Camera> camera)
|
||||||
{
|
{
|
||||||
Private *const d = LIBCAMERA_D_PTR();
|
Private *const d = _d();
|
||||||
|
|
||||||
ASSERT(Thread::current() == d);
|
ASSERT(Thread::current() == d);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue