💥 Rename HostBridge to PluginBridge

As mentioned in the last commit. The original reasoning behind these
names was that the HostBridge talks to the host, and the PluginBridge
talks to the plugin, but you could also argue that the HostBridge should
be part of the Wine VST host and the PluginBridge should be part of the
VST plugin. This removes that ambiguity.
This commit is contained in:
Robbert van der Helm
2020-05-07 13:08:01 +02:00
parent 2d0998047c
commit 7b07a2bfe1
7 changed files with 30 additions and 29 deletions
+1 -1
View File
@@ -254,7 +254,7 @@ launch winedbg in a seperate detached terminal emulator so it doesn't terminate
together with the plugin, and winedbg can be a bit picky about the arguments it together with the plugin, and winedbg can be a bit picky about the arguments it
accepts. I've already set this up behind a feature flag for use in KDE Plasma. accepts. I've already set this up behind a feature flag for use in KDE Plasma.
Other desktop environments and window managers will require some slight Other desktop environments and window managers will require some slight
modifications in `src/plugin/host-bridge.cpp`. To enable this, simply run: modifications in `src/plugin/plugin-bridge.cpp`. To enable this, simply run:
```shell ```shell
meson configure build --buildtype=debug -Duse-winedbg=true meson configure build --buildtype=debug -Duse-winedbg=true
+1 -1
View File
@@ -60,8 +60,8 @@ shared_library(
[ [
'src/common/logging.cpp', 'src/common/logging.cpp',
'src/common/serialization.cpp', 'src/common/serialization.cpp',
'src/plugin/host-bridge.cpp',
'src/plugin/plugin.cpp', 'src/plugin/plugin.cpp',
'src/plugin/plugin-bridge.cpp',
version_header, version_header,
], ],
native : true, native : true,
+2 -2
View File
@@ -284,8 +284,8 @@ auto passthrough_event(AEffect* plugin, F callback) {
// plugin. // plugin.
// These are the same fields written by bitsery in the // These are the same fields written by bitsery in the
// initialization of `HostBridge`. I can't think of a way t // initialization of `PluginBridge`. I can't think of a way
// oreuse the serializer without first having to serialize // to reuse the serializer without first having to serialize
// `updated_plugin` first though. // `updated_plugin` first though.
plugin->magic = updated_plugin.magic; plugin->magic = updated_plugin.magic;
plugin->numPrograms = updated_plugin.numPrograms; plugin->numPrograms = updated_plugin.numPrograms;
+2 -1
View File
@@ -348,7 +348,8 @@ struct Event {
* gets passed along. * gets passed along.
* - A (short) string. * - A (short) string.
* - Some binary blob stored as a byte vector. During `effGetChunk` this will * - Some binary blob stored as a byte vector. During `effGetChunk` this will
contain some chunk data that should be written to `HostBridge::chunk_data`. contain some chunk data that should be written to
`PluginBridge::chunk_data`.
* - A specific struct in response to an event such as `audioMasterGetTime` or * - A specific struct in response to an event such as `audioMasterGetTime` or
* `audioMasterIOChanged`. * `audioMasterIOChanged`.
* - An X11 window pointer for the editor window. * - An X11 window pointer for the editor window.
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "host-bridge.h" #include "plugin-bridge.h"
#include <boost/asio/read_until.hpp> #include <boost/asio/read_until.hpp>
#include <boost/dll/runtime_symbol_info.hpp> #include <boost/dll/runtime_symbol_info.hpp>
@@ -146,11 +146,11 @@ bp::environment set_wineprefix();
* is sadly needed as a workaround to avoid using globals since we need free * is sadly needed as a workaround to avoid using globals since we need free
* function pointers to interface with the VST C API. * function pointers to interface with the VST C API.
*/ */
HostBridge& get_bridge_instance(const AEffect& plugin) { PluginBridge& get_bridge_instance(const AEffect& plugin) {
return *static_cast<HostBridge*>(plugin.ptr3); return *static_cast<PluginBridge*>(plugin.ptr3);
} }
HostBridge::HostBridge(audioMasterCallback host_callback) PluginBridge::PluginBridge(audioMasterCallback host_callback)
: vst_plugin_path(find_vst_plugin()), : vst_plugin_path(find_vst_plugin()),
vst_plugin_arch(find_vst_architecture(vst_plugin_path)), vst_plugin_arch(find_vst_architecture(vst_plugin_path)),
vst_host_path(find_vst_host(vst_plugin_arch)), vst_host_path(find_vst_host(vst_plugin_arch)),
@@ -378,7 +378,7 @@ class DispatchDataConverter : DefaultDataConverter {
} break; } break;
case effGetChunk: { case effGetChunk: {
// Write the chunk data to some publically accessible place in // Write the chunk data to some publically accessible place in
// `HostBridge` and write a pointer to that struct to the data // `PluginBridge` and write a pointer to that struct to the data
// pointer // pointer
const auto buffer = const auto buffer =
std::get<std::vector<uint8_t>>(response.payload); std::get<std::vector<uint8_t>>(response.payload);
@@ -425,12 +425,12 @@ class DispatchDataConverter : DefaultDataConverter {
VstRect& rect; VstRect& rect;
}; };
intptr_t HostBridge::dispatch(AEffect* /*plugin*/, intptr_t PluginBridge::dispatch(AEffect* /*plugin*/,
int opcode, int opcode,
int index, int index,
intptr_t value, intptr_t value,
void* data, void* data,
float option) { float option) {
// HACK: Ardour 5.X has a bug in its VST implementation where it calls the // HACK: Ardour 5.X has a bug in its VST implementation where it calls the
// plugin's dispatcher before the plugin has even finished // plugin's dispatcher before the plugin has even finished
// initializing. This has been fixed back in 2018, but there has not // initializing. This has been fixed back in 2018, but there has not
@@ -533,10 +533,10 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
value, data, option); value, data, option);
} }
void HostBridge::process_replacing(AEffect* /*plugin*/, void PluginBridge::process_replacing(AEffect* /*plugin*/,
float** inputs, float** inputs,
float** outputs, float** outputs,
int sample_frames) { int sample_frames) {
// The inputs and outputs arrays should be `[num_inputs][sample_frames]` and // The inputs and outputs arrays should be `[num_inputs][sample_frames]` and
// `[num_outputs][sample_frames]` floats large respectfully. // `[num_outputs][sample_frames]` floats large respectfully.
std::vector<std::vector<float>> input_buffers( std::vector<std::vector<float>> input_buffers(
@@ -575,7 +575,7 @@ void HostBridge::process_replacing(AEffect* /*plugin*/,
incoming_midi_events.clear(); incoming_midi_events.clear();
} }
float HostBridge::get_parameter(AEffect* /*plugin*/, int index) { float PluginBridge::get_parameter(AEffect* /*plugin*/, int index) {
logger.log_get_parameter(index); logger.log_get_parameter(index);
const Parameter request{index, std::nullopt}; const Parameter request{index, std::nullopt};
@@ -594,7 +594,7 @@ float HostBridge::get_parameter(AEffect* /*plugin*/, int index) {
return response.value.value(); return response.value.value();
} }
void HostBridge::set_parameter(AEffect* /*plugin*/, int index, float value) { void PluginBridge::set_parameter(AEffect* /*plugin*/, int index, float value) {
logger.log_set_parameter(index, value); logger.log_set_parameter(index, value);
const Parameter request{index, value}; const Parameter request{index, value};
@@ -613,9 +613,9 @@ void HostBridge::set_parameter(AEffect* /*plugin*/, int index, float value) {
assert(!response.value.has_value()); assert(!response.value.has_value());
} }
void HostBridge::async_log_pipe_lines(patched_async_pipe& pipe, void PluginBridge::async_log_pipe_lines(patched_async_pipe& pipe,
boost::asio::streambuf& buffer, boost::asio::streambuf& buffer,
std::string prefix) { std::string prefix) {
boost::asio::async_read_until( boost::asio::async_read_until(
pipe, buffer, '\n', [&, prefix](const auto&, size_t) { pipe, buffer, '\n', [&, prefix](const auto&, size_t) {
std::string line; std::string line;
@@ -56,7 +56,7 @@ enum class PluginArchitecture { vst_32, vst_64 };
* Wine VST host. The functions below should be used as callback functions in an * Wine VST host. The functions below should be used as callback functions in an
* `AEffect` object. * `AEffect` object.
*/ */
class HostBridge { class PluginBridge {
public: public:
/** /**
* Initializes the Wine VST bridge. This sets up the sockets for event * Initializes the Wine VST bridge. This sets up the sockets for event
@@ -68,7 +68,7 @@ class HostBridge {
* @throw std::runtime_error Thrown when the VST host could not be found, or * @throw std::runtime_error Thrown when the VST host could not be found, or
* if it could not locate and load a VST .dll file. * if it could not locate and load a VST .dll file.
*/ */
HostBridge(audioMasterCallback host_callback); PluginBridge(audioMasterCallback host_callback);
// The four below functions are the handlers from the VST2 API. They are // The four below functions are the handlers from the VST2 API. They are
// called through proxy functions in `plugin.cpp`. // called through proxy functions in `plugin.cpp`.
+2 -2
View File
@@ -19,7 +19,7 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include "host-bridge.h" #include "plugin-bridge.h"
#define VST_EXPORT __attribute__((visibility("default"))) #define VST_EXPORT __attribute__((visibility("default")))
@@ -51,7 +51,7 @@ VST_EXPORT AEffect* VSTPluginMain(audioMasterCallback host_callback) {
// This is the only place where we have to use manual memory management. // This is the only place where we have to use manual memory management.
// The bridge's destructor is called when the `effClose` opcode is // The bridge's destructor is called when the `effClose` opcode is
// received. // received.
HostBridge* bridge = new HostBridge(host_callback); PluginBridge* bridge = new PluginBridge(host_callback);
return &bridge->plugin; return &bridge->plugin;
} catch (const std::exception& error) { } catch (const std::exception& error) {