ladishd: set vgraph for new ports and use it when port disappears or gets renamed

This commit is contained in:
Nedko Arnaudov 2010-11-03 00:13:34 +02:00
parent f3a59a3561
commit 7d3acd7331
1 changed files with 8 additions and 12 deletions

View File

@ -642,6 +642,10 @@ port_appeared(
/* set port jack id so invisible connections to/from it can be restored */
ladish_port_set_jack_id(port, port_id);
/* for normal ports, one can find the vgraph through the jack client,
but for a2j ports the jack client is shared between graphs */
ladish_port_set_vgraph(port, vgraph);
if (!ladish_graph_add_port(virtualizer_ptr->jack_graph, jack_client, port, jack_port_name, type, flags, false))
{
log_error("ladish_graph_add_port() failed.");
@ -813,7 +817,7 @@ static void port_disappeared(void * context, uint64_t client_id, uint64_t port_i
/* find the virtual graph that owns the app that owns the client that owns the disappeared port */
jmcore = false;
vgraph = ladish_client_get_vgraph(jclient);
vgraph = ladish_port_get_vgraph(port);
if (vgraph == NULL)
{
vgraph = find_link_port_vgraph_by_uuid(virtualizer_ptr, ladish_graph_get_port_name(virtualizer_ptr->jack_graph, port), NULL);
@ -869,22 +873,11 @@ static void port_disappeared(void * context, uint64_t client_id, uint64_t port_i
static void port_renamed(void * context, uint64_t client_id, uint64_t port_id, const char * old_port_name, const char * new_port_name)
{
ladish_client_handle client;
ladish_port_handle port;
ladish_graph_handle vgraph;
log_info("port_renamed(%"PRIu64", '%s', '%s')", port_id, old_port_name, new_port_name);
client = ladish_graph_find_client_by_jack_id(virtualizer_ptr->jack_graph, client_id);
if (client == NULL)
{
log_error("Port of unknown JACK client with id %"PRIu64" was renamed", client_id);
return;
}
/* find the virtual graph that owns the app that owns the client that owns the renamed port */
vgraph = ladish_client_get_vgraph(client);
port = ladish_graph_find_port_by_jack_id(virtualizer_ptr->jack_graph, port_id, true, true);
if (port == NULL)
{
@ -892,6 +885,9 @@ static void port_renamed(void * context, uint64_t client_id, uint64_t port_id, c
return;
}
/* find the virtual graph that owns the app that owns the client that owns the renamed port */
vgraph = ladish_port_get_vgraph(port);
if (!ladish_graph_rename_port(virtualizer_ptr->jack_graph, port, new_port_name))
{
log_error("renaming of port in jack graph failed");