ladishd: properly handle ports with same uuids but in different room vgraphs. Fixes #115

Same or derivate project can be loaded in more than one room. This will cause more than one port
with given uuid to be added to the jack graph. This changeset uses vgraph-port_uuid pair when searching
for port that was added at earlier project load stage. For this to work, when ports are created and added
to the jack graph, the vgraph handle is stored in the port object.
This commit is contained in:
Nedko Arnaudov 2010-11-03 00:29:08 +02:00
parent 1b66932459
commit 2eac623818
7 changed files with 52 additions and 17 deletions

View File

@ -313,6 +313,8 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
ladish_port_set_vgraph(context_ptr->port, g_studio.studio_graph);
if (!ladish_graph_add_port(g_studio.jack_graph, context_ptr->client, context_ptr->port, name, 0, 0, true))
{
log_error("ladish_graph_add_port() failed.");
@ -336,7 +338,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
if (uuid2_str == NULL)
{ /* normal studio port */
context_ptr->port = ladish_graph_find_port_by_uuid(g_studio.jack_graph, uuid, false);
context_ptr->port = ladish_graph_find_port_by_uuid(g_studio.jack_graph, uuid, false, g_studio.studio_graph);
if (context_ptr->port == NULL)
{
log_error("studio client with non-jack port %s", uuid_str);
@ -436,7 +438,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
log_info("studio connection between port %s and port %s", uuid_str, uuid2_str);
port1 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid, true);
port1 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid, true, NULL);
if (port1 == NULL)
{
log_error("studio client with unknown port %s", uuid_str);
@ -444,7 +446,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
port2 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid2, true);
port2 = ladish_graph_find_port_by_uuid(g_studio.studio_graph, uuid2, true, NULL);
if (port2 == NULL)
{
log_error("studio client with unknown port %s", uuid2_str);

View File

@ -219,7 +219,8 @@ ladish_graph_find_port_by_uuid_internal(
struct ladish_graph * graph_ptr,
struct ladish_graph_client * client_ptr,
const uuid_t uuid,
bool use_link_override_uuids)
bool use_link_override_uuids,
void * vgraph_filter)
{
struct list_head * node_ptr;
struct ladish_graph_port * port_ptr;
@ -241,6 +242,11 @@ ladish_graph_find_port_by_uuid_internal(
continue;
}
if (vgraph_filter != NULL && ladish_port_get_vgraph(port_ptr->port) != vgraph_filter)
{
continue;
}
#if defined(LOG_PORT_LOOKUP)
if (port_ptr->link)
{
@ -1668,11 +1674,11 @@ ladish_client_handle ladish_graph_find_client_by_uuid(ladish_graph_handle graph_
return NULL;
}
ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, bool use_link_override_uuids)
ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, bool use_link_override_uuids, void * vgraph_filter)
{
struct ladish_graph_port * port_ptr;
port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, NULL, uuid, use_link_override_uuids);
port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, NULL, uuid, use_link_override_uuids, vgraph_filter);
if (port_ptr != NULL)
{
return port_ptr->port;
@ -2085,7 +2091,7 @@ ladish_graph_find_client_port_by_uuid(
client_ptr = ladish_graph_find_client(graph_ptr, client);
ASSERT(client_ptr != NULL);
port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, client_ptr, uuid, use_link_override_uuids);
port_ptr = ladish_graph_find_port_by_uuid_internal(graph_ptr, client_ptr, uuid, use_link_override_uuids, NULL);
if (port_ptr != NULL)
{
return port_ptr->port;

View File

@ -143,7 +143,7 @@ ladish_client_handle ladish_graph_find_client_by_name(ladish_graph_handle graph_
ladish_client_handle ladish_graph_find_client_by_app(ladish_graph_handle graph_handle, const uuid_t app_uuid);
ladish_port_handle ladish_graph_find_port_by_name(ladish_graph_handle graph_handle, ladish_client_handle client_handle, const char * name);
ladish_client_handle ladish_graph_find_client_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid);
ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, bool use_link_override_uuids);
ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_handle, const uuid_t uuid, bool use_link_override_uuids, void * vgraph_filter);
ladish_port_handle
ladish_graph_find_client_port_by_uuid(

View File

@ -35,6 +35,8 @@ struct ladish_port
uint64_t jack_id; /* JACK port ID. */
uint64_t jack_id_room; /* JACK port ID in room. valid only for link ports */
void * vgraph; /* virtual graph */
ladish_dict_handle dict;
};
@ -74,6 +76,8 @@ ladish_port_create(
port_ptr->link = link;
port_ptr->refcount = 0;
port_ptr->vgraph = NULL;
log_info("port %p created", port_ptr);
*port_handle_ptr = (ladish_port_handle)port_ptr;
return true;
@ -155,4 +159,14 @@ bool ladish_port_is_link(ladish_port_handle port_handle)
return port_ptr->link;
}
void ladish_port_set_vgraph(ladish_port_handle port_handle, void * vgraph)
{
port_ptr->vgraph = vgraph;
}
void * ladish_port_get_vgraph(ladish_port_handle port_handle)
{
return port_ptr->vgraph;
}
#undef port_ptr

