mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 12:30:12 +02:00
Pass plugin path around instead of redetecting
This is now set only once at the top level. This is needed for the chainloading to work because we'll need to set the path when we create the bridge.
This commit is contained in:
+14
-11
@@ -66,23 +66,26 @@ class PluginBridge {
|
||||
* `connect_sockets_guarded()` themselves after their initialization list.
|
||||
*
|
||||
* @param plugin_type The type of the plugin we're handling.
|
||||
* @param plugin_path The path to the plugin. For VST2 plugins this is the
|
||||
* path to the `.dll` file, and for VST3 plugins this is the path to the
|
||||
* module (either a `.vst3` DLL file or a bundle).
|
||||
* @param plugin_path The path to the **native** plugin library `.so` file.
|
||||
* This is used to determine the path to the Windows plugin library we
|
||||
* should load.
|
||||
* @param create_socket_instance A function to create a socket instance.
|
||||
* Using a lambda here feels wrong, but I can't think of a better
|
||||
* solution right now.
|
||||
*
|
||||
* @throw std::runtime_error Thrown when the Wine plugin host could not be
|
||||
* found, or if it could not locate and load a VST3 module.
|
||||
* found, or if it could not locate and load a corresponding Windows
|
||||
* plugin library.
|
||||
*/
|
||||
template <
|
||||
invocable_returning<TSockets, asio::io_context&, const PluginInfo&> F>
|
||||
PluginBridge(PluginType plugin_type, F&& create_socket_instance)
|
||||
PluginBridge(PluginType plugin_type,
|
||||
const ghc::filesystem::path& plugin_path,
|
||||
F&& create_socket_instance)
|
||||
// This is still correct for VST3 plugins because we can configure an
|
||||
// entire directory (the module's bundle) at once
|
||||
: config_(load_config_for(get_this_file_location())),
|
||||
info_(plugin_type, config_.vst3_prefer_32bit),
|
||||
: config_(load_config_for(plugin_path)),
|
||||
info_(plugin_type, plugin_path, config_.vst3_prefer_32bit),
|
||||
io_context_(),
|
||||
sockets_(create_socket_instance(io_context_, info_)),
|
||||
generic_logger_(Logger::create_from_environment(
|
||||
@@ -179,7 +182,7 @@ class PluginBridge {
|
||||
"recommended to set up proper realtime privileges "
|
||||
"for your user. Check the readme for "
|
||||
"instructions on how to do that.",
|
||||
false);
|
||||
std::nullopt);
|
||||
} else {
|
||||
init_msg << "'yes'" << std::endl;
|
||||
}
|
||||
@@ -222,7 +225,7 @@ class PluginBridge {
|
||||
"realtime privileges for your user, and some plugins "
|
||||
"may cause your DAW to crash until you fix this. Check "
|
||||
"the readme for instructions on how to do that.",
|
||||
false);
|
||||
std::nullopt);
|
||||
}
|
||||
} else {
|
||||
init_msg
|
||||
@@ -390,7 +393,7 @@ class PluginBridge {
|
||||
"went wrong. You may need to rerun your DAW from a "
|
||||
"terminal and restart the plugin scanning process to "
|
||||
"see the error.",
|
||||
true);
|
||||
info_.native_library_path_);
|
||||
|
||||
std::terminate();
|
||||
}
|
||||
@@ -426,7 +429,7 @@ class PluginBridge {
|
||||
"Version mismatch",
|
||||
"If you just updated yabridge, then you may need "
|
||||
"to rerun 'yabridgectl sync' first to update your plugins.",
|
||||
true);
|
||||
info_.native_library_path_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,11 @@ Vst2PluginBridge& get_bridge_instance(const AEffect& plugin) noexcept {
|
||||
return *static_cast<Vst2PluginBridge*>(plugin.ptr3);
|
||||
}
|
||||
|
||||
Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
|
||||
Vst2PluginBridge::Vst2PluginBridge(const ghc::filesystem::path& plugin_path,
|
||||
audioMasterCallback host_callback)
|
||||
: PluginBridge(
|
||||
PluginType::vst2,
|
||||
plugin_path,
|
||||
[](asio::io_context& io_context, const PluginInfo& info) {
|
||||
return Vst2Sockets<std::jthread>(
|
||||
io_context,
|
||||
|
||||
@@ -40,13 +40,19 @@ class Vst2PluginBridge : PluginBridge<Vst2Sockets<std::jthread>> {
|
||||
* Initializes the Wine plugin bridge. This sets up the sockets for event
|
||||
* handling.
|
||||
*
|
||||
* @param plugin_path The path to the **native** plugin library `.so` file.
|
||||
* This is used to determine the path to the Windows plugin library we
|
||||
* should load. For directly loaded bridges this should be
|
||||
* `get_this_file_location()`. Chainloaded plugins should use the path of
|
||||
* the chainloader copy instead.
|
||||
* @param host_callback The callback function passed to the VST plugin by
|
||||
* the host.
|
||||
*
|
||||
* @throw std::runtime_error Thrown when the VST host could not be found, or
|
||||
* if it could not locate and load a VST .dll file.
|
||||
*/
|
||||
Vst2PluginBridge(audioMasterCallback host_callback);
|
||||
Vst2PluginBridge(const ghc::filesystem::path& plugin_path,
|
||||
audioMasterCallback host_callback);
|
||||
|
||||
/**
|
||||
* Terminate the Wine plugin host process and drop all work when the module
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
Vst3PluginBridge::Vst3PluginBridge()
|
||||
Vst3PluginBridge::Vst3PluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
: PluginBridge(
|
||||
PluginType::vst3,
|
||||
plugin_path,
|
||||
[](asio::io_context& io_context, const PluginInfo& info) {
|
||||
return Vst3Sockets<std::jthread>(
|
||||
io_context,
|
||||
|
||||
@@ -52,10 +52,16 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
|
||||
* Initializes the VST3 module by starting and setting up communicating with
|
||||
* the Wine plugin host.
|
||||
*
|
||||
* @param plugin_path The path to the **native** plugin library `.so` file.
|
||||
* This is used to determine the path to the Windows plugin library we
|
||||
* should load. For directly loaded bridges this should be
|
||||
* `get_this_file_location()`. Chainloaded plugins should use the path of
|
||||
* the chainloader copy instead.
|
||||
*
|
||||
* @throw std::runtime_error Thrown when the Wine plugin host could not be
|
||||
* found, or if it could not locate and load a VST3 module.
|
||||
*/
|
||||
explicit Vst3PluginBridge();
|
||||
explicit Vst3PluginBridge(const ghc::filesystem::path& plugin_path);
|
||||
|
||||
/**
|
||||
* Terminate the Wine plugin host process and drop all work when the module
|
||||
|
||||
Reference in New Issue
Block a user