event-dispatcher: Group after-events-with-event hooks of a session item

after-events-with-event hooks are rendered based on the priority, this means
when a rescan event happens, all the findDefinedTarget hooks(of different
session items) are run first and then all the findDefinedTarget hooks, so on.

This kind of scheduling of hooks was removing the established link between zoom
voice engine and digial mic. Also It is slightly difficult to follow the flow in
the logs.

Instead of arranging the hooks flately based on priority, better scheme to
prioritize them in two layers. First all the hooks for an event or session items
are grouped and with in that group, priority of the hook is honored.

src/scripts/policy-hooks.lua #	modified:   src/scripts/policy-node.lua #
This commit is contained in:
Ashok Sidipotu 2022-09-16 10:40:53 +05:30 committed by Julian Bouzas
parent 89dcd64003
commit 68eaede3e4

View file

@ -471,12 +471,23 @@ event_cmp_func (const WpEvent *a, const WpEvent *b)
}
static gint
hook_cmp_func (const WpEventHookData *a, const WpEventHookData *b)
hook_cmp_func (const WpEventHookData *new_hook, const WpEventHookData *listed_hook)
{
return wp_event_hook_get_priority ((WpEventHook *) b->hook) -
wp_event_hook_get_priority ((WpEventHook *) a->hook);
return wp_event_hook_get_priority ((WpEventHook *) listed_hook->hook) -
wp_event_hook_get_priority ((WpEventHook *) new_hook->hook);
}
static gint
after_events_hook_cmp_func (const WpEventHookData *new_hook,
const WpEventHookData *listed_hook)
{
if (new_hook->event != listed_hook->event)
return G_MININT;
else
return hook_cmp_func (new_hook, listed_hook);
}
static gint
is_hook_present (const WpEventHookData *hook_data, const WpEventHook *hook)
{
@ -527,7 +538,8 @@ wp_event_dispatcher_push_event (WpEventDispatcher * self, WpEvent * event)
hook_data->event = wp_event_ref (event);
self->rescan_event->hooks = g_list_insert_sorted (
self->rescan_event->hooks, hook_data, (GCompareFunc) hook_cmp_func);
self->rescan_event->hooks, hook_data,
(GCompareFunc) after_events_hook_cmp_func);
rescan_hooks_added = true;
wp_debug_object (self, "added after-events-with-event rescan hook"