Work around improperly late initializing plugins

This fixes the Roland Cloud plugins.
This commit is contained in:
Robbert van der Helm
2020-05-10 13:42:20 +02:00
parent ba91971829
commit 686ca11ba8
5 changed files with 53 additions and 7 deletions
+19 -2
View File
@@ -229,8 +229,9 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
class DispatchDataConverter : DefaultDataConverter {
public:
DispatchDataConverter(std::vector<uint8_t>& chunk_data,
AEffect& plugin,
VstRect& editor_rectangle)
: chunk(chunk_data), rect(editor_rectangle) {}
: chunk(chunk_data), plugin(plugin), rect(editor_rectangle) {}
EventPayload read(const int opcode,
const int index,
@@ -239,6 +240,13 @@ class DispatchDataConverter : DefaultDataConverter {
// There are some events that need specific structs that we can't simply
// serialize as a string because they might contain null bytes
switch (opcode) {
case effOpen:
// This should not be needed, but some improperly coded plugins
// such as the Roland Cloud plugins will initialize part of
// their `AEffect` only after the host calls `effOpen`, instead
// of during the initialization.
return WantsAEffectUpdate{};
break;
case effEditGetRect:
return WantsVstRect();
break;
@@ -325,6 +333,14 @@ class DispatchDataConverter : DefaultDataConverter {
void write(const int opcode, void* data, const EventResult& response) {
switch (opcode) {
case effOpen: {
// Update our `AEffect` object one last time for improperly
// coded late initialing plugins. Hopefully the host will see
// that the object is updated because these plugins don't send
// any notification about this.
const auto updated_plugin = std::get<AEffect>(response.payload);
update_aeffect(plugin, updated_plugin);
} break;
case effEditGetRect: {
// Write back the (hopefully) updated editor dimensions
const auto new_rect = std::get<VstRect>(response.payload);
@@ -423,6 +439,7 @@ class DispatchDataConverter : DefaultDataConverter {
private:
std::vector<uint8_t>& chunk;
AEffect& plugin;
VstRect& rect;
};
@@ -449,7 +466,7 @@ intptr_t PluginBridge::dispatch(AEffect* /*plugin*/,
return 0;
}
DispatchDataConverter converter(chunk_data, editor_rectangle);
DispatchDataConverter converter(chunk_data, plugin, editor_rectangle);
switch (opcode) {
case effClose: {