Also make the GroupHost plugin type agnostic

This commit is contained in:
Robbert van der Helm
2020-12-02 00:43:04 +01:00
parent 0eb80fe866
commit 3db099e0fc
6 changed files with 32 additions and 15 deletions
+3
View File
@@ -16,6 +16,9 @@
#include "common.h" #include "common.h"
HostBridge::HostBridge(boost::filesystem::path plugin_path)
: plugin_path(plugin_path) {}
void HostBridge::handle_win32_events() { void HostBridge::handle_win32_events() {
if (editor) { if (editor) {
editor->handle_win32_events(); editor->handle_win32_events();
+8
View File
@@ -24,6 +24,9 @@
* will actually host a plugin and do all the function call forwarding. * will actually host a plugin and do all the function call forwarding.
*/ */
class HostBridge { class HostBridge {
protected:
HostBridge(boost::filesystem::path plugin_path);
public: public:
virtual ~HostBridge(){}; virtual ~HostBridge(){};
@@ -64,6 +67,11 @@ class HostBridge {
*/ */
void handle_win32_events(); void handle_win32_events();
/**
* The path to the .dll being loaded in the Wine plugin host.
*/
const boost::filesystem::path plugin_path;
protected: protected:
/** /**
* The plugin editor window. Allows embedding the plugin's editor into a * The plugin editor window. Allows embedding the plugin's editor into a
+19 -8
View File
@@ -108,7 +108,7 @@ GroupBridge::~GroupBridge() {
void GroupBridge::handle_plugin_dispatch(size_t plugin_id) { void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
// At this point the `active_plugins` map will already contain the // At this point the `active_plugins` map will already contain the
// intialized plugin's `Vst2Bridge` instance and this thread's handle // intialized plugin's `Vst2Bridge` instance and this thread's handle
Vst2Bridge* bridge; HostBridge* bridge;
{ {
std::lock_guard lock(active_plugins_mutex); std::lock_guard lock(active_plugins_mutex);
bridge = active_plugins[plugin_id].second.get(); 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 // Blocks this thread until the plugin shuts down, handling all events on
// the main IO context // the main IO context
bridge->run(); 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 // 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 // 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 // yabridge plugin will be able to tell if the plugin has caused
// this process to crash during its initialization to prevent // this process to crash during its initialization to prevent
// waiting indefinitely on the sockets to be connected to. // 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); const auto request = read_object<HostRequest>(socket);
write_object(socket, HostResponse{boost::this_process::get_id()}); write_object(socket, HostResponse{boost::this_process::get_id()});
@@ -196,9 +193,23 @@ void GroupBridge::accept_requests() {
"' using socket endpoint base directory '" + "' using socket endpoint base directory '" +
request.endpoint_base_dir + "'"); request.endpoint_base_dir + "'");
try { try {
auto bridge = std::make_unique<Vst2Bridge>( std::unique_ptr<HostBridge> bridge = nullptr;
main_context, request.plugin_path, switch (request.plugin_type) {
request.endpoint_base_dir); 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 + logger.log("Finished initializing '" + request.plugin_path +
"'"); "'");
+1 -1
View File
@@ -252,7 +252,7 @@ class GroupBridge {
* on `next_plugin_id`. * on `next_plugin_id`.
*/ */
std::unordered_map<size_t, std::unordered_map<size_t,
std::pair<Win32Thread, std::unique_ptr<Vst2Bridge>>> std::pair<Win32Thread, std::unique_ptr<HostBridge>>>
active_plugins; active_plugins;
/** /**
* A counter for the next unique plugin ID. When hosting a new plugin we'll * A counter for the next unique plugin ID. When hosting a new plugin we'll
+1 -1
View File
@@ -69,7 +69,7 @@ Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
Vst2Bridge::Vst2Bridge(MainContext& main_context, Vst2Bridge::Vst2Bridge(MainContext& main_context,
std::string plugin_dll_path, std::string plugin_dll_path,
std::string endpoint_base_dir) std::string endpoint_base_dir)
: vst_plugin_path(plugin_dll_path), : HostBridge(plugin_dll_path),
main_context(main_context), main_context(main_context),
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
sockets(main_context.context, endpoint_base_dir, false) { sockets(main_context.context, endpoint_base_dir, false) {
-5
View File
@@ -78,11 +78,6 @@ class Vst2Bridge : public HostBridge {
*/ */
std::optional<VstTimeInfo> time_info; 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: private:
/** /**
* A wrapper around `plugin->dispatcher` that handles the opening and * A wrapper around `plugin->dispatcher` that handles the opening and