diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 8192570e4..b77be1e74 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -3852,6 +3852,18 @@ int jack_port_monitoring_input (jack_port_t *port) return o->port.monitor_requests > 0; } +static void link_proxy_error(void *data, int seq, int res, const char *message) +{ + int *link_res = data; + *link_res = res; +} + +static const struct pw_proxy_events link_proxy_events = { + PW_VERSION_PROXY_EVENTS, + .error = link_proxy_error, +}; + + SPA_EXPORT int jack_connect (jack_client_t *client, const char *source_port, @@ -3862,13 +3874,14 @@ int jack_connect (jack_client_t *client, struct spa_dict props; struct spa_dict_item items[6]; struct pw_proxy *proxy; + struct spa_hook listener; char val[4][16]; const char *str; - int res; + int res, link_res = 0; - spa_return_val_if_fail(c != NULL, -EINVAL); - spa_return_val_if_fail(source_port != NULL, -EINVAL); - spa_return_val_if_fail(destination_port != NULL, -EINVAL); + spa_return_val_if_fail(c != NULL, EINVAL); + spa_return_val_if_fail(source_port != NULL, EINVAL); + spa_return_val_if_fail(destination_port != NULL, EINVAL); pw_log_debug(NAME" %p: connect %s %s", client, source_port, destination_port); @@ -3906,14 +3919,27 @@ int jack_connect (jack_client_t *client, PW_VERSION_LINK, &props, 0); + if (proxy == NULL) { + res = -errno; + goto exit; + } + + spa_zero(listener); + pw_proxy_add_listener(proxy, &listener, &link_proxy_events, &link_res); + res = do_sync(c); + spa_hook_remove(&listener); + + if (link_res < 0) + res = link_res; + pw_proxy_destroy(proxy); exit: pw_thread_loop_unlock(c->context.loop); - return res; + return -res; } SPA_EXPORT @@ -3957,7 +3983,7 @@ int jack_disconnect (jack_client_t *client, exit: pw_thread_loop_unlock(c->context.loop); - return res; + return -res; } SPA_EXPORT @@ -3985,7 +4011,7 @@ int jack_port_disconnect (jack_client_t *client, jack_port_t *port) pw_thread_loop_unlock(c->context.loop); - return res; + return -res; } SPA_EXPORT