1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010,2012 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains the code that checks data integrity
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <unistd.h> /* usleep() */
29 #include "../proxies/notify_proxy.h"
31 struct ladish_check_vgraph_integrity_context
33 ladish_graph_handle jack_graph
;
36 static void ladish_check_integrity_fail(const char * message
)
38 log_error("Integirity check failed: %s", message
);
39 ladish_notify_simple(LADISH_NOTIFY_URGENCY_HIGH
, "ladish daemon integrity check failed", LADISH_CHECK_LOG_TEXT
);
44 #define ctx_ptr ((struct ladish_check_vgraph_integrity_context *)context)
47 ladish_check_vgraph_integrity_client_begin_callback(
48 void * UNUSED(context
),
49 ladish_graph_handle
UNUSED(graph_handle
),
51 ladish_client_handle
UNUSED(client_handle
),
52 const char * UNUSED(client_name
),
53 void ** UNUSED(client_iteration_context_ptr_ptr
))
59 ladish_check_vgraph_integrity_port_callback(
61 ladish_graph_handle vgraph
,
63 void * UNUSED(client_iteration_context_ptr
),
64 ladish_client_handle
UNUSED(client_handle
),
65 const char * client_name
,
66 ladish_port_handle vport
,
67 const char * port_name
,
72 ladish_port_handle jport
;
76 ladish_port_get_uuid(vport
, uuid
);
77 uuid_unparse(uuid
, uuid_str
);
79 link
= ladish_port_is_link(vport
);
85 jport
= ladish_graph_find_port_by_uuid(ctx_ptr
->jack_graph
, uuid
, false, vgraph
);
88 log_error("vgraph: %s", ladish_graph_get_description(vgraph
));
89 log_error("client name: %s", client_name
);
90 log_error("port name: %s", port_name
);
91 log_error("port uuid: %s", uuid_str
);
92 log_error("port ptr: %p", vport
);
93 log_error("port type: 0x%"PRIX32
, port_type
);
94 log_error("port flags: 0x%"PRIX32
, port_flags
);
95 ladish_check_integrity_fail("vgraph port not found in JACK graph.");
102 ladish_check_vgraph_integrity_client_end_callback(
103 void * UNUSED(context
),
104 ladish_graph_handle
UNUSED(graph_handle
),
106 ladish_client_handle
UNUSED(client_handle
),
107 const char * UNUSED(client_name
),
108 void * UNUSED(client_iteration_context_ptr
))
116 ladish_check_vgraph_integrity(
118 ladish_graph_handle graph
,
119 ladish_app_supervisor_handle
UNUSED(app_supervisor
))
121 ladish_graph_iterate_nodes(
124 ladish_check_vgraph_integrity_client_begin_callback
,
125 ladish_check_vgraph_integrity_port_callback
,
126 ladish_check_vgraph_integrity_client_end_callback
);
131 void ladish_check_integrity(void)
133 struct ladish_check_vgraph_integrity_context ctx
;
135 //ladish_check_integrity_fail("test");
137 if (!ladish_studio_is_loaded())
142 ctx
.jack_graph
= ladish_studio_get_jack_graph();
144 ladish_studio_iterate_virtual_graphs(&ctx
, ladish_check_vgraph_integrity
);