Commit Graph

15 Commits

Author SHA1 Message Date
Robbert van der Helm 7b3a6af7d1 Use raw pointers for the plugin factory
Since the object cleans up after itself after the smart pointers are
dropped on the host side this would result in a use after free by the
smart pointers.
2020-12-07 18:28:17 +01:00
Robbert van der Helm d79bc3b936 Don't use STL smart pointers with VST3 interfaces
This would cause double frees since those objects are supposed to clean
up after themselves.
2020-12-07 18:28:17 +01:00
Robbert van der Helm 9954282065 Add manual reference counting to GetPluginFactory
Since even though we're passign raw pointers, it's expected that they
are actually `IPtr<T>`s.
2020-12-07 18:28:17 +01:00
Robbert van der Helm 8ea40cd9f9 Rework Vst3MessageHandler::receive_messages
This now takes a regular overloaded function and the visiting is done in
`receive_messages()` itself. This way we can use templates to ensure
that the return type is correct. Otherwise auto will cause issues in the
future when we want to return multiple concrete types from a function
that takes a single variant. The alternative would be both receiving a
variant as a parameter and then returning another variant as a result,
but that is much less type safe.
2020-12-07 18:28:16 +01:00
Robbert van der Helm 7fb8cf97b1 Request factory after setting up callback handlers
Otherwise we'll get a deadlock.
2020-12-07 18:28:16 +01:00
Robbert van der Helm 79c6f02d91 Request and deserialize plugin factory from plugin 2020-12-07 18:28:16 +01:00
Robbert van der Helm d5374e4540 💥 Rework Vst3MessageHandler
- Now allows direct deserialization into existing objects. This will be
  necessary for our VST3 implementations since the interface instances
  we'll deserialize into will not be trivially constructable because
  they have to be able to do callbacks.
- `ControlResponse` and `CallbackResponse` were dropped. These response
  enums are not necessary because of the `T::Response` associated type
  and returning the types directly makes the direct deserialization
  possible.
2020-12-07 18:28:16 +01:00
Robbert van der Helm 426231a22b Avoid potential UB in loggers using composition
This cast would work fine, but any other fields added to those loggers
would be left uninitialized.
2020-12-07 18:28:16 +01:00
Robbert van der Helm c1e7f53cd0 💥 Major refactor of initialization plumbing
To account for the differences in VST2 plugins and VST3 modules we had
to wrap most of our old functions from `src/plugin/utils.h` in a new
`PluginInfo` struct that gathers all of this information while taking
into account the differences between VST2 and VST3 plugins.

With this change things are also a lot more organized. We can just query
the plugin information we need rather than having to store things
separately or having to recalculate things. This also moved the
responsibility of all the weird `WINEPREFIX` behaviour to a single place
instead of having it spread around `utils.pp`, the initialisation
message, and `host-procoess.cpp`.
2020-12-07 18:28:16 +01:00
Robbert van der Helm 0819e9fda9 Request/send config for VST3 plugins
Using the new Vst3MessageHandler.
2020-12-07 18:28:16 +01:00
Robbert van der Helm 2e9b100090 Add handlers for control messages and callbacks 2020-12-07 18:28:16 +01:00
Robbert van der Helm b9e63ea335 Move the host guard handler to PluginBridge 2020-12-07 18:28:16 +01:00
Robbert van der Helm c2d2ac8fbf Inherit Vst3PluginBridge init from PluginBridge 2020-12-07 18:28:16 +01:00
Robbert van der Helm 3c72ab31f8 Shut up clang/ccls 2020-12-07 18:28:16 +01:00
Robbert van der Helm ff2807c939 Add all the boilerplate for the Vst3PluginBridge
And now that I also have an idea of what the communication model will
look like, this can server as a base for instantiating plugins.
2020-12-07 18:28:16 +01:00