Factor out sending and passing through events

Since we can use this both for the dispatch function and for host
callbacks.
This commit is contained in:
Robbert van der Helm
2020-03-01 00:18:00 +01:00
parent bdaa1bbeba
commit ca713ada4e
3 changed files with 90 additions and 49 deletions
+1 -15
View File
@@ -96,21 +96,7 @@ intptr_t Bridge::dispatch(AEffect* /*plugin*/,
break;
}
auto payload =
data == nullptr
? std::nullopt
: std::make_optional(std::string(static_cast<char*>(data)));
const Event event{opcode, index, value, option, payload};
write_object(host_vst_dispatch, event);
const auto response = read_object<EventResult>(host_vst_dispatch);
if (response.data.has_value()) {
std::copy(response.data->begin(), response.data->end(),
static_cast<char*>(data));
}
return response.return_value;
return send_event(host_vst_dispatch, opcode, index, value, data, option);
}
void Bridge::process(AEffect* /*plugin*/,