mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Use designated initializers for complex structs
This was one of the main reasons why I wanted to switch to C++20, I just forgot to do it.
This commit is contained in:
+9
-2
@@ -160,7 +160,12 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
value_payload);
|
||||
}
|
||||
|
||||
const Event event{opcode, index, value, option, payload, value_payload};
|
||||
const Event event{.opcode = opcode,
|
||||
.index = index,
|
||||
.value = value,
|
||||
.option = option,
|
||||
.payload = payload,
|
||||
.value_payload = value_payload};
|
||||
|
||||
// Prevent two threads from writing over the socket at the same time and
|
||||
// messages getting out of order. This is needed because we can't prevent
|
||||
@@ -394,7 +399,9 @@ auto passthrough_event(AEffect* plugin, F callback) {
|
||||
std::visit(write_payload_fn, *event.value_payload);
|
||||
}
|
||||
|
||||
EventResult response{return_value, response_data, value_response_data};
|
||||
EventResult response{.return_value = return_value,
|
||||
.payload = response_data,
|
||||
.value_payload = value_response_data};
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
@@ -166,8 +166,9 @@ GroupHost::GroupHost(
|
||||
boost::asio::local::stream_protocol::socket group_socket(io_context);
|
||||
group_socket.connect(group_socket_path.string());
|
||||
|
||||
write_object(group_socket, GroupRequest{plugin_path.string(),
|
||||
socket_endpoint.string()});
|
||||
write_object(group_socket,
|
||||
GroupRequest{.plugin_path = plugin_path.string(),
|
||||
.socket_path = socket_endpoint.string()});
|
||||
const auto response = read_object<GroupResponse>(group_socket);
|
||||
|
||||
host_pid = response.pid;
|
||||
@@ -202,9 +203,10 @@ GroupHost::GroupHost(
|
||||
io_context);
|
||||
group_socket.connect(group_socket_path.string());
|
||||
|
||||
write_object(group_socket,
|
||||
GroupRequest{plugin_path.string(),
|
||||
socket_endpoint.string()});
|
||||
write_object(
|
||||
group_socket,
|
||||
GroupRequest{.plugin_path = plugin_path.string(),
|
||||
.socket_path = socket_endpoint.string()});
|
||||
const auto response =
|
||||
read_object<GroupResponse>(group_socket);
|
||||
|
||||
|
||||
@@ -155,7 +155,9 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
||||
|
||||
incoming_midi_events.push_back(
|
||||
std::get<DynamicVstEvents>(event.payload));
|
||||
EventResult response{1, nullptr, std::nullopt};
|
||||
EventResult response{.return_value = 1,
|
||||
.payload = nullptr,
|
||||
.value_payload = std::nullopt};
|
||||
|
||||
return response;
|
||||
} else {
|
||||
|
||||
@@ -132,7 +132,9 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context,
|
||||
// of this object will be sent over the `dispatcher()` socket. This would be
|
||||
// done after the host calls `effOpen()`, and when the plugin calls
|
||||
// `audioMasterIOChanged()`.
|
||||
write_object(host_vst_control, EventResult{0, *plugin, std::nullopt});
|
||||
write_object(host_vst_control, EventResult{.return_value = 0,
|
||||
.payload = *plugin,
|
||||
.value_payload = std::nullopt});
|
||||
|
||||
// After sending the AEffect struct we'll receive this instance's
|
||||
// configuration as a response
|
||||
@@ -218,8 +220,9 @@ void Vst2Bridge::handle_dispatch_midi_events() {
|
||||
plugin, event.opcode, event.index, event.value,
|
||||
&events.as_c_events(), event.option);
|
||||
|
||||
EventResult response{return_value, nullptr,
|
||||
std::nullopt};
|
||||
EventResult response{.return_value = return_value,
|
||||
.payload = nullptr,
|
||||
.value_payload = std::nullopt};
|
||||
|
||||
return response;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user