Fix regression in socket path generation

The latest master branch version would log parsing errors, but that
results in cyclic dependencies. `info_` here would end up being used
before its initialized, which meant that the socket base directory and
thus the logging path would not include the plugin's name.
This commit is contained in:
Robbert van der Helm
2023-11-26 14:13:54 +01:00
parent 5323283609
commit 204e2a6aa1
3 changed files with 21 additions and 22 deletions
+17 -17
View File
@@ -82,13 +82,13 @@ class PluginBridge {
const ghc::filesystem::path& plugin_path,
F&& create_socket_instance)
: io_context_(),
// This works for both individual files (VST2 and CLAP) and entire
// directories (VST3)
config_(load_config_for(plugin_path)),
info_(plugin_type, plugin_path, config_.vst3_prefer_32bit),
sockets_(create_socket_instance(io_context_, info_)),
generic_logger_(Logger::create_from_environment(
create_logger_prefix(sockets_.base_dir_))),
// This works for both individual files (VST2 and CLAP) and entire
// directories (VST3)
config_(load_config_for(plugin_path, generic_logger_)),
info_(plugin_type, plugin_path, config_.vst3_prefer_32bit),
plugin_host_(
config_.group
? std::unique_ptr<HostProcess>(std::make_unique<GroupHost>(
@@ -440,6 +440,19 @@ class PluginBridge {
asio::io_context io_context_;
/**
* The configuration for this instance of yabridge. Set based on the values
* from a `yabridge.toml`, if it exists.
*
* @see ../utils.h:load_config_for
*/
Configuration config_;
/**
* Information about the plugin we're bridging.
*/
const PluginInfo info_;
/**
* The sockets used for communication with the Wine process.
*
@@ -458,19 +471,6 @@ class PluginBridge {
*/
Logger generic_logger_;
/**
* The configuration for this instance of yabridge. Set based on the values
* from a `yabridge.toml`, if it exists.
*
* @see ../utils.h:load_config_for
*/
Configuration config_;
/**
* Information about the plugin we're bridging.
*/
const PluginInfo info_;
/**
* The Wine process hosting our plugins. In the case of group hosts a
* `PluginBridge` instance doesn't actually own a process, but rather either
+3 -1
View File
@@ -398,7 +398,7 @@ ghc::filesystem::path generate_group_endpoint(
return get_temporary_directory() / socket_name.str();
}
Configuration load_config_for(const fs::path& yabridge_path, Logger& logger) {
Configuration load_config_for(const fs::path& yabridge_path) {
// First find the closest `yabridge.tmol` file for the plugin, falling back
// to default configuration settings if it doesn't exist
const std::optional<fs::path> config_file =
@@ -410,6 +410,8 @@ Configuration load_config_for(const fs::path& yabridge_path, Logger& logger) {
try {
return Configuration(*config_file, yabridge_path);
} catch (const toml::parse_error& error) {
Logger logger = Logger::create_exception_logger();
// Parsing failures should be non-fatal since that leads to a pretty
// confusing user experience (see
// https://github.com/robbert-vdh/yabridge/issues/282). They should,
+1 -4
View File
@@ -248,8 +248,6 @@ ghc::filesystem::path generate_group_endpoint(
* @param yabridge_path The path to the .so file that's being loaded.by the VST
* host. This will be used both for the starting location of the search and to
* determine which section in the config file to use.
* @param logger The logger used to log parsing errors to. Parsing errors are
* non-fatal, but they should still be very visible.
*
* @return Either a configuration object populated with values from matched glob
* pattern within the found configuration file, or an empty configuration
@@ -258,8 +256,7 @@ ghc::filesystem::path generate_group_endpoint(
*
* @see Configuration
*/
Configuration load_config_for(const ghc::filesystem::path& yabridge_path,
Logger& logger);
Configuration load_config_for(const ghc::filesystem::path& yabridge_path);
/**
* Starting from the starting file or directory, go up in the directory