Rename both Bridge classes to differentiate

Switching between them became a bit confusing.
This commit is contained in:
Robbert van der Helm
2020-03-01 01:17:15 +01:00
parent 5ace761ce9
commit cb6ad5f043
7 changed files with 63 additions and 46 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ include_dir = include_directories('src/include')
shared_library(
'yabridge',
[
'src/plugin/bridge.cpp',
'src/plugin/host-bridge.cpp',
'src/plugin/plugin.cpp',
],
native : true,
@@ -43,7 +43,7 @@ shared_library(
executable(
'yabridge-host',
[
'src/wine-host/bridge.cpp',
'src/wine-host/plugin-bridge.cpp',
'src/wine-host/vst-host.cpp',
],
native : false,
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "bridge.h"
#include "host-bridge.h"
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/filesystem.hpp>
@@ -51,7 +51,7 @@ bp::environment set_wineprefix();
// TODO: When adding debug information, print both the path to the VST host and
// the chosen wineprefix
Bridge::Bridge(AEffect* plugin, audioMasterCallback host_callback)
HostBridge::HostBridge(AEffect* plugin, audioMasterCallback host_callback)
: io_context(),
socket_endpoint(generate_endpoint_name().string()),
socket_acceptor(io_context, socket_endpoint),
@@ -78,12 +78,12 @@ Bridge::Bridge(AEffect* plugin, audioMasterCallback host_callback)
* Handle an event sent by the VST host. Most of these opcodes will be passed
* through to the winelib VST host.
*/
intptr_t Bridge::dispatch(AEffect* /*plugin*/,
int32_t opcode,
int32_t index,
intptr_t value,
void* data,
float option) {
intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
int32_t opcode,
int32_t index,
intptr_t value,
void* data,
float option) {
// Some events need some extra handling
// TODO: Handle other things such as GUI itneraction
switch (opcode) {
@@ -106,20 +106,20 @@ intptr_t Bridge::dispatch(AEffect* /*plugin*/,
return send_event(host_vst_dispatch, opcode, index, value, data, option);
}
void Bridge::process(AEffect* /*plugin*/,
float** /*inputs*/,
float** /*outputs*/,
int32_t /*sample_frames*/) {
void HostBridge::process(AEffect* /*plugin*/,
float** /*inputs*/,
float** /*outputs*/,
int32_t /*sample_frames*/) {
// TODO: Unimplmemented
}
void Bridge::set_parameter(AEffect* /*plugin*/,
int32_t /*index*/,
float /*value*/) {
void HostBridge::set_parameter(AEffect* /*plugin*/,
int32_t /*index*/,
float /*value*/) {
// TODO: Unimplmemented
}
float Bridge::get_parameter(AEffect* /*plugin*/, int32_t /*index*/
float HostBridge::get_parameter(AEffect* /*plugin*/, int32_t /*index*/
) {
// TODO: Unimplmemented
return 0.0f;
@@ -223,7 +223,7 @@ fs::path generate_endpoint_name() {
// TODO: Replace blocking loop with async readers or threads for all of the
// sockets. Also extract this functionality somewhere since the host event
// callback needs to do exactly the same thing.
void Bridge::host_callback_loop(AEffect* plugin) {
void HostBridge::host_callback_loop(AEffect* plugin) {
while (true) {
passthrough_event(vst_host_callback, plugin, host_callback_function);
}
@@ -29,7 +29,7 @@
* Wine VST host. The functions below should be used as callback functions in an
* `AEffect` object.
*/
class Bridge {
class HostBridge {
public:
/**
* Initializes the Wine VST bridge. This sets up the sockets for event
@@ -45,7 +45,7 @@ class Bridge {
* if it could not locate and load a VST .dll file.
*/
// TODO: The plugin struct should be created here, not passed in
Bridge(AEffect* plugin, audioMasterCallback host_callback);
HostBridge(AEffect* plugin, audioMasterCallback host_callback);
// The four below functions are the handlers from the VST2 API. They are
// called through proxy functions in `plugin.cpp`.
+4 -4
View File
@@ -19,7 +19,7 @@
#include <iostream>
#include <memory>
#include "bridge.h"
#include "host-bridge.h"
#define VST_EXPORT __attribute__((visibility("default")))
@@ -48,8 +48,8 @@ float getParameter_proxy(AEffect*, int32_t);
* is sadly needed as a workaround to avoid using globals since we need free
* function pointers to interface with the VST C API.
*/
Bridge& get_bridge_instance(const AEffect& plugin) {
return *static_cast<Bridge*>(plugin.ptr3);
HostBridge& get_bridge_instance(const AEffect& plugin) {
return *static_cast<HostBridge*>(plugin.ptr3);
}
/**
@@ -67,7 +67,7 @@ VST_EXPORT AEffect* VSTPluginMain(audioMasterCallback host_callback) {
// parameters. We can then also use a smart pointer so we only
// have to manually delete the bridge instance.
AEffect* plugin = new AEffect();
Bridge* bridge = new Bridge(plugin, host_callback);
HostBridge* bridge = new HostBridge(plugin, host_callback);
plugin->ptr3 = bridge;
plugin->dispatcher = dispatch_proxy;
@@ -1,4 +1,20 @@
#include "bridge.h"
// yabridge: a Wine VST bridge
// Copyright (C) 2020 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "plugin-bridge.h"
#include "../common/communication.h"
@@ -11,18 +27,18 @@ using VstEntryPoint = AEffect*(VST_CALL_CONV*)(audioMasterCallback);
* This ugly global is needed so we can get the instance of a `Brdige` class
* from an `AEffect` when it performs a host callback during its initialization.
*/
Bridge* current_bridge_isntance = nullptr;
PluginBridge* current_bridge_isntance = nullptr;
intptr_t VST_CALL_CONV
host_callback_proxy(AEffect*, int32_t, int32_t, intptr_t, void*, float);
/**
* Fetch the bridge instance stored in one of the two pointers reserved for the
* host of the hosted VST plugin. This is sadly needed as a workaround to avoid
* using globals since we need free function pointers to interface with the VST
* C API.
* Fetch the Pluginbridge instance stored in one of the two pointers reserved
* for the host of the hosted VST plugin. This is sadly needed as a workaround
* to avoid using globals since we need free function pointers to interface with
* the VST C API.
*/
Bridge& get_bridge_instance(const AEffect* plugin) {
PluginBridge& get_bridge_instance(const AEffect* plugin) {
// This is needed during the initialization of the plugin since we can only
// add our own pointer after it's done initializing
if (current_bridge_isntance != nullptr) {
@@ -31,10 +47,11 @@ Bridge& get_bridge_instance(const AEffect* plugin) {
return *current_bridge_isntance;
}
return *static_cast<Bridge*>(plugin->ptr1);
return *static_cast<PluginBridge*>(plugin->ptr1);
}
Bridge::Bridge(std::string plugin_dll_path, std::string socket_endpoint_path)
PluginBridge::PluginBridge(std::string plugin_dll_path,
std::string socket_endpoint_path)
: plugin_handle(LoadLibrary(plugin_dll_path.c_str()), &FreeLibrary),
io_context(),
socket_endpoint(socket_endpoint_path),
@@ -88,18 +105,18 @@ Bridge::Bridge(std::string plugin_dll_path, std::string socket_endpoint_path)
// TODO: Replace blocking loop with async readers or threads for all of the
// sockets. Also extract this functionality somewhere since the host event
// callback needs to do exactly the same thing.
void Bridge::dispatch_loop() {
void PluginBridge::dispatch_loop() {
while (true) {
passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher);
}
}
intptr_t Bridge::host_callback(AEffect* /*plugin*/,
int32_t opcode,
int32_t index,
intptr_t value,
void* data,
float option) {
intptr_t PluginBridge::host_callback(AEffect* /*plugin*/,
int32_t opcode,
int32_t index,
intptr_t value,
void* data,
float option) {
return send_event(vst_host_callback, opcode, index, value, data, option);
}
@@ -29,7 +29,7 @@
* Wine VST host. The functions below should be used as callback functions in an
* `AEffect` object.
*/
class Bridge {
class PluginBridge {
public:
/**
* Initializes the Windows VST plugin and set up communication with the
@@ -43,7 +43,7 @@ class Bridge {
* @throw std::runtime_error Thrown when the VST plugin could not be loaded,
* or if communication could not be set up.
*/
Bridge(std::string plugin_dll_path, std::string socket_endpoint_path);
PluginBridge(std::string plugin_dll_path, std::string socket_endpoint_path);
intptr_t host_callback(AEffect*, int32_t, int32_t, intptr_t, void*, float);
+3 -3
View File
@@ -16,7 +16,7 @@
#include <iostream>
#include "bridge.h"
#include "plugin-bridge.h"
int main(int argc, char* argv[]) {
// We pass the name of the VST plugin .dll file to load and the Unix domain
@@ -33,10 +33,10 @@ int main(int argc, char* argv[]) {
const std::string socket_endpoint_path(argv[2]);
try {
Bridge bridge(plugin_dll_path, socket_endpoint_path);
PluginBridge Pluginbridge(plugin_dll_path, socket_endpoint_path);
// TODO: Remove debug
bridge.dispatch_loop();
Pluginbridge.dispatch_loop();
} catch (const std::runtime_error& error) {
std::cerr << "Error while initializing plugin:" << std::endl;
std::cerr << error.what() << std::endl;