Commit Graph

1900 Commits

Author SHA1 Message Date
Robbert van der Helm da8f4aae19 Preallocate small vectors for VST3 queues
Events, parameter changes, and the individual queues contained within
the parameter changes all use dynamic memory allocation. Preallocating
some memory for those things inside of the objects may prevent latency
spikes when they those objects are first filled. This is especially
useful for the parameter changes since there's no way to reserve memory
in a vector of vectors.
2021-05-22 23:38:31 +02:00
Robbert van der Helm 90338abe6d Add bitsery trait for Boost.Container small_vector
I was going to implement these myself since we don't need them to be
contiguous like Boost's implementation is, but this is much easier of
course.
2021-05-22 23:25:36 +02:00
Robbert van der Helm 7c49fe739d Use our new custom std::variant bitsery extension
This prevents reinitializing `std::variant`s when the variant we want to
deserialize is already active. We store audio buffers in variants, so
reinitializing them results in a lot of unnecessary memory frees,
allocations and writes during every processing cycle.
2021-05-22 17:51:01 +02:00
Robbert van der Helm 6ee905c79f Add a realtime-safe bitsery extension for variants
I blindly assumed the original implementation also did this, but this
version `std::variant<Ts...>` objects from being reinitialized if we're
deserializing a variant that's also currently active in the object we're
deserializing into. For simple structs this won't make any difference,
but in yabridge we often use variants to differentiate between things
like single precision and double precision audio buffers. Those buffers
are allocated on the heap, so recreating the objects every time we
deserialize them adds a lot of unnecessary overhead.
2021-05-22 17:27:54 +02:00
Robbert van der Helm 88a45e6178 Prevent unnecessary copies during audio processing
We did a ton of work earlier to make sure we can reuse these objects,
but `auto` implies the type is never a reference type, and we were thus
unnecessarily creating copies every iteration, kind of defeating the
purpose of doing all of this in the first place. We could do some
template trickery here, but it's also safe to just make the persistent
object thread local since the actual objects aren't that large.
2021-05-22 16:07:11 +02:00
Robbert van der Helm 549306b295 Include effString2Parameter in opcode list
We don't need any special handling for this since our default argument
detection will handle strings, but it might be useful for log output if
a host ever uses this. At the moment there don't seem to be any hosts on
Linux that use this.
2021-05-21 02:03:27 +02:00
Robbert van der Helm 0e3a4f6d54 Move EventResultPayload to Vst2EventResult::Payload 2021-05-20 15:55:39 +02:00
Robbert van der Helm bd0dd63ad2 Rename the EventResult struct to Vst2EventResult 2021-05-20 15:53:16 +02:00
Robbert van der Helm 2bf41c6fe1 Move EventPayload to Vst2Event::Payload 2021-05-20 15:52:40 +02:00
Robbert van der Helm b1c9d75112 Rename the Event struct to Vst2Event 2021-05-20 15:50:09 +02:00
Robbert van der Helm 0bc91443b0 Remove old Ardour effEditIdle() hack
We no longer pass effEditIdle() to the plugin (we now use a timer to be
more consistent and configurable), so this is not needed anymore.
2021-05-20 15:29:23 +02:00
Robbert van der Helm a96cfc8090 Allow mutual recursion between audioMasterUpdateDisplay and effGetProgram
This prevents Voxengo VST2 plugins from freezing in Renoise when
recalling their state. See the comments in the diff for why this is
necessary.
2021-05-20 15:28:00 +02:00
Robbert van der Helm 808cca3cb2 Always use static const instead of const static 2021-05-20 15:12:44 +02:00
Robbert van der Helm 3e6bf3adfd Allow overriding sending behaviour for VST2 events
Now we can implement mutual recursion for VST2 plugins. Wish we didn't
have to.
2021-05-20 14:49:11 +02:00
Robbert van der Helm ccfda51a69 Clarify the DefaultDataConverter method names 2021-05-20 14:49:11 +02:00
Robbert van der Helm 06bae784a8 Update documentation in passthrough_event()
There were some glaring typos in there. I probably replaced them with
new ones.
2021-05-20 14:31:59 +02:00
Robbert van der Helm 8bfaade2a6 Change wording in the MessageReference bitsery ext
I had to reread the docstrings to remember what `deseerialization_store`
was, so it probably needed a better name.
2021-05-20 14:31:59 +02:00
Robbert van der Helm c2186fa55b Use the std::derived_from concept when applicable
This probably makes things much clearer at a glance instead of using a
blanked typename.
2021-05-20 14:31:59 +02:00
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