View File

@ -47,4 +47,7 @@ void ladish_port_del_ref(ladish_port_handle port_handle);
bool ladish_port_is_link(ladish_port_handle port_handle);
void ladish_port_set_vgraph(ladish_port_handle port_handle, void * vgraph);
void * ladish_port_get_vgraph(ladish_port_handle port_handle);
#endif /* #ifndef PORT_H__62F81E7C_91FA_44AB_94A9_E0E2D226ED58__INCLUDED */

View File

@ -271,6 +271,8 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
ladish_port_set_vgraph(context_ptr->port, room_ptr->graph);
if (!ladish_graph_add_port(ladish_studio_get_jack_graph(), context_ptr->client, context_ptr->port, name, 0, 0, true))
{
log_error("ladish_graph_add_port() failed.");
@ -288,7 +290,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
context_ptr->port = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, false);
context_ptr->port = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, false, NULL);
if (context_ptr->port != NULL)
{
if (!ladish_port_is_link(context_ptr->port))
@ -299,7 +301,9 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
context_ptr->port = ladish_graph_find_port_by_uuid(ladish_studio_get_jack_graph(), uuid, false);
/* there can be two ports with same uuid in the jack graph so we search for a port
with vgraph for the room where porject is being loaded to */
context_ptr->port = ladish_graph_find_port_by_uuid(ladish_studio_get_jack_graph(), uuid, false, room_ptr->graph);
if (context_ptr->port == NULL)
{
log_info("app port \"%s\" with uuid %s not found in the jack graph", name, uuid_str);
@ -342,10 +346,10 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
context_ptr->port = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, false);
context_ptr->port = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, false, NULL);
if (context_ptr->port == NULL)
{
log_error("Cannot find room link port() failed.");
log_error("Cannot find room link port.");
context_ptr->port = NULL;
}
@ -389,7 +393,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
log_info("studio connection between port %s and port %s", uuid_str, uuid2_str);
port1 = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, true);
port1 = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid, true, NULL);
if (port1 == NULL)
{
log_error("studio client with unknown port %s", uuid_str);
@ -397,7 +401,7 @@ static void callback_elstart(void * data, const char * el, const char ** attr)
return;
}
port2 = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid2, true);
port2 = ladish_graph_find_port_by_uuid(room_ptr->graph, uuid2, true, NULL);
if (port2 == NULL)
{
log_error("studio client with unknown port %s", uuid2_str);

View File

@ -137,7 +137,7 @@ static bool find_link_port_vgraph_callback_by_uuid(void * context, ladish_graph_
{
ladish_port_handle port;
port = ladish_graph_find_port_by_uuid(graph, find_link_port_context_ptr->uuid, true);
port = ladish_graph_find_port_by_uuid(graph, find_link_port_context_ptr->uuid, true, NULL);
if (port != NULL)
{
find_link_port_context_ptr->port = port;
@ -522,6 +522,10 @@ port_appeared(
ladish_graph_show_port(vgraph, port);
goto exit;
}
else
{
//log_info("Port of virtual graph '%s'", ladish_graph_get_description(vgraph));
}
jack_client_name = ladish_graph_get_client_name(virtualizer_ptr->jack_graph, jack_client);
@ -577,7 +581,7 @@ port_appeared(
port = ladish_graph_find_port_by_name(virtualizer_ptr->jack_graph, jack_client, jack_port_name);
if (port != NULL)
{
log_info("found existing port");
log_info("found existing port %p", port);
if (ladish_port_get_jack_id(port) != 0)
{
@ -592,7 +596,9 @@ port_appeared(
vclient = ladish_graph_get_port_client(vgraph, port);
if (vclient == NULL)
{
log_error("JACK port not found in virtual graph");
log_error("JACK port not found in virtual graph '%s'", ladish_graph_get_description(vgraph));
ladish_graph_dump(g_studio.jack_graph);
ladish_graph_dump(vgraph);
ASSERT_NO_PASS;
goto free_alsa_names;
}