diff --git a/src/plugin/bridges/vst2.cpp b/src/plugin/bridges/vst2.cpp index 54f394f0..842f3b2f 100644 --- a/src/plugin/bridges/vst2.cpp +++ b/src/plugin/bridges/vst2.cpp @@ -19,10 +19,6 @@ #include "../../common/communication/vst2.h" #include "../utils.h" -// I'd rather use std::filesystem instead, but Boost.Process depends on -// boost::filesystem -namespace fs = boost::filesystem; - intptr_t dispatch_proxy(AEffect*, int, int, intptr_t, void*, float); void process_proxy(AEffect*, float**, float**, int); void process_replacing_proxy(AEffect*, float**, float**, int); @@ -119,6 +115,15 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) update_aeffect(plugin, initialized_plugin); } +Vst2PluginBridge::~Vst2PluginBridge() { + // Drop all work make sure all sockets are closed + plugin_host->terminate(); + + // The `stop()` method will cause the IO context to just drop all of its + // outstanding work immediately + io_context.stop(); +} + class DispatchDataConverter : DefaultDataConverter { public: DispatchDataConverter(std::vector& chunk_data, @@ -389,15 +394,6 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, logger.log("The plugin crashed during shutdown, ignoring"); } - plugin_host->terminate(); - - // The `stop()` method will cause the IO context to just drop all of - // its work immediately and not throw any exceptions that would have - // 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; diff --git a/src/plugin/bridges/vst2.h b/src/plugin/bridges/vst2.h index 0b7cb3c9..46415d8e 100644 --- a/src/plugin/bridges/vst2.h +++ b/src/plugin/bridges/vst2.h @@ -49,6 +49,12 @@ class Vst2PluginBridge : PluginBridge> { */ Vst2PluginBridge(audioMasterCallback host_callback); + /** + * Terminate the Wine plugin host process and drop all work when the module + * gets unloaded. + */ + ~Vst2PluginBridge(); + // The four below functions are the handlers from the VST2 API. They are // called through proxy functions in `plugin.cpp`.