From b3eb4518cb209945b7eb8c3f1572c4cc9d14aa8f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 12 May 2023 15:25:38 +0200 Subject: [PATCH] jack: only emit register notify in pairs Only emit Off when On was sent. --- pipewire-jack/src/pipewire-jack.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index a21888f8e..84fd588cc 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -166,6 +166,7 @@ struct object { struct pw_proxy *proxy; struct spa_hook proxy_listener; struct spa_hook object_listener; + int registered; unsigned int removing:1; unsigned int removed:1; }; @@ -929,6 +930,8 @@ static void emit_callbacks(struct client *c) switch (notify->type) { case NOTIFY_TYPE_REGISTRATION: + if (o->registered == notify->arg1) + break; pw_log_debug("%p: node %u %s %u", c, o->serial, o->node.name, notify->arg1); do_callback(c, registration_callback, true, @@ -937,6 +940,8 @@ static void emit_callbacks(struct client *c) c->registration_arg); break; case NOTIFY_TYPE_PORTREGISTRATION: + if (o->registered == notify->arg1) + break; pw_log_debug("%p: port %u %s %u", c, o->serial, o->port.name, notify->arg1); do_callback(c, portregistration_callback, c->active, @@ -945,6 +950,8 @@ static void emit_callbacks(struct client *c) c->portregistration_arg); break; case NOTIFY_TYPE_CONNECT: + if (o->registered == notify->arg1) + break; pw_log_debug("%p: link %u %u -> %u %u", c, o->serial, o->port_link.src_serial, o->port_link.dst, notify->arg1); @@ -997,9 +1004,12 @@ static void emit_callbacks(struct client *c) default: break; } - if (o != NULL && notify->arg1 == 0 && o->removing) { - o->removing = false; - free_object(c, o); + if (o != NULL) { + o->registered = notify->arg1; + if (notify->arg1 == 0 && o->removing) { + o->removing = false; + free_object(c, o); + } } avail -= sizeof(struct notify); index += sizeof(struct notify);