Use a template argument for serializing behaviour

This keeps it a bit more readable.
This commit is contained in:
Robbert van der Helm
2020-03-09 20:13:08 +01:00
parent 10b6121cb8
commit adf33e84a8
5 changed files with 86 additions and 87 deletions
+19 -2
View File
@@ -138,6 +138,22 @@ HostBridge::HostBridge(audioMasterCallback host_callback)
plugin = read_object(vst_host_aeffect, plugin);
}
struct DispatchDataConverter : DefaultDataConverter {
EventPayload operator()(int opcode, void* data) {
// There are some events that need specific structs that we can't simply
// serialize as a string because they might contain null bytes
// TODO: More of these structs
switch (opcode) {
case effProcessEvents:
return DynamicVstEvents(*static_cast<VstEvents*>(data));
break;
default:
return DefaultDataConverter{}(opcode, data);
break;
}
}
};
/**
* Handle an event sent by the VST host. Most of these opcodes will be passed
* through to the winelib VST host.
@@ -167,8 +183,9 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
break;
}
return send_event(host_vst_dispatch, true, opcode, index, value, data,
option, &logger);
return send_event<DispatchDataConverter>(
host_vst_dispatch, opcode, index, value, data, option,
std::pair<Logger&, bool>(logger, true));
}
void HostBridge::process_replacing(AEffect* /*plugin*/,