From 8754090c472380b74e2665713d379368dfab7138 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 20 Sep 2020 23:06:27 +0200 Subject: [PATCH] VST3: cleanup component, release resources This fixes a hang at exit (in FreeLibrary, dlclose) for some VST3 plugins. --- libs/ardour/vst3_plugin.cc | 10 ++++++++-- libs/ardour/vst3_scan.cc | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 219eef02b0..0e6c65b1e6 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -1003,17 +1003,19 @@ VST3PI::VST3PI (boost::shared_ptr m, int index, std::s if (!_controller) { _component->terminate (); + _component->release (); throw failed_constructor (); } if (_controller->setComponentHandler (this) != kResultOk) { _component->terminate (); + _component->release (); throw failed_constructor (); } if (!(_processor = FUnknownPtr (_component))) { - //_controller->terminate(); _component->terminate (); + _component->release (); throw failed_constructor (); } @@ -1031,6 +1033,7 @@ VST3PI::VST3PI (boost::shared_ptr m, int index, std::s if (!connect_components ()) { //_controller->terminate(); // XXX ? _component->terminate (); + _component->release (); throw failed_constructor (); } @@ -1147,12 +1150,15 @@ VST3PI::terminate () _controller->terminate (); } + _component->release (); + if (_factory) { _factory->release (); } - _component = 0; _controller = 0; + _component = 0; + _factory = 0; } bool diff --git a/libs/ardour/vst3_scan.cc b/libs/ardour/vst3_scan.cc index 3a4f0ca010..cd7163c2ef 100644 --- a/libs/ardour/vst3_scan.cc +++ b/libs/ardour/vst3_scan.cc @@ -152,7 +152,6 @@ ARDOUR::discover_vst3 (boost::shared_ptr m, std::vectorinitialize (HostApplication::getHostContext ()) != kResultOk) { cerr << "Failed to initialize VST3 component\n"; - //component->terminate(); continue; } @@ -160,12 +159,14 @@ ARDOUR::discover_vst3 (boost::shared_ptr m, std::vector (component))) { cerr << "VST3: No valid processor"; component->terminate (); + component->release (); continue; } if (processor->canProcessSampleSize (Vst::kSample32) != kResultTrue) { cerr << "VST3: Cannot process 32bit float"; component->terminate (); + component->release (); continue; } @@ -179,8 +180,8 @@ ARDOUR::discover_vst3 (boost::shared_ptr m, std::vectorsetProcessing (false); component->setActive (false); - //controller->terminate(); component->terminate (); + component->release (); rv.push_back (nfo); } }