graph object implementation
This commit is contained in:
parent
44eb0c093a
commit
aea1b7bd19
|
@ -199,25 +199,33 @@ dbus_call_simple(
|
|||
goto fail;
|
||||
}
|
||||
|
||||
reply_signature = dbus_message_get_signature(reply_ptr);
|
||||
|
||||
if (strcmp(reply_signature, output_signature) != 0)
|
||||
if (output_signature != NULL)
|
||||
{
|
||||
lash_error("reply signature is '%s' but expected signature is '%s'", reply_signature, output_signature);
|
||||
reply_signature = dbus_message_get_signature(reply_ptr);
|
||||
|
||||
if (strcmp(reply_signature, output_signature) != 0)
|
||||
{
|
||||
lash_error("reply signature is '%s' but expected signature is '%s'", reply_signature, output_signature);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(reply_ptr, &iter);
|
||||
|
||||
while (*output_signature++ != '\0')
|
||||
{
|
||||
assert(dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID); /* we've checked the signature, this should not happen */
|
||||
parameter_ptr = va_arg(ap, void *);
|
||||
dbus_message_iter_get_basic(&iter, parameter_ptr);
|
||||
dbus_message_iter_next(&iter);
|
||||
}
|
||||
|
||||
assert(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INVALID); /* we've checked the signature, this should not happen */
|
||||
}
|
||||
|
||||
dbus_message_iter_init(reply_ptr, &iter);
|
||||
|
||||
while (*output_signature++ != '\0')
|
||||
else
|
||||
{
|
||||
assert(dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID); /* we've checked the signature, this should not happen */
|
||||
parameter_ptr = va_arg(ap, void *);
|
||||
dbus_message_iter_get_basic(&iter, parameter_ptr);
|
||||
dbus_message_iter_next(&iter);
|
||||
parameter_ptr = va_arg(ap, DBusMessage **);
|
||||
*(DBusMessage **)parameter_ptr = reply_ptr;
|
||||
}
|
||||
|
||||
assert(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INVALID); /* we've checked the signature, this should not happen */
|
||||
|
||||
ret = true;
|
||||
|
||||
fail:
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <stdbool.h> /* C99 bool */
|
||||
#include <stdint.h> /* fixed bit size ints */
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
|
|
576
gui/graph.c
576
gui/graph.c
|
@ -24,9 +24,26 @@
|
|||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "graph.h"
|
||||
#include "../common/klist.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../dbus/helpers.h"
|
||||
|
||||
#define JACKDBUS_IFACE_PATCHBAY "org.jackaudio.JackPatchbay"
|
||||
|
||||
#define JACKDBUS_PORT_FLAG_INPUT 0x00000001
|
||||
#define JACKDBUS_PORT_FLAG_OUTPUT 0x00000002
|
||||
#define JACKDBUS_PORT_FLAG_PHYSICAL 0x00000004
|
||||
#define JACKDBUS_PORT_FLAG_CAN_MONITOR 0x00000008
|
||||
#define JACKDBUS_PORT_FLAG_TERMINAL 0x00000010
|
||||
|
||||
#define JACKDBUS_PORT_TYPE_AUDIO 0
|
||||
#define JACKDBUS_PORT_TYPE_MIDI 1
|
||||
|
||||
struct monitor
|
||||
{
|
||||
|
@ -35,7 +52,7 @@ struct monitor
|
|||
void (* clear)(void * context);
|
||||
void (* client_appeared)(void * context, uint64_t id, const char * name);
|
||||
void (* client_disappeared)(void * context, uint64_t id);
|
||||
void (* port_sappeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi);
|
||||
void (* port_appeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi);
|
||||
void (* port_disappeared)(void * context, uint64_t client_id, uint64_t port_id);
|
||||
void (* ports_connected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id);
|
||||
void (* ports_disconnected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id);
|
||||
|
@ -44,35 +61,405 @@ struct monitor
|
|||
struct graph
|
||||
{
|
||||
struct list_head monitors;
|
||||
char * service;
|
||||
char * object;
|
||||
uint64_t version;
|
||||
};
|
||||
|
||||
DBusHandlerResult message_hook(DBusConnection *, DBusMessage *, void *);
|
||||
|
||||
static void clear(struct graph * graph_ptr)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->clear(monitor_ptr->context);
|
||||
}
|
||||
}
|
||||
|
||||
static void client_appeared(struct graph * graph_ptr, uint64_t id, const char * name)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->client_appeared(monitor_ptr->context, id, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void client_disappeared(struct graph * graph_ptr, uint64_t id)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->client_disappeared(monitor_ptr->context, id);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
port_appeared(
|
||||
struct graph * graph_ptr,
|
||||
uint64_t client_id,
|
||||
uint64_t port_id,
|
||||
const char * port_name,
|
||||
uint32_t port_flags,
|
||||
uint32_t port_type)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
bool is_input;
|
||||
bool is_terminal;
|
||||
bool is_midi;
|
||||
|
||||
if (port_type != JACKDBUS_PORT_TYPE_AUDIO && port_type != JACKDBUS_PORT_TYPE_MIDI)
|
||||
{
|
||||
lash_error("Unknown JACK D-Bus port type %d", (unsigned int)port_type);
|
||||
return;
|
||||
}
|
||||
|
||||
is_input = port_flags & JACKDBUS_PORT_FLAG_INPUT;
|
||||
is_terminal = port_flags & JACKDBUS_PORT_FLAG_TERMINAL;
|
||||
is_midi = port_flags == JACKDBUS_PORT_TYPE_MIDI;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->port_appeared(monitor_ptr->context, client_id, port_id, port_name, is_input, is_terminal, is_midi);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
port_disappeared(
|
||||
struct graph * graph_ptr,
|
||||
uint64_t client_id,
|
||||
uint64_t port_id)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->port_disappeared(monitor_ptr->context, client_id, port_id);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
ports_connected(
|
||||
struct graph * graph_ptr,
|
||||
uint64_t client1_id,
|
||||
uint64_t port1_id,
|
||||
uint64_t client2_id,
|
||||
uint64_t port2_id)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->ports_connected(monitor_ptr->context, client1_id, port1_id, client2_id, port2_id);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
ports_disconnected(
|
||||
struct graph * graph_ptr,
|
||||
uint64_t client1_id,
|
||||
uint64_t port1_id,
|
||||
uint64_t client2_id,
|
||||
uint64_t port2_id)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
monitor_ptr->ports_disconnected(monitor_ptr->context, client1_id, port1_id, client2_id, port2_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void refresh_internal(struct graph * graph_ptr, bool force)
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
DBusMessageIter iter;
|
||||
dbus_uint64_t version;
|
||||
const char * reply_signature;
|
||||
DBusMessageIter clients_array_iter;
|
||||
DBusMessageIter client_struct_iter;
|
||||
DBusMessageIter ports_array_iter;
|
||||
DBusMessageIter port_struct_iter;
|
||||
DBusMessageIter connections_array_iter;
|
||||
DBusMessageIter connection_struct_iter;
|
||||
dbus_uint64_t client_id;
|
||||
const char *client_name;
|
||||
dbus_uint64_t port_id;
|
||||
const char *port_name;
|
||||
dbus_uint32_t port_flags;
|
||||
dbus_uint32_t port_type;
|
||||
dbus_uint64_t client2_id;
|
||||
const char *client2_name;
|
||||
dbus_uint64_t port2_id;
|
||||
const char *port2_name;
|
||||
dbus_uint64_t connection_id;
|
||||
|
||||
if (force)
|
||||
{
|
||||
version = 0; // workaround module split/join stupidity
|
||||
}
|
||||
else
|
||||
{
|
||||
version = graph_ptr->version;
|
||||
}
|
||||
|
||||
if (!dbus_call_simple(graph_ptr->service, graph_ptr->object, JACKDBUS_IFACE_PATCHBAY, "GetGraph", "t", &version, NULL, &reply_ptr))
|
||||
{
|
||||
lash_error("GetGraph() failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
reply_signature = dbus_message_get_signature(reply_ptr);
|
||||
|
||||
if (strcmp(reply_signature, "ta(tsa(tsuu))a(tstststst)") != 0)
|
||||
{
|
||||
lash_error("GetGraph() reply signature mismatch. '%s'", reply_signature);
|
||||
goto unref;
|
||||
}
|
||||
|
||||
dbus_message_iter_init(reply_ptr, &iter);
|
||||
|
||||
//info_msg((std::string)"version " + (char)dbus_message_iter_get_arg_type(&iter));
|
||||
dbus_message_iter_get_basic(&iter, &version);
|
||||
dbus_message_iter_next(&iter);
|
||||
|
||||
if (!force && version <= graph_ptr->version)
|
||||
{
|
||||
goto unref;
|
||||
}
|
||||
|
||||
clear(graph_ptr);
|
||||
|
||||
//info_msg(str(boost::format("got new graph version %llu") % version));
|
||||
graph_ptr->version = version;
|
||||
|
||||
//info_msg((std::string)"clients " + (char)dbus_message_iter_get_arg_type(&iter));
|
||||
|
||||
for (dbus_message_iter_recurse(&iter, &clients_array_iter);
|
||||
dbus_message_iter_get_arg_type(&clients_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&clients_array_iter))
|
||||
{
|
||||
//info_msg((std::string)"a client " + (char)dbus_message_iter_get_arg_type(&clients_array_iter));
|
||||
dbus_message_iter_recurse(&clients_array_iter, &client_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&client_struct_iter, &client_id);
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&client_struct_iter, &client_name);
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
|
||||
//info_msg((std::string)"client '" + client_name + "'");
|
||||
|
||||
client_appeared(graph_ptr, client_id, client_name);
|
||||
|
||||
for (dbus_message_iter_recurse(&client_struct_iter, &ports_array_iter);
|
||||
dbus_message_iter_get_arg_type(&ports_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&ports_array_iter))
|
||||
{
|
||||
//info_msg((std::string)"a port " + (char)dbus_message_iter_get_arg_type(&ports_array_iter));
|
||||
dbus_message_iter_recurse(&ports_array_iter, &port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_id);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_name);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_flags);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_type);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
//info_msg((std::string)"port: " + port_name);
|
||||
|
||||
port_appeared(graph_ptr, client_id, port_id, port_name, port_flags, port_type);
|
||||
}
|
||||
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
}
|
||||
|
||||
dbus_message_iter_next(&iter);
|
||||
|
||||
for (dbus_message_iter_recurse(&iter, &connections_array_iter);
|
||||
dbus_message_iter_get_arg_type(&connections_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&connections_array_iter))
|
||||
{
|
||||
//info_msg((std::string)"a connection " + (char)dbus_message_iter_get_arg_type(&connections_array_iter));
|
||||
dbus_message_iter_recurse(&connections_array_iter, &connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client2_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client2_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port2_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port2_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &connection_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
//info_msg(str(boost::format("connection(%llu) %s(%llu):%s(%llu) <-> %s(%llu):%s(%llu)") %
|
||||
// connection_id %
|
||||
// client_name %
|
||||
// client_id %
|
||||
// port_name %
|
||||
// port_id %
|
||||
// client2_name %
|
||||
// client2_id %
|
||||
// port2_name %
|
||||
// port2_id));
|
||||
|
||||
ports_connected(graph_ptr, client_id, port_id, client2_id, port2_id);
|
||||
}
|
||||
|
||||
unref:
|
||||
dbus_message_unref(reply_ptr);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
graph_create(
|
||||
const char * service,
|
||||
const char * object,
|
||||
graph_handle * graph_ptr)
|
||||
graph_handle * graph_handle_ptr)
|
||||
{
|
||||
struct graph * graph_ptr;
|
||||
|
||||
graph_ptr = malloc(sizeof(struct graph));
|
||||
if (graph_ptr == NULL)
|
||||
{
|
||||
lash_error("malloc() failed to allocate struct graph");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
graph_ptr->service = strdup(service);
|
||||
if (graph_ptr->service == NULL)
|
||||
{
|
||||
lash_error("strdup() failed too duplicate service name '%s'", service);
|
||||
goto free_graph;
|
||||
}
|
||||
|
||||
graph_ptr->object = strdup(object);
|
||||
if (graph_ptr->object == NULL)
|
||||
{
|
||||
lash_error("strdup() failed too duplicate object name '%s'", object);
|
||||
goto free_service;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&graph_ptr->monitors);
|
||||
|
||||
graph_ptr->version = 0;
|
||||
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=ClientAppeared", NULL);
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=ClientDisappeared", NULL);
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortAppeared", NULL);
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortDisappeared", NULL);
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsConnected", NULL);
|
||||
dbus_bus_add_match(g_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsDisconnected", NULL);
|
||||
|
||||
dbus_connection_add_filter(g_dbus_connection, message_hook, graph_ptr, NULL);
|
||||
|
||||
refresh_internal(graph_ptr, true);
|
||||
|
||||
*graph_handle_ptr = (graph_handle)graph_ptr;
|
||||
|
||||
return true;
|
||||
|
||||
free_service:
|
||||
free(graph_ptr->service);
|
||||
|
||||
free_graph:
|
||||
free(graph_ptr);
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
#define graph_ptr ((struct graph *)graph)
|
||||
|
||||
void
|
||||
graph_destroy(
|
||||
graph_handle graph)
|
||||
{
|
||||
assert(list_empty(&graph_ptr->monitors));
|
||||
|
||||
free(graph_ptr->object);
|
||||
free(graph_ptr->service);
|
||||
free(graph_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
graph_attach(
|
||||
graph_handle graph,
|
||||
void * context,
|
||||
void (* clear)(void * context),
|
||||
void (* client_appeared)(void * context, uint64_t id, const char * name),
|
||||
void (* client_disappeared)(void * context, uint64_t id),
|
||||
void (* port_sappeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi),
|
||||
void (* port_appeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi),
|
||||
void (* port_disappeared)(void * context, uint64_t client_id, uint64_t port_id),
|
||||
void (* ports_connected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id),
|
||||
void (* ports_disconnected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id))
|
||||
{
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
monitor_ptr = malloc(sizeof(struct monitor));
|
||||
if (monitor_ptr == NULL)
|
||||
{
|
||||
lash_error("malloc() failed to allocate struct monitor");
|
||||
return false;
|
||||
}
|
||||
|
||||
monitor_ptr->context = context;
|
||||
monitor_ptr->clear = clear;
|
||||
monitor_ptr->client_appeared = client_appeared;
|
||||
monitor_ptr->client_disappeared = client_disappeared;
|
||||
monitor_ptr->port_appeared = port_appeared;
|
||||
monitor_ptr->port_disappeared = port_disappeared;
|
||||
monitor_ptr->ports_connected = ports_connected;
|
||||
monitor_ptr->ports_disconnected = ports_disconnected;
|
||||
|
||||
list_add_tail(&monitor_ptr->siblings, &graph_ptr->monitors);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -80,6 +467,21 @@ graph_detach(
|
|||
graph_handle graph,
|
||||
void * context)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
struct monitor * monitor_ptr;
|
||||
|
||||
list_for_each(node_ptr, &graph_ptr->monitors)
|
||||
{
|
||||
monitor_ptr = list_entry(node_ptr, struct monitor, siblings);
|
||||
if (monitor_ptr->context == context)
|
||||
{
|
||||
list_del(&monitor_ptr->siblings);
|
||||
free(monitor_ptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -88,6 +490,10 @@ graph_connect_ports(
|
|||
uint64_t port1_id,
|
||||
uint64_t port2_id)
|
||||
{
|
||||
if (!dbus_call_simple(graph_ptr->service, graph_ptr->object, JACKDBUS_IFACE_PATCHBAY, "ConnectPortsByID", "tt", &port1_id, &port2_id, ""))
|
||||
{
|
||||
lash_error("ConnectPortsByID() failed.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -96,4 +502,166 @@ graph_disconnect_ports(
|
|||
uint64_t port1_id,
|
||||
uint64_t port2_id)
|
||||
{
|
||||
if (!dbus_call_simple(graph_ptr->service, graph_ptr->object, JACKDBUS_IFACE_PATCHBAY, "DisconnectPortsByID", "tt", &port1_id, &port2_id, ""))
|
||||
{
|
||||
lash_error("DisconnectPortsByID() failed.");
|
||||
}
|
||||
}
|
||||
|
||||
DBusHandlerResult
|
||||
message_hook(
|
||||
DBusConnection * connection,
|
||||
DBusMessage * message,
|
||||
void * graph)
|
||||
{
|
||||
dbus_uint64_t new_graph_version;
|
||||
dbus_uint64_t client_id;
|
||||
const char *client_name;
|
||||
dbus_uint64_t port_id;
|
||||
const char *port_name;
|
||||
dbus_uint32_t port_flags;
|
||||
dbus_uint32_t port_type;
|
||||
dbus_uint64_t client2_id;
|
||||
const char *client2_name;
|
||||
dbus_uint64_t port2_id;
|
||||
const char *port2_name;
|
||||
dbus_uint64_t connection_id;
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "ClientAppeared"))
|
||||
{
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract ClientAppeared signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
lash_info("ClientAppeared, %s(%llu)", client_name, client_id);
|
||||
|
||||
client_appeared(graph_ptr, client_id, client_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "ClientDisappeared"))
|
||||
{
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract ClientDisappeared signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
lash_info("ClientDisappeared, %s(%llu)", client_name, client_id);
|
||||
|
||||
client_disappeared(graph_ptr, client_id);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortAppeared"))
|
||||
{
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT32, &port_flags,
|
||||
DBUS_TYPE_UINT32, &port_type,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract PortAppeared signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
//me->info_msg(str(boost::format("PortAppeared, %s(%llu):%s(%llu), %lu, %lu") % client_name % client_id % port_name % port_id % port_flags % port_type));
|
||||
|
||||
port_appeared(graph_ptr, client_id, port_id, port_name, port_flags, port_type);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortDisappeared"))
|
||||
{
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract PortDisappeared signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
//me->info_msg(str(boost::format("PortDisappeared, %s(%llu):%s(%llu)") % client_name % client_id % port_name % port_id));
|
||||
|
||||
port_disappeared(graph_ptr, client_id, port_id);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsConnected"))
|
||||
{
|
||||
if (!dbus_message_get_args(message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT64, &client2_id,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_UINT64, &port2_id,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_UINT64, &connection_id,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract PortsConnected signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
ports_connected(graph_ptr, client_id, port_id, client2_id, port2_id);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsDisconnected"))
|
||||
{
|
||||
if (!dbus_message_get_args(message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT64, &client2_id,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_UINT64, &port2_id,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_UINT64, &connection_id,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
lash_error("dbus_message_get_args() failed to extract PortsConnected signal arguments (%s)", g_dbus_error.message);
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
ports_disconnected(graph_ptr, client_id, port_id, client2_id, port2_id);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ void
|
|||
graph_destroy(
|
||||
graph_handle graph);
|
||||
|
||||
void
|
||||
bool
|
||||
graph_attach(
|
||||
graph_handle graph,
|
||||
void * context,
|
||||
void (* clear)(void * context),
|
||||
void (* client_appeared)(void * context, uint64_t id, const char * name),
|
||||
void (* client_disappeared)(void * context, uint64_t id),
|
||||
void (* port_sappeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi),
|
||||
void (* port_appeared)(void * context, uint64_t client_id, uint64_t port_id, const char * port_name, bool is_input, bool is_terminal, bool is_midi),
|
||||
void (* port_disappeared)(void * context, uint64_t client_id, uint64_t port_id),
|
||||
void (* ports_connected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id),
|
||||
void (* ports_disconnected)(void * context, uint64_t client1_id, uint64_t port1_id, uint64_t client2_id, uint64_t port2_id));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains code that interface with JACK through D-Bus
|
||||
|
@ -43,7 +43,6 @@
|
|||
#define JACKDBUS_SERVICE "org.jackaudio.service"
|
||||
#define JACKDBUS_OBJECT "/org/jackaudio/Controller"
|
||||
#define JACKDBUS_IFACE_CONTROL "org.jackaudio.JackControl"
|
||||
#define JACKDBUS_IFACE_PATCHBAY "org.jackaudio.JackPatchbay"
|
||||
|
||||
#define JACKDBUS_PORT_FLAG_INPUT 0x00000001
|
||||
#define JACKDBUS_PORT_FLAG_OUTPUT 0x00000002
|
||||
|
@ -54,9 +53,6 @@
|
|||
#define JACKDBUS_PORT_TYPE_AUDIO 0
|
||||
#define JACKDBUS_PORT_TYPE_MIDI 1
|
||||
|
||||
//#define USE_FULL_REFRESH
|
||||
|
||||
|
||||
jack_proxy::jack_proxy(Patchage* app)
|
||||
: _app(app)
|
||||
, _server_responding(false)
|
||||
|
@ -65,16 +61,6 @@ jack_proxy::jack_proxy(Patchage* app)
|
|||
, _max_dsp_load(0.0)
|
||||
{
|
||||
patchage_dbus_add_match("type='signal',interface='" DBUS_INTERFACE_DBUS "',member=NameOwnerChanged,arg0='" JACKDBUS_SERVICE "'");
|
||||
#if defined(USE_FULL_REFRESH)
|
||||
patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=GraphChanged");
|
||||
#else
|
||||
// patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=ClientAppeared");
|
||||
// patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=ClientDisappeared");
|
||||
patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortAppeared");
|
||||
patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortDisappeared");
|
||||
patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsConnected");
|
||||
patchage_dbus_add_match("type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsDisconnected");
|
||||
#endif
|
||||
patchage_dbus_add_filter(dbus_message_hook, this);
|
||||
|
||||
update_attached();
|
||||
|
@ -147,18 +133,6 @@ jack_proxy::dbus_message_hook(
|
|||
DBusMessage* message,
|
||||
void* jack_driver)
|
||||
{
|
||||
dbus_uint64_t new_graph_version;
|
||||
dbus_uint64_t client_id;
|
||||
const char *client_name;
|
||||
dbus_uint64_t port_id;
|
||||
const char *port_name;
|
||||
dbus_uint32_t port_flags;
|
||||
dbus_uint32_t port_type;
|
||||
dbus_uint64_t client2_id;
|
||||
const char *client2_name;
|
||||
dbus_uint64_t port2_id;
|
||||
const char *port2_name;
|
||||
dbus_uint64_t connection_id;
|
||||
const char *object_name;
|
||||
const char *old_owner;
|
||||
const char *new_owner;
|
||||
|
@ -196,162 +170,6 @@ jack_proxy::dbus_message_hook(
|
|||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
#if defined(USE_FULL_REFRESH)
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "GraphChanged")) {
|
||||
if (!dbus_message_get_args(message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
|
||||
"GraphChanged signal arguments (%s)") % g_dbus_error.message));
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (!me->_server_started) {
|
||||
me->_server_started = true;
|
||||
me->signal_attached.emit();
|
||||
}
|
||||
|
||||
if (new_graph_version > me->_graph_version) {
|
||||
me->refresh_internal(false);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
#else
|
||||
// if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "ClientAppeared")) {
|
||||
// me->info_msg("ClientAppeared");
|
||||
// return DBUS_HANDLER_RESULT_HANDLED;
|
||||
// }
|
||||
|
||||
// if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "ClientDisappeared")) {
|
||||
// me->info_msg("ClientDisappeared");
|
||||
// return DBUS_HANDLER_RESULT_HANDLED;
|
||||
// }
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortAppeared")) {
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT32, &port_flags,
|
||||
DBUS_TYPE_UINT32, &port_type,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
|
||||
"PortAppeared signal arguments (%s)") % g_dbus_error.message));
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
//me->info_msg(str(boost::format("PortAppeared, %s(%llu):%s(%llu), %lu, %lu") % client_name % client_id % port_name % port_id % port_flags % port_type));
|
||||
|
||||
if (!me->_server_started) {
|
||||
me->_server_started = true;
|
||||
me->signal_started.emit();
|
||||
}
|
||||
|
||||
me->on_port_added(client_id, client_name, port_id, port_name, port_flags, port_type);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortDisappeared")) {
|
||||
if (!dbus_message_get_args( message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
|
||||
"PortDisappeared signal arguments (%s)") % g_dbus_error.message));
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
//me->info_msg(str(boost::format("PortDisappeared, %s(%llu):%s(%llu)") % client_name % client_id % port_name % port_id));
|
||||
|
||||
if (!me->_server_started) {
|
||||
me->_server_started = true;
|
||||
me->signal_started.emit();
|
||||
}
|
||||
|
||||
me->on_port_removed(client_id, client_name, port_id, port_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsConnected")) {
|
||||
if (!dbus_message_get_args(message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT64, &client2_id,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_UINT64, &port2_id,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_UINT64, &connection_id,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
|
||||
"PortsConnected signal arguments (%s)") % g_dbus_error.message));
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (!me->_server_started) {
|
||||
me->_server_started = true;
|
||||
me->signal_started.emit();
|
||||
}
|
||||
|
||||
me->on_ports_connected(
|
||||
connection_id,
|
||||
client_id, client_name,
|
||||
port_id, port_name,
|
||||
client2_id, client2_name,
|
||||
port2_id, port2_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsDisconnected")) {
|
||||
if (!dbus_message_get_args(message, &g_dbus_error,
|
||||
DBUS_TYPE_UINT64, &new_graph_version,
|
||||
DBUS_TYPE_UINT64, &client_id,
|
||||
DBUS_TYPE_STRING, &client_name,
|
||||
DBUS_TYPE_UINT64, &port_id,
|
||||
DBUS_TYPE_STRING, &port_name,
|
||||
DBUS_TYPE_UINT64, &client2_id,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_UINT64, &port2_id,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_UINT64, &connection_id,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
|
||||
"PortsConnected signal arguments (%s)") % g_dbus_error.message));
|
||||
dbus_error_free(&g_dbus_error);
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
if (!me->_server_started) {
|
||||
me->_server_started = true;
|
||||
me->signal_started.emit();
|
||||
}
|
||||
|
||||
me->on_ports_disconnected(
|
||||
connection_id,
|
||||
client_id, client_name,
|
||||
port_id, port_name,
|
||||
client2_id, client2_name,
|
||||
port2_id, port2_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
#endif
|
||||
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -520,221 +338,9 @@ jack_proxy::on_ports_disconnected(
|
|||
_app->on_ports_disconnected(client1_name, port1_name, client2_name, port2_name);
|
||||
}
|
||||
|
||||
void
|
||||
jack_proxy::refresh_internal(bool force)
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
DBusMessageIter iter;
|
||||
dbus_uint64_t version;
|
||||
const char * reply_signature;
|
||||
DBusMessageIter clients_array_iter;
|
||||
DBusMessageIter client_struct_iter;
|
||||
DBusMessageIter ports_array_iter;
|
||||
DBusMessageIter port_struct_iter;
|
||||
DBusMessageIter connections_array_iter;
|
||||
DBusMessageIter connection_struct_iter;
|
||||
dbus_uint64_t client_id;
|
||||
const char *client_name;
|
||||
dbus_uint64_t port_id;
|
||||
const char *port_name;
|
||||
dbus_uint32_t port_flags;
|
||||
dbus_uint32_t port_type;
|
||||
dbus_uint64_t client2_id;
|
||||
const char *client2_name;
|
||||
dbus_uint64_t port2_id;
|
||||
const char *port2_name;
|
||||
dbus_uint64_t connection_id;
|
||||
|
||||
if (!_server_started)
|
||||
{
|
||||
info_msg("ignoring refresh request because JACK server is stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
if (force) {
|
||||
version = 0; // workaround module split/join stupidity
|
||||
} else {
|
||||
version = _graph_version;
|
||||
}
|
||||
|
||||
if (!call(true, JACKDBUS_IFACE_PATCHBAY, "GetGraph", &reply_ptr, DBUS_TYPE_UINT64, &version, DBUS_TYPE_INVALID)) {
|
||||
error_msg("GetGraph() failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
reply_signature = dbus_message_get_signature(reply_ptr);
|
||||
|
||||
if (strcmp(reply_signature, "ta(tsa(tsuu))a(tstststst)") != 0) {
|
||||
error_msg((std::string )"GetGraph() reply signature mismatch. " + reply_signature);
|
||||
goto unref;
|
||||
}
|
||||
|
||||
dbus_message_iter_init(reply_ptr, &iter);
|
||||
|
||||
//info_msg((std::string)"version " + (char)dbus_message_iter_get_arg_type(&iter));
|
||||
dbus_message_iter_get_basic(&iter, &version);
|
||||
dbus_message_iter_next(&iter);
|
||||
|
||||
if (!force && version <= _graph_version) {
|
||||
goto unref;
|
||||
}
|
||||
|
||||
_app->clear_canvas();
|
||||
|
||||
//info_msg(str(boost::format("got new graph version %llu") % version));
|
||||
_graph_version = version;
|
||||
|
||||
//info_msg((std::string)"clients " + (char)dbus_message_iter_get_arg_type(&iter));
|
||||
|
||||
for (dbus_message_iter_recurse(&iter, &clients_array_iter);
|
||||
dbus_message_iter_get_arg_type(&clients_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&clients_array_iter)) {
|
||||
//info_msg((std::string)"a client " + (char)dbus_message_iter_get_arg_type(&clients_array_iter));
|
||||
dbus_message_iter_recurse(&clients_array_iter, &client_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&client_struct_iter, &client_id);
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&client_struct_iter, &client_name);
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
|
||||
//info_msg((std::string)"client '" + client_name + "'");
|
||||
|
||||
for (dbus_message_iter_recurse(&client_struct_iter, &ports_array_iter);
|
||||
dbus_message_iter_get_arg_type(&ports_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&ports_array_iter)) {
|
||||
//info_msg((std::string)"a port " + (char)dbus_message_iter_get_arg_type(&ports_array_iter));
|
||||
dbus_message_iter_recurse(&ports_array_iter, &port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_id);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_name);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_flags);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&port_struct_iter, &port_type);
|
||||
dbus_message_iter_next(&port_struct_iter);
|
||||
|
||||
//info_msg((std::string)"port: " + port_name);
|
||||
|
||||
on_port_added(client_id, client_name, port_id, port_name, port_flags, port_type);
|
||||
}
|
||||
|
||||
dbus_message_iter_next(&client_struct_iter);
|
||||
}
|
||||
|
||||
dbus_message_iter_next(&iter);
|
||||
|
||||
for (dbus_message_iter_recurse(&iter, &connections_array_iter);
|
||||
dbus_message_iter_get_arg_type(&connections_array_iter) != DBUS_TYPE_INVALID;
|
||||
dbus_message_iter_next(&connections_array_iter)) {
|
||||
//info_msg((std::string)"a connection " + (char)dbus_message_iter_get_arg_type(&connections_array_iter));
|
||||
dbus_message_iter_recurse(&connections_array_iter, &connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client2_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &client2_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port2_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &port2_name);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
dbus_message_iter_get_basic(&connection_struct_iter, &connection_id);
|
||||
dbus_message_iter_next(&connection_struct_iter);
|
||||
|
||||
//info_msg(str(boost::format("connection(%llu) %s(%llu):%s(%llu) <-> %s(%llu):%s(%llu)") %
|
||||
// connection_id %
|
||||
// client_name %
|
||||
// client_id %
|
||||
// port_name %
|
||||
// port_id %
|
||||
// client2_name %
|
||||
// client2_id %
|
||||
// port2_name %
|
||||
// port2_id));
|
||||
|
||||
on_ports_connected(
|
||||
connection_id,
|
||||
client_id, client_name,
|
||||
port_id, port_name,
|
||||
client2_id, client2_name,
|
||||
port2_id, port2_name);
|
||||
}
|
||||
|
||||
unref:
|
||||
dbus_message_unref(reply_ptr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
jack_proxy::refresh()
|
||||
{
|
||||
refresh_internal(true);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
jack_proxy::connect(
|
||||
const char * client1_name,
|
||||
const char * port1_name,
|
||||
const char * client2_name,
|
||||
const char * port2_name)
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
|
||||
if (!call(true, JACKDBUS_IFACE_PATCHBAY, "ConnectPortsByName", &reply_ptr,
|
||||
DBUS_TYPE_STRING, &client1_name,
|
||||
DBUS_TYPE_STRING, &port1_name,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
error_msg("ConnectPortsByName() failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
jack_proxy::disconnect(
|
||||
const char * client1_name,
|
||||
const char * port1_name,
|
||||
const char * client2_name,
|
||||
const char * port2_name)
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
|
||||
if (!call(true, JACKDBUS_IFACE_PATCHBAY, "DisconnectPortsByName", &reply_ptr,
|
||||
DBUS_TYPE_STRING, &client1_name,
|
||||
DBUS_TYPE_STRING, &port1_name,
|
||||
DBUS_TYPE_STRING, &client2_name,
|
||||
DBUS_TYPE_STRING, &port2_name,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
error_msg("DisconnectPortsByName() failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
10
wscript
10
wscript
|
@ -251,6 +251,7 @@ def build(bld):
|
|||
gladish = bld.new_task_gen('cxx', 'program')
|
||||
gladish.features.append('cc')
|
||||
gladish.target = 'gladish'
|
||||
gladish.defines = ['DEBUG_OUTPUT_TERMINAL']
|
||||
gladish.includes = "build/default" # XXX config.h version.h and other generated files
|
||||
gladish.uselib = 'DBUS-1 LIBGNOMECANVASMM-2.6 LIBGLADEMM-2.4 FLOWCANVAS DBUS-GLIB-1'
|
||||
gladish.source = []
|
||||
|
@ -270,9 +271,16 @@ def build(bld):
|
|||
'a2j_proxy.cpp',
|
||||
'dbus_helpers.c',
|
||||
'canvas.cpp',
|
||||
'graph.c',
|
||||
]:
|
||||
gladish.source.append(os.path.join("gui", source))
|
||||
|
||||
|
||||
for source in [
|
||||
'method.c',
|
||||
'helpers.c',
|
||||
]:
|
||||
gladish.source.append(os.path.join("dbus", source))
|
||||
|
||||
# Glade UI definitions (XML)
|
||||
bld.install_files(bld.env['DATA_DIR'], 'gui/gui.glade')
|
||||
|
||||
|
|
Loading…
Reference in New Issue