mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Rename both Bridge classes to differentiate
Switching between them became a bit confusing.
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ include_dir = include_directories('src/include')
|
|||||||
shared_library(
|
shared_library(
|
||||||
'yabridge',
|
'yabridge',
|
||||||
[
|
[
|
||||||
'src/plugin/bridge.cpp',
|
'src/plugin/host-bridge.cpp',
|
||||||
'src/plugin/plugin.cpp',
|
'src/plugin/plugin.cpp',
|
||||||
],
|
],
|
||||||
native : true,
|
native : true,
|
||||||
@@ -43,7 +43,7 @@ shared_library(
|
|||||||
executable(
|
executable(
|
||||||
'yabridge-host',
|
'yabridge-host',
|
||||||
[
|
[
|
||||||
'src/wine-host/bridge.cpp',
|
'src/wine-host/plugin-bridge.cpp',
|
||||||
'src/wine-host/vst-host.cpp',
|
'src/wine-host/vst-host.cpp',
|
||||||
],
|
],
|
||||||
native : false,
|
native : false,
|
||||||
|
|||||||
@@ -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 "bridge.h"
|
#include "host-bridge.h"
|
||||||
|
|
||||||
#include <boost/dll/runtime_symbol_info.hpp>
|
#include <boost/dll/runtime_symbol_info.hpp>
|
||||||
#include <boost/filesystem.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
|
// TODO: When adding debug information, print both the path to the VST host and
|
||||||
// the chosen wineprefix
|
// the chosen wineprefix
|
||||||
Bridge::Bridge(AEffect* plugin, audioMasterCallback host_callback)
|
HostBridge::HostBridge(AEffect* plugin, audioMasterCallback host_callback)
|
||||||
: io_context(),
|
: io_context(),
|
||||||
socket_endpoint(generate_endpoint_name().string()),
|
socket_endpoint(generate_endpoint_name().string()),
|
||||||
socket_acceptor(io_context, socket_endpoint),
|
socket_acceptor(io_context, socket_endpoint),
|
||||||
@@ -78,7 +78,7 @@ Bridge::Bridge(AEffect* plugin, audioMasterCallback host_callback)
|
|||||||
* Handle an event sent by the VST host. Most of these opcodes will be passed
|
* Handle an event sent by the VST host. Most of these opcodes will be passed
|
||||||
* through to the winelib VST host.
|
* through to the winelib VST host.
|
||||||
*/
|
*/
|
||||||
intptr_t Bridge::dispatch(AEffect* /*plugin*/,
|
intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
|
||||||
int32_t opcode,
|
int32_t opcode,
|
||||||
int32_t index,
|
int32_t index,
|
||||||
intptr_t value,
|
intptr_t value,
|
||||||
@@ -106,20 +106,20 @@ intptr_t Bridge::dispatch(AEffect* /*plugin*/,
|
|||||||
return send_event(host_vst_dispatch, opcode, index, value, data, option);
|
return send_event(host_vst_dispatch, opcode, index, value, data, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bridge::process(AEffect* /*plugin*/,
|
void HostBridge::process(AEffect* /*plugin*/,
|
||||||
float** /*inputs*/,
|
float** /*inputs*/,
|
||||||
float** /*outputs*/,
|
float** /*outputs*/,
|
||||||
int32_t /*sample_frames*/) {
|
int32_t /*sample_frames*/) {
|
||||||
// TODO: Unimplmemented
|
// TODO: Unimplmemented
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bridge::set_parameter(AEffect* /*plugin*/,
|
void HostBridge::set_parameter(AEffect* /*plugin*/,
|
||||||
int32_t /*index*/,
|
int32_t /*index*/,
|
||||||
float /*value*/) {
|
float /*value*/) {
|
||||||
// TODO: Unimplmemented
|
// TODO: Unimplmemented
|
||||||
}
|
}
|
||||||
|
|
||||||
float Bridge::get_parameter(AEffect* /*plugin*/, int32_t /*index*/
|
float HostBridge::get_parameter(AEffect* /*plugin*/, int32_t /*index*/
|
||||||
) {
|
) {
|
||||||
// TODO: Unimplmemented
|
// TODO: Unimplmemented
|
||||||
return 0.0f;
|
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
|
// TODO: Replace blocking loop with async readers or threads for all of the
|
||||||
// sockets. Also extract this functionality somewhere since the host event
|
// sockets. Also extract this functionality somewhere since the host event
|
||||||
// callback needs to do exactly the same thing.
|
// callback needs to do exactly the same thing.
|
||||||
void Bridge::host_callback_loop(AEffect* plugin) {
|
void HostBridge::host_callback_loop(AEffect* plugin) {
|
||||||
while (true) {
|
while (true) {
|
||||||
passthrough_event(vst_host_callback, plugin, host_callback_function);
|
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
|
* Wine VST host. The functions below should be used as callback functions in an
|
||||||
* `AEffect` object.
|
* `AEffect` object.
|
||||||
*/
|
*/
|
||||||
class Bridge {
|
class HostBridge {
|
||||||
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
|
||||||
@@ -45,7 +45,7 @@ class Bridge {
|
|||||||
* if it could not locate and load a VST .dll file.
|
* if it could not locate and load a VST .dll file.
|
||||||
*/
|
*/
|
||||||
// TODO: The plugin struct should be created here, not passed in
|
// 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
|
// 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`.
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "bridge.h"
|
#include "host-bridge.h"
|
||||||
|
|
||||||
#define VST_EXPORT __attribute__((visibility("default")))
|
#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
|
* 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.
|
||||||
*/
|
*/
|
||||||
Bridge& get_bridge_instance(const AEffect& plugin) {
|
HostBridge& get_bridge_instance(const AEffect& plugin) {
|
||||||
return *static_cast<Bridge*>(plugin.ptr3);
|
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
|
// parameters. We can then also use a smart pointer so we only
|
||||||
// have to manually delete the bridge instance.
|
// have to manually delete the bridge instance.
|
||||||
AEffect* plugin = new AEffect();
|
AEffect* plugin = new AEffect();
|
||||||
Bridge* bridge = new Bridge(plugin, host_callback);
|
HostBridge* bridge = new HostBridge(plugin, host_callback);
|
||||||
plugin->ptr3 = bridge;
|
plugin->ptr3 = bridge;
|
||||||
|
|
||||||
plugin->dispatcher = dispatch_proxy;
|
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"
|
#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
|
* 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.
|
* 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
|
intptr_t VST_CALL_CONV
|
||||||
host_callback_proxy(AEffect*, int32_t, int32_t, intptr_t, void*, float);
|
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
|
* Fetch the Pluginbridge instance stored in one of the two pointers reserved
|
||||||
* host of the hosted VST plugin. This is sadly needed as a workaround to avoid
|
* for the host of the hosted VST plugin. This is sadly needed as a workaround
|
||||||
* using globals since we need free function pointers to interface with the VST
|
* to avoid using globals since we need free function pointers to interface with
|
||||||
* C API.
|
* 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
|
// This is needed during the initialization of the plugin since we can only
|
||||||
// add our own pointer after it's done initializing
|
// add our own pointer after it's done initializing
|
||||||
if (current_bridge_isntance != nullptr) {
|
if (current_bridge_isntance != nullptr) {
|
||||||
@@ -31,10 +47,11 @@ Bridge& get_bridge_instance(const AEffect* plugin) {
|
|||||||
return *current_bridge_isntance;
|
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),
|
: plugin_handle(LoadLibrary(plugin_dll_path.c_str()), &FreeLibrary),
|
||||||
io_context(),
|
io_context(),
|
||||||
socket_endpoint(socket_endpoint_path),
|
socket_endpoint(socket_endpoint_path),
|
||||||
@@ -88,13 +105,13 @@ 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
|
// TODO: Replace blocking loop with async readers or threads for all of the
|
||||||
// sockets. Also extract this functionality somewhere since the host event
|
// sockets. Also extract this functionality somewhere since the host event
|
||||||
// callback needs to do exactly the same thing.
|
// callback needs to do exactly the same thing.
|
||||||
void Bridge::dispatch_loop() {
|
void PluginBridge::dispatch_loop() {
|
||||||
while (true) {
|
while (true) {
|
||||||
passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher);
|
passthrough_event(host_vst_dispatch, plugin, plugin->dispatcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t Bridge::host_callback(AEffect* /*plugin*/,
|
intptr_t PluginBridge::host_callback(AEffect* /*plugin*/,
|
||||||
int32_t opcode,
|
int32_t opcode,
|
||||||
int32_t index,
|
int32_t index,
|
||||||
intptr_t value,
|
intptr_t value,
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
* 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 Bridge {
|
class PluginBridge {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Initializes the Windows VST plugin and set up communication with the
|
* 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,
|
* @throw std::runtime_error Thrown when the VST plugin could not be loaded,
|
||||||
* or if communication could not be set up.
|
* 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);
|
intptr_t host_callback(AEffect*, int32_t, int32_t, intptr_t, void*, float);
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "bridge.h"
|
#include "plugin-bridge.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
// We pass the name of the VST plugin .dll file to load and the Unix domain
|
// 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]);
|
const std::string socket_endpoint_path(argv[2]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Bridge bridge(plugin_dll_path, socket_endpoint_path);
|
PluginBridge Pluginbridge(plugin_dll_path, socket_endpoint_path);
|
||||||
|
|
||||||
// TODO: Remove debug
|
// TODO: Remove debug
|
||||||
bridge.dispatch_loop();
|
Pluginbridge.dispatch_loop();
|
||||||
} catch (const std::runtime_error& error) {
|
} catch (const std::runtime_error& error) {
|
||||||
std::cerr << "Error while initializing plugin:" << std::endl;
|
std::cerr << "Error while initializing plugin:" << std::endl;
|
||||||
std::cerr << error.what() << std::endl;
|
std::cerr << error.what() << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user