From 46d544345cbae270da533a737e334880720ceea5 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 2 Jun 2020 11:15:37 +0900 Subject: libcamera: IPAManager: make IPAManager lifetime explicitly managed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/internal/ipa_manager.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index 9f35b16d..f17fd0a8 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -22,6 +22,9 @@ namespace libcamera { class IPAManager { public: + IPAManager(); + ~IPAManager(); + static IPAManager *instance(); std::unique_ptr createIPA(PipelineHandler *pipe, @@ -29,8 +32,7 @@ public: uint32_t minVersion); private: - IPAManager(); - ~IPAManager(); + static IPAManager *self_; void parseDir(const char *libDir, unsigned int maxDepth, std::vector &files); -- cgit v1.2.1