Add a way to retrieve clap_event_header_t*s

This sets the correct pointer in the SysEx events just before returning
them.
This commit is contained in:
Robbert van der Helm
2022-10-01 15:57:06 +02:00
parent 72e2a9c9f7
commit 7e5bc6b07b
2 changed files with 42 additions and 13 deletions
+20 -13
View File
@@ -238,6 +238,12 @@ struct alignas(16) Event {
*/
static std::optional<Event> parse(const clap_event_header_t& generic_event);
/**
* Get the `clap_event_header_t*` representation for this event. The pointer
* is valid as long as this struct isn't moved.
*/
const clap_event_header_t* get() const;
/**
* The actual event data. These also contain the header because storing the
* entire `clap_event_*_t` struct is the only way to serialize the event
@@ -247,19 +253,20 @@ struct alignas(16) Event {
* `clap_input_events::get()`, but that would cause unexpected lifetime
* issues.
*/
std::variant<payload::Note,
payload::NoteExpression,
payload::ParamValue,
payload::ParamMod,
payload::ParamGesture,
// Most events are about the same length, but having the
// transport in here sadly doubles this struct's size
// TODO: Pack the events at some point, this will require
// special handling for SysEx events
payload::Transport,
payload::Midi,
payload::MidiSysex,
payload::Midi2>
mutable std::variant<
payload::Note,
payload::NoteExpression,
payload::ParamValue,
payload::ParamMod,
payload::ParamGesture,
// Most events are about the same length, but having the transport in
// here sadly doubles this struct's size
// TODO: Pack the events at some point, this will require special
// handling for SysEx events
payload::Transport,
payload::Midi,
payload::MidiSysex,
payload::Midi2>
payload;
template <typename S>