mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
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:
+4
-8
@@ -43,14 +43,10 @@ class DefaultDataConverter {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Assume buffers are zeroed out, this is probably not the case
|
||||
// FIXME: Some plugins, such as Fabfilter plugins, don't zero out their
|
||||
// string buffers (such as when calling
|
||||
// `audioMasterGetVendorString` and
|
||||
// `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.
|
||||
// This is a simple fallback that will work in almost every case.
|
||||
// Because some plugins don't zero out their string buffers when sending
|
||||
// host callbacks, we will explicitely list all callbacks that expect a
|
||||
// string in `DispatchDataConverter` adn `HostCallbackDataConverter`.
|
||||
const char* c_string = static_cast<const char*>(data);
|
||||
if (c_string[0] != 0) {
|
||||
return std::string(c_string);
|
||||
|
||||
@@ -241,6 +241,21 @@ class DispatchDataConverter : DefaultDataConverter {
|
||||
break;
|
||||
case effGetMidiKeyName:
|
||||
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:
|
||||
return DefaultDataConverter::read(opcode, index, value, data);
|
||||
break;
|
||||
|
||||
@@ -352,6 +352,13 @@ class HostCallbackDataConverter : DefaultDataConverter {
|
||||
// done inside of `passthrough_event`.
|
||||
return AEffect(*plugin);
|
||||
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:
|
||||
return DefaultDataConverter::read(opcode, index, value, data);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user