Commit Graph

1882 Commits

Author SHA1 Message Date
Robbert van der Helm 626c31beb3 Update documentation on mutual recursion functions 2021-05-20 14:00:03 +02:00
Robbert van der Helm a194765696 Rename EventHandler to Vst2EventHandler 2021-05-20 13:54:31 +02:00
Robbert van der Helm e4ca520b64 💥 Redo all higher order template functions
This does what we did for a few functions in the last few commits for
every function. We now use either the `std::invocable` concept or our
own `invocable_returning` concept wherever possible to make sure we pass
function types to these template functions, since constraint errors are
a lot more readable than template deduction errors. And instead of
having to specify the return type as a template argument, we now just
use `std::invoke_result_t<F>` instead. The VST3 message handling
functions are still using the good old `typename F` since those are
overloaded polymorphic functions. This was also a good moment to modify
`AdHocSocketHandler::send()` to allow functions returning void (this got
rid of an old fixme where we had to return some dummy value from a
function instead of just not returning anything).
2021-05-20 01:03:58 +02:00
Robbert van der Helm 6c58f4e305 Fix the return type constraint
Apparently T is only convertible to T if it can be copy constructed.
2021-05-20 00:10:00 +02:00
Robbert van der Helm 35cc47d021 Add a concept for invocables with a return type
Because for some reason this is not part of the standard library.
2021-05-19 23:30:42 +02:00
Robbert van der Helm 57d7141681 Remove redundant template arguments in MainContext 2021-05-19 22:56:37 +02:00
Robbert van der Helm 398ae789e0 Use MutualRecursionHelper in the VST3 plugin
We should tidy all of these functions up a bit and then implement this
for the VST2 bridging on the Wine side.
2021-05-19 19:57:21 +02:00
Robbert van der Helm 11cfd15308 Use MutualRecursionHelper in the Wine VST3 bridge 2021-05-19 19:36:44 +02:00
Robbert van der Helm 53794f94bf Encapsulate the mutual recursion behaviour
As it turns out, we'll sadly also need this for VST2 plugins on the Wine
side, so we should probably finally encapsulate this instead of
duplicating it a third time.
2021-05-19 19:36:44 +02:00
Robbert van der Helm 4d256e12e2 Fix a typo in the issue template contact links 2021-05-18 23:01:48 +02:00
Robbert van der Helm e5bfb56756 Mention the disable_pipes option in the changelog
I somehow forgot to do this in the last commit.
2021-05-18 22:57:41 +02:00
Robbert van der Helm 95badeb1bc Add a way to disable pipes for the Wine host
For some reason ujam plugins (and other plugins made with the Gorilla
Engine, like the LoopCloud plugins) will throw a `JS_EXEC_FAILED` error
when trying to load the plugin while either of the STDOUT or STDERR
streams is pointing to a pipe. Simply redirecting the output to a file
fixes this. By default we'll write the output to
`<temporary_directory>/yabridge-plugin-output.log`, but you can also set
the new `disable_pipes` option to `"/dev/null"` to completely throw away
all output.

This addresses #47.
2021-05-18 17:59:43 +02:00
Robbert van der Helm 99428ba28e Unify STDIO redirection in Wine host launching
This may also fix some weird cases where everything appeared to work
fine, but where the file descriptors weren't actually assigned
correctly. Not sure what that happened, but it with carla-single the
Wine host's STDOUT and STDERR would still point to the orignal pty even
though everything still went through the pipes.
2021-05-18 15:35:33 +02:00
Robbert van der Helm f7901266b7 Use STDERR for all output in the Wine plugin hosts 2021-05-18 13:39:49 +02:00
Robbert van der Helm 09c2ed96ad Fix Win32Thread trampoline since last commit
In e974d1d2b1 we added the forward, and
that will of course cause us to capture references instead of moved
functions again.
2021-05-17 01:31:16 +02:00
Robbert van der Helm e974d1d2b1 Use perfect forwarding in templates where possible 2021-05-17 01:02:45 +02:00
Robbert van der Helm 883b6b7700 Manually close descriptors instead of using vfork
With `vfork()` the child process inherits the parents process image and
prevents copying them, but if it outlives its parent then the file
descriptors will still remain open. Manually closing all file
descriptors is the only solution here.

