Pass throug the VstEvents struct

This commit is contained in:
Robbert van der Helm
2020-03-08 20:29:40 +01:00
parent c5ea1e5153
commit 40142f801e
5 changed files with 34 additions and 23 deletions
+20 -15
View File
@@ -1,40 +1,45 @@
#include "communication.h"
intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
bool is_dispatch,
int opcode,
int index,
intptr_t value,
void* data,
float option,
std::optional<std::pair<Logger&, bool>> logging) {
Logger* logger) {
// Encode the right payload type for this event. Check the documentation for
// `EventPayload` for more information.
EventPayload payload = nullptr;
if (data != nullptr) {
// TODO: Specific structs go here
// Assume buffers are zeroed out, this is probably not the case
char* c_string = static_cast<char*>(data);
if (c_string[0] != 0) {
payload = std::string(c_string);
// There are some events that need specific structs that we can't simply
// serialize as a string because they might contain null bytes
if (is_dispatch && opcode == effProcessEvents) {
payload = *static_cast<VstEvents*>(data);
} else {
payload = NeedsBuffer{};
// TODO: More of these structs
// Assume buffers are zeroed out, this is probably not the case
char* c_string = static_cast<char*>(data);
if (c_string[0] != 0) {
payload = std::string(c_string);
} else {
payload = NeedsBuffer{};
}
}
}
if (logging.has_value()) {
auto [logger, is_dispatch] = *logging;
logger.log_event(is_dispatch, opcode, index, value, payload, option);
if (logger != nullptr) {
logger->log_event(is_dispatch, opcode, index, value, payload, option);
}
const Event event{opcode, index, value, option, payload};
write_object(socket, event);
const auto response = read_object<EventResult>(socket);
if (logging.has_value()) {
auto [logger, is_dispatch] = *logging;
logger.log_event_response(is_dispatch, response.return_value,
response.data);
if (logger != nullptr) {
logger->log_event_response(is_dispatch, response.return_value,
response.data);
}
if (response.data.has_value()) {
char* output = static_cast<char*>(data);