daemon: when destroying room, remove its hidden app ports. Fixes #87
If ports stay hidden in JACK graph and they get reused, no vgraph will exist
This commit is contained in:
parent
9a42d3d998
commit
3126bbdb5d
|
@ -66,6 +66,18 @@ uninit_room_ports(
|
|||
return true;
|
||||
}
|
||||
|
||||
static void remove_port_callback(ladish_port_handle port)
|
||||
{
|
||||
ladish_client_handle jack_client;
|
||||
|
||||
jack_client = ladish_graph_remove_port(g_studio.jack_graph, port);
|
||||
ASSERT(jack_client != NULL); /* room app port not found in jack graph */
|
||||
if (ladish_graph_client_is_empty(g_studio.jack_graph, jack_client))
|
||||
{
|
||||
ladish_graph_remove_client(g_studio.jack_graph, jack_client);
|
||||
}
|
||||
}
|
||||
|
||||
#define cmd_ptr ((struct ladish_command_delete_room *)context)
|
||||
|
||||
static bool run(void * context)
|
||||
|
@ -121,13 +133,13 @@ found:
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!ladish_graph_is_empty(graph))
|
||||
if (!ladish_graph_looks_empty(graph))
|
||||
{
|
||||
log_info("the room \"%s\" graph is still not empty", cmd_ptr->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ladish_graph_is_client_looks_empty(g_studio.studio_graph, room_client))
|
||||
if (!ladish_graph_client_looks_empty(g_studio.studio_graph, room_client))
|
||||
{
|
||||
log_info("the room \"%s\" studio client still does not look empty", cmd_ptr->name);
|
||||
return true;
|
||||
|
@ -137,6 +149,8 @@ found:
|
|||
/* ladish_graph_dump(g_studio.studio_graph); */
|
||||
/* ladish_graph_dump(g_studio.jack_graph); */
|
||||
|
||||
ladish_graph_clear(graph, remove_port_callback);
|
||||
|
||||
list_del(node_ptr);
|
||||
ladish_studio_emit_room_disappeared(room);
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ static bool run(void * context)
|
|||
|
||||
ladish_graph_dump(g_studio.studio_graph);
|
||||
ladish_graph_dump(g_studio.jack_graph);
|
||||
ladish_graph_clear(g_studio.studio_graph);
|
||||
ladish_graph_clear(g_studio.jack_graph);
|
||||
ladish_graph_clear(g_studio.studio_graph, NULL);
|
||||
ladish_graph_clear(g_studio.jack_graph, NULL);
|
||||
|
||||
ladish_studio_remove_all_rooms();
|
||||
|
||||
|
|
|
@ -962,13 +962,18 @@ void
|
|||
ladish_graph_remove_client_internal(
|
||||
struct ladish_graph * graph_ptr,
|
||||
struct ladish_graph_client * client_ptr,
|
||||
bool destroy_client)
|
||||
bool destroy_client,
|
||||
ladish_graph_simple_port_callback port_callback)
|
||||
{
|
||||
struct ladish_graph_port * port_ptr;
|
||||
|
||||
while (!list_empty(&client_ptr->ports))
|
||||
{
|
||||
port_ptr = list_entry(client_ptr->ports.next, struct ladish_graph_port, siblings_client);
|
||||
if (port_callback != NULL)
|
||||
{
|
||||
port_callback(port_ptr->port);
|
||||
}
|
||||
ladish_graph_remove_port_internal(graph_ptr, client_ptr, port_ptr);
|
||||
}
|
||||
|
||||
|
@ -998,11 +1003,34 @@ ladish_graph_remove_client_internal(
|
|||
free(client_ptr);
|
||||
}
|
||||
|
||||
bool ladish_graph_client_looks_empty_internal(struct ladish_graph * graph_ptr, struct ladish_graph_client * client_ptr)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct ladish_graph_port * port_ptr;
|
||||
|
||||
list_for_each(node_ptr, &client_ptr->ports)
|
||||
{
|
||||
port_ptr = list_entry(node_ptr, struct ladish_graph_port, siblings_client);
|
||||
if (!port_ptr->hidden)
|
||||
{
|
||||
//log_info("port '%s' is visible, client '%s' does not look empty", port_ptr->name, client_ptr->name);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//log_info("port '%s' is invisible", port_ptr->name);
|
||||
}
|
||||
}
|
||||
|
||||
//log_info("client '%s' looks empty in graph %s", client_ptr->name, graph_ptr->opath != NULL ? graph_ptr->opath : "JACK");
|
||||
return true;
|
||||
}
|
||||
|
||||
#define graph_ptr ((struct ladish_graph *)graph_handle)
|
||||
|
||||
void ladish_graph_destroy(ladish_graph_handle graph_handle)
|
||||
{
|
||||
ladish_graph_clear(graph_handle);
|
||||
ladish_graph_clear(graph_handle, NULL);
|
||||
ladish_dict_destroy(graph_ptr->dict);
|
||||
if (graph_ptr->opath != NULL)
|
||||
{
|
||||
|
@ -1034,7 +1062,7 @@ ladish_graph_set_connection_handlers(
|
|||
graph_ptr->disconnect_handler = disconnect_handler;
|
||||
}
|
||||
|
||||
void ladish_graph_clear(ladish_graph_handle graph_handle)
|
||||
void ladish_graph_clear(ladish_graph_handle graph_handle, ladish_graph_simple_port_callback port_callback)
|
||||
{
|
||||
struct ladish_graph_client * client_ptr;
|
||||
struct ladish_graph_connection * connection_ptr;
|
||||
|
@ -1050,7 +1078,7 @@ void ladish_graph_clear(ladish_graph_handle graph_handle)
|
|||
while (!list_empty(&graph_ptr->clients))
|
||||
{
|
||||
client_ptr = list_entry(graph_ptr->clients.next, struct ladish_graph_client, siblings);
|
||||
ladish_graph_remove_client_internal(graph_ptr, client_ptr, true);
|
||||
ladish_graph_remove_client_internal(graph_ptr, client_ptr, true, port_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1294,7 @@ ladish_graph_remove_client(
|
|||
client_ptr = ladish_graph_find_client(graph_ptr, client_handle);
|
||||
if (client_ptr != NULL)
|
||||
{
|
||||
ladish_graph_remove_client_internal(graph_ptr, client_ptr, false);
|
||||
ladish_graph_remove_client_internal(graph_ptr, client_ptr, false, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1844,7 +1872,7 @@ const char * ladish_graph_get_client_name(ladish_graph_handle graph_handle, ladi
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool ladish_graph_is_client_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle)
|
||||
bool ladish_graph_client_is_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle)
|
||||
{
|
||||
struct ladish_graph_client * client_ptr;
|
||||
|
||||
|
@ -1858,35 +1886,24 @@ bool ladish_graph_is_client_empty(ladish_graph_handle graph_handle, ladish_clien
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ladish_graph_is_client_looks_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle)
|
||||
bool ladish_graph_client_looks_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle)
|
||||
{
|
||||
struct ladish_graph_client * client_ptr;
|
||||
struct list_head * node_ptr;
|
||||
struct ladish_graph_port * port_ptr;
|
||||
|
||||
client_ptr = ladish_graph_find_client(graph_ptr, client_handle);
|
||||
if (client_ptr != NULL)
|
||||
if (client_ptr == NULL)
|
||||
{
|
||||
list_for_each(node_ptr, &client_ptr->ports)
|
||||
{
|
||||
port_ptr = list_entry(node_ptr, struct ladish_graph_port, siblings_client);
|
||||
if (!port_ptr->hidden)
|
||||
{
|
||||
//log_info("port '%s' is visible, client '%s' does not look empty", port_ptr->name, client_ptr->name);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//log_info("port '%s' is invisible", port_ptr->name);
|
||||
}
|
||||
}
|
||||
|
||||
log_info("client '%s' looks empty in graph %s", client_ptr->name, graph_ptr->opath != NULL ? graph_ptr->opath : "JACK");
|
||||
ASSERT_NO_PASS;
|
||||
return true;
|
||||
}
|
||||
|
||||
ASSERT_NO_PASS;
|
||||
return true;
|
||||
if (ladish_graph_client_looks_empty_internal(graph_ptr, client_ptr))
|
||||
{
|
||||
//log_info("client '%s' looks empty in graph %s", client_ptr->name, graph_ptr->opath != NULL ? graph_ptr->opath : "JACK");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ladish_try_connect_hidden_connections(ladish_graph_handle graph_handle)
|
||||
|
@ -2193,9 +2210,32 @@ bool ladish_graph_is_persist(ladish_graph_handle graph_handle)
|
|||
return graph_ptr->persist;
|
||||
}
|
||||
|
||||
bool ladish_graph_is_empty(ladish_graph_handle graph_handle)
|
||||
bool ladish_graph_looks_empty(ladish_graph_handle graph_handle)
|
||||
{
|
||||
return list_empty(&graph_ptr->clients) && list_empty(&graph_ptr->ports) && list_empty(&graph_ptr->connections);
|
||||
struct list_head * node_ptr;
|
||||
struct ladish_graph_connection * connection_ptr;
|
||||
struct ladish_graph_client * client_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->connections)
|
||||
{
|
||||
connection_ptr = list_entry(node_ptr, struct ladish_graph_connection, siblings);
|
||||
|
||||
if (!connection_ptr->hidden)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->clients)
|
||||
{
|
||||
client_ptr = list_entry(node_ptr, struct ladish_graph_client, siblings);
|
||||
if (!ladish_graph_client_looks_empty_internal(graph_ptr, client_ptr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef graph_ptr
|
||||
|
|
|
@ -47,6 +47,8 @@ bool
|
|||
ladish_graph_handle graph_handle,
|
||||
uint64_t connection_id);
|
||||
|
||||
typedef void (* ladish_graph_simple_port_callback)(ladish_port_handle port_handle);
|
||||
|
||||
bool ladish_graph_create(ladish_graph_handle * graph_handle_ptr, const char * opath);
|
||||
bool ladish_graph_copy(ladish_graph_handle src, ladish_graph_handle dest, bool skip_hidden);
|
||||
void ladish_graph_destroy(ladish_graph_handle graph_handle);
|
||||
|
@ -61,7 +63,7 @@ ladish_graph_set_connection_handlers(
|
|||
ladish_graph_connect_request_handler connect_handler,
|
||||
ladish_graph_disconnect_request_handler disconnect_handler);
|
||||
|
||||
void ladish_graph_clear(ladish_graph_handle graph_handle);
|
||||
void ladish_graph_clear(ladish_graph_handle graph_handle, ladish_graph_simple_port_callback port_callback);
|
||||
void * ladish_graph_get_dbus_context(ladish_graph_handle graph_handle);
|
||||
ladish_dict_handle ladish_graph_get_dict(ladish_graph_handle graph_handle);
|
||||
ladish_dict_handle ladish_graph_get_connection_dict(ladish_graph_handle graph_handle, uint64_t connection_id);
|
||||
|
@ -144,8 +146,8 @@ ladish_port_handle ladish_graph_find_port_by_uuid(ladish_graph_handle graph_hand
|
|||
ladish_client_handle ladish_graph_get_port_client(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
||||
const char * ladish_graph_get_client_name(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||
const char * ladish_graph_get_port_name(ladish_graph_handle graph, ladish_port_handle port);
|
||||
bool ladish_graph_is_client_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||
bool ladish_graph_is_client_looks_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||
bool ladish_graph_client_is_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||
bool ladish_graph_client_looks_empty(ladish_graph_handle graph_handle, ladish_client_handle client_handle);
|
||||
bool ladish_graph_is_port_present(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
||||
void ladish_graph_show_port(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
||||
void ladish_graph_hide_port(ladish_graph_handle graph_handle, ladish_port_handle port_handle);
|
||||
|
@ -196,7 +198,7 @@ ladish_graph_iterate_connections(
|
|||
|
||||
void ladish_graph_clear_persist(ladish_graph_handle graph_handle);
|
||||
bool ladish_graph_is_persist(ladish_graph_handle graph_handle);
|
||||
bool ladish_graph_is_empty(ladish_graph_handle graph_handle);
|
||||
bool ladish_graph_looks_empty(ladish_graph_handle graph_handle);
|
||||
|
||||
extern const struct dbus_interface_descriptor g_interface_patchbay;
|
||||
|
||||
|
|
|
@ -758,7 +758,7 @@ static void port_disappeared(void * context, uint64_t client_id, uint64_t port_i
|
|||
{
|
||||
ladish_graph_hide_port(vgraph, port);
|
||||
client = ladish_graph_get_port_client(vgraph, port);
|
||||
if (ladish_graph_is_client_looks_empty(vgraph, client))
|
||||
if (ladish_graph_client_looks_empty(vgraph, client))
|
||||
{
|
||||
ladish_graph_hide_client(vgraph, client);
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ static void port_disappeared(void * context, uint64_t client_id, uint64_t port_i
|
|||
client = ladish_graph_remove_port(vgraph, port);
|
||||
if (client != NULL)
|
||||
{
|
||||
if (ladish_graph_is_client_empty(vgraph, client))
|
||||
if (ladish_graph_client_is_empty(vgraph, client))
|
||||
{
|
||||
ladish_graph_remove_client(vgraph, client);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue