libcamera: Add a PipelineHandler::releaseDevice method
This notifies pipeline handlers when a camera is released, in case they want to free any resources or memory buffers. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
75e7befb16
commit
a5fdf63e90
3 changed files with 19 additions and 3 deletions
|
@ -46,7 +46,7 @@ public:
|
|||
const DeviceMatch &dm);
|
||||
|
||||
bool acquire();
|
||||
void release();
|
||||
void release(Camera *camera);
|
||||
|
||||
virtual std::unique_ptr<CameraConfiguration> generateConfiguration(Camera *camera,
|
||||
const StreamRoles &roles) = 0;
|
||||
|
@ -74,6 +74,8 @@ protected:
|
|||
virtual int queueRequestDevice(Camera *camera, Request *request) = 0;
|
||||
virtual void stopDevice(Camera *camera) = 0;
|
||||
|
||||
virtual void releaseDevice(Camera *camera);
|
||||
|
||||
CameraManager *manager_;
|
||||
|
||||
private:
|
||||
|
|
|
@ -870,7 +870,7 @@ int Camera::release()
|
|||
return ret == -EACCES ? -EBUSY : ret;
|
||||
|
||||
if (d->isAcquired())
|
||||
d->pipe_->release();
|
||||
d->pipe_->release(this);
|
||||
|
||||
d->setState(Private::CameraAvailable);
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ bool PipelineHandler::acquire()
|
|||
|
||||
/**
|
||||
* \brief Release exclusive access to the pipeline handler
|
||||
* \param[in] camera The camera for which to release data
|
||||
*
|
||||
* This function releases access to the pipeline handler previously acquired by
|
||||
* a call to acquire(). Every release() call shall match a previous successful
|
||||
|
@ -196,7 +197,7 @@ bool PipelineHandler::acquire()
|
|||
*
|
||||
* \sa acquire()
|
||||
*/
|
||||
void PipelineHandler::release()
|
||||
void PipelineHandler::release(Camera *camera)
|
||||
{
|
||||
MutexLocker locker(lock_);
|
||||
|
||||
|
@ -204,9 +205,22 @@ void PipelineHandler::release()
|
|||
|
||||
unlockMediaDevices();
|
||||
|
||||
releaseDevice(camera);
|
||||
|
||||
--useCount_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Release resources associated with this camera
|
||||
* \param[in] camera The camera for which to release resources
|
||||
*
|
||||
* Pipeline handlers may override this in order to perform cleanup operations
|
||||
* when a camera is released, such as freeing memory.
|
||||
*/
|
||||
void PipelineHandler::releaseDevice([[maybe_unused]] Camera *camera)
|
||||
{
|
||||
}
|
||||
|
||||
void PipelineHandler::unlockMediaDevices()
|
||||
{
|
||||
for (std::shared_ptr<MediaDevice> &media : mediaDevices_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue