mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Spawn all hosts directly using HostRequest
This way we can set the plugin type inside of the `Vst*PluginBridge` instance.
This commit is contained in:
+17
-12
@@ -61,18 +61,23 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
|
|||||||
logger(Logger::create_from_environment(
|
logger(Logger::create_from_environment(
|
||||||
create_logger_prefix(sockets.base_dir))),
|
create_logger_prefix(sockets.base_dir))),
|
||||||
wine_version(get_wine_version()),
|
wine_version(get_wine_version()),
|
||||||
vst_host(config.group
|
vst_host(
|
||||||
? std::unique_ptr<HostProcess>(
|
config.group
|
||||||
std::make_unique<GroupHost>(io_context,
|
? std::unique_ptr<HostProcess>(std::make_unique<GroupHost>(
|
||||||
logger,
|
io_context,
|
||||||
vst_plugin_path,
|
logger,
|
||||||
sockets,
|
HostRequest{.plugin_type = PluginType::vst2,
|
||||||
*config.group))
|
.plugin_path = vst_plugin_path.string(),
|
||||||
: std::unique_ptr<HostProcess>(
|
.endpoint_base_dir = sockets.base_dir.string()},
|
||||||
std::make_unique<IndividualHost>(io_context,
|
sockets,
|
||||||
logger,
|
*config.group))
|
||||||
vst_plugin_path,
|
: std::unique_ptr<HostProcess>(std::make_unique<IndividualHost>(
|
||||||
sockets))),
|
io_context,
|
||||||
|
logger,
|
||||||
|
HostRequest{
|
||||||
|
.plugin_type = PluginType::vst2,
|
||||||
|
.plugin_path = vst_plugin_path.string(),
|
||||||
|
.endpoint_base_dir = sockets.base_dir.string()}))),
|
||||||
has_realtime_priority(set_realtime_priority()),
|
has_realtime_priority(set_realtime_priority()),
|
||||||
wine_io_handler([&]() { io_context.run(); }) {
|
wine_io_handler([&]() { io_context.run(); }) {
|
||||||
log_init_message();
|
log_init_message();
|
||||||
|
|||||||
+13
-19
@@ -86,20 +86,19 @@ void HostProcess::async_log_pipe_lines(patched_async_pipe& pipe,
|
|||||||
|
|
||||||
IndividualHost::IndividualHost(boost::asio::io_context& io_context,
|
IndividualHost::IndividualHost(boost::asio::io_context& io_context,
|
||||||
Logger& logger,
|
Logger& logger,
|
||||||
fs::path plugin_path,
|
const HostRequest& plugin_info)
|
||||||
const Sockets& sockets)
|
|
||||||
: HostProcess(io_context, logger),
|
: HostProcess(io_context, logger),
|
||||||
plugin_arch(find_dll_architecture(plugin_path)),
|
// FIXME: This will require changing for VST3 bundles
|
||||||
|
plugin_arch(find_dll_architecture(plugin_info.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(plugin_info.plugin_type),
|
||||||
plugin_type_to_string(PluginType::vst2),
|
|
||||||
#ifdef WITH_WINEDBG
|
#ifdef WITH_WINEDBG
|
||||||
plugin_path.filename(),
|
plugin_info.plugin_path.filename(),
|
||||||
#else
|
#else
|
||||||
plugin_path,
|
plugin_info.plugin_path,
|
||||||
#endif
|
#endif
|
||||||
sockets.base_dir,
|
plugin_info.endpoint_base_dir,
|
||||||
bp::env = set_wineprefix(),
|
bp::env = set_wineprefix(),
|
||||||
bp::std_out = stdout_pipe,
|
bp::std_out = stdout_pipe,
|
||||||
bp::std_err = stderr_pipe
|
bp::std_err = stderr_pipe
|
||||||
@@ -135,11 +134,12 @@ void IndividualHost::terminate() {
|
|||||||
|
|
||||||
GroupHost::GroupHost(boost::asio::io_context& io_context,
|
GroupHost::GroupHost(boost::asio::io_context& io_context,
|
||||||
Logger& logger,
|
Logger& logger,
|
||||||
fs::path plugin_path,
|
const HostRequest& host_request,
|
||||||
Sockets& sockets,
|
Sockets& sockets,
|
||||||
std::string group_name)
|
std::string group_name)
|
||||||
: HostProcess(io_context, logger),
|
: HostProcess(io_context, logger),
|
||||||
plugin_arch(find_dll_architecture(plugin_path)),
|
// FIXME: This will require changing for VST3 bundles
|
||||||
|
plugin_arch(find_dll_architecture(host_request.plugin_path)),
|
||||||
host_path(find_vst_host(plugin_arch, true)),
|
host_path(find_vst_host(plugin_arch, true)),
|
||||||
sockets(sockets) {
|
sockets(sockets) {
|
||||||
#ifdef WITH_WINEDBG
|
#ifdef WITH_WINEDBG
|
||||||
@@ -175,17 +175,12 @@ GroupHost::GroupHost(boost::asio::io_context& io_context,
|
|||||||
const fs::path endpoint_base_dir = sockets.base_dir;
|
const fs::path endpoint_base_dir = sockets.base_dir;
|
||||||
const fs::path group_socket_path =
|
const fs::path group_socket_path =
|
||||||
generate_group_endpoint(group_name, wine_prefix, plugin_arch);
|
generate_group_endpoint(group_name, wine_prefix, plugin_arch);
|
||||||
const auto connect = [&io_context, plugin_path, endpoint_base_dir,
|
const auto connect = [&io_context, host_request, endpoint_base_dir,
|
||||||
group_socket_path]() {
|
group_socket_path]() {
|
||||||
boost::asio::local::stream_protocol::socket group_socket(io_context);
|
boost::asio::local::stream_protocol::socket group_socket(io_context);
|
||||||
group_socket.connect(group_socket_path.string());
|
group_socket.connect(group_socket_path.string());
|
||||||
|
|
||||||
write_object(
|
write_object(group_socket, host_request);
|
||||||
group_socket,
|
|
||||||
// TODO: The plugin type should of course not be hardcoded
|
|
||||||
HostRequest{.plugin_type = PluginType::vst2,
|
|
||||||
.plugin_path = plugin_path.string(),
|
|
||||||
.endpoint_base_dir = endpoint_base_dir.string()});
|
|
||||||
const auto response = read_object<HostResponse>(group_socket);
|
const auto response = read_object<HostResponse>(group_socket);
|
||||||
assert(response.pid > 0);
|
assert(response.pid > 0);
|
||||||
};
|
};
|
||||||
@@ -205,8 +200,7 @@ GroupHost::GroupHost(boost::asio::io_context& io_context,
|
|||||||
|
|
||||||
const pid_t group_host_pid = group_host.id();
|
const pid_t group_host_pid = group_host.id();
|
||||||
group_host_connect_handler =
|
group_host_connect_handler =
|
||||||
std::jthread([this, connect, group_socket_path, plugin_path,
|
std::jthread([this, connect, group_host_pid]() {
|
||||||
endpoint_base_dir, group_host_pid]() {
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
// We'll first try to connect to the group host we just spawned
|
// We'll first try to connect to the group host we just spawned
|
||||||
|
|||||||
@@ -119,16 +119,16 @@ class IndividualHost : public HostProcess {
|
|||||||
* handled on.
|
* handled on.
|
||||||
* @param logger The `Logger` instance the redirected STDIO streams will be
|
* @param logger The `Logger` instance the redirected STDIO streams will be
|
||||||
* written to.
|
* written to.
|
||||||
* @param sockets The socket endpoints that will be used for communication
|
* @param plugin_info The information about the plugin we should launch a
|
||||||
* with the plugin.
|
* host process for. The values in the struct will be used as command line
|
||||||
|
* arguments.
|
||||||
*
|
*
|
||||||
* @throw std::runtime_error When `plugin_path` does not point to a valid
|
* @throw std::runtime_error When `plugin_path` does not point to a valid
|
||||||
* 32-bit or 64-bit .dll file.
|
* 32-bit or 64-bit .dll file.
|
||||||
*/
|
*/
|
||||||
IndividualHost(boost::asio::io_context& io_context,
|
IndividualHost(boost::asio::io_context& io_context,
|
||||||
Logger& logger,
|
Logger& logger,
|
||||||
boost::filesystem::path plugin_path,
|
const HostRequest& plugin_info);
|
||||||
const Sockets& sockets);
|
|
||||||
|
|
||||||
LibArchitecture architecture() override;
|
LibArchitecture architecture() override;
|
||||||
boost::filesystem::path path() override;
|
boost::filesystem::path path() override;
|
||||||
@@ -162,6 +162,8 @@ class GroupHost : public HostProcess {
|
|||||||
* handled on.
|
* handled on.
|
||||||
* @param logger The `Logger` instance the redirected STDIO streams will be
|
* @param logger The `Logger` instance the redirected STDIO streams will be
|
||||||
* written to.
|
* written to.
|
||||||
|
* @param host_request The information about the plugin we should launch a
|
||||||
|
* host process for. This object will be sent to the group host process.
|
||||||
* @param sockets The socket endpoints that will be used for communication
|
* @param sockets The socket endpoints that will be used for communication
|
||||||
* with the plugin. When the plugin shuts down, we'll terminate the
|
* with the plugin. When the plugin shuts down, we'll terminate the
|
||||||
* dispatch socket contained in this object.
|
* dispatch socket contained in this object.
|
||||||
@@ -169,7 +171,7 @@ class GroupHost : public HostProcess {
|
|||||||
*/
|
*/
|
||||||
GroupHost(boost::asio::io_context& io_context,
|
GroupHost(boost::asio::io_context& io_context,
|
||||||
Logger& logger,
|
Logger& logger,
|
||||||
boost::filesystem::path plugin_path,
|
const HostRequest& host_request,
|
||||||
Sockets& socket_endpoint,
|
Sockets& socket_endpoint,
|
||||||
std::string group_name);
|
std::string group_name);
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,6 @@ 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 `HostRequest`.
|
|
||||||
*/
|
*/
|
||||||
Vst2Bridge(MainContext& main_context,
|
Vst2Bridge(MainContext& main_context,
|
||||||
std::string plugin_dll_path,
|
std::string plugin_dll_path,
|
||||||
|
|||||||
Reference in New Issue
Block a user