Inherit Vst3PluginBridge init from PluginBridge

This commit is contained in:
Robbert van der Helm
2020-12-04 00:12:05 +01:00
parent 21a8c232a1
commit c2d2ac8fbf
3 changed files with 38 additions and 114 deletions
+2 -71
View File
@@ -16,14 +16,11 @@
#pragma once
#include <boost/asio/io_context.hpp>
#include <mutex>
#include <thread>
#include "../../common/communication/vst3.h"
#include "../../common/configuration.h"
#include "../../common/logging/vst3.h"
#include "../host-process.h"
#include "common.h"
/**
* This handles the communication between the native host and a VST3 plugin
@@ -42,10 +39,8 @@
* The naming scheme of all of these 'bridge' classes is `<type>{,Plugin}Bridge`
* for greppability reasons. The `Plugin` infix is added on the native plugin
* side.
*
* TODO: Also inherit this from PluginBridge
*/
class Vst3PluginBridge {
class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
public:
/**
* Initializes the VST3 module by starting and setting up communicating with
@@ -56,74 +51,10 @@ class Vst3PluginBridge {
*/
Vst3PluginBridge();
/**
* The configuration for this instance of yabridge. Set based on the values
* from a `yabridge.toml`, if it exists.
*
* @see ../utils.h:load_config_for
*/
Configuration config;
/**
* The path to the VST3 module being loaded in the Wine VST host. This is
* normally a directory called `MyPlugin.vst3` that contains
* `MyPlugin.vst3/Contents/x86-win/MyPlugin.vst3`, but there's also an older
* deprecated (but still ubiquitous) format where the top level
* `MyPlugin.vst3` is not a directory but a .dll file. This points to either
* of those things, and then `VST3::Hosting::Win32Module::create()` will be
* able to load it.
*
* https://developer.steinberg.help/pages/viewpage.action?pageId=9798275
*/
const boost::filesystem::path plugin_module_path;
private:
/**
* Format and log all relevant debug information during initialization.
*/
void log_init_message();
boost::asio::io_context io_context;
Vst3Sockets<std::jthread> sockets;
/**
* The logging facility used for this instance of yabridge. Wraps around
* `PluginBridge::generic_logger`.
*/
Vst3Logger logger;
/**
* The version of Wine currently in use. Used in the debug output on plugin
* startup.
*/
const std::string wine_version;
/**
* The Wine process hosting the Windows VST3 plugin.
*
* @see launch_vst_host
*/
std::unique_ptr<HostProcess> vst_host;
/**
* A thread used during the initialisation process to terminate listening on
* the sockets if the Wine process cannot start for whatever reason. This
* has to be defined here instead of in the constructor we can't simply
* detach the thread as it has to check whether the Wine plugin host is
* still running.
*/
std::jthread host_guard_handler;
/**
* Whether this process runs with realtime priority. We'll set this _after_
* spawning the Wine process because from my testing running wineserver with
* realtime priority can actually increase latency.
*/
bool has_realtime_priority;
/**
* Runs the Boost.Asio `io_context` thread for logging the Wine process
* STDOUT and STDERR messages.
*/
std::jthread wine_io_handler;
};