From 1c6326439f9343aacd7371eb4327bbc5691a91bf Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Sat, 3 Jul 2021 16:58:20 +0900 Subject: [PATCH] jack: make cycle_wait() loop until a valid cycle pw_data_loop_wait() can return due to activity on another socket, so keep looping until cycle_run() gets a valid command. Fixes #1386 --- pipewire-jack/src/pipewire-jack.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index c82233103..6f33c0c94 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -1182,7 +1182,6 @@ static inline uint32_t cycle_run(struct client *c) struct pw_node_activation *activation = c->activation; struct pw_node_activation *driver = c->rt.driver_activation; - /* this is blocking if nothing ready */ while (true) { if (SPA_UNLIKELY(read(fd, &cmd, sizeof(cmd)) != sizeof(cmd))) { if (errno == EINTR) @@ -1237,13 +1236,18 @@ static inline uint32_t cycle_run(struct client *c) static inline uint32_t cycle_wait(struct client *c) { int res; + uint32_t nframes; - res = pw_data_loop_wait(c->loop, -1); - if (SPA_UNLIKELY(res <= 0)) { - pw_log_warn(NAME" %p: wait error %m", c); - return 0; - } - return cycle_run(c); + do { + res = pw_data_loop_wait(c->loop, -1); + if (SPA_UNLIKELY(res <= 0)) { + pw_log_warn(NAME" %p: wait error %m", c); + return 0; + } + nframes = cycle_run(c); + } while (!nframes); + + return nframes; } static inline void signal_sync(struct client *c)