Rename EventResponsePayload to be clearer

This commit is contained in:
Robbert van der Helm
2020-05-07 17:21:38 +02:00
parent a3aad51e41
commit 92f0d95357
4 changed files with 26 additions and 29 deletions
+11 -13
View File
@@ -282,8 +282,8 @@ auto passthrough_event(AEffect* plugin, F callback) {
// Only write back data when needed, this depends on the event payload
// type
auto write_payload_fn = overload{
[&](auto) -> EventResposnePayload { return nullptr; },
[&](const AEffect& updated_plugin) -> EventResposnePayload {
[&](auto) -> EventResultPayload { return nullptr; },
[&](const AEffect& updated_plugin) -> EventResultPayload {
// This is a bit of a special case! Instead of writing some
// return value, we will update values on the native VST
// plugin's `AEffect` object. This is triggered by the
@@ -308,7 +308,7 @@ auto passthrough_event(AEffect* plugin, F callback) {
return nullptr;
},
[&](WantsChunkBuffer&) -> EventResposnePayload {
[&](WantsChunkBuffer&) -> EventResultPayload {
// In this case the plugin will have written its data stored in
// an array to which a pointer is stored in `data`, with the
// return value from the event determines how much data the
@@ -317,21 +317,19 @@ auto passthrough_event(AEffect* plugin, F callback) {
return std::vector<uint8_t>(chunk_data,
chunk_data + return_value);
},
[&](VstIOProperties& props) -> EventResposnePayload {
return props;
},
[&](VstMidiKeyName& key_name) -> EventResposnePayload {
[&](VstIOProperties& props) -> EventResultPayload { return props; },
[&](VstMidiKeyName& key_name) -> EventResultPayload {
return key_name;
},
[&](VstParameterProperties& props) -> EventResposnePayload {
[&](VstParameterProperties& props) -> EventResultPayload {
return props;
},
[&](WantsVstRect&) -> EventResposnePayload {
[&](WantsVstRect&) -> EventResultPayload {
// The plugin has written a pointer to a VstRect struct into the
// data poitner
return **static_cast<VstRect**>(data);
},
[&](WantsVstTimeInfo&) -> EventResposnePayload {
[&](WantsVstTimeInfo&) -> EventResultPayload {
// Not sure why the VST API has twenty different ways of
// returning structs, but in this case the value returned from
// the callback function is actually a pointer to a
@@ -345,7 +343,7 @@ auto passthrough_event(AEffect* plugin, F callback) {
return *time_info;
}
},
[&](WantsString&) -> EventResposnePayload {
[&](WantsString&) -> EventResultPayload {
return std::string(static_cast<char*>(data));
}};
@@ -355,9 +353,9 @@ auto passthrough_event(AEffect* plugin, F callback) {
// `effGetSpeakerArrangement` expects the plugin to write its own data
// to this value. Hence why we need to encode the response here
// separately.
const EventResposnePayload response_data =
const EventResultPayload response_data =
std::visit(write_payload_fn, event.payload);
std::optional<EventResposnePayload> value_response_data = std::nullopt;
std::optional<EventResultPayload> value_response_data = std::nullopt;
if (event.value_payload.has_value()) {
value_response_data =
std::visit(write_payload_fn, event.value_payload.value());
+1 -1
View File
@@ -210,7 +210,7 @@ void Logger::log_event(bool is_dispatch,
void Logger::log_event_response(bool is_dispatch,
int opcode,
intptr_t return_value,
const EventResposnePayload& payload) {
const EventResultPayload& payload) {
if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) {
if (should_filter_event(is_dispatch, opcode)) {
return;
+1 -1
View File
@@ -108,7 +108,7 @@ class Logger {
void log_event_response(bool is_dispatch,
int opcode,
intptr_t return_value,
const EventResposnePayload& payload);
const EventResultPayload& payload);
private:
/**
+13 -14
View File
@@ -422,19 +422,19 @@ struct Event {
* `audioMasterIOChanged`.
* - An X11 window pointer for the editor window.
*/
using EventResposnePayload = std::variant<std::nullptr_t,
std::string,
std::vector<uint8_t>,
AEffect,
DynamicSpeakerArrangement,
VstIOProperties,
VstMidiKeyName,
VstParameterProperties,
VstRect,
VstTimeInfo>;
using EventResultPayload = std::variant<std::nullptr_t,
std::string,
std::vector<uint8_t>,
AEffect,
DynamicSpeakerArrangement,
VstIOProperties,
VstMidiKeyName,
VstParameterProperties,
VstRect,
VstTimeInfo>;
template <typename S>
void serialize(S& s, EventResposnePayload& payload) {
void serialize(S& s, EventResultPayload& payload) {
s.ext(payload,
bitsery::ext::StdVariant{
[](S&, std::nullptr_t&) {},
@@ -468,14 +468,13 @@ struct EventResult {
* into the void pointer, but sometimes an event response should forward
* some kind of special struct.
*/
// TODO: Fix typo and rename to `EventResultPayload` for consistency
EventResposnePayload payload;
EventResultPayload payload;
/**
* The same as the above value, but for returning values written to the
* `intptr_t` value parameter. This is only used during
* `effGetSpeakerArrangement`.
*/
std::optional<EventResposnePayload> value_payload;
std::optional<EventResultPayload> value_payload;
template <typename S>
void serialize(S& s) {