mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Factor out the serializer for event payloads
This commit is contained in:
+17
-14
@@ -138,6 +138,22 @@ struct NeedsBuffer {};
|
|||||||
using EventPayload =
|
using EventPayload =
|
||||||
std::variant<std::nullptr_t, std::string, DynamicVstEvents, NeedsBuffer>;
|
std::variant<std::nullptr_t, std::string, DynamicVstEvents, NeedsBuffer>;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s, EventPayload& payload) {
|
||||||
|
s.ext(payload, bitsery::ext::StdVariant{
|
||||||
|
[](S&, std::nullptr_t&) {},
|
||||||
|
[](S& s, std::string& string) {
|
||||||
|
s.text1b(string, max_string_length);
|
||||||
|
},
|
||||||
|
[](S& s, DynamicVstEvents& events) {
|
||||||
|
s.container(events.events, max_midi_events,
|
||||||
|
[](S& s, VstEvent& event) {
|
||||||
|
s.container1b(event.dump);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[](S&, NeedsBuffer&) {}});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event as dispatched by the VST host. These events will get forwarded to
|
* An event as dispatched by the VST host. These events will get forwarded to
|
||||||
* the VST host process running under Wine. The fields here mirror those
|
* the VST host process running under Wine. The fields here mirror those
|
||||||
@@ -173,20 +189,7 @@ struct Event {
|
|||||||
s.value8b(value);
|
s.value8b(value);
|
||||||
s.value4b(option);
|
s.value4b(option);
|
||||||
|
|
||||||
// I couldn't get this serializer to work seperately without
|
s.object(payload);
|
||||||
// `EventPayload` in a struct
|
|
||||||
s.ext(payload, bitsery::ext::StdVariant{
|
|
||||||
[](S&, std::nullptr_t&) {},
|
|
||||||
[](S& s, std::string& string) {
|
|
||||||
s.text1b(string, max_string_length);
|
|
||||||
},
|
|
||||||
[](S& s, DynamicVstEvents& events) {
|
|
||||||
s.container(events.events, max_midi_events,
|
|
||||||
[](S& s, VstEvent& event) {
|
|
||||||
s.container1b(event.dump);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[](S&, NeedsBuffer&) {}});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ intptr_t HostBridge::dispatch(AEffect* /*plugin*/,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Maybe reuse buffers here when dealing with chunk data
|
||||||
return send_event<DispatchDataConverter>(
|
return send_event<DispatchDataConverter>(
|
||||||
host_vst_dispatch, opcode, index, value, data, option,
|
host_vst_dispatch, opcode, index, value, data, option,
|
||||||
std::pair<Logger&, bool>(logger, true));
|
std::pair<Logger&, bool>(logger, true));
|
||||||
|
|||||||
Reference in New Issue
Block a user