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
+5 -15
View File
@@ -34,10 +34,8 @@ class DefaultDataConverter {
/** /**
* Read data from the `data` void pointer into a an `EventPayload` value * Read data from the `data` void pointer into a an `EventPayload` value
* that can be serialized and conveys the meaning of the event. * 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*/, virtual EventPayload read(const int /*opcode*/,
const int /*index*/, const int /*index*/,
const intptr_t /*value*/, const intptr_t /*value*/,
const void* data) { const void* data) {
@@ -125,24 +123,16 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
void* data, void* data,
float option) { float option) {
// Encode the right payload type for this event. Check the documentation for // Encode the right payload type for this event. Check the documentation for
// `EventPayload` for more information. We have to skip some opcodes because // `EventPayload` for more information
// some VST hsots will outright crash if they receive them, please let me const EventPayload payload =
// know if there's a better way to do this.
const std::optional<EventPayload> payload =
data_converter.read(opcode, index, value, data); 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()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value(); auto [logger, is_dispatch] = logging.value();
logger.log_event(is_dispatch, opcode, index, value, payload.value(), logger.log_event(is_dispatch, opcode, index, value, payload, option);
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 // 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 // messages getting out of order. This is needed because we can't prevent
+1 -1
View File
@@ -186,7 +186,7 @@ class DispatchDataConverter : DefaultDataConverter {
VstRect& editor_rectangle) VstRect& editor_rectangle)
: chunk(chunk_data), rect(editor_rectangle) {} : chunk(chunk_data), rect(editor_rectangle) {}
std::optional<EventPayload> read(const int opcode, EventPayload read(const int opcode,
const int index, const int index,
const intptr_t value, const intptr_t value,
const void* data) { const void* data) {
+1 -1
View File
@@ -284,7 +284,7 @@ class HostCallbackDataConverter : DefaultDataConverter {
std::optional<VstTimeInfo>& time_info) std::optional<VstTimeInfo>& time_info)
: plugin(plugin), time_info(time_info) {} : plugin(plugin), time_info(time_info) {}
std::optional<EventPayload> read(const int opcode, EventPayload read(const int opcode,
const int index, const int index,
const intptr_t value, const intptr_t value,
const void* data) { const void* data) {