iterate studio graph on save

This commit is contained in:
Nedko Arnaudov 2009-09-12 21:42:19 +03:00
parent a7cddc8ae5
commit 83423d7fb7
5 changed files with 134 additions and 0 deletions

View File

@ -122,4 +122,9 @@ ladish_dict_handle ladish_client_get_dict(ladish_client_handle client_handle)
return client_ptr->dict;
}
void ladish_client_get_uuid(ladish_client_handle client_handle, uuid_t uuid)
{
uuid_copy(uuid, client_ptr->uuid);
}
#undef client_ptr

View File

@ -45,4 +45,6 @@ ladish_client_destroy(
ladish_dict_handle ladish_client_get_dict(ladish_client_handle client_handle);
void ladish_client_get_uuid(ladish_client_handle client_handle, uuid_t uuid);
#endif /* #ifndef CLIENT_H__2160B4BA_D6D1_464D_9DC5_ECA50B0958AD__INCLUDED */

View File

@ -690,6 +690,63 @@ ladish_port_handle ladish_graph_find_port_by_id(ladish_graph_handle graph_handle
return NULL;
}
bool
ladish_graph_iterate_nodes(
ladish_graph_handle graph_handle,
void * callback_context,
bool
(* client_callback)(
void * context,
ladish_client_handle client_handle,
const char * client_name,
void ** client_iteration_context_ptr_ptr),
bool
(* port_callback)(
void * context,
void * client_iteration_context_ptr,
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 list_head * client_node_ptr;
struct ladish_graph_client * client_ptr;
void * client_context;
struct list_head * port_node_ptr;
struct ladish_graph_port * port_ptr;
list_for_each(client_node_ptr, &graph_ptr->clients)
{
client_ptr = list_entry(client_node_ptr, struct ladish_graph_client, siblings);
if (!client_callback(callback_context, client_ptr->client, client_ptr->name, &client_context))
{
return false;
}
list_for_each(port_node_ptr, &client_ptr->ports)
{
port_ptr = list_entry(port_node_ptr, struct ladish_graph_port, siblings_client);
if (!port_callback(
callback_context,
client_context,
client_ptr->client,
client_ptr->name,
port_ptr->port,
port_ptr->name,
port_ptr->type,
port_ptr->flags))
{
return false;
}
}
}
return true;
}
#undef graph_ptr
METHOD_ARGS_BEGIN(GetAllPorts, "Get all ports")

View File

@ -63,6 +63,27 @@ ladish_graph_remove_port(
ladish_client_handle ladish_graph_find_client_by_id(ladish_graph_handle graph_handle, uint64_t client_id);
ladish_port_handle ladish_graph_find_port_by_id(ladish_graph_handle graph_handle, uint64_t port_id);
bool
ladish_graph_iterate_nodes(
ladish_graph_handle graph_handle,
void * callback_context,
bool
(* client_callback)(
void * context,
ladish_client_handle client_handle,
const char * client_name,
void ** client_iteration_context_ptr_ptr),
bool
(* port_callback)(
void * context,
void * client_iteration_context_ptr,
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));
extern const struct dbus_interface_descriptor g_interface_patchbay;
#endif /* #ifndef PATCHBAY_H__30334B9A_8847_4E8C_AFF9_73DB13406C8E__INCLUDED */

View File

@ -142,6 +142,39 @@ write_jack_parameter(
return true;
}
bool
save_jack_client(
void * context,
ladish_client_handle client_handle,
const char * client_name,
void ** client_iteration_context_ptr_ptr)
{
#if 0
uuid_t uuid;
char str[37];
ladish_client_get_uuid(client_handle, uuid);
uuid_unparse(uuid, str);
#endif
lash_info("saving jack client '%s'", client_name);
return true;
}
bool
save_jack_port(
void * context,
void * client_iteration_context_ptr,
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)
{
lash_info("saving jack port '%s':'%s'", client_name, port_name);
return true;
}
bool studio_save(void * call_ptr)
{
struct list_head * node_ptr;
@ -291,6 +324,22 @@ bool studio_save(void * call_ptr)
goto close;
}
if (!write_string(fd, " <clients>\n", call_ptr))
{
goto close;
}
if (!ladish_graph_iterate_nodes(g_studio.graph, call_ptr, save_jack_client, save_jack_port))
{
lash_error("ladish_graph_iterate_nodes() failed");
goto close;
}
if (!write_string(fd, " </clients>\n", call_ptr))
{
goto close;
}
if (!write_string(fd, "</studio>\n", call_ptr))
{
goto close;