mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Move the configuration object to src/common/
This commit is contained in:
+2
-1
@@ -89,9 +89,9 @@ include_dir = include_directories('src/include')
|
|||||||
shared_library(
|
shared_library(
|
||||||
'yabridge',
|
'yabridge',
|
||||||
[
|
[
|
||||||
|
'src/common/configuration.cpp',
|
||||||
'src/common/logging.cpp',
|
'src/common/logging.cpp',
|
||||||
'src/common/serialization.cpp',
|
'src/common/serialization.cpp',
|
||||||
'src/plugin/configuration.cpp',
|
|
||||||
'src/plugin/host-process.cpp',
|
'src/plugin/host-process.cpp',
|
||||||
'src/plugin/plugin.cpp',
|
'src/plugin/plugin.cpp',
|
||||||
'src/plugin/plugin-bridge.cpp',
|
'src/plugin/plugin-bridge.cpp',
|
||||||
@@ -112,6 +112,7 @@ shared_library(
|
|||||||
)
|
)
|
||||||
|
|
||||||
host_sources = [
|
host_sources = [
|
||||||
|
'src/common/configuration.cpp',
|
||||||
'src/common/logging.cpp',
|
'src/common/logging.cpp',
|
||||||
'src/common/serialization.cpp',
|
'src/common/serialization.cpp',
|
||||||
'src/wine-host/bridges/vst2.cpp',
|
'src/wine-host/bridges/vst2.cpp',
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
#include <toml++/toml.h>
|
#include <toml++/toml.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
Configuration::Configuration() {}
|
Configuration::Configuration() {}
|
||||||
@@ -57,15 +55,3 @@ Configuration::Configuration(const fs::path& config_path,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Configuration Configuration::load_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 =
|
|
||||||
find_dominating_file("yabridge.toml", yabridge_path);
|
|
||||||
if (!config_file) {
|
|
||||||
return Configuration();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Configuration(*config_file, yabridge_path);
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __WINE__
|
||||||
|
#include "../wine-host/boost-fix.h"
|
||||||
|
#endif
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +29,9 @@
|
|||||||
* plugins that will be hosted in the same process rather than individually so
|
* plugins that will be hosted in the same process rather than individually so
|
||||||
* they can share resources. Configuration file loading works as follows:
|
* they can share resources. Configuration file loading works as follows:
|
||||||
*
|
*
|
||||||
* 1. `Configuration::load_for(path)` gets called with a path to the copy of or
|
* 1. `load_config_for(path)` from `src/plugin/utils.h` gets called with a path
|
||||||
* symlink to `libyabridge.so` that the plugin host has tried to load.
|
* to the copy of or symlink to `libyabridge.so` that the plugin host has
|
||||||
|
* tried to load.
|
||||||
* 2. We start looking for a file named `yabridge.toml` in the same directory as
|
* 2. We start looking for a file named `yabridge.toml` in the same directory as
|
||||||
* that `.so` file, iteratively continuing to search one directory higher
|
* that `.so` file, iteratively continuing to search one directory higher
|
||||||
* until we either find the file or we reach the filesystem root.
|
* until we either find the file or we reach the filesystem root.
|
||||||
@@ -60,31 +65,11 @@ class Configuration {
|
|||||||
*
|
*
|
||||||
* @throw toml::parsing_error If the file could not be parsed.
|
* @throw toml::parsing_error If the file could not be parsed.
|
||||||
*
|
*
|
||||||
* @see Configuration::load_for
|
* @see ../plugin/utils.h:load_config_for
|
||||||
*/
|
*/
|
||||||
Configuration(const boost::filesystem::path& config_path,
|
Configuration(const boost::filesystem::path& config_path,
|
||||||
const boost::filesystem::path& yabridge_path);
|
const boost::filesystem::path& yabridge_path);
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the configuration that belongs to a copy of or symlink to
|
|
||||||
* `libyabridge.so`. If no configuration file could be found then this will
|
|
||||||
* return an empty configuration object with default settings.
|
|
||||||
*
|
|
||||||
* This function will take any optional compile-time features that have not
|
|
||||||
* been enabled into account.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* @return Either a configuration object populated with values from matched
|
|
||||||
* glob pattern within the found configuration file, or an empty
|
|
||||||
* configuration object if no configuration file could be found or if the
|
|
||||||
* plugin could not be matched to any of the glob patterns in the
|
|
||||||
* configuration file.
|
|
||||||
*/
|
|
||||||
static Configuration load_for(const boost::filesystem::path& yabridge_path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the plugin group that should be used for the plugin this
|
* The name of the plugin group that should be used for the plugin this
|
||||||
* configuration object was created for. If not set, then the plugin should
|
* configuration object was created for. If not set, then the plugin should
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "../common/communication.h"
|
#include "../common/communication.h"
|
||||||
#include "../common/events.h"
|
#include "../common/events.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
namespace bp = boost::process;
|
namespace bp = boost::process;
|
||||||
// I'd rather use std::filesystem instead, but Boost.Process depends on
|
// I'd rather use std::filesystem instead, but Boost.Process depends on
|
||||||
@@ -44,7 +45,7 @@ PluginBridge& get_bridge_instance(const AEffect& plugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
||||||
: config(Configuration::load_for(get_this_file_location())),
|
: config(load_config_for(get_this_file_location())),
|
||||||
vst_plugin_path(find_vst_plugin()),
|
vst_plugin_path(find_vst_plugin()),
|
||||||
// All the fields should be zero initialized because
|
// All the fields should be zero initialized because
|
||||||
// `Vst2PluginInstance::vstAudioMasterCallback` from Bitwig's plugin
|
// `Vst2PluginInstance::vstAudioMasterCallback` from Bitwig's plugin
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include "../common/configuration.h"
|
||||||
#include "../common/logging.h"
|
#include "../common/logging.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "host-process.h"
|
#include "host-process.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ class PluginBridge {
|
|||||||
* The configuration for this instance of yabridge. Set based on the values
|
* The configuration for this instance of yabridge. Set based on the values
|
||||||
* from a `yabridge.toml`, if it exists.
|
* from a `yabridge.toml`, if it exists.
|
||||||
*
|
*
|
||||||
* @see Configuration::load_for
|
* @see ./utils.h:load_config_for
|
||||||
*/
|
*/
|
||||||
Configuration config;
|
Configuration config;
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -28,7 +28,7 @@
|
|||||||
// Generated inside of build directory
|
// Generated inside of build directory
|
||||||
#include <src/common/config/config.h>
|
#include <src/common/config/config.h>
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "../common/configuration.h"
|
||||||
|
|
||||||
namespace bp = boost::process;
|
namespace bp = boost::process;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@@ -269,6 +269,18 @@ std::string get_wine_version() {
|
|||||||
return version_string;
|
return version_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 =
|
||||||
|
find_dominating_file("yabridge.toml", yabridge_path);
|
||||||
|
if (!config_file) {
|
||||||
|
return Configuration();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Configuration(*config_file, yabridge_path);
|
||||||
|
}
|
||||||
|
|
||||||
bp::environment set_wineprefix() {
|
bp::environment set_wineprefix() {
|
||||||
bp::environment env = boost::this_process::environment();
|
bp::environment env = boost::this_process::environment();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include <boost/process/async_pipe.hpp>
|
#include <boost/process/async_pipe.hpp>
|
||||||
#include <boost/process/environment.hpp>
|
#include <boost/process/environment.hpp>
|
||||||
|
|
||||||
|
#include "../common/configuration.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boost 1.72 was released with a known breaking bug caused by a missing
|
* Boost 1.72 was released with a known breaking bug caused by a missing
|
||||||
* typedef: https://github.com/boostorg/process/issues/116.
|
* typedef: https://github.com/boostorg/process/issues/116.
|
||||||
@@ -164,6 +166,29 @@ boost::filesystem::path get_this_file_location();
|
|||||||
*/
|
*/
|
||||||
std::string get_wine_version();
|
std::string get_wine_version();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the configuration that belongs to a copy of or symlink to
|
||||||
|
* `libyabridge.so`. If no configuration file could be found then this will
|
||||||
|
* return an empty configuration object with default settings. See the docstrong
|
||||||
|
* on the `Configuration` class for more details on how to choose the config
|
||||||
|
* file to load.
|
||||||
|
*
|
||||||
|
* This function will take any optional compile-time features that have not been
|
||||||
|
* enabled into account.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*
|
||||||
|
* @return Either a configuration object populated with values from matched glob
|
||||||
|
* pattern within the found configuration file, or an empty configuration
|
||||||
|
* object if no configuration file could be found or if the plugin could not
|
||||||
|
* be matched to any of the glob patterns in the configuration file.
|
||||||
|
*
|
||||||
|
* @see Configuration
|
||||||
|
*/
|
||||||
|
Configuration load_config_for(const boost::filesystem::path& yabridge_path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locate the Wine prefix and set the `WINEPREFIX` environment variable if
|
* Locate the Wine prefix and set the `WINEPREFIX` environment variable if
|
||||||
* found. This way it's also possible to run .dll files outside of a Wine prefix
|
* found. This way it's also possible to run .dll files outside of a Wine prefix
|
||||||
|
|||||||
Reference in New Issue
Block a user