diff --git a/src/common/plugins.cpp b/src/common/plugins.cpp index b545abc6..abca7b49 100644 --- a/src/common/plugins.cpp +++ b/src/common/plugins.cpp @@ -53,9 +53,9 @@ LibArchitecture find_dll_architecture(const fs::path& plugin_path) { } PluginType plugin_type_from_string(const std::string& plugin_type) { - if (plugin_type == "vst2") { + if (plugin_type == "VST2") { return PluginType::vst2; - } else if (plugin_type == "vst3") { + } else if (plugin_type == "VST3") { return PluginType::vst3; } else { return PluginType::unknown; @@ -63,11 +63,13 @@ PluginType plugin_type_from_string(const std::string& plugin_type) { } std::string plugin_type_to_string(const PluginType& plugin_type) { + // We'll capitalize the acronyms because this is also our human readable + // format if (plugin_type == PluginType::vst2) { - return "vst2"; + return "VST2"; } else if (plugin_type == PluginType::vst3) { - return "vst3"; + return "VST3"; } else { - return "unknown"; + return ""; } } diff --git a/src/common/serialization/common.h b/src/common/serialization/common.h index 7c9f60bc..bd8f4d54 100644 --- a/src/common/serialization/common.h +++ b/src/common/serialization/common.h @@ -22,6 +22,8 @@ #include #include +#include "../plugins.h" + // The plugin should always be compiled to a 64-bit version, but the host // application can also be 32-bit to allow using 32-bit legacy Windows VST in a // modern Linux VST host. Because of this we have to make sure to always use @@ -54,11 +56,13 @@ overload(Ts...) -> overload; * to `yabridge-host.exe` were the plugin to be hosted individually. */ struct GroupRequest { + PluginType plugin_type; std::string plugin_path; std::string endpoint_base_dir; template void serialize(S& s) { + s.object(plugin_type); s.text1b(plugin_path, 4096); s.text1b(endpoint_base_dir, 4096); } diff --git a/src/plugin/host-process.cpp b/src/plugin/host-process.cpp index 94e67563..1d949d3e 100644 --- a/src/plugin/host-process.cpp +++ b/src/plugin/host-process.cpp @@ -92,6 +92,8 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context, plugin_arch(find_dll_architecture(plugin_path)), host_path(find_vst_host(plugin_arch, false)), host(launch_host(host_path, + // TODO: This should of course not be hardcoded + plugin_type_to_string(PluginType::vst2), #ifdef WITH_WINEDBG plugin_path.filename(), #else @@ -180,7 +182,9 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, write_object( group_socket, - GroupRequest{.plugin_path = plugin_path.string(), + // TODO: The plugin type should of course not be hardcoded + GroupRequest{.plugin_type = PluginType::vst2, + .plugin_path = plugin_path.string(), .endpoint_base_dir = endpoint_base_dir.string()}); const auto response = read_object(group_socket); assert(response.pid > 0); diff --git a/src/wine-host/bridges/group.cpp b/src/wine-host/bridges/group.cpp index 4e0c1d4d..ca4f757c 100644 --- a/src/wine-host/bridges/group.cpp +++ b/src/wine-host/bridges/group.cpp @@ -181,6 +181,9 @@ 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(socket); write_object(socket, GroupResponse{boost::this_process::get_id()}); diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index 9ddfe3b0..0cb68926 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -66,6 +66,9 @@ class Vst2Bridge { * * @throw std::runtime_error Thrown when the VST plugin could not be loaded, * or if communication could not be set up. + * + * TODO: Make these two arguments `boost::filesystem::path`, also use those + * in `GroupRequest`. */ Vst2Bridge(MainContext& main_context, std::string plugin_dll_path, diff --git a/src/wine-host/individual-host.cpp b/src/wine-host/individual-host.cpp index 3beff56b..7746db1b 100644 --- a/src/wine-host/individual-host.cpp +++ b/src/wine-host/individual-host.cpp @@ -25,9 +25,9 @@ #include "bridges/vst2.h" /** - * This is the default VST host application. It will load the specified VST2 - * plugin, and then connect back to the `libyabridge-{vst2,vst3}.so` instance - * that spawned this over the socket. + * This is the default plugin host application. It will load the specified + * plugin plugin, and then connect back to the `libyabridge-{vst2,vst3}.so` + * instance that spawned this over the socket. * * The explicit calling convention is needed to work around a bug introduced in * Wine 5.7: https://bugs.winehq.org/show_bug.cgi?id=49138 @@ -36,23 +36,28 @@ int __cdecl __attribute__((visibility("default"))) main(int argc, char* argv[]) { set_realtime_priority(); - // We pass the name of the VST plugin .dll file to load and the base - // directory for the Unix domain socket endpoints to connect to as the first - // two arguments of this process in plugin/bridge.cpp. - if (argc < 3) { - std::cerr << "Usage: " + // We pass plugin format, the name of the VST2 plugin .dll file or VST3 + // bundle to load, and the base directory for the Unix domain socket + // endpoints to connect to as the first two arguments of this process in + // `src/plugin/host-process.cpp` + if (argc < 4) { + std::cerr + << "Usage: " #ifdef __i386__ - << yabridge_individual_host_name_32bit + << yabridge_individual_host_name_32bit #else - << yabridge_individual_host_name + << yabridge_individual_host_name #endif - << " " << std::endl; + << " " + << std::endl; return 1; } - const std::string plugin_dll_path(argv[1]); - const std::string socket_endpoint_path(argv[2]); + // TODO: Do something with the plugin type + const PluginType plugin_type = plugin_type_from_string(argv[1]); + const std::string plugin_location(argv[2]); + const std::string socket_endpoint_path(argv[3]); std::cout << "Initializing yabridge host version " << yabridge_git_version #ifdef __i386__ @@ -68,7 +73,7 @@ main(int argc, char* argv[]) { MainContext main_context{}; std::unique_ptr bridge; try { - bridge = std::make_unique(main_context, plugin_dll_path, + bridge = std::make_unique(main_context, plugin_location, socket_endpoint_path); } catch (const std::runtime_error& error) { std::cerr << "Error while initializing Wine VST host:" << std::endl; @@ -77,7 +82,7 @@ main(int argc, char* argv[]) { return 1; } - std::cout << "Finished initializing '" << plugin_dll_path << "'" + std::cout << "Finished initializing '" << plugin_location << "'" << std::endl; // We'll listen for `dispatcher()` calls on a different thread, but the