Move the sockets after the threads in Vst2Bridge

This way the sockets can be destroyed before the threads, and we can
safely wait for the threads to shut down. I initially had Win32Thread
imitate std::jthread's join-on-destruct, but that was causing group
processes to hang. Now we can safely add that back again, and this will
fix some spurious segfaults during plugin scans when using plugin groups
containing a massive amount of plugins.
This commit is contained in:
Robbert van der Helm
2020-10-28 21:05:14 +01:00
parent d81759c929
commit dd9957159a
+9 -5
View File
@@ -186,11 +186,6 @@ class Vst2Bridge {
*/
AEffect* plugin;
/**
* All sockets used for communicating with this specific plugin.
*/
Sockets<Win32Thread> sockets;
/**
* The thread that specifically handles `effProcessEvents` opcodes so the
* plugin can still receive MIDI during GUI interaction to work around Win32
@@ -207,6 +202,15 @@ class Vst2Bridge {
*/
Win32Thread process_replacing_handler;
/**
* All sockets used for communicating with this specific plugin.
*
* NOTE: This is defined **after** the threads on purpose. This way the
* sockets will be closed first, and we can then safely wait for the
* threads to exit.
*/
Sockets<Win32Thread> sockets;
/**
* A scratch buffer for sending and receiving data during `process` and
* `processReplacing` calls.