Allow the module to be properly unloaded

Terminating the host process will cause all sockets to be closed so we
can join the threads.
This commit is contained in:
Robbert van der Helm
2020-12-14 22:49:20 +01:00
parent c815b3903b
commit 62f376d952
3 changed files with 14 additions and 0 deletions
+2
View File
@@ -396,6 +396,8 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/,
// been caused by pipes and sockets being closed.
io_context.stop();
// TODO: For consistency with the VST3 version, move the above to
// the destructor
delete this;
return return_value;
+6
View File
@@ -83,6 +83,12 @@ Vst3PluginBridge::Vst3PluginBridge()
});
}
Vst3PluginBridge::~Vst3PluginBridge() {
// Drop all work make sure all sockets are closed
plugin_host->terminate();
io_context.stop();
}
Steinberg::IPluginFactory* Vst3PluginBridge::get_plugin_factory() {
// Even though we're working with raw pointers here, we should pretend that
// we're `IPtr<Steinberg::IPluginFactory>` and do the reference counting
+6
View File
@@ -55,6 +55,12 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
*/
Vst3PluginBridge();
/**
* Terminate the Wine plugin host process and drop all work when the module
* gets unloaded.
*/
~Vst3PluginBridge();
/**
* When the host loads the module it will call `GetPluginFactory()` which
* will in turn call this function. The idea is that we return an