This was only an issue with Ardour since they don't open all of their
files with `FD_CLOEXEC`. Last update's watchdog timer somewhat mitigated
the issue, but Ardour should now no longer freeze when reopening because
of this. The watchdog timer is still necessary, since hanging Wine
processes will still prevent the Wine server from shutting down.
2021-05-16 15:28:53 +02:00
Robbert van der Helm 448243050a Always serialize in little-endian and skip checks
These checks are not necessary since we can trust ourselves to not try
to cause any buffer overflows.
2021-05-16 13:15:14 +02:00
Robbert van der Helm 4b5cb3e205 Initialize thread locals later
This shouldn't be necessary, but maybe this helps with the issue where
the optional is suddenly a nullopt.
2021-05-16 01:36:17 +02:00
Robbert van der Helm 7b005eed7f Also use mutual recursion for creating instances
We were having similar clashes like the one we fixed in the last commit
here.
2021-05-16 01:20:39 +02:00
Robbert van der Helm 37d706df63 Handle mutual recursion on plugin side globally
This makes much more sense, since all plugin instances will be sharing a
single GUI thread. What would happen was that resize calls from one
instance and GUI thread function calls from another instance would
collide. Using a single shared mutual recursion mechanism (just like on
the Wine side) fixes this.
2021-05-16 01:17:04 +02:00
Robbert van der Helm 9696e96564 Forcefully initialize the thread local object
Not sure why the initialization wouldn't work, but apparently in some
cases it doesn't. This will still only be initialized once, hopefully.
2021-05-16 00:46:25 +02:00
Robbert van der Helm fc04e2edcb Properly initialize the thread local objects
Instead of doing assignment. Assignment will probably reinitialize every
cycle, and it also didn't work on one person's computer.
2021-05-16 00:30:46 +02:00
Robbert van der Helm 70a546d160 Handle setting channel infos as mutually recursive
This was causing a timing issue with DMG plugins where the plugins would
try to resize after receiving new state (and not during the call), while
REAPER at the same time would try to set channel context information on
the plugin (which also has to be handled on the GUI thread).
2021-05-15 23:47:07 +02:00
Robbert van der Helm 171d8facee [yabridgectl] Improve the Wine check warning
This can also fail if you're using a version of yabridge that was
compiled against more recent libraries.
2021-05-15 23:03:23 +02:00
Robbert van der Helm 52cbc35867 [yabridgectl] Downgrade textwrap again
Partially reverts f02b9e646b. Newer
versions don't take the indentation into account when wrapping.
2021-05-15 22:47:06 +02:00
Robbert van der Helm 0df900647c Add back the recommendation for preferring VST3
This was removed in 4a92034620 after the
VST2 callback prefetching from yabridge 3.2.0. Now with the recent VST3
optimizations, VST3 plugins always outperform VST2 plugins on my system
even when using plugin groups for the VST2 version (and not having to
use plugin groups is of course another good reason to prefer VST3).
2021-05-14 18:39:32 +02:00
Robbert van der Helm a9643577fd Also add noexcept qualifications on the Wine side
See the last few commits.
2021-05-14 18:27:19 +02:00
Robbert van der Helm 37257298a1 Add noexcept qualifications on the plugin side
See the last few commits.
2021-05-14 18:22:58 +02:00
Robbert van der Helm 8ba6e4a937 Noexcept qualify the VST3 proxy implementations
For the same reasons mentioned in the last commit.
2021-05-14 17:30:05 +02:00
Robbert van der Helm 59ba2aeb5f Add noexcept qualifications in src/common
Apparently this can actually make a difference in some cases, and the
C++ Core Guideliens recommend doing this on all default constructors,
destructors, and all functions that can not throw (and thus also don't
allocate).
2021-05-14 17:12:24 +02:00
Robbert van der Helm db6ecdbbd4 Also define the shobjidl.h define globally
This was needed for Wine 6.2.
2021-05-11 02:27:43 +02:00
Robbert van der Helm af299f3c66 Always define NOMINMAX and friends globally
Repeating this every time is worse than defining them in the compiler
command line.
2021-05-11 02:27:43 +02:00
Robbert van der Helm 5577c4bfd8 Fix build on Wine 6.8 #103
Wine dropped `WINE_NOWINSOCK`, so now we sadly have to define this
globally instead.
2021-05-11 02:27:38 +02:00
Robbert van der Helm f1d7b7bf57 Avoid allocations in VST3 process response
This is very ugly so hopefully I can think of a neater way, but now the
response object is just a set of pointers, so we can avoid all copies
and moves on the Wine side.
2021-05-07 19:24:28 +02:00
Robbert van der Helm 93b8643cba Avoid allocations when reconstructing process data 2021-05-07 18:21:30 +02:00
Robbert van der Helm 814d3c688c Fix the VST3 audio processing sending buffers
Making these thread local statics makes much more sense for their
purpose. The old approach technically wasn't thread safe (even if it was
never an issue) and this gets rid of a data structure.
2021-05-07 17:41:42 +02:00
Robbert van der Helm 671587f981 Further reduce allocations by reusing responses
On the plugin's side, still need to do a lot of work on the Wine side of
things.
2021-05-07 17:00:43 +02:00
Robbert van der Helm fcaac219a6 💥 Reduce allocations in VST3 audio sockets
We do this by using this new `MessageReference<T>` type to avoid copying
our `YaAudioProcessor::Process` struct and the contained `YaProcessData`
object. This is only part of the work, but this redesign lets us keep
the these objects alive on both the plugin and the host side. On the
plugin side, we'll simply serialize the data from the referred to object
without copying it. On the Wine side, we'll write the data to a
persistent thread local object, and then reassign the
`MessageReference<T>` to point to that object. This lets us serialize
'references', thus avoiding potentially expensive allocations. With
these last few changes alone VST3 plugins are already at the same
performance level as our optimized VST2 plugin groups.
2021-05-07 16:32:08 +02:00
Robbert van der Helm d08ec70f2c Add a bitsery adapter for MessageReference<T>
This lets us deserialize into an actual persistent object and then
reassign the reference to point to that object.
2021-05-07 16:23:04 +02:00
Robbert van der Helm c6fc24f210 Add a reference wrapper for VST3 message objects
This is kind of equivalent to `std::reference_wrapper`, but with default
initialization support (which is UB, but is required for serialization)
and a forward for `T::Response` as used by your sockets API.
2021-05-07 16:21:48 +02:00
Robbert van der Helm 578259a002 Fix the canProcessSampleSize() cache
This is what you get for carelessly copying and pasting.
2021-05-06 18:55:01 +02:00
Robbert van der Helm b6f96fc920 Cache IAudioProcessor::canProcessSampleSize() 2021-05-06 18:32:46 +02:00
Robbert van der Helm 8f310ed89b Rename ParameterInfoCache to be more general 2021-05-06 18:16:33 +02:00
Robbert van der Helm a9a7e3e711 Note that objects in audio sockets doesn't work 2021-05-06 18:05:10 +02:00
Robbert van der Helm 9f5066a293 Avoid allocations when reading VST3 process data
On the plugin side. We still need to do a lot of optimizations
elsewhere.
2021-05-06 17:50:41 +02:00
Robbert van der Helm 0b173ecba8 Reuse objects in the VST3 audio processor sockets
This means that, we're now receiving into an existing `YaProcessData`
object, which should reduce the number of allocations on the Wine side
considerably. Next we should also reuse the `YaProcessDataResponse`
object.
2021-05-06 16:41:11 +02:00
Robbert van der Helm 6231ab7816 Reuse YaProcessData object on the plugin side
Well, kind of. This doesn't do anything yet since the default assignment
operator will just destroy and recreate objects as normal.
2021-05-06 16:34:23 +02:00
Robbert van der Helm e3f65374f4 Add downgrade instructions for Wine Staging 6.4
And the general recommendation to stick with this version for the time
being.
2021-05-06 12:49:07 +02:00
Robbert van der Helm 9424c36993 Temporarily memoize IPlugView::canResize()
This makes VST3 plugin resizing more responsive, because this function
would otherwise be constantly running in lockstep from the GUI thread.
2021-05-05 19:44:44 +02:00