mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +02:00
Fix GUI related data races within Serum
This commit is contained in:
+29
-3
@@ -13,6 +13,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
@@ -43,6 +44,8 @@ class Editor {
|
||||
* windows.
|
||||
* @param effect The plugin this window is being created for. Used to send
|
||||
* `effEditIdle` messages on a timer.
|
||||
* @param processing_mutex The mutex belonging to `effect` audio processing
|
||||
* routine.
|
||||
* @param parent_window_handle The X11 window handle passed by the VST host
|
||||
* for the editor to embed itself into.
|
||||
*
|
||||
@@ -50,16 +53,22 @@ class Editor {
|
||||
*/
|
||||
Editor(const std::string& window_class_name,
|
||||
AEffect* effect,
|
||||
std::mutex& processing_mutex,
|
||||
const size_t parent_window_handle);
|
||||
|
||||
/**
|
||||
* Send a single `effEditIdle` event to the plugin to allow it to update its
|
||||
* GUI state. This is called periodically from a timer while the GUI is
|
||||
* being blocked.
|
||||
*/
|
||||
void send_idle_event();
|
||||
|
||||
/**
|
||||
* Pump messages from the editor GUI's event loop until all events are
|
||||
* process. Must be run from the same thread the GUI was created in because
|
||||
* of Win32 limitations. I guess that's what `effEditIdle` is for.
|
||||
*/
|
||||
void handle_events();
|
||||
// Needed to handle idle updates through a timer
|
||||
AEffect* plugin;
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -76,6 +85,14 @@ class Editor {
|
||||
win32_handle;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Run the win32 message handling loop, filtering out the events generated
|
||||
* by the `effEditIdle` timer since those are sent manually on every
|
||||
* invocation of `handle_events()` to match the `effEditIdle` events sent by
|
||||
* the DAW.
|
||||
*/
|
||||
void win32_event_loop();
|
||||
|
||||
/**
|
||||
* The window handle of the editor window created by the DAW.
|
||||
*/
|
||||
@@ -85,10 +102,19 @@ class Editor {
|
||||
*/
|
||||
xcb_window_t child_window;
|
||||
|
||||
/**
|
||||
*Needed to handle idle updates through a timer
|
||||
*/
|
||||
AEffect* plugin;
|
||||
/**
|
||||
* The mutex belonging to `plugin`'s audio processing routine, see
|
||||
* `PluginBridge::processing_mutex`'s docstring for more information.
|
||||
*/
|
||||
std::mutex& processing_mutex;
|
||||
|
||||
/**
|
||||
* A pointer to the currently active window. Will be a null pointer if no
|
||||
* window is active.
|
||||
*/
|
||||
|
||||
std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)> x11_connection;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user