mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Pass plugin type when calling the host application
This commit is contained in:
@@ -53,9 +53,9 @@ LibArchitecture find_dll_architecture(const fs::path& plugin_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PluginType plugin_type_from_string(const std::string& plugin_type) {
|
PluginType plugin_type_from_string(const std::string& plugin_type) {
|
||||||
if (plugin_type == "vst2") {
|
if (plugin_type == "VST2") {
|
||||||
return PluginType::vst2;
|
return PluginType::vst2;
|
||||||
} else if (plugin_type == "vst3") {
|
} else if (plugin_type == "VST3") {
|
||||||
return PluginType::vst3;
|
return PluginType::vst3;
|
||||||
} else {
|
} else {
|
||||||
return PluginType::unknown;
|
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) {
|
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) {
|
if (plugin_type == PluginType::vst2) {
|
||||||
return "vst2";
|
return "VST2";
|
||||||
} else if (plugin_type == PluginType::vst3) {
|
} else if (plugin_type == PluginType::vst3) {
|
||||||
return "vst3";
|
return "VST3";
|
||||||
} else {
|
} else {
|
||||||
return "unknown";
|
return "<unknown>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "../plugins.h"
|
||||||
|
|
||||||
// The plugin should always be compiled to a 64-bit version, but the host
|
// 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
|
// 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
|
// modern Linux VST host. Because of this we have to make sure to always use
|
||||||
@@ -54,11 +56,13 @@ overload(Ts...) -> overload<Ts...>;
|
|||||||
* to `yabridge-host.exe` were the plugin to be hosted individually.
|
* to `yabridge-host.exe` were the plugin to be hosted individually.
|
||||||
*/
|
*/
|
||||||
struct GroupRequest {
|
struct GroupRequest {
|
||||||
|
PluginType plugin_type;
|
||||||
std::string plugin_path;
|
std::string plugin_path;
|
||||||
std::string endpoint_base_dir;
|
std::string endpoint_base_dir;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
|
s.object(plugin_type);
|
||||||
s.text1b(plugin_path, 4096);
|
s.text1b(plugin_path, 4096);
|
||||||
s.text1b(endpoint_base_dir, 4096);
|
s.text1b(endpoint_base_dir, 4096);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context,
|
|||||||
plugin_arch(find_dll_architecture(plugin_path)),
|
plugin_arch(find_dll_architecture(plugin_path)),
|
||||||
host_path(find_vst_host(plugin_arch, false)),
|
host_path(find_vst_host(plugin_arch, false)),
|
||||||
host(launch_host(host_path,
|
host(launch_host(host_path,
|
||||||
|
// TODO: This should of course not be hardcoded
|
||||||
|
plugin_type_to_string(PluginType::vst2),
|
||||||
#ifdef WITH_WINEDBG
|
#ifdef WITH_WINEDBG
|
||||||
plugin_path.filename(),
|
plugin_path.filename(),
|
||||||
#else
|
#else
|
||||||
@@ -180,7 +182,9 @@ GroupHost::GroupHost(boost::asio::io_context& io_context,
|
|||||||
|
|
||||||
write_object(
|
write_object(
|
||||||
group_socket,
|
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()});
|
.endpoint_base_dir = endpoint_base_dir.string()});
|
||||||
const auto response = read_object<GroupResponse>(group_socket);
|
const auto response = read_object<GroupResponse>(group_socket);
|
||||||
assert(response.pid > 0);
|
assert(response.pid > 0);
|
||||||
|
|||||||
@@ -181,6 +181,9 @@ 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<GroupRequest>(socket);
|
const auto request = read_object<GroupRequest>(socket);
|
||||||
write_object(socket, GroupResponse{boost::this_process::get_id()});
|
write_object(socket, GroupResponse{boost::this_process::get_id()});
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ class Vst2Bridge {
|
|||||||
*
|
*
|
||||||
* @throw std::runtime_error Thrown when the VST plugin could not be loaded,
|
* @throw std::runtime_error Thrown when the VST plugin could not be loaded,
|
||||||
* or if communication could not be set up.
|
* 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,
|
Vst2Bridge(MainContext& main_context,
|
||||||
std::string plugin_dll_path,
|
std::string plugin_dll_path,
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
#include "bridges/vst2.h"
|
#include "bridges/vst2.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default VST host application. It will load the specified VST2
|
* This is the default plugin host application. It will load the specified
|
||||||
* plugin, and then connect back to the `libyabridge-{vst2,vst3}.so` instance
|
* plugin plugin, and then connect back to the `libyabridge-{vst2,vst3}.so`
|
||||||
* that spawned this over the socket.
|
* instance that spawned this over the socket.
|
||||||
*
|
*
|
||||||
* The explicit calling convention is needed to work around a bug introduced in
|
* 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
|
* 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[]) {
|
main(int argc, char* argv[]) {
|
||||||
set_realtime_priority();
|
set_realtime_priority();
|
||||||
|
|
||||||
// We pass the name of the VST plugin .dll file to load and the base
|
// We pass plugin format, the name of the VST2 plugin .dll file or VST3
|
||||||
// directory for the Unix domain socket endpoints to connect to as the first
|
// bundle to load, and the base directory for the Unix domain socket
|
||||||
// two arguments of this process in plugin/bridge.cpp.
|
// endpoints to connect to as the first two arguments of this process in
|
||||||
if (argc < 3) {
|
// `src/plugin/host-process.cpp`
|
||||||
std::cerr << "Usage: "
|
if (argc < 4) {
|
||||||
|
std::cerr
|
||||||
|
<< "Usage: "
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
<< yabridge_individual_host_name_32bit
|
<< yabridge_individual_host_name_32bit
|
||||||
#else
|
#else
|
||||||
<< yabridge_individual_host_name
|
<< yabridge_individual_host_name
|
||||||
#endif
|
#endif
|
||||||
<< " <vst_plugin_dll> <endpoint_base_directory>" << std::endl;
|
<< " <plugin_type> <plugin_location> <endpoint_base_directory>"
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string plugin_dll_path(argv[1]);
|
// TODO: Do something with the plugin type
|
||||||
const std::string socket_endpoint_path(argv[2]);
|
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
|
std::cout << "Initializing yabridge host version " << yabridge_git_version
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
@@ -68,7 +73,7 @@ main(int argc, char* argv[]) {
|
|||||||
MainContext main_context{};
|
MainContext main_context{};
|
||||||
std::unique_ptr<Vst2Bridge> bridge;
|
std::unique_ptr<Vst2Bridge> bridge;
|
||||||
try {
|
try {
|
||||||
bridge = std::make_unique<Vst2Bridge>(main_context, plugin_dll_path,
|
bridge = std::make_unique<Vst2Bridge>(main_context, plugin_location,
|
||||||
socket_endpoint_path);
|
socket_endpoint_path);
|
||||||
} catch (const std::runtime_error& error) {
|
} catch (const std::runtime_error& error) {
|
||||||
std::cerr << "Error while initializing Wine VST host:" << std::endl;
|
std::cerr << "Error while initializing Wine VST host:" << std::endl;
|
||||||
@@ -77,7 +82,7 @@ main(int argc, char* argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Finished initializing '" << plugin_dll_path << "'"
|
std::cout << "Finished initializing '" << plugin_location << "'"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// We'll listen for `dispatcher()` calls on a different thread, but the
|
// We'll listen for `dispatcher()` calls on a different thread, but the
|
||||||
|
|||||||
Reference in New Issue
Block a user