mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 20:10:13 +02:00
Also make the GroupHost plugin type agnostic
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
HostBridge::HostBridge(boost::filesystem::path plugin_path)
|
||||
: plugin_path(plugin_path) {}
|
||||
|
||||
void HostBridge::handle_win32_events() {
|
||||
if (editor) {
|
||||
editor->handle_win32_events();
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
* will actually host a plugin and do all the function call forwarding.
|
||||
*/
|
||||
class HostBridge {
|
||||
protected:
|
||||
HostBridge(boost::filesystem::path plugin_path);
|
||||
|
||||
public:
|
||||
virtual ~HostBridge(){};
|
||||
|
||||
@@ -64,6 +67,11 @@ class HostBridge {
|
||||
*/
|
||||
void handle_win32_events();
|
||||
|
||||
/**
|
||||
* The path to the .dll being loaded in the Wine plugin host.
|
||||
*/
|
||||
const boost::filesystem::path plugin_path;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The plugin editor window. Allows embedding the plugin's editor into a
|
||||
|
||||
@@ -108,7 +108,7 @@ GroupBridge::~GroupBridge() {
|
||||
void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
|
||||
// At this point the `active_plugins` map will already contain the
|
||||
// intialized plugin's `Vst2Bridge` instance and this thread's handle
|
||||
Vst2Bridge* bridge;
|
||||
HostBridge* bridge;
|
||||
{
|
||||
std::lock_guard lock(active_plugins_mutex);
|
||||
bridge = active_plugins[plugin_id].second.get();
|
||||
@@ -117,7 +117,7 @@ void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
|
||||
// Blocks this thread until the plugin shuts down, handling all events on
|
||||
// the main IO context
|
||||
bridge->run();
|
||||
logger.log("'" + bridge->vst_plugin_path.string() + "' has exited");
|
||||
logger.log("'" + bridge->plugin_path.string() + "' has exited");
|
||||
|
||||
// After the plugin has exited we'll remove this thread's plugin from the
|
||||
// active plugins. This is done within the IO context because the call to
|
||||
@@ -181,9 +181,6 @@ void GroupBridge::accept_requests() {
|
||||
// yabridge plugin will be able to tell if the plugin has caused
|
||||
// this process to crash during its initialization to prevent
|
||||
// waiting indefinitely on the sockets to be connected to.
|
||||
// TODO: Do something with the plugin type
|
||||
// TODO: Maybe try to merge instantiation with `individual_host`?
|
||||
// Might only make things messier
|
||||
const auto request = read_object<HostRequest>(socket);
|
||||
write_object(socket, HostResponse{boost::this_process::get_id()});
|
||||
|
||||
@@ -196,9 +193,23 @@ void GroupBridge::accept_requests() {
|
||||
"' using socket endpoint base directory '" +
|
||||
request.endpoint_base_dir + "'");
|
||||
try {
|
||||
auto bridge = std::make_unique<Vst2Bridge>(
|
||||
main_context, request.plugin_path,
|
||||
request.endpoint_base_dir);
|
||||
std::unique_ptr<HostBridge> bridge = nullptr;
|
||||
switch (request.plugin_type) {
|
||||
case PluginType::vst2:
|
||||
bridge = std::make_unique<Vst2Bridge>(
|
||||
main_context, request.plugin_path,
|
||||
request.endpoint_base_dir);
|
||||
break;
|
||||
case PluginType::vst3:
|
||||
throw std::runtime_error("TODO: Not yet implemented");
|
||||
break;
|
||||
case PluginType::unknown:
|
||||
throw std::runtime_error(
|
||||
"Invalid plugin host request received, how did you "
|
||||
"even manage to do this?");
|
||||
break;
|
||||
}
|
||||
|
||||
logger.log("Finished initializing '" + request.plugin_path +
|
||||
"'");
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ class GroupBridge {
|
||||
* on `next_plugin_id`.
|
||||
*/
|
||||
std::unordered_map<size_t,
|
||||
std::pair<Win32Thread, std::unique_ptr<Vst2Bridge>>>
|
||||
std::pair<Win32Thread, std::unique_ptr<HostBridge>>>
|
||||
active_plugins;
|
||||
/**
|
||||
* A counter for the next unique plugin ID. When hosting a new plugin we'll
|
||||
|
||||
@@ -69,7 +69,7 @@ Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
|
||||
Vst2Bridge::Vst2Bridge(MainContext& main_context,
|
||||
std::string plugin_dll_path,
|
||||
std::string endpoint_base_dir)
|
||||
: vst_plugin_path(plugin_dll_path),
|
||||
: HostBridge(plugin_dll_path),
|
||||
main_context(main_context),
|
||||
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
|
||||
sockets(main_context.context, endpoint_base_dir, false) {
|
||||
|
||||
@@ -78,11 +78,6 @@ class Vst2Bridge : public HostBridge {
|
||||
*/
|
||||
std::optional<VstTimeInfo> time_info;
|
||||
|
||||
/**
|
||||
* The path to the .dll being loaded in the Wine VST host.
|
||||
*/
|
||||
const boost::filesystem::path vst_plugin_path;
|
||||
|
||||
private:
|
||||
/**
|
||||
* A wrapper around `plugin->dispatcher` that handles the opening and
|
||||
|
||||
Reference in New Issue
Block a user