Move work dropping to Vst2PluginBridge destructor

For consistency with `Vst3PluginBridge`.
This commit is contained in:
Robbert van der Helm
2020-12-17 13:51:39 +01:00
parent a5834cd438
commit f71c7a3895
2 changed files with 15 additions and 13 deletions
+9 -13
View File
@@ -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<uint8_t>& 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;
+6
View File
@@ -49,6 +49,12 @@ class Vst2PluginBridge : PluginBridge<Vst2Sockets<std::jthread>> {
*/
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`.