mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 12:30:12 +02:00
Rename both Bridge classes to differentiate
Switching between them became a bit confusing.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user