mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
loop: simplify before and after events
Because the signal can't be removed from the callback we can simply iterate backwards and then forwards. The first added hook (the unlock/lock pair) is called last before going into the poll and first when leaving. This executes all other callbacks inside a locked situation. And removing them with the lock is not going to cause problems.
This commit is contained in:
parent
854d019343
commit
e5f7e040dc
3 changed files with 28 additions and 16 deletions
|
|
@ -278,24 +278,13 @@ static int loop_iterate(void *object, int timeout)
|
|||
struct impl *impl = object;
|
||||
struct spa_loop *loop = &impl->loop;
|
||||
struct spa_poll_event ep[32];
|
||||
struct spa_list save;
|
||||
struct spa_hook *hook;
|
||||
int i, nfds;
|
||||
|
||||
spa_list_init(&save);
|
||||
spa_list_consume(hook, &impl->hooks_list.list, link) {
|
||||
spa_list_remove(&hook->link);
|
||||
spa_list_prepend(&save, &hook->link);
|
||||
spa_callbacks_call(&hook->cb, struct spa_loop_control_hooks, before, 0);
|
||||
}
|
||||
spa_loop_control_hook_before(&impl->hooks_list);
|
||||
|
||||
nfds = spa_system_pollfd_wait(impl->system, impl->poll_fd, ep, SPA_N_ELEMENTS(ep), timeout);
|
||||
|
||||
spa_list_consume(hook, &save, link) {
|
||||
spa_list_remove(&hook->link);
|
||||
spa_list_append(&impl->hooks_list.list, &hook->link);
|
||||
spa_callbacks_call(&hook->cb, struct spa_loop_control_hooks, after, 0);
|
||||
}
|
||||
spa_loop_control_hook_after(&impl->hooks_list);
|
||||
|
||||
if (SPA_UNLIKELY(nfds < 0))
|
||||
return nfds;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue