Commit Graph

28 Commits

Author SHA1 Message Date
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 8198a73742 Add support for double precision audio #34
So far I've only seen REAPER running iZotope Rx plugins utilize this.
2020-08-24 16:13:29 +02:00
Robbert van der Helm 6073d812a5 Clarify the issue in REAPER
It's caused by mutual recursion which at the moment does not work with
yabridge's communication model.
2020-08-21 16:43:49 +02:00
Robbert van der Helm b452f961db Add option to work around bugs in REAPER/Renoise
This is not ideal since it requires the user to know about this option
and to create a config file, but I think it's the best we can do without
compromising on yabridge's transparency and 'zero hacks' philosophy.

See #29 and #32.
2020-08-17 15:49:16 +02: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 b1dd301a98 Add an optional double editor embedding mode #27
This sounds like it would the simplest way to work around the issue of
E27 calculating its own coordinates based on the parent window's
coordinates. I have not noticed any weird issues with having this
enabled all the time, but less moving parts is always better so it's
still behind an option.
2020-07-23 16:56:10 +02:00
Robbert van der Helm 523f77d334 Use designated initializers for complex structs
This was one of the main reasons why I wanted to switch to C++20, I just
forgot to do it.
2020-07-23 14:12:07 +02:00
Robbert van der Helm cd02ab5fc9 Send the configuration from plugin to Wine host
Next we can add some options for different plugin editor behaviours for #27.
2020-07-22 17:15:55 +02:00
Robbert van der Helm 6f772ca899 Send the AEffect object over a new control socket
We'll use the same socket to send the configuration data back to the
plugin.
2020-07-22 13:36:29 +02:00
Robbert van der Helm f5f6f04016 Rearrange the try-catch in the thread handlers
It's a bit clearer this way. I would prefer using jthreads here, but we
would still need this try-catch block since there's no way to cancel
synchronous Boost.Asio socket operations other than closing the socket.
2020-06-20 15:47:30 +02:00
Robbert van der Helm 8202a6b250 Add missing const qualifiers to member functions 2020-06-06 13:44:26 +02:00
Robbert van der Helm 33777d2876 Use same style for optional and avoid double check
I did not know that `std::optional::value()` did checked access. And I
still prefer a more explicit .has_value() over boolean conversion, but
this seems to be the accepted way to do this.
2020-06-05 22:35:56 +02:00
Robbert van der Helm ff298f3f46 Remove redundant conditions
As mentioned in C++ Core Guidelines ES.87.
2020-06-05 22:18:40 +02:00
Robbert van der Helm 890e5b736b Revert "Work around a memory corruption issue on unload"
This reverts commit 0c047f9a66.

This workaround was needed because of the weird threading behavior with
the Win32 APIs, std::thread and winelib. Now that the actual
`active_plugins.erase()` call is done from within the plugin
context/main thread, this hack is no longer needed.
2020-05-29 11:24:56 +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 706b34eeb4 Rearrange order of Win32 and X11 event handling
Should not matter that much, but a potential situation where you would
want to have handled the X11 events first is when the editor enters a
blocking message loop while it is waiting on a GUI component just as the
window gets moved by an external program or window manager.
2020-05-27 15:44:14 +02:00
Robbert van der Helm 5a0c3c4627 Simplify the opening editor behaviour again
This partially reverts 16fce5577d.
2020-05-27 14:05:57 +02:00
Robbert van der Helm 0c047f9a66 Work around a memory corruption issue on unload
I'm really not sure what is happening here, and it might just be a
winelib thing.
2020-05-26 17:09:09 +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 9a35023990 Split X11 and Win32 event handling
X11 events should always be handled since it's thread safe and they
don't block.
2020-05-26 11:11:34 +02:00
Robbert van der Helm 23f15c8d8a Rename the two handle_dispatch functions
To better differentiate between their intended uses.
2020-05-25 15:10:19 +02:00
Robbert van der Helm 85fb3a2588 Conditionally disiable the message loop from
Based on a function. This is needed because the message loop should be
skipped while any of the plugins is opening their GUI, similar to how
`EditorOpening` worked for individually hosted plugins.
2020-05-25 15:04:43 +02:00
Robbert van der Helm 2e68ade2a3 Allow handling events inside of an IO context
This is needed when using multiple plugins since their GUI operations
all have to be run from the same thread.
2020-05-25 14:38:30 +02:00
Robbert van der Helm 9c901935d4 Fix editor GUIs for plugin groups
Handles for things like timers should be unique on a per-thread basis in
the Win32 API, but apparently window classes have to be unique for the
entire application.
2020-05-23 15:09:56 +02:00
Robbert van der Helm 3a9d902c72 Allow all threads to return when sockets close
This was not a problem with individually hosted plugins because the
entire process got terminated at once, but here we all threads to shut
down gracefully when a plugin's sockets get closed. I wish this wouldn't
need all these try-catches, but we're not writing Haskell here.

The only issue remaining is that for some reason only the first
instance's editor works, at least for Serum. This might be because of
the message loop.
2020-05-22 23:22:49 +02:00
Robbert van der Helm bea924c0e1 Make plugin initialization thread safe 2020-05-22 22:42:24 +02:00
Robbert van der Helm 53acb1f78a Move wine-bridge.h -> bridges/vst2.h
This way we can structure the group handling and a potential future VST3
bridge in the same way.
2020-05-18 16:15:07 +02:00