mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Pass throug the VstEvents struct
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user