13 Commits

Author SHA1 Message Date
Ashok Sidipotu
27c1ea869b event*.c: add a few more log msgs 2023-08-15 07:14:59 +00:00
Julian Bouzas
19213efa9f event-hook: fix different signedness comparison warning 2023-06-05 15:20:44 -04:00
George Kiagiadakis
4736d56557 log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.

Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.

Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.

Messages coming from GLib are checked inside the handler.

An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 20:42:28 +03:00
George Kiagiadakis
3a23fb451a event-dispatcher: refactor to use before/after dependencies on hooks
* Remove entirely the hook priority numbers and use before/after dependencies
* Split the WpEvent code out of WpEventDispatcher
* Add methods on WpEvent to interface with it from the WpEventDispatcher.
  As a bonus, we can now also implement tooling to inspect which hooks would
  in theory run for an event and write tests around that
* Removed some internal debugging facilities and log calls, will redo it later.
* Using spa_list now for the list of hooks, to reduce the number of allocations
  happening in the "hook collection" algorithm
* Switched some internal data to use g_new0 instead of g_slice_new0
* Added g_free to free WpEvent structures... surprisingly, we were leaking them
  before
2023-04-17 07:48:18 -04:00
George Kiagiadakis
b100bdda4a event-hook: remove the exec type property & enumeration
With the latest changes, we can implement the "after-events" type
with external code that pushes a very low priority event that is
the "rescan" event.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
497f30453d lib: event-hook/dispatcher: constness and staticness fixes 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
33ee9984ed Revert "event-dispatcher: after-events hooks to get the trigger event info"
This reverts commit f97e60a331e72e1c1b79075a9498517628e2a349.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
3ff9f240c8 event-dispatcher: after-events hooks to get the trigger event info
after-events hooks will get the original event triggering it, instead of the
rescan event.

after-events hook can register with any event, but it is called with rescan event
info. This is so because, after-events hook run after all the on-events hooks
are done with and as a part of the rescan event. so it is triggered with rescan
event data, which doesnt carry much info, instead of rescan event, it makes more
sense to call the after-events hook with the original event which triggered it.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
ff833b138d event-dispatcher: log event and hook names and chains
- Add a new variable "name" in WpEventHook and use it to log all the
  hooks(by name) picked up in _push_event(). This gives a clear picture
  if hook is registered for a given event.
- Form a name for an event and a chain of events for an event run, log
  both of them. This gives a clear picture of the events executed and
  order in which they are dispatched.
- Similarly build hooks chain and print it in _source_dispatch(), this
  gives a clear picture of the hooks picked and the order in which they
  are dispatched.
- Log only the dispatchable(with hooks) events, this de-clutters
  the log messages.
2023-04-17 07:47:09 -04:00
George Kiagiadakis
f91ff40a2d simple-event-hook: do not pass the dispatcher as argument to the closure 2023-04-17 07:47:09 -04:00
George Kiagiadakis
795dc240b6 event-hook: add an async event hook implementation
This one uses 2 closures to implement a WpTransition internally
2023-04-17 07:47:09 -04:00
George Kiagiadakis
60e1f320c9 event-hook: use WP_TYPE_EVENT as the type for hook interest
and also accept other types, which will match the type of the
event subject
2023-04-17 07:47:09 -04:00
George Kiagiadakis
9afd588d79 lib: initial version of WpEventDispatcher / WpEvent / WpEventHook 2023-04-17 07:47:09 -04:00