Move the MainContext to HostBridge

We'll use this to create a watchdog timer that shuts down the sockets
when the native host gets terminated.
This commit is contained in:
Robbert van der Helm
2021-05-01 15:06:13 +02:00
parent 564e047b4b
commit b22f207aee
6 changed files with 16 additions and 22 deletions
+5 -2
View File
@@ -18,8 +18,11 @@
#include "../editor.h"
HostBridge::HostBridge(boost::filesystem::path plugin_path)
: plugin_path(plugin_path), generic_logger(Logger::create_wine_stderr()) {}
HostBridge::HostBridge(MainContext& main_context,
boost::filesystem::path plugin_path)
: plugin_path(plugin_path),
main_context(main_context),
generic_logger(Logger::create_wine_stderr()) {}
void HostBridge::handle_win32_events() {
MSG msg;
+9 -1
View File
@@ -21,6 +21,7 @@
#include <boost/filesystem.hpp>
#include "../../common/logging/common.h"
#include "../utils.h"
/**
* The base for the Wine plugin host bridge interface for all plugin types. This
@@ -29,7 +30,7 @@
*/
class HostBridge {
protected:
HostBridge(boost::filesystem::path plugin_path);
HostBridge(MainContext& main_context, boost::filesystem::path plugin_path);
public:
virtual ~HostBridge(){};
@@ -91,6 +92,13 @@ class HostBridge {
const boost::filesystem::path plugin_path;
protected:
/**
* The IO context used for event handling so that all events and window
* message handling can be performed from a single thread, even when hosting
* multiple plugins.
*/
MainContext& main_context;
/**
* A logger, just like we have on the plugin side. This is normally not
* needed because we can just print to STDERR, but this way we can
+1 -2
View File
@@ -69,9 +69,8 @@ Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
Vst2Bridge::Vst2Bridge(MainContext& main_context,
std::string plugin_dll_path,
std::string endpoint_base_dir)
: HostBridge(plugin_dll_path),
: HostBridge(main_context, plugin_dll_path),
logger(generic_logger),
main_context(main_context),
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
sockets(main_context.context, endpoint_base_dir, false) {
// HACK: If the plugin library was unable to load, then there's a tiny
-8
View File
@@ -28,7 +28,6 @@
#include "../../common/communication/vst2.h"
#include "../../common/configuration.h"
#include "../editor.h"
#include "../utils.h"
#include "common.h"
/**
@@ -96,13 +95,6 @@ class Vst2Bridge : public HostBridge {
*/
Vst2Logger logger;
/**
* The IO context used for event handling so that all events and window
* message handling can be performed from a single thread, even when hosting
* multiple plugins.
*/
MainContext& main_context;
/**
* The configuration for this instance of yabridge based on the `.so` file
* that got loaded by the host. This configuration gets loaded on the plugin
+1 -2
View File
@@ -90,9 +90,8 @@ InstanceInterfaces::InstanceInterfaces(
Vst3Bridge::Vst3Bridge(MainContext& main_context,
std::string plugin_dll_path,
std::string endpoint_base_dir)
: HostBridge(plugin_dll_path),
: HostBridge(main_context, plugin_dll_path),
logger(generic_logger),
main_context(main_context),
sockets(main_context.context, endpoint_base_dir, false) {
std::string error;
module = VST3::Hosting::Win32Module::create(plugin_dll_path, error);
-7
View File
@@ -420,13 +420,6 @@ class Vst3Bridge : public HostBridge {
*/
void unregister_object_instance(size_t instance_id);
/**
* The IO context used for event handling so that all events and window
* message handling can be performed from a single thread, even when hosting
* multiple plugins.
*/
MainContext& main_context;
/**
* The configuration for this instance of yabridge based on the `.so` file
* that got loaded by the host. This configuration gets loaded on the plugin