ladishd: don't save hidden ports of runnings apps

This commit is contained in:
Nedko Arnaudov 2010-12-27 01:37:14 +02:00
parent 21a1c96a16
commit 9868de418b
4 changed files with 45 additions and 11 deletions

View File

@ -355,7 +355,7 @@ static bool run(void * command_context)
goto close; goto close;
} }
if (!ladish_write_jgraph(fd, 2, ladish_studio_get_studio_graph())) if (!ladish_write_jgraph(fd, 2, ladish_studio_get_studio_graph(), ladish_studio_get_studio_app_supervisor()))
{ {
log_error("ladish_write_jgraph() failed for studio graph"); log_error("ladish_write_jgraph() failed for studio graph");
goto close; goto close;

View File

@ -207,7 +207,7 @@ static bool ladish_room_save_project_do(struct ladish_room * room_ptr)
goto close; goto close;
} }
if (!ladish_write_jgraph(fd, 2, room_ptr->graph)) if (!ladish_write_jgraph(fd, 2, room_ptr->graph, room_ptr->app_supervisor))
{ {
log_error("ladish_write_jgraph() failed for room graph"); log_error("ladish_write_jgraph() failed for room graph");
goto close; goto close;

View File

@ -34,6 +34,7 @@ struct ladish_write_vgraph_context
{ {
int fd; int fd;
int indent; int indent;
ladish_app_supervisor_handle app_supervisor;
bool client_visible; bool client_visible;
}; };
@ -44,11 +45,29 @@ static bool is_system_client(ladish_client_handle client)
return ladish_virtualizer_is_system_client(uuid); return ladish_virtualizer_is_system_client(uuid);
} }
#define is_port_interesting(client, port) ( \ static bool is_app_running(ladish_app_supervisor_handle app_supervisor, ladish_port_handle port)
ladish_port_has_app(port) || \ {
ladish_port_is_link(port) || \ uuid_t app_uuid;
is_system_client(client) \ ladish_app_handle app;
)
if (!ladish_port_get_app(port, app_uuid))
{
return false;
}
app = ladish_app_supervisor_find_app_by_uuid(app_supervisor, app_uuid);
if (app == NULL)
{
return false;
}
return ladish_app_is_running(app);
}
#define is_port_interesting(app_supervisor, client, port) ( \
is_app_running(app_supervisor, port) || \
ladish_port_is_link(port) || \
is_system_client(client))
bool ladish_write_string(int fd, const char * string) bool ladish_write_string(int fd, const char * string)
{ {
@ -468,6 +487,12 @@ ladish_save_vgraph_port(
return true; return true;
} }
/* skip hidden ports of running apps */
if (hidden && !is_port_interesting(ctx_ptr->app_supervisor, client_handle, port_handle))
{
return true;
}
link = ladish_get_vgraph_port_uuids(graph, port_handle, uuid, link_uuid); link = ladish_get_vgraph_port_uuids(graph, port_handle, uuid, link_uuid);
uuid_unparse(uuid, str); uuid_unparse(uuid, str);
if (link) if (link)
@ -578,8 +603,8 @@ ladish_save_vgraph_connection(
char str[37]; char str[37];
if (hidden && if (hidden &&
(!is_port_interesting(client1, port1) || (!is_port_interesting(ctx_ptr->app_supervisor, client1, port1) ||
!is_port_interesting(client2, port2))) !is_port_interesting(ctx_ptr->app_supervisor, client2, port2)))
{ {
return true; return true;
} }
@ -755,6 +780,7 @@ bool ladish_write_vgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_
context.fd = fd; context.fd = fd;
context.indent = indent + 1; context.indent = indent + 1;
context.app_supervisor = app_supervisor;
if (!ladish_write_indented_string(fd, indent, "<clients>\n")) if (!ladish_write_indented_string(fd, indent, "<clients>\n"))
{ {
@ -820,6 +846,7 @@ struct ladish_write_jack_context
int fd; int fd;
int indent; int indent;
ladish_graph_handle vgraph_filter; ladish_graph_handle vgraph_filter;
ladish_app_supervisor_handle app_supervisor;
bool client_vgraph_match; bool client_vgraph_match;
bool a2j; bool a2j;
bool client_visible; bool client_visible;
@ -973,6 +1000,12 @@ ladish_save_jack_port(
return true; return true;
} }
/* skip hidden ports of running apps */
if (hidden && !is_port_interesting(ctx_ptr->app_supervisor, client_handle, port_handle))
{
return true;
}
ladish_port_get_uuid(port_handle, uuid); ladish_port_get_uuid(port_handle, uuid);
uuid_unparse(uuid, str); uuid_unparse(uuid, str);
@ -1010,7 +1043,7 @@ ladish_save_jack_port(
#undef indent #undef indent
#undef fd #undef fd
bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph) bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor)
{ {
struct ladish_write_jack_context context; struct ladish_write_jack_context context;
@ -1024,6 +1057,7 @@ bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph)
context.fd = fd; context.fd = fd;
context.indent = indent + 1; context.indent = indent + 1;
context.vgraph_filter = vgraph; context.vgraph_filter = vgraph;
context.app_supervisor = app_supervisor;
if (!ladish_graph_iterate_nodes( if (!ladish_graph_iterate_nodes(
ladish_studio_get_jack_graph(), ladish_studio_get_jack_graph(),

View File

@ -48,6 +48,6 @@ bool ladish_write_string_escape_ex(int fd, const char * string, unsigned int fla
bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict); bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict);
bool ladish_write_vgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor); bool ladish_write_vgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor);
bool ladish_write_room_link_ports(int fd, int indent, ladish_room_handle room); bool ladish_write_room_link_ports(int fd, int indent, ladish_room_handle room);
bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph); bool ladish_write_jgraph(int fd, int indent, ladish_graph_handle vgraph, ladish_app_supervisor_handle app_supervisor);
#endif /* #ifndef SAVE_H__120D6D3D_90A9_4998_8F00_23FCB8BA8DE9__INCLUDED */ #endif /* #ifndef SAVE_H__120D6D3D_90A9_4998_8F00_23FCB8BA8DE9__INCLUDED */