From 0055cc613d0099cfb2228f8494ea071c7dc86d63 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 3 Aug 2023 11:43:42 +0200 Subject: [PATCH] jack: always do graph update when link changes Don't make a special event but do the graph change callbacks when a link was notified. Bundle all graph updates together when we can. --- pipewire-jack/src/pipewire-jack.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 67a5ad9c9..3d71f67be 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -928,6 +928,7 @@ static void emit_callbacks(struct client *c) int32_t avail; uint32_t index; struct notify *notify; + bool do_graph = false; if (c->frozen_callbacks != 0 || !c->pending_callbacks) return; @@ -978,11 +979,12 @@ static void emit_callbacks(struct client *c) o->port_link.dst_serial, notify->arg1, c->connect_arg); + + do_graph = true; break; case NOTIFY_TYPE_GRAPH: pw_log_debug("%p: graph", c); - recompute_latencies(c); - do_callback(c, graph_callback, c->active, c->graph_arg); + do_graph = true; break; case NOTIFY_TYPE_BUFFER_FRAMES: pw_log_debug("%p: buffer frames %d", c, notify->arg1); @@ -1033,6 +1035,10 @@ static void emit_callbacks(struct client *c) index += sizeof(struct notify); spa_ringbuffer_read_update(&c->notify_ring, index); } + if (do_graph) { + recompute_latencies(c); + do_callback(c, graph_callback, c->active, c->graph_arg); + } thaw_callbacks(c); pw_log_debug("%p: leave", c); } @@ -3470,8 +3476,8 @@ static void registry_event_global(void *data, uint32_t id, pw_log_info("%p: link %u %u/%u -> %u/%u added", c, o->id, o->port_link.src, o->port_link.src_serial, o->port_link.dst, o->port_link.dst_serial); - queue_notify(c, NOTIFY_TYPE_CONNECT, o, 1, NULL); - queue_notify(c, NOTIFY_TYPE_GRAPH, NULL, 0, NULL); + if (do_emit) + queue_notify(c, NOTIFY_TYPE_CONNECT, o, 1, NULL); break; } emit_callbacks(c); @@ -3525,7 +3531,6 @@ static void registry_event_global_remove(void *data, uint32_t id) o->port_link.src, o->port_link.src_serial, o->port_link.dst, o->port_link.dst_serial); queue_notify(c, NOTIFY_TYPE_CONNECT, o, 0, NULL); - queue_notify(c, NOTIFY_TYPE_GRAPH, NULL, 0, NULL); } else { pw_log_warn("unlink between unknown ports %d and %d", o->port_link.src, o->port_link.dst);