From 91b87783d7a68c49c01252465dfdf6cc3a63d1a7 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sun, 2 Jan 2011 05:04:29 +0200 Subject: [PATCH] ladishd: workaround for bug in jack2/jackdbus http://trac.jackaudio.org/ticket/209 --- daemon/graph.c | 53 +++++++++++++++++++++++++++++++++++++++++++- daemon/graph.h | 19 +++++++++++++++- daemon/virtualizer.c | 34 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) diff --git a/daemon/graph.c b/daemon/graph.c index 1b9f59a7..96dd14e7 100644 --- a/daemon/graph.c +++ b/daemon/graph.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2008, 2009, 2010 Nedko Arnaudov + * Copyright (C) 2008, 2009, 2010, 2011 Nedko Arnaudov * Copyright (C) 2008 Juuso Alasuutari * ************************************************************************** @@ -2540,6 +2540,57 @@ ladish_graph_iterate_connections( return true; } +bool +ladish_graph_interate_client_ports( + ladish_graph_handle graph_handle, + ladish_client_handle client, + void * callback_context, + bool + (* port_callback)( + void * context, + ladish_graph_handle graph_handle, + bool hidden, + ladish_client_handle client_handle, + const char * client_name, + ladish_port_handle port_handle, + const char * port_name, + uint32_t port_type, + uint32_t port_flags)) +{ + struct ladish_graph_client * client_ptr; + struct list_head * port_node_ptr; + struct list_head * port_temp_node_ptr; + struct ladish_graph_port * port_ptr; + + client_ptr = ladish_graph_find_client(graph_ptr, client); + if (client_ptr == NULL) + { + ASSERT_NO_PASS; + return false; + } + + list_for_each_safe(port_node_ptr, port_temp_node_ptr, &client_ptr->ports) + { + port_ptr = list_entry(port_node_ptr, struct ladish_graph_port, siblings_client); + + if (!port_callback( + callback_context, + graph_handle, + port_ptr->hidden, + client_ptr->client, + client_ptr->name, + port_ptr->port, + port_ptr->name, + port_ptr->type, + port_ptr->flags)) + { + return false; + } + } + + return true; +} + static bool dump_dict_entry( diff --git a/daemon/graph.h b/daemon/graph.h index a59d6842..d4167955 100644 --- a/daemon/graph.h +++ b/daemon/graph.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009, 2010 Nedko Arnaudov + * Copyright (C) 2009, 2010, 2011 Nedko Arnaudov * ************************************************************************** * This file contains interface to the D-Bus patchbay interface helpers @@ -228,6 +228,23 @@ ladish_graph_iterate_connections( bool port2_hidden, ladish_dict_handle dict)); +bool +ladish_graph_interate_client_ports( + ladish_graph_handle graph_handle, + ladish_client_handle client_handle, + void * callback_context, + bool + (* port_callback)( + void * context, + ladish_graph_handle graph_handle, + bool hidden, + ladish_client_handle client_handle, + const char * client_name, + ladish_port_handle port_handle, + const char * port_name, + uint32_t port_type, + uint32_t port_flags)); + void ladish_graph_clear_persist(ladish_graph_handle graph_handle); void ladish_graph_set_persist(ladish_graph_handle graph_handle); bool ladish_graph_is_persist(ladish_graph_handle graph_handle); diff --git a/daemon/virtualizer.c b/daemon/virtualizer.c index 4c4795f1..29b56ec9 100644 --- a/daemon/virtualizer.c +++ b/daemon/virtualizer.c @@ -379,6 +379,37 @@ exit: return; } +static void port_disappeared(void * context, uint64_t client_id, uint64_t port_id); + +bool +force_port_disappear( + void * context, + ladish_graph_handle graph_handle, + bool hidden, + ladish_client_handle client_handle, + const char * client_name, + ladish_port_handle port_handle, + const char * port_name, + uint32_t port_type, + uint32_t port_flags) +{ + uint64_t client_id; + uint64_t port_id; + + if (hidden) + { + return true; + } + + log_error("forcing disappear of port '%s':'%s'", client_name, port_name); + + client_id = ladish_client_get_jack_id(client_handle); + port_id = ladish_port_get_jack_id(port_handle); + port_disappeared(context, client_id, port_id); + + return true; +} + static void client_disappeared(void * context, uint64_t id) { ladish_client_handle client; @@ -398,6 +429,9 @@ static void client_disappeared(void * context, uint64_t id) log_info("client disappeared: '%s'", ladish_graph_get_client_name(virtualizer_ptr->jack_graph, client)); + /* This is a workaround for jack2/jackdbus bug. */ + ladish_graph_interate_client_ports(virtualizer_ptr->jack_graph, client, context, force_port_disappear); + vgraph = ladish_client_get_vgraph(client); pid = ladish_client_get_pid(client);