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:
Robbert van der Helm
2020-11-30 23:25:56 +01:00
parent e21d3e020f
commit 278cd2e710
4 changed files with 37 additions and 39 deletions
+17 -12
View File
@@ -61,18 +61,23 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
logger(Logger::create_from_environment(
create_logger_prefix(sockets.base_dir))),
wine_version(get_wine_version()),
vst_host(config.group
? std::unique_ptr<HostProcess>(
std::make_unique<GroupHost>(io_context,
logger,
vst_plugin_path,
sockets,
*config.group))
: std::unique_ptr<HostProcess>(
std::make_unique<IndividualHost>(io_context,
logger,
vst_plugin_path,
sockets))),
vst_host(
config.group
? std::unique_ptr<HostProcess>(std::make_unique<GroupHost>(
io_context,
logger,
HostRequest{.plugin_type = PluginType::vst2,
.plugin_path = vst_plugin_path.string(),
.endpoint_base_dir = sockets.base_dir.string()},
sockets,
*config.group))
: std::unique_ptr<HostProcess>(std::make_unique<IndividualHost>(
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()),
wine_io_handler([&]() { io_context.run(); }) {
log_init_message();
+13 -19
View File
@@ -86,20 +86,19 @@ void HostProcess::async_log_pipe_lines(patched_async_pipe& pipe,
IndividualHost::IndividualHost(boost::asio::io_context& io_context,
Logger& logger,
fs::path plugin_path,
const Sockets& sockets)
const HostRequest& plugin_info)
: 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(launch_host(host_path,
// TODO: This should of course not be hardcoded
plugin_type_to_string(PluginType::vst2),
plugin_type_to_string(plugin_info.plugin_type),
#ifdef WITH_WINEDBG
plugin_path.filename(),
plugin_info.plugin_path.filename(),
#else
plugin_path,
plugin_info.plugin_path,
#endif
sockets.base_dir,
plugin_info.endpoint_base_dir,
bp::env = set_wineprefix(),
bp::std_out = stdout_pipe,
bp::std_err = stderr_pipe
@@ -135,11 +134,12 @@ void IndividualHost::terminate() {
GroupHost::GroupHost(boost::asio::io_context& io_context,
Logger& logger,
fs::path plugin_path,
const HostRequest& host_request,
Sockets& sockets,
std::string group_name)
: 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)),
sockets(sockets) {
#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 group_socket_path =
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]() {
boost::asio::local::stream_protocol::socket group_socket(io_context);
group_socket.connect(group_socket_path.string());
write_object(
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()});
write_object(group_socket, host_request);
const auto response = read_object<HostResponse>(group_socket);
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();
group_host_connect_handler =
std::jthread([this, connect, group_socket_path, plugin_path,
endpoint_base_dir, group_host_pid]() {
std::jthread([this, connect, group_host_pid]() {
using namespace std::literals::chrono_literals;
// We'll first try to connect to the group host we just spawned
+7 -5
View File
@@ -119,16 +119,16 @@ class IndividualHost : public HostProcess {
* handled on.
* @param logger The `Logger` instance the redirected STDIO streams will be
* written to.
* @param sockets The socket endpoints that will be used for communication
* with the plugin.
* @param plugin_info The information about the plugin we should launch a
* 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
* 32-bit or 64-bit .dll file.
*/
IndividualHost(boost::asio::io_context& io_context,
Logger& logger,
boost::filesystem::path plugin_path,
const Sockets& sockets);
const HostRequest& plugin_info);
LibArchitecture architecture() override;
boost::filesystem::path path() override;
@@ -162,6 +162,8 @@ class GroupHost : public HostProcess {
* handled on.
* @param logger The `Logger` instance the redirected STDIO streams will be
* 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
* with the plugin. When the plugin shuts down, we'll terminate the
* dispatch socket contained in this object.
@@ -169,7 +171,7 @@ class GroupHost : public HostProcess {
*/
GroupHost(boost::asio::io_context& io_context,
Logger& logger,
boost::filesystem::path plugin_path,
const HostRequest& host_request,
Sockets& socket_endpoint,
std::string group_name);
-3
View File
@@ -66,9 +66,6 @@ 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 `HostRequest`.
*/
Vst2Bridge(MainContext& main_context,
std::string plugin_dll_path,