From ebd13a2a74742599ed96ee4e4edd8731196c4854 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 19 Apr 2018 22:01:18 +0200 Subject: [PATCH] loop: blocking wait Release the locks before waiting. --- spa/plugins/support/loop.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index 0dd7cc97d..2dd58873b 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -248,10 +248,15 @@ loop_invoke(struct spa_loop *loop, if (block) { uint64_t count = 1; + + spa_hook_list_call(&impl->hooks_list, struct spa_loop_control_hooks, before); + if (read(impl->ack_fd, &count, sizeof(uint64_t)) != sizeof(uint64_t)) spa_log_warn(impl->log, NAME " %p: failed to read event fd: %s", impl, strerror(errno)); + spa_hook_list_call(&impl->hooks_list, struct spa_loop_control_hooks, after); + res = item->res; } else { @@ -740,7 +745,7 @@ impl_init(const struct spa_handle_factory *factory, spa_ringbuffer_init(&impl->buffer); impl->wakeup = spa_loop_utils_add_event(&impl->utils, wakeup_func, impl); - impl->ack_fd = eventfd(0, EFD_CLOEXEC); + impl->ack_fd = eventfd(0, EFD_SEMAPHORE | EFD_CLOEXEC); spa_log_debug(impl->log, NAME " %p: initialized", impl);