Explicitly list opcodes that should return strings

The automatic detection works fine in every case I've tested other than
Fabfilter plugins, but this is probably for the best.
This commit is contained in:
Robbert van der Helm
2020-04-30 20:55:49 +02:00
parent 4f2058da7d
commit 6266072641
3 changed files with 26 additions and 8 deletions
+4 -8
View File
@@ -43,14 +43,10 @@ class DefaultDataConverter {
return nullptr; return nullptr;
} }
// Assume buffers are zeroed out, this is probably not the case // This is a simple fallback that will work in almost every case.
// FIXME: Some plugins, such as Fabfilter plugins, don't zero out their // Because some plugins don't zero out their string buffers when sending
// string buffers (such as when calling // host callbacks, we will explicitely list all callbacks that expect a
// `audioMasterGetVendorString` and // string in `DispatchDataConverter` adn `HostCallbackDataConverter`.
// `audioMasterGetProductString`). We'll have to either manually
// specify which opcodes are expected to be strings or always
// write back changed strings. I think the first choice is
// cleaner.
const char* c_string = static_cast<const char*>(data); const char* c_string = static_cast<const char*>(data);
if (c_string[0] != 0) { if (c_string[0] != 0) {
return std::string(c_string); return std::string(c_string);
+15
View File
@@ -241,6 +241,21 @@ class DispatchDataConverter : DefaultDataConverter {
break; break;
case effGetMidiKeyName: case effGetMidiKeyName:
return *static_cast<const VstMidiKeyName*>(data); return *static_cast<const VstMidiKeyName*>(data);
// Any VST host I've encountered has properly zeroed out these their
// string buffers, but we'll add a list of opcodes that should
// return a string just in case `DefaultDataConverter::read()` can't
// figure it out.
case effGetProgramName:
case effGetParamLabel:
case effGetParamDisplay:
case effGetParamName:
case effGetProgramNameIndexed:
case effGetEffectName:
case effGetVendorString:
case effGetProductString:
case effShellGetNextPlugin:
return WantsString{};
break;
default: default:
return DefaultDataConverter::read(opcode, index, value, data); return DefaultDataConverter::read(opcode, index, value, data);
break; break;
+7
View File
@@ -352,6 +352,13 @@ class HostCallbackDataConverter : DefaultDataConverter {
// done inside of `passthrough_event`. // done inside of `passthrough_event`.
return AEffect(*plugin); return AEffect(*plugin);
break; break;
// We detect whether an opcode should return a string by checking
// whether there's a zeroed out buffer behind the void pointer. This
// works for any host, but not all plugins zero out their buffers.
case audioMasterGetVendorString:
case audioMasterGetProductString:
return WantsString{};
break;
default: default:
return DefaultDataConverter::read(opcode, index, value, data); return DefaultDataConverter::read(opcode, index, value, data);
break; break;