MCPcopy Create free account
hub / github.com/DISTRHO/DPF / ClapEventQueue

Class ClapEventQueue

distrho/src/DistrhoPluginCLAP.cpp:76–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74typedef std::map<const String, String> StringMap;
75
76struct ClapEventQueue
77{
78 #if DISTRHO_PLUGIN_HAS_UI
79 enum EventType {
80 kEventGestureBegin,
81 kEventGestureEnd,
82 kEventParamSet
83 };
84
85 struct Event {
86 EventType type;
87 uint32_t index;
88 float value;
89 };
90
91 struct Queue {
92 RecursiveMutex lock;
93 uint allocated;
94 uint used;
95 Event* events;
96
97 Queue()
98 : allocated(0),
99 used(0),
100 events(nullptr) {}
101
102 ~Queue()
103 {
104 delete[] events;
105 }
106
107 void addEventFromUI(const Event& event)
108 {
109 const RecursiveMutexLocker crml(lock);
110
111 if (events == nullptr)
112 {
113 events = static_cast<Event*>(std::malloc(sizeof(Event) * 8));
114 allocated = 8;
115 }
116 else if (used + 1 > allocated)
117 {
118 allocated = used * 2;
119 events = static_cast<Event*>(std::realloc(events, sizeof(Event) * allocated));
120 }
121
122 std::memcpy(&events[used++], &event, sizeof(Event));
123 }
124 } fEventQueue;
125
126 #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
127 SmallStackBuffer fNotesBuffer;
128 #endif
129 #endif
130
131 #if DISTRHO_PLUGIN_WANT_PROGRAMS
132 uint32_t fCurrentProgram;
133 #endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected