From 4be368c9576dc6872fde54f18fd4cf3da962f1ad Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 14 Dec 2018 16:35:57 +0100 Subject: [PATCH] media-session: handle dont-reconnect If dont-reconnect is given and a target node, kill the stream when the target node can't be found. --- src/examples/media-session.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/examples/media-session.c b/src/examples/media-session.c index 120901eb1..78ca61ea2 100644 --- a/src/examples/media-session.c +++ b/src/examples/media-session.c @@ -1084,12 +1084,20 @@ static int rescan_node(struct impl *impl, struct node *node) pw_log_debug(NAME " %p: no session found for %d, try node", impl, node->obj.id); n_links = 1; - peer = find_object(impl, find.path_id); - if (peer != NULL && peer->obj.type == PW_TYPE_INTERFACE_Node) { - if (peer->media_type == SPA_MEDIA_TYPE_audio) - goto do_link_profile; - else - goto do_link; + if ((peer = find_object(impl, find.path_id)) != NULL) { + if (peer->obj.type == PW_TYPE_INTERFACE_Node) { + if (peer->media_type == SPA_MEDIA_TYPE_audio) + goto do_link_profile; + else + goto do_link; + } + } + else { + str = spa_dict_lookup(props, "pipewire.dont-reconnect"); + if (str != NULL && pw_properties_parse_bool(str)) { + pw_registry_proxy_destroy(impl->registry_proxy, node->obj.id); + return -ENOENT; + } } } @@ -1101,7 +1109,7 @@ static int rescan_node(struct impl *impl, struct node *node) client = find_object(impl, node->obj.parent_id); if (client && client->obj.type == PW_TYPE_INTERFACE_Client) { pw_client_proxy_error((struct pw_client_proxy*)client->obj.proxy, - node->obj.id, ENOENT, "no session available"); + node->obj.id, -ENOENT, "no session available"); } return -ENOENT; }