Remove the now unused ability to skip opcodes

If this is needed again in the future (it shouldn't be), then it should
be re-implemented using a separate function.
This commit is contained in:
Robbert van der Helm
2020-04-26 16:29:41 +02:00
parent 0ce9c1e3a4
commit aee890fbf6
3 changed files with 16 additions and 26 deletions
+8 -18
View File
@@ -34,13 +34,11 @@ class DefaultDataConverter {
/**
* Read data from the `data` void pointer into a an `EventPayload` value
* that can be serialized and conveys the meaning of the event.
*
* If this returns a nullopt, then the event will be skipped.
*/
virtual std::optional<EventPayload> read(const int /*opcode*/,
const int /*index*/,
const intptr_t /*value*/,
const void* data) {
virtual EventPayload read(const int /*opcode*/,
const int /*index*/,
const intptr_t /*value*/,
const void* data) {
if (data == nullptr) {
return nullptr;
}
@@ -125,24 +123,16 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
void* data,
float option) {
// Encode the right payload type for this event. Check the documentation for
// `EventPayload` for more information. We have to skip some opcodes because
// some VST hsots will outright crash if they receive them, please let me
// know if there's a better way to do this.
const std::optional<EventPayload> payload =
// `EventPayload` for more information
const EventPayload payload =
data_converter.read(opcode, index, value, data);
if (!payload.has_value()) {
// A 0 usually means that the event was not supported by the other
// rendpoint
return 0;
}
if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value();
logger.log_event(is_dispatch, opcode, index, value, payload.value(),
option);
logger.log_event(is_dispatch, opcode, index, value, payload, option);
}
const Event event{opcode, index, value, option, payload.value()};
const Event event{opcode, index, value, option, 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
+4 -4
View File
@@ -186,10 +186,10 @@ class DispatchDataConverter : DefaultDataConverter {
VstRect& editor_rectangle)
: chunk(chunk_data), rect(editor_rectangle) {}
std::optional<EventPayload> read(const int opcode,
const int index,
const intptr_t value,
const void* data) {
EventPayload read(const int opcode,
const int index,
const intptr_t value,
const void* data) {
// There are some events that need specific structs that we can't simply
// serialize as a string because they might contain null bytes
switch (opcode) {
+4 -4
View File
@@ -284,10 +284,10 @@ class HostCallbackDataConverter : DefaultDataConverter {
std::optional<VstTimeInfo>& time_info)
: plugin(plugin), time_info(time_info) {}
std::optional<EventPayload> read(const int opcode,
const int index,
const intptr_t value,
const void* data) {
EventPayload read(const int opcode,
const int index,
const intptr_t value,
const void* data) {
switch (opcode) {
case audioMasterGetTime:
return WantsVstTimeInfo{};