libcamera: IPAManager: make IPAManager lifetime explicitly managed

If any ipa_context instances are destroyed after the IPAManager is
destroyed, then a segfault will occur, since the modules have been
unloaded by the IPAManager and the context function pointers have been
freed.

Fix this by making the lifetime of the IPAManager explicit, and make the
CameraManager construct and deconstruct (automatically, via a unique
pointer) the IPAManager.

Also update the IPA interface test to do the construction and
deconstruction of the IPAManager, as it does not use the CameraManager.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Paul Elder 2020-06-02 11:15:37 +09:00
parent 79d6662471
commit 46d544345c
4 changed files with 32 additions and 7 deletions

View file

@ -39,11 +39,15 @@ public:
~IPAInterfaceTest()
{
delete notifier_;
ipa_.reset();
ipaManager_.reset();
}
protected:
int init() override
{
ipaManager_ = make_unique<IPAManager>();
/* Create a pipeline handler for vimc. */
std::vector<PipelineHandlerFactory *> &factories =
PipelineHandlerFactory::factories();
@ -161,6 +165,7 @@ private:
std::shared_ptr<PipelineHandler> pipe_;
std::unique_ptr<IPAProxy> ipa_;
std::unique_ptr<IPAManager> ipaManager_;
enum IPAOperationCode trace_;
EventNotifier *notifier_;
int fd_;