13#ifndef __GUI_BACKEND_EVENT_MANAGER_H__
14#define __GUI_BACKEND_EVENT_MANAGER_H__
67#define EVENT_MANAGER (ZRYTHM->event_manager)
70#define EVENT_QUEUE (EVENT_MANAGER->mqueue)
72#define EVENT_MANAGER_MAX_EVENTS 4000
74#define event_queue_push_back_event(q, x) \
75 mpmc_queue_push_back (q, (void *) x)
77#define event_queue_dequeue_event(q, x) \
78 mpmc_queue_dequeue (q, (void *) x)
83#define EVENTS_PUSH(et, _arg) \
85 ZRYTHM_HAVE_UI && EVENT_MANAGER && EVENT_QUEUE \
86 && (!PROJECT || !AUDIO_ENGINE || !AUDIO_ENGINE->exporting) \
87 && EVENT_MANAGER->process_source_id) \
89 ZEvent * _ev = (ZEvent *) object_pool_get ( \
90 EVENT_MANAGER->obj_pool); \
91 _ev->file = __FILE__; \
92 _ev->func = __func__; \
93 _ev->lineno = __LINE__; \
95 _ev->arg = (void *) (_arg); \
97 zrythm_app->gtk_thread \
101 _ev->backtrace = backtrace_get ("", 40, false); \
106 (et) != ET_PLAYHEAD_POS_CHANGED \
107 && g_thread_self () == zrythm_app->gtk_thread) \
110 "pushing UI event " #et " (%s:%d)", __func__, \
113 event_queue_push_back_event (EVENT_QUEUE, _ev); \
117#define EVENTS_PUSH_NOW(et, _arg) \
119 ZRYTHM_HAVE_UI && EVENT_MANAGER && EVENT_QUEUE \
120 && zrythm_app->gtk_thread == g_thread_self () \
121 && (!PROJECT || !AUDIO_ENGINE || !AUDIO_ENGINE->exporting) \
122 && EVENT_MANAGER->process_source_id) \
124 ZEvent * _ev = (ZEvent *) object_pool_get ( \
125 EVENT_MANAGER->obj_pool); \
126 _ev->file = __FILE__; \
127 _ev->func = __func__; \
128 _ev->lineno = __LINE__; \
130 _ev->arg = (void *) _arg; \
134 _ev->backtrace = backtrace_get ("", 40, false); \
138 if (et != ET_PLAYHEAD_POS_CHANGED) \
141 "processing UI event now " #et " (%s:%d)", \
142 __func__, __LINE__); \
144 event_manager_process_event (EVENT_MANAGER, _ev); \
145 object_pool_return (EVENT_MANAGER->obj_pool, _ev); \
void event_manager_process_event(EventManager *self, ZEvent *ev)
Processes the given event.
void event_manager_process_now(EventManager *self)
Processes the events now.
void event_manager_start_events(EventManager *self)
Starts accepting events.
EventManager * event_manager_new(void)
Creates the event queue and starts the event loop.
void event_manager_stop_events(EventManager *self)
Stops events from getting fired.
void event_manager_remove_events_for_obj(EventManager *self, void *obj)
Removes events where the arg matches the given object.
Multiple Producer Multiple Consumer lock-free queue.
Thread-safe object pool implementation.
Event manager for the UI.
guint process_source_id
ID of the event processing source func.
bool pending_soft_recalc
A soft recalculation of the routing graph is pending.
ObjectPool * obj_pool
Object pool of event structs to avoid real time allocation.
GPtrArray * events_arr
Events array to use during processing.
MPMCQueue * mqueue
Event queue, mainly for GUI events.
Multiple Producer Multiple Consumer lock-free queue.
To be used throughout the program.