jack graph object to store jack clients and ports

This commit is contained in:
Nedko Arnaudov 2009-09-12 22:30:33 +03:00
parent 83423d7fb7
commit 2862ba7650
6 changed files with 157 additions and 66 deletions

View File

@ -384,18 +384,28 @@ bool ladish_graph_create(ladish_graph_handle * graph_handle_ptr, const char * op
return false;
}
graph_ptr->opath = strdup(opath);
if (graph_ptr->opath == NULL)
if (opath != NULL)
{
lash_error("strdup() failed for graph opath");
free(graph_ptr);
return false;
graph_ptr->opath = strdup(opath);
if (graph_ptr->opath == NULL)
{
lash_error("strdup() failed for graph opath");
free(graph_ptr);
return false;
}
}
else
{
graph_ptr->opath = NULL;
}
if (!ladish_dict_create(&graph_ptr->dict))
{
lash_error("ladish_dict_create() failed for graph");
free(graph_ptr->opath);
if (graph_ptr->opath != NULL)
{
free(graph_ptr->opath);
}
free(graph_ptr);
return false;
}
@ -449,17 +459,20 @@ ladish_graph_remove_port_internal(
list_del(&port_ptr->siblings_graph);
lash_info("removing port '%s':'%s' (%llu:%llu)", client_ptr->name, port_ptr->name, (unsigned long long)client_ptr->id, (unsigned long long)port_ptr->id);
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"PortDisappeared",
"ttsts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name,
&port_ptr->id,
&port_ptr->name);
if (graph_ptr->opath != NULL)
{
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"PortDisappeared",
"ttsts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name,
&port_ptr->id,
&port_ptr->name);
}
free(port_ptr->name);
free(port_ptr);
@ -482,15 +495,18 @@ ladish_graph_remove_client_internal(
graph_ptr->graph_version++;
list_del(&client_ptr->siblings);
lash_info("removing client '%s' (%llu)", client_ptr->name, (unsigned long long)client_ptr->id);
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"ClientDisappeared",
"tts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name);
if (graph_ptr->opath != NULL)
{
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"ClientDisappeared",
"tts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name);
}
free(client_ptr->name);
free(client_ptr);
@ -502,7 +518,10 @@ void ladish_graph_destroy(ladish_graph_handle graph_handle)
{
ladish_graph_clear(graph_handle);
ladish_dict_destroy(graph_ptr->dict);
free(graph_ptr->opath);
if (graph_ptr->opath != NULL)
{
free(graph_ptr->opath);
}
free(graph_ptr);
}
@ -533,7 +552,7 @@ bool ladish_graph_add_client(ladish_graph_handle graph_handle, ladish_client_han
{
struct ladish_graph_client * client_ptr;
lash_info("adding client '%s' (%p) to graph %s", name, client_handle, graph_ptr->opath);
lash_info("adding client '%s' (%p) to graph %s", name, client_handle, graph_ptr->opath != NULL ? graph_ptr->opath : "JACK");
client_ptr = malloc(sizeof(struct ladish_graph_client));
if (client_ptr == NULL)
@ -558,15 +577,18 @@ bool ladish_graph_add_client(ladish_graph_handle graph_handle, ladish_client_han
list_add_tail(&client_ptr->siblings, &graph_ptr->clients);
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"ClientAppeared",
"tts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name);
if (graph_ptr->opath != NULL)
{
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"ClientAppeared",
"tts",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name);
}
return true;
}
@ -612,7 +634,7 @@ ladish_graph_add_port(
return false;
}
lash_info("adding port '%s':'%s' (%p)to graph %s", client_ptr->name, name, port_handle, graph_ptr->opath);
lash_info("adding port '%s':'%s' (%p)to graph %s", client_ptr->name, name, port_handle, graph_ptr->opath != NULL ? graph_ptr->opath : "JACK");
port_ptr = malloc(sizeof(struct ladish_graph_port));
if (port_ptr == NULL)
@ -639,19 +661,22 @@ ladish_graph_add_port(
list_add_tail(&port_ptr->siblings_client, &client_ptr->ports);
list_add_tail(&port_ptr->siblings_graph, &graph_ptr->ports);
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"PortAppeared",
"ttstsuu",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name,
&port_ptr->id,
&port_ptr->name,
&flags,
&type);
if (graph_ptr->opath != NULL)
{
dbus_signal_emit(
g_dbus_connection,
graph_ptr->opath,
JACKDBUS_IFACE_PATCHBAY,
"PortAppeared",
"ttstsuu",
&graph_ptr->graph_version,
&client_ptr->id,
&client_ptr->name,
&port_ptr->id,
&port_ptr->name,
&flags,
&type);
}
return true;
}

View File

@ -29,7 +29,9 @@
struct jack_dispatcher
{
graph_proxy_handle jack_graph;
graph_proxy_handle jack_graph_proxy;
ladish_graph_handle jack_graph;
ladish_graph_handle studio_graph;
uint64_t system_client_id;
ladish_client_handle system_capture_client;
@ -173,7 +175,8 @@ static void ports_disconnected(void * context, uint64_t client1_id, uint64_t por
bool
ladish_jack_dispatcher_create(
graph_proxy_handle jack_graph,
graph_proxy_handle jack_graph_proxy,
ladish_graph_handle jack_graph,
ladish_graph_handle studio_graph,
ladish_jack_dispatcher_handle * handle_ptr)
{
@ -186,6 +189,7 @@ ladish_jack_dispatcher_create(
return false;
}
dispatcher_ptr->jack_graph_proxy = jack_graph_proxy;
dispatcher_ptr->jack_graph = jack_graph;
dispatcher_ptr->studio_graph = studio_graph;
dispatcher_ptr->system_client_id = 0;
@ -193,7 +197,7 @@ ladish_jack_dispatcher_create(
dispatcher_ptr->system_playback_client = NULL;
if (!graph_proxy_attach(
jack_graph,
jack_graph_proxy,
dispatcher_ptr,
clear,
client_appeared,

View File

@ -35,7 +35,8 @@ typedef struct ladish_jack_dispatcher { int unused; } * ladish_jack_dispatcher_h
bool
ladish_jack_dispatcher_create(
graph_proxy_handle jack_graph,
graph_proxy_handle jack_graph_proxy,
ladish_graph_handle jack_graph,
ladish_graph_handle studio_graph,
ladish_jack_dispatcher_handle * handle_ptr);

View File

@ -86,8 +86,8 @@ studio_publish(void)
object = dbus_object_path_new(
STUDIO_OBJECT_PATH,
&g_interface_studio, &g_studio,
&g_interface_patchbay, ladish_graph_get_dbus_context(g_studio.graph),
&g_iface_graph_dict, g_studio.graph,
&g_interface_patchbay, ladish_graph_get_dbus_context(g_studio.studio_graph),
&g_iface_graph_dict, g_studio.studio_graph,
NULL);
if (object == NULL)
{
@ -237,7 +237,7 @@ void on_event_jack_started(void)
}
else
{
if (!ladish_jack_dispatcher_create(g_studio.jack_graph_proxy, g_studio.graph, &g_studio.jack_dispatcher))
if (!ladish_jack_dispatcher_create(g_studio.jack_graph_proxy, g_studio.jack_graph, g_studio.studio_graph, &g_studio.jack_dispatcher))
{
lash_error("ladish_jack_dispatcher_create() failed.");
}
@ -261,7 +261,8 @@ void on_event_jack_stopped(void)
g_studio.jack_dispatcher = NULL;
}
ladish_graph_clear(g_studio.graph);
ladish_graph_clear(g_studio.jack_graph);
ladish_graph_clear(g_studio.studio_graph);
if (g_studio.jack_graph_proxy)
{
@ -377,12 +378,18 @@ bool studio_init(void)
//studio_clear();
if (!ladish_graph_create(&g_studio.graph, STUDIO_OBJECT_PATH))
if (!ladish_graph_create(&g_studio.jack_graph, STUDIO_OBJECT_PATH))
{
lash_error("ladish_graph_create() failed.");
lash_error("ladish_graph_create() failed to create jack graph object.");
goto free_studios_dir;
}
if (!ladish_graph_create(&g_studio.studio_graph, NULL))
{
lash_error("ladish_graph_create() failed to create studio graph object.");
goto jack_graph_destroy;
}
if (!jack_proxy_init(
on_jack_server_started,
on_jack_server_stopped,
@ -390,13 +397,15 @@ bool studio_init(void)
on_jack_server_disappeared))
{
lash_error("jack_proxy_init() failed.");
goto graph_destroy;
goto studio_graph_destroy;
}
return true;
graph_destroy:
ladish_graph_destroy(g_studio.graph);
studio_graph_destroy:
ladish_graph_destroy(g_studio.studio_graph);
jack_graph_destroy:
ladish_graph_destroy(g_studio.jack_graph);
free_studios_dir:
studio_clear();
free(g_studios_dir);
@ -408,6 +417,8 @@ void studio_uninit(void)
{
jack_proxy_uninit();
ladish_graph_destroy(g_studio.studio_graph);
studio_clear();
free(g_studios_dir);

View File

@ -63,7 +63,8 @@ struct studio
char * filename;
graph_proxy_handle jack_graph_proxy;
ladish_graph_handle graph;
ladish_graph_handle jack_graph;
ladish_graph_handle studio_graph;
ladish_jack_dispatcher_handle jack_dispatcher;
};

View File

@ -175,6 +175,39 @@ save_jack_port(
return true;
}
bool
save_studio_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 studio client '%s'", client_name);
return true;
}
bool
save_studio_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 studio port '%s':'%s'", client_name, port_name);
return true;
}
bool studio_save(void * call_ptr)
{
struct list_head * node_ptr;
@ -319,6 +352,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.jack_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, " </jack>\n", call_ptr))
{
goto close;
@ -329,7 +378,7 @@ bool studio_save(void * call_ptr)
goto close;
}
if (!ladish_graph_iterate_nodes(g_studio.graph, call_ptr, save_jack_client, save_jack_port))
if (!ladish_graph_iterate_nodes(g_studio.studio_graph, call_ptr, save_studio_client, save_studio_port))
{
lash_error("ladish_graph_iterate_nodes() failed");
goto close;