From 6c496da455bb880ad13f44bfd7091ed1edfaa1d0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 30 Apr 2020 22:45:22 +0200 Subject: [PATCH] Clean up after reverting buffer handling change This is what you get from not taking any breaks. --- src/common/events.h | 64 +++++++++++++++++--------------------- src/plugin/host-bridge.cpp | 2 +- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index 60df9399..37f6100b 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -193,43 +193,37 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, // arbitrary C-style string. std::array string_buffer; string_buffer[0] = 0; - // This buffer is only used for retrieving chunk data and will be allocated - // as needed - std::vector binary_buffer; void* data = std::visit( - overload{[&](const std::nullptr_t&) -> void* { return nullptr; }, - [&](const std::string& s) -> void* { - return const_cast(s.c_str()); - }, - [&](const std::vector& buffer) -> void* { - return const_cast(buffer.data()); - }, - [&](native_size_t& window_handle) -> void* { - // This is the X11 window handle that the editor should - // reparent itself to. We have a special wrapper around the - // dispatch function that intercepts `effEditOpen` events - // and creates a Win32 window and then finally embeds the - // X11 window Wine created into this wnidow handle. - // Make sure to convert the window ID first to `size_t` in - // case this is the 32-bit host. - return reinterpret_cast( - static_cast(window_handle)); - }, - [&](const AEffect&) -> void* { return nullptr; }, - [&](DynamicVstEvents& events) -> void* { - return &events.as_c_events(); - }, - [&](WantsChunkBuffer&) -> void* { - binary_buffer.resize(binary_buffer_size); - return binary_buffer.data(); - }, - [&](VstIOProperties& props) -> void* { return &props; }, - [&](VstMidiKeyName& key_name) -> void* { return &key_name; }, - [&](VstParameterProperties& props) -> void* { return &props; }, - [&](WantsVstRect&) -> void* { return string_buffer.data(); }, - [&](const WantsVstTimeInfo&) -> void* { return nullptr; }, - [&](WantsString&) -> void* { return string_buffer.data(); }}, + overload{ + [&](const std::nullptr_t&) -> void* { return nullptr; }, + [&](const std::string& s) -> void* { + return const_cast(s.c_str()); + }, + [&](const std::vector& buffer) -> void* { + return const_cast(buffer.data()); + }, + [&](native_size_t& window_handle) -> void* { + // This is the X11 window handle that the editor should reparent + // itself to. We have a special wrapper around the dispatch + // function that intercepts `effEditOpen` events and creates a + // Win32 window and then finally embeds the X11 window Wine + // created into this wnidow handle. Make sure to convert the + // window ID first to `size_t` in case this is the 32-bit host. + return reinterpret_cast( + static_cast(window_handle)); + }, + [&](const AEffect&) -> void* { return nullptr; }, + [&](DynamicVstEvents& events) -> void* { + return &events.as_c_events(); + }, + [&](WantsChunkBuffer&) -> void* { return string_buffer.data(); }, + [&](VstIOProperties& props) -> void* { return &props; }, + [&](VstMidiKeyName& key_name) -> void* { return &key_name; }, + [&](VstParameterProperties& props) -> void* { return &props; }, + [&](WantsVstRect&) -> void* { return string_buffer.data(); }, + [&](const WantsVstTimeInfo&) -> void* { return nullptr; }, + [&](WantsString&) -> void* { return string_buffer.data(); }}, event.payload); const intptr_t return_value = callback(plugin, event.opcode, event.index, diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index bf732c25..9684edd6 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -279,7 +279,7 @@ class DispatchDataConverter : DefaultDataConverter { std::get>(response.payload); chunk.assign(buffer.begin(), buffer.end()); - *static_cast(data) = chunk.data(); + *static_cast(data) = chunk.data(); } break; case effGetInputProperties: case effGetOutputProperties: {