mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-14 04:19:59 +02:00
Use same style for optional and avoid double check
I did not know that `std::optional::value()` did checked access. And I still prefer a more explicit .has_value() over boolean conversion, but this seems to be the accepted way to do this.
This commit is contained in:
@@ -63,9 +63,9 @@ Configuration Configuration::load_for(const fs::path& yabridge_path) {
|
||||
// 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.has_value()) {
|
||||
if (!config_file) {
|
||||
return Configuration();
|
||||
}
|
||||
|
||||
return Configuration(config_file.value(), yabridge_path);
|
||||
return Configuration(*config_file, yabridge_path);
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
||||
create_logger_prefix(socket_endpoint.path()))),
|
||||
wine_version(get_wine_version()),
|
||||
vst_host(
|
||||
config.group.has_value()
|
||||
config.group
|
||||
? std::unique_ptr<HostProcess>(
|
||||
std::make_unique<GroupHost>(io_context,
|
||||
logger,
|
||||
vst_plugin_path,
|
||||
socket_endpoint.path(),
|
||||
config.group.value(),
|
||||
*config.group,
|
||||
host_vst_dispatch))
|
||||
: std::unique_ptr<HostProcess>(
|
||||
std::make_unique<IndividualHost>(io_context,
|
||||
@@ -554,9 +554,9 @@ float PluginBridge::get_parameter(AEffect* /*plugin*/, int index) {
|
||||
response = read_object<ParameterResult>(host_vst_parameters);
|
||||
}
|
||||
|
||||
logger.log_get_parameter_response(response.value.value());
|
||||
logger.log_get_parameter_response(*response.value);
|
||||
|
||||
return response.value.value();
|
||||
return *response.value;
|
||||
}
|
||||
|
||||
void PluginBridge::set_parameter(AEffect* /*plugin*/, int index, float value) {
|
||||
@@ -575,7 +575,7 @@ void PluginBridge::set_parameter(AEffect* /*plugin*/, int index, float value) {
|
||||
logger.log_set_parameter_response();
|
||||
|
||||
// This should not contain any values and just serve as an acknowledgement
|
||||
assert(!response.value.has_value());
|
||||
assert(!response.value);
|
||||
}
|
||||
|
||||
void PluginBridge::log_init_message() {
|
||||
@@ -602,8 +602,8 @@ void PluginBridge::log_init_message() {
|
||||
<< config.matched_file.value_or("<defaults>").string() << "'"
|
||||
<< std::endl;
|
||||
init_msg << "hosting mode: '";
|
||||
if (config.group.has_value()) {
|
||||
init_msg << "plugin group \"" << config.group.value() << "\"";
|
||||
if (config.group) {
|
||||
init_msg << "plugin group \"" << *config.group << "\"";
|
||||
} else {
|
||||
init_msg << "individually";
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ std::string create_logger_prefix(const fs::path& socket_path) {
|
||||
std::optional<fs::path> find_wineprefix() {
|
||||
std::optional<fs::path> dosdevices_dir =
|
||||
find_dominating_file("dosdevices", find_vst_plugin(), fs::is_directory);
|
||||
if (!dosdevices_dir.has_value()) {
|
||||
if (!dosdevices_dir) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ bp::environment set_wineprefix() {
|
||||
}
|
||||
|
||||
const auto wineprefix_path = find_wineprefix();
|
||||
if (wineprefix_path.has_value()) {
|
||||
if (wineprefix_path) {
|
||||
env["WINEPREFIX"] = wineprefix_path->string();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user