Add a general entry point to HostBridge

Since for all plugin types we would need to start listening for incoming
events this way.
This commit is contained in:
Robbert van der Helm
2020-12-02 00:35:41 +01:00
parent 3dd5090023
commit 0eb80fe866
5 changed files with 31 additions and 29 deletions
+15
View File
@@ -25,6 +25,21 @@
*/
class HostBridge {
public:
virtual ~HostBridge(){};
/**
* Handle events until the plugin exits. The actual events are posted to
* `main_context` to ensure that all operations to could potentially
* interact with Win32 code are run from a single thread, even when hosting
* multiple plugins. The message loop should be run on a timer within the
* same IO context.
*
* @note Because of the reasons mentioned above, for this to work the plugin
* should be initialized within the same thread that calls
* `main_context.run()`.
*/
virtual void run() = 0;
/**
* Handle X11 events for the editor window if it is open. This can safely be
* run from any thread.
+1 -1
View File
@@ -116,7 +116,7 @@ void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
// Blocks this thread until the plugin shuts down, handling all events on
// the main IO context
bridge->handle_dispatch();
bridge->run();
logger.log("'" + bridge->vst_plugin_path.string() + "' has exited");
// After the plugin has exited we'll remove this thread's plugin from the
+1 -1
View File
@@ -271,7 +271,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
});
}
void Vst2Bridge::handle_dispatch() {
void Vst2Bridge::run() {
sockets.host_vst_dispatch.receive_events(
std::nullopt, [&](Event& event, bool /*on_main_thread*/) {
if (event.opcode == effProcessEvents) {
+1 -12
View File
@@ -62,18 +62,7 @@ class Vst2Bridge : public HostBridge {
std::string plugin_dll_path,
std::string endpoint_base_dir);
/**
* Handle events until the plugin exits. The actual events are posted to
* `main_context` to ensure that all operations to could potentially
* interact with Win32 code are run from a single thread, even when hosting
* multiple plugins. The message loop should be run on a timer within the
* same IO context.
*
* @note Because of the reasons mentioned above, for this to work the plugin
* should be initialized within the same thread that calls
* `main_context.run()`.
*/
void handle_dispatch();
void run() override;
/**
* Forward the host callback made by the plugin to the host and return the