13#ifndef __GUI_BACKEND_EVENT_MANAGER_H__
14#define __GUI_BACKEND_EVENT_MANAGER_H__
67#define EVENT_MANAGER (gZrythm->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) mpmc_queue_push_back (q, (void *) x)
76#define event_queue_dequeue_event(q, x) mpmc_queue_dequeue (q, (void **) x)
81#define EVENTS_PUSH(et, _arg) \
83 ZRYTHM_HAVE_UI && EVENT_MANAGER && EVENT_QUEUE \
84 && (!PROJECT || !AUDIO_ENGINE || !AUDIO_ENGINE->exporting) \
85 && EVENT_MANAGER->process_source_id) \
87 ZEvent * _ev = (ZEvent *) object_pool_get (EVENT_MANAGER->obj_pool); \
88 _ev->file = __FILE__; \
89 _ev->func = __func__; \
90 _ev->lineno = __LINE__; \
92 _ev->arg = (void *) (_arg); \
94 zrythm_app->gtk_thread == g_thread_self () \
97 _ev->backtrace = backtrace_get ("", 40, false); \
102 (et) != EventType::ET_PLAYHEAD_POS_CHANGED \
103 && g_thread_self () == zrythm_app->gtk_thread) \
105 g_debug ("pushing UI event " #et " (%s:%d)", __func__, __LINE__); \
107 event_queue_push_back_event (EVENT_QUEUE, _ev); \
111#define EVENTS_PUSH_NOW(et, _arg) \
113 ZRYTHM_HAVE_UI && EVENT_MANAGER && EVENT_QUEUE \
114 && zrythm_app->gtk_thread == g_thread_self () \
115 && (!PROJECT || !AUDIO_ENGINE || !AUDIO_ENGINE->exporting) \
116 && EVENT_MANAGER->process_source_id) \
118 ZEvent * _ev = (ZEvent *) object_pool_get (EVENT_MANAGER->obj_pool); \
119 _ev->file = __FILE__; \
120 _ev->func = __func__; \
121 _ev->lineno = __LINE__; \
123 _ev->arg = (void *) _arg; \
127 _ev->backtrace = backtrace_get ("", 40, false); \
131 if (et != EventType::ET_PLAYHEAD_POS_CHANGED) \
134 "processing UI event now " #et " (%s:%d)", __func__, __LINE__); \
136 event_manager_process_event (EVENT_MANAGER, _ev); \
137 object_pool_return (EVENT_MANAGER->obj_pool, _ev); \
To be used throughout the program.
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.