Commit Graph

33 Commits

Author SHA1 Message Date
Robbert van der Helm 29f1754527 Link to the issue instead of listing issue number 2020-12-11 13:01:45 +01:00
Robbert van der Helm c306048988 Fix hanging processes for good #69 2020-12-11 12:40:50 +01:00
Robbert van der Helm ac0d83e555 Fix concurrency issue in plugin group shutdown 2020-12-10 21:41:04 +01:00
Robbert van der Helm d2500ff31d Get rid of message loop skipping and EditorOpening
This special behaviour is no longer needed now that event handling is
fully concurrent and the Win32 message loop no longer blocks
`dispatch()` calls.
2020-11-07 22:06:58 +01:00
Robbert van der Helm bece654c2d Rename PluginContext to MainContext for clarity 2020-10-28 01:02:56 +01:00
Robbert van der Helm a6b5951d81 Replace std::jthread with Win32Thread everywhere 2020-10-27 17:38:13 +01:00
Robbert van der Helm 5b00ddb0c4 Fall back to waiting when socket is not yet ready
This can happen with plugin groups.
2020-10-27 11:13:39 +01:00
Robbert van der Helm ca2b95e7aa Handle dispatch() directly during event handling
When the message loop is active and we get an incoming dispatch() event,
we'll just handle it directly. In practice this would only be needed
when the event is a response to an `audioMaster()` call made during the
event loop, but we can't know that. This allows the `getProgram()`
during `audioMasterUpdateDisplay()` in REAPER and Renoise to work
correctly. Hopefully this doesn't cause random rare breakage.
2020-10-26 20:03:54 +01:00
Robbert van der Helm 523ac64d11 Add a missing lock to reading from active_plugins
I've never seen this cause memory errors, but there exist a rare
situation where it could.
2020-10-26 12:45:38 +01:00
Robbert van der Helm d82f8463d9 Use simple numerical IDs for plugins in groups
We'll be using a similar approach to identify threads for event
handlers.
2020-10-26 11:51:13 +01:00
Robbert van der Helm 4b53342514 💥 Encapsulate and rework all socket logic
This is a pretty huge change that will be important for being able to
handle nested or mutually recursive `dispatch()` and `audioMaster()`
calls. This sadly all had to be done in a single commit, so here's a
summary:

- `src/common/sockets.h:Sockets` contains all sockets on both the plugin
  and the Wine host side, and is used to both listen on and connect to
  the sockets.
- Sockets and other temporary files respect `$XDG_RUNTIME_DIR` instead
  of being dumped in `/tmp`.
- All sockets now have a unique endpoint in
  `/run/user/<uid>/yabridge-<plugin_name>-<random_id>/`. This is
  important for when we want to have multiple socket connections for
  handling `dispatch()` and `audioMaster()`.
- Because of the above, we no longer clean up the socket endpoint files
  after the connection gets established during initialization. Instead
  we'll remove the socket base directory when shutting down.
2020-10-25 21:24:56 +01:00
Robbert van der Helm becb73928e Add a limit to all Win32 message loops #28
This works around Waves plugins causing an infinite message loop. Since
we run the loop 30 times per second anyways splitting the loop up into
chunks of 20 shouldn't be an issue.
2020-08-14 11:36:55 +02:00
Robbert van der Helm 1e6188d774 Check the return value from pipe(2)
Starting from GCC 10 not checking this will produce a warning.
2020-06-20 18:43:36 +02:00
Robbert van der Helm 61cde0bd43 Use std::jthread 2020-06-20 16:16:12 +02:00
Robbert van der Helm 4403585a70 Use the new C++20 starts_with() and contains() 2020-06-06 13:44:26 +02:00
Robbert van der Helm 1746fce7e3 Clarify group host plugin removal process better 2020-05-29 11:28:19 +02:00
Robbert van der Helm 2a31a60266 Get rid of the ugly Win32 threads in group host
Running the audio processing and midi dispatcher loops in a regular
`std::thread` causes weird memory corruption issues (likely because of
calling conventions are not being respected). Luckily this does not
cause any issues here, so we can get rid of a lot of ugly glue code and
manual memory management.
2020-05-28 16:27:30 +02:00
Robbert van der Helm 06de49ded2 Unify event handling behavior for all cases
This makes the individual plugin host slightly more complex, but now
both individually hosted plugins and plugin groups handle both
dispatcher events and GUI events in the exact same way.
2020-05-28 13:53:25 +02:00
Robbert van der Helm 198807a15a Run events async and centralized for group hosts
At a 30 fps rate with a limit on the number of window messages per
frame. This is somehow needed for Melda plugins, as they otherwise
dispatch tiemr messages indefinitely after opening a second editor with
seemingly no way around it.

With this and some refactoring #15 should be almost done.
2020-05-26 12:13:37 +02:00
Robbert van der Helm 16fce5577d Skip the message loop when an editor is opening
This is a bit more restrictive than the old approach that only skipped
when `effEditOpen()` got called after `effEditGetRect()`. Not sure why
the Melda plugins block indefinitely on the message loop without this
now.
2020-05-26 11:12:36 +02:00
Robbert van der Helm 064bb2684f Init plugins and handle events on the main thread
Within the plugin IO context.
2020-05-25 15:19:46 +02:00
Robbert van der Helm bbfe522343 Use a seperate thread for STDIO capture for groups
When running the plugins on the main thread the window message loop may
block for a while, which would cause the STDIO redirect to be
interrupted.
2020-05-25 15:15:32 +02:00
Robbert van der Helm c387238b78 Change wording in group related log messages 2020-05-23 15:16:33 +02:00
Robbert van der Helm f50d04ce04 Defer group host shutdown
This allows for a significant speedup in plugin scanning time for plugin
groups, since starting Wine processes takes up pretty much the entirety
of the time spent scanning plugins.
2020-05-23 13:54:40 +02:00
Robbert van der Helm b4b471523f Fix assertion in group host connection handler 2020-05-22 20:15:53 +02:00
Robbert van der Helm 9fb7f1fc03 Add handling for stale and active group sockets 2020-05-22 19:06:43 +02:00
Robbert van der Helm 9b50bac179 Reply with the group process's PID after a request 2020-05-22 19:06:43 +02:00
Robbert van der Helm dd843519ce Rename PluginParameters to GroupReuqest 2020-05-22 19:06:43 +02:00
Robbert van der Helm 8c22f37f29 Actually host plugins in the group process 2020-05-21 17:12:55 +02:00
Robbert van der Helm 17cff5722e Lock the active plugins map early
To prevent a race condition when an exiting plugin wants to terminate
the process when it think there are no plugins left just as another
yabridge instance is connecting to the group socket.
2020-05-21 17:12:41 +02:00
Robbert van der Helm 8eb01cb519 Listen on the group socket and handle requests 2020-05-20 18:45:33 +02:00
Robbert van der Helm 6d6d928838 Move all plugin group handling boilerplate 2020-05-19 15:29:48 +02:00
Robbert van der Helm 8bd1dc8c50 Encapsulate the STDOUT/STDERR capturing 2020-05-18 16:15:07 +02:00