jack: improve running check

When we get a node info about our own state, we can use the active state
of the node to decide if we are running or not.

Otherwise, we will try to hide ports from JACK clients that suspend
(while still active).

See #3794
This commit is contained in:
Wim Taymans 2024-01-24 12:08:00 +01:00
parent c298d7faef
commit 13511e9295

View file

@ -3241,18 +3241,28 @@ static const struct pw_proxy_events proxy_events = {
.destroy = proxy_destroy,
};
static bool node_is_active(struct client *c, struct object *n)
{
return !n->node.is_jack ||
(c->node_id == n->id ? c->active : n->node.is_running);
}
static void node_info(void *data, const struct pw_node_info *info)
{
struct object *n = data;
struct client *c = n->client;
const char *str;
bool active;
if (info->change_mask & PW_NODE_CHANGE_MASK_PROPS) {
str = spa_dict_lookup(info->props, PW_KEY_NODE_ALWAYS_PROCESS);
/* JACK clients always need ALWAYS_PROCESS=true or else they don't
* conform to the JACK API. We would try to hide the ports of
* PAUSED JACK clients, for example, even if they are active. */
const char *str = spa_dict_lookup(info->props, PW_KEY_NODE_ALWAYS_PROCESS);
n->node.is_jack = str ? spa_atob(str) : false;
}
n->node.is_running = !n->node.is_jack || (info->state == PW_NODE_STATE_RUNNING);
n->node.is_running = info->state == PW_NODE_STATE_RUNNING;
active = node_is_active(c, n);
pw_log_debug("DSP node %d %08"PRIx64" jack:%u state change %s running:%d", info->id,
info->change_mask, n->node.is_jack,
@ -3264,7 +3274,7 @@ static void node_info(void *data, const struct pw_node_info *info)
if (p->type != INTERFACE_Port || p->removed ||
p->port.node_id != info->id)
continue;
if (n->node.is_running)
if (active)
queue_notify(c, NOTIFY_TYPE_PORTREGISTRATION, p, 1, NULL);
else {
spa_list_for_each(l, &c->context.objects, link) {
@ -3492,7 +3502,7 @@ static void registry_event_global(void *data, uint32_t id,
o->port.latency[SPA_DIRECTION_INPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_INPUT);
o->port.latency[SPA_DIRECTION_OUTPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_OUTPUT);
do_emit = !ot->node.is_jack || ot->node.is_running;
do_emit = node_is_active(c, ot);
o->proxy = pw_registry_bind(c->registry,
id, type, PW_VERSION_PORT, 0);