1 /* -*- Mode: C ; c-basic-offset: 4 -*- */
3 Copyright (C) 2008 Nedko Arnaudov
4 Copyright (C) 2008 Juuso Alasuutari
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #if defined(HAVE_CONFIG_H)
25 #define _GNU_SOURCE /* PTHREAD_MUTEX_RECURSIVE */
32 #include <dbus/dbus.h>
36 #include "controller_internal.h"
39 #define JACK_DBUS_IFACE_NAME "org.jackaudio.JackPatchbay"
41 /* FIXME: these need to be retrieved from common headers */
42 #define JACK_CLIENT_NAME_SIZE 64
43 #define JACK_PORT_NAME_SIZE 256
48 struct list_head clients
;
49 struct list_head ports
;
50 struct list_head connections
;
53 struct jack_graph_client
58 struct list_head siblings
;
59 struct list_head ports
;
62 struct jack_graph_port
68 struct list_head siblings_graph
;
69 struct list_head siblings_client
;
70 struct jack_graph_client
* client
;
73 struct jack_graph_connection
76 struct jack_graph_port
* port1
;
77 struct jack_graph_port
* port2
;
78 struct list_head siblings
;
81 struct jack_controller_patchbay
84 struct jack_graph graph
;
85 uint64_t next_client_id
;
86 uint64_t next_port_id
;
87 uint64_t next_connection_id
;
91 jack_controller_patchbay_send_signal_graph_changed(
92 dbus_uint64_t new_graph_version
)
95 jack_dbus_send_signal(
96 JACK_CONTROLLER_OBJECT_PATH
,
105 jack_controller_patchbay_send_signal_client_appeared(
106 dbus_uint64_t new_graph_version
,
107 dbus_uint64_t client_id
,
108 const char * client_name
)
111 jack_dbus_send_signal(
112 JACK_CONTROLLER_OBJECT_PATH
,
113 JACK_DBUS_IFACE_NAME
,
125 jack_controller_patchbay_send_signal_client_disappeared(
126 dbus_uint64_t new_graph_version
,
127 dbus_uint64_t client_id
,
128 const char * client_name
)
131 jack_dbus_send_signal(
132 JACK_CONTROLLER_OBJECT_PATH
,
133 JACK_DBUS_IFACE_NAME
,
145 jack_controller_patchbay_send_signal_port_appeared(
146 dbus_uint64_t new_graph_version
,
147 dbus_uint64_t client_id
,
148 const char * client_name
,
149 dbus_uint64_t port_id
,
150 const char * port_name
,
151 dbus_uint32_t port_flags
,
152 dbus_uint32_t port_type
)
155 jack_dbus_send_signal(
156 JACK_CONTROLLER_OBJECT_PATH
,
157 JACK_DBUS_IFACE_NAME
,
177 jack_controller_patchbay_send_signal_port_disappeared(
178 dbus_uint64_t new_graph_version
,
179 dbus_uint64_t client_id
,
180 const char * client_name
,
181 dbus_uint64_t port_id
,
182 const char * port_name
)
185 jack_dbus_send_signal(
186 JACK_CONTROLLER_OBJECT_PATH
,
187 JACK_DBUS_IFACE_NAME
,
203 jack_controller_patchbay_send_signal_ports_connected(
204 dbus_uint64_t new_graph_version
,
205 dbus_uint64_t client1_id
,
206 const char * client1_name
,
207 dbus_uint64_t port1_id
,
208 const char * port1_name
,
209 dbus_uint64_t client2_id
,
210 const char * client2_name
,
211 dbus_uint64_t port2_id
,
212 const char * port2_name
,
213 dbus_uint64_t connection_id
)
216 jack_dbus_send_signal(
217 JACK_CONTROLLER_OBJECT_PATH
,
218 JACK_DBUS_IFACE_NAME
,
244 jack_controller_patchbay_send_signal_ports_disconnected(
245 dbus_uint64_t new_graph_version
,
246 dbus_uint64_t client1_id
,
247 const char * client1_name
,
248 dbus_uint64_t port1_id
,
249 const char * port1_name
,
250 dbus_uint64_t client2_id
,
251 const char * client2_name
,
252 dbus_uint64_t port2_id
,
253 const char * port2_name
,
254 dbus_uint64_t connection_id
)
257 jack_dbus_send_signal(
258 JACK_CONTROLLER_OBJECT_PATH
,
259 JACK_DBUS_IFACE_NAME
,
285 struct jack_graph_client
*
286 jack_controller_patchbay_find_client(
287 struct jack_controller_patchbay
*patchbay_ptr
,
288 const char *client_name
, /* not '\0' terminated */
289 size_t client_name_len
) /* without terminating '\0' */
291 struct list_head
*node_ptr
;
292 struct jack_graph_client
*client_ptr
;
294 list_for_each(node_ptr
, &patchbay_ptr
->graph
.clients
)
296 client_ptr
= list_entry(node_ptr
, struct jack_graph_client
, siblings
);
297 if (strncmp(client_ptr
->name
, client_name
, client_name_len
) == 0)
307 struct jack_graph_client
*
308 jack_controller_patchbay_find_client_by_id(
309 struct jack_controller_patchbay
*patchbay_ptr
,
312 struct list_head
*node_ptr
;
313 struct jack_graph_client
*client_ptr
;
315 list_for_each(node_ptr
, &patchbay_ptr
->graph
.clients
)
317 client_ptr
= list_entry(node_ptr
, struct jack_graph_client
, siblings
);
318 if (client_ptr
->id
== id
)
328 struct jack_graph_client
*
329 jack_controller_patchbay_create_client(
330 struct jack_controller_patchbay
*patchbay_ptr
,
331 const char *client_name
, /* not '\0' terminated */
332 size_t client_name_len
) /* without terminating '\0' */
334 struct jack_graph_client
* client_ptr
;
336 client_ptr
= malloc(sizeof(struct jack_graph_client
));
337 if (client_ptr
== NULL
)
339 jack_error("Memory allocation of jack_graph_client structure failed.");
343 client_ptr
->name
= malloc(client_name_len
+ 1);
344 if (client_ptr
->name
== NULL
)
346 jack_error("malloc() failed to allocate memory for client name.");
347 goto fail_free_client
;
350 memcpy(client_ptr
->name
, client_name
, client_name_len
);
351 client_ptr
->name
[client_name_len
] = 0;
353 client_ptr
->pid
= jack_get_client_pid(client_ptr
->name
);
354 jack_info("New client '%s' with PID %d", client_ptr
->name
, client_ptr
->pid
);
356 client_ptr
->id
= patchbay_ptr
->next_client_id
++;
357 INIT_LIST_HEAD(&client_ptr
->ports
);
360 pthread_mutex_lock(&patchbay_ptr
->lock
);
361 list_add_tail(&client_ptr
->siblings
, &patchbay_ptr
->graph
.clients
);
362 patchbay_ptr
->graph
.version
++;
363 jack_controller_patchbay_send_signal_client_appeared(patchbay_ptr
->graph
.version
, client_ptr
->id
, client_ptr
->name
);
364 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
365 pthread_mutex_unlock(&patchbay_ptr
->lock
);
378 jack_controller_patchbay_destroy_client(
379 struct jack_controller_patchbay
*patchbay_ptr
,
380 struct jack_graph_client
*client_ptr
)
382 jack_info("Client '%s' with PID %d is out", client_ptr
->name
, client_ptr
->pid
);
384 pthread_mutex_lock(&patchbay_ptr
->lock
);
385 list_del(&client_ptr
->siblings
);
386 patchbay_ptr
->graph
.version
++;
387 jack_controller_patchbay_send_signal_client_disappeared(patchbay_ptr
->graph
.version
, client_ptr
->id
, client_ptr
->name
);
388 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
389 pthread_mutex_unlock(&patchbay_ptr
->lock
);
391 free(client_ptr
->name
);
397 jack_controller_patchbay_destroy_client_by_name(
398 struct jack_controller_patchbay
*patchbay_ptr
,
399 const char *client_name
) /* '\0' terminated */
401 struct jack_graph_client
*client_ptr
;
403 client_ptr
= jack_controller_patchbay_find_client(patchbay_ptr
, client_name
, strlen(client_name
));
404 if (client_ptr
== NULL
)
406 jack_error("Cannot destroy unknown client '%s'", client_name
);
410 jack_controller_patchbay_destroy_client(patchbay_ptr
, client_ptr
);
415 jack_controller_patchbay_new_port(
416 struct jack_controller_patchbay
*patchbay_ptr
,
417 const char *port_full_name
,
421 struct jack_graph_client
*client_ptr
;
422 struct jack_graph_port
*port_ptr
;
423 const char *port_short_name
;
424 size_t client_name_len
;
426 //jack_info("name: %s", port_full_name);
428 port_short_name
= strchr(port_full_name
, ':');
429 if (port_short_name
== NULL
)
431 jack_error("port name '%s' does not contain ':' separator char", port_full_name
);
435 port_short_name
++; /* skip ':' separator char */
437 client_name_len
= port_short_name
- port_full_name
- 1; /* without terminating '\0' */
439 client_ptr
= jack_controller_patchbay_find_client(patchbay_ptr
, port_full_name
, client_name_len
);
440 if (client_ptr
== NULL
)
442 client_ptr
= jack_controller_patchbay_create_client(patchbay_ptr
, port_full_name
, client_name_len
);
443 if (client_ptr
== NULL
)
445 jack_error("Creation of new jack_graph client failed.");
450 port_ptr
= malloc(sizeof(struct jack_graph_port
));
451 if (port_ptr
== NULL
)
453 jack_error("Memory allocation of jack_graph_port structure failed.");
457 port_ptr
->name
= strdup(port_short_name
);
458 if (port_ptr
->name
== NULL
)
460 jack_error("strdup() call for port name '%s' failed.", port_short_name
);
465 port_ptr
->id
= patchbay_ptr
->next_port_id
++;
466 port_ptr
->flags
= port_flags
;
467 port_ptr
->type
= port_type
;
468 port_ptr
->client
= client_ptr
;
470 pthread_mutex_lock(&patchbay_ptr
->lock
);
471 list_add_tail(&port_ptr
->siblings_client
, &client_ptr
->ports
);
472 list_add_tail(&port_ptr
->siblings_graph
, &patchbay_ptr
->graph
.ports
);
473 patchbay_ptr
->graph
.version
++;
474 jack_controller_patchbay_send_signal_port_appeared(
475 patchbay_ptr
->graph
.version
,
482 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
483 pthread_mutex_unlock(&patchbay_ptr
->lock
);
488 jack_controller_patchbay_remove_port(
489 struct jack_controller_patchbay
*patchbay_ptr
,
490 struct jack_graph_port
*port_ptr
)
492 pthread_mutex_lock(&patchbay_ptr
->lock
);
493 list_del(&port_ptr
->siblings_client
);
494 list_del(&port_ptr
->siblings_graph
);
495 patchbay_ptr
->graph
.version
++;
496 jack_controller_patchbay_send_signal_port_disappeared(patchbay_ptr
->graph
.version
, port_ptr
->client
->id
, port_ptr
->client
->name
, port_ptr
->id
, port_ptr
->name
);
497 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
498 pthread_mutex_unlock(&patchbay_ptr
->lock
);
500 free(port_ptr
->name
);
505 struct jack_graph_port
*
506 jack_controller_patchbay_find_port_by_id(
507 struct jack_controller_patchbay
*patchbay_ptr
,
510 struct list_head
*node_ptr
;
511 struct jack_graph_port
*port_ptr
;
513 list_for_each(node_ptr
, &patchbay_ptr
->graph
.ports
)
515 port_ptr
= list_entry(node_ptr
, struct jack_graph_port
, siblings_graph
);
516 if (port_ptr
->id
== port_id
)
526 struct jack_graph_port
*
527 jack_controller_patchbay_find_client_port_by_name(
528 struct jack_controller_patchbay
*patchbay_ptr
,
529 struct jack_graph_client
*client_ptr
,
530 const char *port_name
)
532 struct list_head
*node_ptr
;
533 struct jack_graph_port
*port_ptr
;
535 list_for_each(node_ptr
, &client_ptr
->ports
)
537 port_ptr
= list_entry(node_ptr
, struct jack_graph_port
, siblings_client
);
538 if (strcmp(port_ptr
->name
, port_name
) == 0)
548 struct jack_graph_port
*
549 jack_controller_patchbay_find_port_by_full_name(
550 struct jack_controller_patchbay
*patchbay_ptr
,
551 const char *port_full_name
)
553 const char *port_short_name
;
554 size_t client_name_len
;
555 struct jack_graph_client
*client_ptr
;
557 //jack_info("name: %s", port_full_name);
559 port_short_name
= strchr(port_full_name
, ':');
560 if (port_short_name
== NULL
)
562 jack_error("port name '%s' does not contain ':' separator char", port_full_name
);
566 port_short_name
++; /* skip ':' separator char */
568 client_name_len
= port_short_name
- port_full_name
- 1; /* without terminating '\0' */
570 client_ptr
= jack_controller_patchbay_find_client(patchbay_ptr
, port_full_name
, client_name_len
);
571 if (client_ptr
== NULL
)
573 jack_error("cannot find client of port '%s'", port_full_name
);
577 return jack_controller_patchbay_find_client_port_by_name(patchbay_ptr
, client_ptr
, port_short_name
);
581 struct jack_graph_port
*
582 jack_controller_patchbay_find_port_by_names(
583 struct jack_controller_patchbay
*patchbay_ptr
,
584 const char *client_name
,
585 const char *port_name
)
587 struct jack_graph_client
*client_ptr
;
589 client_ptr
= jack_controller_patchbay_find_client(patchbay_ptr
, client_name
, strlen(client_name
));
590 if (client_ptr
== NULL
)
592 jack_error("cannot find client '%s'", client_name
);
596 return jack_controller_patchbay_find_client_port_by_name(patchbay_ptr
, client_ptr
, port_name
);
600 struct jack_graph_connection
*
601 jack_controller_patchbay_create_connection(
602 struct jack_controller_patchbay
*patchbay_ptr
,
603 struct jack_graph_port
*port1_ptr
,
604 struct jack_graph_port
*port2_ptr
)
606 struct jack_graph_connection
* connection_ptr
;
608 connection_ptr
= malloc(sizeof(struct jack_graph_connection
));
609 if (connection_ptr
== NULL
)
611 jack_error("Memory allocation of jack_graph_connection structure failed.");
615 connection_ptr
->id
= patchbay_ptr
->next_connection_id
++;
616 connection_ptr
->port1
= port1_ptr
;
617 connection_ptr
->port2
= port2_ptr
;
619 pthread_mutex_lock(&patchbay_ptr
->lock
);
620 list_add_tail(&connection_ptr
->siblings
, &patchbay_ptr
->graph
.connections
);
621 patchbay_ptr
->graph
.version
++;
622 jack_controller_patchbay_send_signal_ports_connected(
623 patchbay_ptr
->graph
.version
,
624 port1_ptr
->client
->id
,
625 port1_ptr
->client
->name
,
628 port2_ptr
->client
->id
,
629 port2_ptr
->client
->name
,
633 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
634 pthread_mutex_unlock(&patchbay_ptr
->lock
);
636 return connection_ptr
;
641 jack_controller_patchbay_destroy_connection(
642 struct jack_controller_patchbay
*patchbay_ptr
,
643 struct jack_graph_connection
*connection_ptr
)
645 pthread_mutex_lock(&patchbay_ptr
->lock
);
646 list_del(&connection_ptr
->siblings
);
647 patchbay_ptr
->graph
.version
++;
648 jack_controller_patchbay_send_signal_ports_disconnected(
649 patchbay_ptr
->graph
.version
,
650 connection_ptr
->port1
->client
->id
,
651 connection_ptr
->port1
->client
->name
,
652 connection_ptr
->port1
->id
,
653 connection_ptr
->port1
->name
,
654 connection_ptr
->port2
->client
->id
,
655 connection_ptr
->port2
->client
->name
,
656 connection_ptr
->port2
->id
,
657 connection_ptr
->port2
->name
,
659 jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr
->graph
.version
);
660 pthread_mutex_unlock(&patchbay_ptr
->lock
);
662 free(connection_ptr
);
666 struct jack_graph_connection
*
667 jack_controller_patchbay_find_connection(
668 struct jack_controller_patchbay
*patchbay_ptr
,
669 struct jack_graph_port
*port1_ptr
,
670 struct jack_graph_port
*port2_ptr
)
672 struct list_head
*node_ptr
;
673 struct jack_graph_connection
*connection_ptr
;
675 list_for_each(node_ptr
, &patchbay_ptr
->graph
.connections
)
677 connection_ptr
= list_entry(node_ptr
, struct jack_graph_connection
, siblings
);
678 if ((connection_ptr
->port1
== port1_ptr
&&
679 connection_ptr
->port2
== port2_ptr
) ||
680 (connection_ptr
->port1
== port2_ptr
&&
681 connection_ptr
->port2
== port1_ptr
))
683 return connection_ptr
;
691 struct jack_graph_connection
*
692 jack_controller_patchbay_find_connection_by_id(
693 struct jack_controller_patchbay
*patchbay_ptr
,
694 uint64_t connection_id
)
696 struct list_head
*node_ptr
;
697 struct jack_graph_connection
*connection_ptr
;
699 list_for_each(node_ptr
, &patchbay_ptr
->graph
.connections
)
701 connection_ptr
= list_entry(node_ptr
, struct jack_graph_connection
, siblings
);
702 if (connection_ptr
->id
== connection_id
)
704 return connection_ptr
;
713 jack_controller_patchbay_connect(
714 struct jack_dbus_method_call
*dbus_call_ptr
,
715 struct jack_controller
*controller_ptr
,
716 struct jack_graph_port
*port1_ptr
,
717 struct jack_graph_port
*port2_ptr
)
720 char port1_name
[JACK_CLIENT_NAME_SIZE
+ JACK_PORT_NAME_SIZE
];
721 char port2_name
[JACK_CLIENT_NAME_SIZE
+ JACK_PORT_NAME_SIZE
];
723 sprintf(port1_name
, "%s:%s", port1_ptr
->client
->name
, port1_ptr
->name
);
724 sprintf(port2_name
, "%s:%s", port2_ptr
->client
->name
, port2_ptr
->name
);
726 ret
= jack_connect(controller_ptr
->client
, port1_name
, port2_name
);
729 jack_dbus_error(dbus_call_ptr
, JACK_DBUS_ERROR_GENERIC
, "jack_connect() failed with %d", ret
);
738 jack_controller_patchbay_disconnect(
739 struct jack_dbus_method_call
*dbus_call_ptr
,
740 struct jack_controller
*controller_ptr
,
741 struct jack_graph_port
*port1_ptr
,
742 struct jack_graph_port
*port2_ptr
)
745 char port1_name
[JACK_CLIENT_NAME_SIZE
+ JACK_PORT_NAME_SIZE
];
746 char port2_name
[JACK_CLIENT_NAME_SIZE
+ JACK_PORT_NAME_SIZE
];
748 sprintf(port1_name
, "%s:%s", port1_ptr
->client
->name
, port1_ptr
->name
);
749 sprintf(port2_name
, "%s:%s", port2_ptr
->client
->name
, port2_ptr
->name
);
751 ret
= jack_disconnect(controller_ptr
->client
, port1_name
, port2_name
);
754 jack_dbus_error(dbus_call_ptr
, JACK_DBUS_ERROR_GENERIC
, "jack_connect() failed with %d", ret
);
761 #define controller_ptr ((struct jack_controller *)call->context)
762 #define patchbay_ptr ((struct jack_controller_patchbay *)controller_ptr->patchbay_context)
766 jack_controller_dbus_get_all_ports(
767 struct jack_dbus_method_call
* call
)
769 struct list_head
* client_node_ptr
;
770 struct list_head
* port_node_ptr
;
771 struct jack_graph_client
* client_ptr
;
772 struct jack_graph_port
* port_ptr
;
773 DBusMessageIter iter
, sub_iter
;
774 char fullname
[JACK_CLIENT_NAME_SIZE
+ JACK_PORT_NAME_SIZE
];
775 char *fullname_var
= fullname
;
777 if (!controller_ptr
->started
)
781 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
782 "Can't execute this method with stopped JACK server");
786 call
->reply
= dbus_message_new_method_return (call
->message
);
792 dbus_message_iter_init_append (call
->reply
, &iter
);
794 if (!dbus_message_iter_open_container (&iter
, DBUS_TYPE_ARRAY
, "s", &sub_iter
))
799 pthread_mutex_lock(&patchbay_ptr
->lock
);
801 list_for_each(client_node_ptr
, &patchbay_ptr
->graph
.clients
)
803 client_ptr
= list_entry(client_node_ptr
, struct jack_graph_client
, siblings
);
805 list_for_each(port_node_ptr
, &client_ptr
->ports
)
807 port_ptr
= list_entry(port_node_ptr
, struct jack_graph_port
, siblings_client
);
809 jack_info("%s:%s", client_ptr
->name
, port_ptr
->name
);
810 sprintf(fullname
, "%s:%s", client_ptr
->name
, port_ptr
->name
);
811 if (!dbus_message_iter_append_basic (&sub_iter
, DBUS_TYPE_STRING
, &fullname_var
))
813 pthread_mutex_unlock(&patchbay_ptr
->lock
);
814 dbus_message_iter_close_container (&iter
, &sub_iter
);
820 pthread_mutex_unlock(&patchbay_ptr
->lock
);
822 if (!dbus_message_iter_close_container (&iter
, &sub_iter
))
830 dbus_message_unref (call
->reply
);
834 jack_error ("Ran out of memory trying to construct method return");
839 jack_controller_dbus_get_graph(
840 struct jack_dbus_method_call
* call
)
842 struct list_head
* client_node_ptr
;
843 struct list_head
* port_node_ptr
;
844 struct list_head
* connection_node_ptr
;
845 struct jack_graph_client
* client_ptr
;
846 struct jack_graph_port
* port_ptr
;
847 struct jack_graph_connection
* connection_ptr
;
848 DBusMessageIter iter
;
849 DBusMessageIter clients_array_iter
;
850 DBusMessageIter client_struct_iter
;
851 DBusMessageIter ports_array_iter
;
852 DBusMessageIter port_struct_iter
;
853 dbus_uint64_t version
;
854 DBusMessageIter connections_array_iter
;
855 DBusMessageIter connection_struct_iter
;
857 if (!controller_ptr
->started
)
861 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
862 "Can't execute this method with stopped JACK server");
866 if (!jack_dbus_get_method_args(call
, DBUS_TYPE_UINT64
, &version
, DBUS_TYPE_INVALID
))
868 /* The method call had invalid arguments meaning that
869 * jack_dbus_get_method_args() has constructed an error for us.
874 //jack_info("Getting graph, know version is %" PRIu32, version);
876 call
->reply
= dbus_message_new_method_return(call
->message
);
879 jack_error("Ran out of memory trying to construct method return");
883 dbus_message_iter_init_append (call
->reply
, &iter
);
885 pthread_mutex_lock(&patchbay_ptr
->lock
);
887 if (version
> patchbay_ptr
->graph
.version
)
891 JACK_DBUS_ERROR_INVALID_ARGS
,
892 "known graph version %" PRIu64
" is newer than actual version %" PRIu64
,
894 patchbay_ptr
->graph
.version
);
895 pthread_mutex_unlock(&patchbay_ptr
->lock
);
899 if (!dbus_message_iter_append_basic(&iter
, DBUS_TYPE_UINT64
, &patchbay_ptr
->graph
.version
))
904 if (!dbus_message_iter_open_container(&iter
, DBUS_TYPE_ARRAY
, "(tsa(tsuu))", &clients_array_iter
))
909 if (version
< patchbay_ptr
->graph
.version
)
911 list_for_each(client_node_ptr
, &patchbay_ptr
->graph
.clients
)
913 client_ptr
= list_entry(client_node_ptr
, struct jack_graph_client
, siblings
);
915 if (!dbus_message_iter_open_container (&clients_array_iter
, DBUS_TYPE_STRUCT
, NULL
, &client_struct_iter
))
917 goto nomem_close_clients_array
;
920 if (!dbus_message_iter_append_basic(&client_struct_iter
, DBUS_TYPE_UINT64
, &client_ptr
->id
))
922 goto nomem_close_client_struct
;
925 if (!dbus_message_iter_append_basic(&client_struct_iter
, DBUS_TYPE_STRING
, &client_ptr
->name
))
927 goto nomem_close_client_struct
;
930 if (!dbus_message_iter_open_container(&client_struct_iter
, DBUS_TYPE_ARRAY
, "(tsuu)", &ports_array_iter
))
932 goto nomem_close_client_struct
;
935 list_for_each(port_node_ptr
, &client_ptr
->ports
)
937 port_ptr
= list_entry(port_node_ptr
, struct jack_graph_port
, siblings_client
);
939 if (!dbus_message_iter_open_container(&ports_array_iter
, DBUS_TYPE_STRUCT
, NULL
, &port_struct_iter
))
941 goto nomem_close_ports_array
;
944 if (!dbus_message_iter_append_basic(&port_struct_iter
, DBUS_TYPE_UINT64
, &port_ptr
->id
))
946 goto nomem_close_port_struct
;
949 if (!dbus_message_iter_append_basic(&port_struct_iter
, DBUS_TYPE_STRING
, &port_ptr
->name
))
951 goto nomem_close_port_struct
;
954 if (!dbus_message_iter_append_basic(&port_struct_iter
, DBUS_TYPE_UINT32
, &port_ptr
->flags
))
956 goto nomem_close_port_struct
;
959 if (!dbus_message_iter_append_basic(&port_struct_iter
, DBUS_TYPE_UINT32
, &port_ptr
->type
))
961 goto nomem_close_port_struct
;
964 if (!dbus_message_iter_close_container(&ports_array_iter
, &port_struct_iter
))
966 goto nomem_close_ports_array
;
970 if (!dbus_message_iter_close_container(&client_struct_iter
, &ports_array_iter
))
972 goto nomem_close_client_struct
;
975 if (!dbus_message_iter_close_container(&clients_array_iter
, &client_struct_iter
))
977 goto nomem_close_clients_array
;
982 if (!dbus_message_iter_close_container(&iter
, &clients_array_iter
))
987 if (!dbus_message_iter_open_container(&iter
, DBUS_TYPE_ARRAY
, "(tstststst)", &connections_array_iter
))
992 if (version
< patchbay_ptr
->graph
.version
)
994 list_for_each(connection_node_ptr
, &patchbay_ptr
->graph
.connections
)
996 connection_ptr
= list_entry(connection_node_ptr
, struct jack_graph_connection
, siblings
);
998 if (!dbus_message_iter_open_container(&connections_array_iter
, DBUS_TYPE_STRUCT
, NULL
, &connection_struct_iter
))
1000 goto nomem_close_connections_array
;
1003 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_UINT64
, &connection_ptr
->port1
->client
->id
))
1005 goto nomem_close_connection_struct
;
1008 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_STRING
, &connection_ptr
->port1
->client
->name
))
1010 goto nomem_close_connection_struct
;
1013 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_UINT64
, &connection_ptr
->port1
->id
))
1015 goto nomem_close_connection_struct
;
1018 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_STRING
, &connection_ptr
->port1
->name
))
1020 goto nomem_close_connection_struct
;
1023 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_UINT64
, &connection_ptr
->port2
->client
->id
))
1025 goto nomem_close_connection_struct
;
1028 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_STRING
, &connection_ptr
->port2
->client
->name
))
1030 goto nomem_close_connection_struct
;
1033 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_UINT64
, &connection_ptr
->port2
->id
))
1035 goto nomem_close_connection_struct
;
1038 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_STRING
, &connection_ptr
->port2
->name
))
1040 goto nomem_close_connection_struct
;
1043 if (!dbus_message_iter_append_basic(&connection_struct_iter
, DBUS_TYPE_UINT64
, &connection_ptr
->id
))
1045 goto nomem_close_connection_struct
;
1048 if (!dbus_message_iter_close_container(&connections_array_iter
, &connection_struct_iter
))
1050 goto nomem_close_connections_array
;
1055 if (!dbus_message_iter_close_container(&iter
, &connections_array_iter
))
1060 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1064 nomem_close_connection_struct
:
1065 dbus_message_iter_close_container(&connections_array_iter
, &connection_struct_iter
);
1067 nomem_close_connections_array
:
1068 dbus_message_iter_close_container(&iter
, &connections_array_iter
);
1071 nomem_close_port_struct
:
1072 dbus_message_iter_close_container(&ports_array_iter
, &port_struct_iter
);
1074 nomem_close_ports_array
:
1075 dbus_message_iter_close_container(&client_struct_iter
, &ports_array_iter
);
1077 nomem_close_client_struct
:
1078 dbus_message_iter_close_container(&clients_array_iter
, &client_struct_iter
);
1080 nomem_close_clients_array
:
1081 dbus_message_iter_close_container(&iter
, &clients_array_iter
);
1084 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1087 dbus_message_unref(call
->reply
);
1089 jack_error("Ran out of memory trying to construct method return");
1097 jack_controller_dbus_connect_ports_by_name(
1098 struct jack_dbus_method_call
* call
)
1100 const char * client1_name
;
1101 const char * port1_name
;
1102 const char * client2_name
;
1103 const char * port2_name
;
1104 struct jack_graph_port
*port1_ptr
;
1105 struct jack_graph_port
*port2_ptr
;
1107 /* jack_info("jack_controller_dbus_connect_ports_by_name() called."); */
1109 if (!controller_ptr
->started
)
1113 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
1114 "Can't execute this method with stopped JACK server");
1118 if (!jack_dbus_get_method_args(
1130 /* The method call had invalid arguments meaning that
1131 * jack_dbus_get_method_args() has constructed an error for us.
1136 /* jack_info("connecting %s:%s and %s:%s", client1_name, port1_name, client2_name, port2_name); */
1138 pthread_mutex_lock(&patchbay_ptr
->lock
);
1140 port1_ptr
= jack_controller_patchbay_find_port_by_names(patchbay_ptr
, client1_name
, port1_name
);
1141 if (port1_ptr
== NULL
)
1143 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port '%s':'%s'", client1_name
, port1_name
);
1147 port2_ptr
= jack_controller_patchbay_find_port_by_names(patchbay_ptr
, client2_name
, port2_name
);
1148 if (port2_ptr
== NULL
)
1150 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port '%s':'%s'", client2_name
, port2_name
);
1154 if (!jack_controller_patchbay_connect(
1160 /* jack_controller_patchbay_connect() constructed error reply */
1164 jack_dbus_construct_method_return_empty(call
);
1167 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1172 jack_controller_dbus_connect_ports_by_id(
1173 struct jack_dbus_method_call
* call
)
1175 dbus_uint64_t port1_id
;
1176 dbus_uint64_t port2_id
;
1177 struct jack_graph_port
*port1_ptr
;
1178 struct jack_graph_port
*port2_ptr
;
1180 /* jack_info("jack_controller_dbus_connect_ports_by_id() called."); */
1182 if (!controller_ptr
->started
)
1186 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
1187 "Can't execute this method with stopped JACK server");
1191 if (!jack_dbus_get_method_args(
1199 /* The method call had invalid arguments meaning that
1200 * jack_dbus_get_method_args() has constructed an error for us.
1205 pthread_mutex_lock(&patchbay_ptr
->lock
);
1207 port1_ptr
= jack_controller_patchbay_find_port_by_id(patchbay_ptr
, port1_id
);
1208 if (port1_ptr
== NULL
)
1210 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port %" PRIu64
, port1_id
);
1214 port2_ptr
= jack_controller_patchbay_find_port_by_id(patchbay_ptr
, port2_id
);
1215 if (port2_ptr
== NULL
)
1217 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port %" PRIu64
, port2_id
);
1221 if (!jack_controller_patchbay_connect(
1227 /* jack_controller_patchbay_connect() constructed error reply */
1231 jack_dbus_construct_method_return_empty(call
);
1234 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1239 jack_controller_dbus_disconnect_ports_by_name(
1240 struct jack_dbus_method_call
* call
)
1242 const char * client1_name
;
1243 const char * port1_name
;
1244 const char * client2_name
;
1245 const char * port2_name
;
1246 struct jack_graph_port
*port1_ptr
;
1247 struct jack_graph_port
*port2_ptr
;
1249 /* jack_info("jack_controller_dbus_disconnect_ports_by_name() called."); */
1251 if (!controller_ptr
->started
)
1255 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
1256 "Can't execute this method with stopped JACK server");
1260 if (!jack_dbus_get_method_args(
1272 /* The method call had invalid arguments meaning that
1273 * jack_dbus_get_method_args() has constructed an error for us.
1278 /* jack_info("disconnecting %s:%s and %s:%s", client1_name, port1_name, client2_name, port2_name); */
1280 pthread_mutex_lock(&patchbay_ptr
->lock
);
1282 port1_ptr
= jack_controller_patchbay_find_port_by_names(patchbay_ptr
, client1_name
, port1_name
);
1283 if (port1_ptr
== NULL
)
1285 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port '%s':'%s'", client1_name
, port1_name
);
1289 port2_ptr
= jack_controller_patchbay_find_port_by_names(patchbay_ptr
, client2_name
, port2_name
);
1290 if (port2_ptr
== NULL
)
1292 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port '%s':'%s'", client2_name
, port2_name
);
1296 if (!jack_controller_patchbay_disconnect(
1302 /* jack_controller_patchbay_connect() constructed error reply */
1306 jack_dbus_construct_method_return_empty(call
);
1309 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1314 jack_controller_dbus_disconnect_ports_by_id(
1315 struct jack_dbus_method_call
* call
)
1317 dbus_uint64_t port1_id
;
1318 dbus_uint64_t port2_id
;
1319 struct jack_graph_port
*port1_ptr
;
1320 struct jack_graph_port
*port2_ptr
;
1322 /* jack_info("jack_controller_dbus_disconnect_ports_by_id() called."); */
1324 if (!controller_ptr
->started
)
1328 JACK_DBUS_ERROR_SERVER_NOT_RUNNING
,
1329 "Can't execute this method with stopped JACK server");
1333 if (!jack_dbus_get_method_args(
1341 /* The method call had invalid arguments meaning that
1342 * jack_dbus_get_method_args() has constructed an error for us.
1347 pthread_mutex_lock(&patchbay_ptr
->lock
);
1349 port1_ptr
= jack_controller_patchbay_find_port_by_id(patchbay_ptr
, port1_id
);
1350 if (port1_ptr
== NULL
)
1352 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port %" PRIu64
, port1_id
);
1356 port2_ptr
= jack_controller_patchbay_find_port_by_id(patchbay_ptr
, port2_id
);
1357 if (port2_ptr
== NULL
)
1359 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find port %" PRIu64
, port2_id
);
1363 if (!jack_controller_patchbay_disconnect(
1369 /* jack_controller_patchbay_connect() constructed error reply */
1373 jack_dbus_construct_method_return_empty(call
);
1376 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1381 jack_controller_dbus_disconnect_ports_by_connection_id(
1382 struct jack_dbus_method_call
* call
)
1384 dbus_uint64_t connection_id
;
1385 struct jack_graph_connection
*connection_ptr
;
1387 /* jack_info("jack_controller_dbus_disconnect_ports_by_id() called."); */
1389 if (!jack_dbus_get_method_args(
1395 /* The method call had invalid arguments meaning that
1396 * jack_dbus_get_method_args() has constructed an error for us.
1401 pthread_mutex_lock(&patchbay_ptr
->lock
);
1403 connection_ptr
= jack_controller_patchbay_find_connection_by_id(patchbay_ptr
, connection_id
);
1404 if (connection_ptr
== NULL
)
1406 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find connection %" PRIu64
, connection_id
);
1410 if (!jack_controller_patchbay_disconnect(
1413 connection_ptr
->port1
,
1414 connection_ptr
->port2
))
1416 /* jack_controller_patchbay_connect() constructed error reply */
1420 jack_dbus_construct_method_return_empty(call
);
1423 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1428 jack_controller_dbus_get_client_pid(
1429 struct jack_dbus_method_call
* call
)
1431 dbus_uint64_t client_id
;
1432 struct jack_graph_client
*client_ptr
;
1435 /* jack_info("jack_controller_dbus_get_client_pid() called."); */
1437 if (!jack_dbus_get_method_args(
1443 /* The method call had invalid arguments meaning that
1444 * jack_dbus_get_method_args() has constructed an error for us.
1449 pthread_mutex_lock(&patchbay_ptr
->lock
);
1451 client_ptr
= jack_controller_patchbay_find_client_by_id(patchbay_ptr
, client_id
);
1452 if (client_ptr
== NULL
)
1454 jack_dbus_error(call
, JACK_DBUS_ERROR_INVALID_ARGS
, "cannot find client %" PRIu64
, client_id
);
1458 arg
.int64
= client_ptr
->pid
;
1460 jack_dbus_construct_method_return_single(call
, DBUS_TYPE_INT64
, arg
);
1463 pthread_mutex_unlock(&patchbay_ptr
->lock
);
1466 #undef controller_ptr
1467 #define controller_ptr ((struct jack_controller *)context)
1471 jack_controller_graph_order_callback(
1476 jack_port_t
*port_ptr
;
1478 if (patchbay_ptr
->graph
.version
> 1)
1480 /* we use this only for initial catchup */
1484 ports
= jack_get_ports(controller_ptr
->client
, NULL
, NULL
, 0);
1487 for (i
= 0; ports
[i
]; ++i
)
1489 jack_info("graph reorder: new port '%s'", ports
[i
]);
1490 port_ptr
= jack_port_by_name(controller_ptr
->client
, ports
[i
]);;
1491 jack_controller_patchbay_new_port(patchbay_ptr
, ports
[i
], jack_port_flags(port_ptr
), jack_port_type_id(port_ptr
));
1497 if (patchbay_ptr
->graph
.version
== 1)
1499 /* we have empty initial graph, increment graph version,
1500 so we dont do jack_get_ports() again,
1501 on next next graph change */
1502 patchbay_ptr
->graph
.version
++;
1509 jack_controller_client_registration_callback(
1510 const char *client_name
,
1516 jack_log("client '%s' created", client_name
);
1517 jack_controller_patchbay_create_client(patchbay_ptr
, client_name
, strlen(client_name
));
1521 jack_log("client '%s' destroyed", client_name
);
1522 jack_controller_patchbay_destroy_client_by_name(patchbay_ptr
, client_name
);
1527 jack_controller_port_registration_callback(
1528 jack_port_id_t port_id
,
1532 jack_port_t
*port_ptr
;
1533 struct jack_graph_port
*graph_port_ptr
;
1534 const char *port_name
;
1536 port_ptr
= jack_port_by_id(controller_ptr
->client
, port_id
);
1537 port_name
= jack_port_name(port_ptr
);
1541 jack_log("port '%s' created", port_name
);
1542 jack_controller_patchbay_new_port(patchbay_ptr
, port_name
, jack_port_flags(port_ptr
), jack_port_type_id(port_ptr
));
1546 jack_log("port '%s' destroyed", port_name
);
1547 graph_port_ptr
= jack_controller_patchbay_find_port_by_full_name(patchbay_ptr
, port_name
);
1548 if (graph_port_ptr
== NULL
)
1550 jack_error("Failed to find port '%s' to destroy", port_name
);
1554 jack_controller_patchbay_remove_port(patchbay_ptr
, graph_port_ptr
);
1559 jack_controller_port_connect_callback(
1560 jack_port_id_t port1_id
,
1561 jack_port_id_t port2_id
,
1567 const char *port1_name
;
1568 const char *port2_name
;
1569 struct jack_graph_port
*port1_ptr
;
1570 struct jack_graph_port
*port2_ptr
;
1571 struct jack_graph_connection
*connection_ptr
;
1573 port1
= jack_port_by_id(controller_ptr
->client
, port1_id
);
1574 port2
= jack_port_by_id(controller_ptr
->client
, port2_id
);
1576 port1_name
= jack_port_name(port1
);
1577 port2_name
= jack_port_name(port2
);
1579 port1_ptr
= jack_controller_patchbay_find_port_by_full_name(patchbay_ptr
, port1_name
);
1580 if (port1_ptr
== NULL
)
1582 jack_error("Failed to find port '%s' to [dis]connect", port1_name
);
1586 port2_ptr
= jack_controller_patchbay_find_port_by_full_name(patchbay_ptr
, port2_name
);
1587 if (port2_ptr
== NULL
)
1589 jack_error("Failed to find port '%s' to [dis]connect", port2_name
);
1595 jack_info("Connecting '%s' to '%s'", port1_name
, port2_name
);
1596 connection_ptr
= jack_controller_patchbay_find_connection(patchbay_ptr
, port1_ptr
, port2_ptr
);
1597 if (connection_ptr
!= NULL
)
1599 jack_error("'%s' and '%s' are already connected", port1_name
, port2_name
);
1603 jack_controller_patchbay_create_connection(patchbay_ptr
, port1_ptr
, port2_ptr
);
1607 jack_info("Disonnecting '%s' from '%s'", port1_name
, port2_name
);
1608 connection_ptr
= jack_controller_patchbay_find_connection(patchbay_ptr
, port1_ptr
, port2_ptr
);
1609 if (connection_ptr
== NULL
)
1611 jack_error("Cannot find connection being removed");
1615 jack_controller_patchbay_destroy_connection(patchbay_ptr
, connection_ptr
);
1619 #undef controller_ptr
1622 jack_controller_patchbay_uninit(
1623 struct jack_controller
* controller_ptr
)
1625 struct jack_graph_client
*client_ptr
;
1626 struct jack_graph_port
*port_ptr
;
1628 /* jack_info("jack_controller_patchbay_uninit() called"); */
1630 while (!list_empty(&patchbay_ptr
->graph
.ports
))
1632 port_ptr
= list_entry(patchbay_ptr
->graph
.ports
.next
, struct jack_graph_port
, siblings_graph
);
1633 jack_controller_patchbay_remove_port(patchbay_ptr
, port_ptr
);
1636 while (!list_empty(&patchbay_ptr
->graph
.clients
))
1638 client_ptr
= list_entry(patchbay_ptr
->graph
.clients
.next
, struct jack_graph_client
, siblings
);
1639 jack_controller_patchbay_destroy_client(patchbay_ptr
, client_ptr
);
1642 pthread_mutex_destroy(&patchbay_ptr
->lock
);
1648 jack_controller_patchbay_init(
1649 struct jack_controller
* controller_ptr
)
1652 struct jack_controller_patchbay
* patchbay_ptr
;
1653 pthread_mutexattr_t attr
;
1655 /* jack_info("jack_controller_patchbay_init() called"); */
1657 patchbay_ptr
= malloc(sizeof(struct jack_controller_patchbay
));
1658 if (patchbay_ptr
== NULL
)
1660 jack_error("Memory allocation of jack_controller_patchbay structure failed.");
1664 ret
= pthread_mutexattr_init(&attr
);
1670 ret
= pthread_mutexattr_settype(&attr
, PTHREAD_MUTEX_RECURSIVE
);
1676 pthread_mutex_init(&patchbay_ptr
->lock
, &attr
);
1677 INIT_LIST_HEAD(&patchbay_ptr
->graph
.clients
);
1678 INIT_LIST_HEAD(&patchbay_ptr
->graph
.ports
);
1679 INIT_LIST_HEAD(&patchbay_ptr
->graph
.connections
);
1680 patchbay_ptr
->graph
.version
= 1;
1681 patchbay_ptr
->next_client_id
= 1;
1682 patchbay_ptr
->next_port_id
= 1;
1683 patchbay_ptr
->next_connection_id
= 1;
1685 controller_ptr
->patchbay_context
= patchbay_ptr
;
1687 ret
= jack_set_graph_order_callback(controller_ptr
->client
, jack_controller_graph_order_callback
, controller_ptr
);
1690 jack_error("jack_set_graph_order_callback() failed with error %d", ret
);
1691 goto fail_uninit_mutex
;
1694 ret
= jack_set_client_registration_callback(controller_ptr
->client
, jack_controller_client_registration_callback
, controller_ptr
);
1697 jack_error("jack_set_client_registration_callback() failed with error %d", ret
);
1698 goto fail_uninit_mutex
;
1701 ret
= jack_set_port_registration_callback(controller_ptr
->client
, jack_controller_port_registration_callback
, controller_ptr
);
1704 jack_error("jack_set_port_registration_callback() failed with error %d", ret
);
1705 goto fail_uninit_mutex
;
1708 ret
= jack_set_port_connect_callback(controller_ptr
->client
, jack_controller_port_connect_callback
, controller_ptr
);
1711 jack_error("jack_set_port_connect_callback() failed with error %d", ret
);
1712 goto fail_uninit_mutex
;
1718 pthread_mutex_destroy(&patchbay_ptr
->lock
);
1724 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetAllPorts
)
1725 JACK_DBUS_METHOD_ARGUMENT("ports_list", "as", true)
1726 JACK_DBUS_METHOD_ARGUMENTS_END
1728 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetGraph
)
1729 JACK_DBUS_METHOD_ARGUMENT("known_graph_version", DBUS_TYPE_UINT64_AS_STRING
, false)
1730 JACK_DBUS_METHOD_ARGUMENT("current_graph_version", DBUS_TYPE_UINT64_AS_STRING
, true)
1731 JACK_DBUS_METHOD_ARGUMENT("clients_and_ports", "a(tsa(tsuu))", true)
1732 JACK_DBUS_METHOD_ARGUMENT("connections", "a(tstststst)", true)
1733 JACK_DBUS_METHOD_ARGUMENTS_END
1735 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ConnectPortsByName
)
1736 JACK_DBUS_METHOD_ARGUMENT("client1_name", DBUS_TYPE_STRING_AS_STRING
, false)
1737 JACK_DBUS_METHOD_ARGUMENT("port1_name", DBUS_TYPE_STRING_AS_STRING
, false)
1738 JACK_DBUS_METHOD_ARGUMENT("client2_name", DBUS_TYPE_STRING_AS_STRING
, false)
1739 JACK_DBUS_METHOD_ARGUMENT("port2_name", DBUS_TYPE_STRING_AS_STRING
, false)
1740 JACK_DBUS_METHOD_ARGUMENTS_END
1742 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ConnectPortsByID
)
1743 JACK_DBUS_METHOD_ARGUMENT("port1_id", DBUS_TYPE_UINT64_AS_STRING
, false)
1744 JACK_DBUS_METHOD_ARGUMENT("port2_id", DBUS_TYPE_UINT64_AS_STRING
, false)
1745 JACK_DBUS_METHOD_ARGUMENTS_END
1747 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(DisconnectPortsByName
)
1748 JACK_DBUS_METHOD_ARGUMENT("client1_name", DBUS_TYPE_STRING_AS_STRING
, false)
1749 JACK_DBUS_METHOD_ARGUMENT("port1_name", DBUS_TYPE_STRING_AS_STRING
, false)
1750 JACK_DBUS_METHOD_ARGUMENT("client2_name", DBUS_TYPE_STRING_AS_STRING
, false)
1751 JACK_DBUS_METHOD_ARGUMENT("port2_name", DBUS_TYPE_STRING_AS_STRING
, false)
1752 JACK_DBUS_METHOD_ARGUMENTS_END
1754 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(DisconnectPortsByID
)
1755 JACK_DBUS_METHOD_ARGUMENT("port1_id", DBUS_TYPE_UINT64_AS_STRING
, false)
1756 JACK_DBUS_METHOD_ARGUMENT("port2_id", DBUS_TYPE_UINT64_AS_STRING
, false)
1757 JACK_DBUS_METHOD_ARGUMENTS_END
1759 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(DisconnectPortsByConnectionID
)
1760 JACK_DBUS_METHOD_ARGUMENT("connection_id", DBUS_TYPE_UINT64_AS_STRING
, false)
1761 JACK_DBUS_METHOD_ARGUMENTS_END
1763 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetClientPID
)
1764 JACK_DBUS_METHOD_ARGUMENT("client_id", DBUS_TYPE_INT64_AS_STRING
, false)
1765 JACK_DBUS_METHOD_ARGUMENTS_END
1767 JACK_DBUS_METHODS_BEGIN
1768 JACK_DBUS_METHOD_DESCRIBE(GetAllPorts
, jack_controller_dbus_get_all_ports
)
1769 JACK_DBUS_METHOD_DESCRIBE(GetGraph
, jack_controller_dbus_get_graph
)
1770 JACK_DBUS_METHOD_DESCRIBE(ConnectPortsByName
, jack_controller_dbus_connect_ports_by_name
)
1771 JACK_DBUS_METHOD_DESCRIBE(ConnectPortsByID
, jack_controller_dbus_connect_ports_by_id
)
1772 JACK_DBUS_METHOD_DESCRIBE(DisconnectPortsByName
, jack_controller_dbus_disconnect_ports_by_name
)
1773 JACK_DBUS_METHOD_DESCRIBE(DisconnectPortsByID
, jack_controller_dbus_disconnect_ports_by_id
)
1774 JACK_DBUS_METHOD_DESCRIBE(DisconnectPortsByConnectionID
, jack_controller_dbus_disconnect_ports_by_connection_id
)
1775 JACK_DBUS_METHOD_DESCRIBE(GetClientPID
, jack_controller_dbus_get_client_pid
)
1776 JACK_DBUS_METHODS_END
1778 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(GraphChanged
)
1779 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1780 JACK_DBUS_SIGNAL_ARGUMENTS_END
1782 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(ClientAppeared
)
1783 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1784 JACK_DBUS_SIGNAL_ARGUMENT("client_id", DBUS_TYPE_UINT64_AS_STRING
)
1785 JACK_DBUS_SIGNAL_ARGUMENT("client_name", DBUS_TYPE_STRING_AS_STRING
)
1786 JACK_DBUS_SIGNAL_ARGUMENTS_END
1788 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(ClientDisappeared
)
1789 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1790 JACK_DBUS_SIGNAL_ARGUMENT("client_id", DBUS_TYPE_UINT64_AS_STRING
)
1791 JACK_DBUS_SIGNAL_ARGUMENT("client_name", DBUS_TYPE_STRING_AS_STRING
)
1792 JACK_DBUS_SIGNAL_ARGUMENTS_END
1794 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(PortAppeared
)
1795 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1796 JACK_DBUS_SIGNAL_ARGUMENT("client_id", DBUS_TYPE_UINT64_AS_STRING
)
1797 JACK_DBUS_SIGNAL_ARGUMENT("client_name", DBUS_TYPE_STRING_AS_STRING
)
1798 JACK_DBUS_SIGNAL_ARGUMENT("port_id", DBUS_TYPE_UINT64_AS_STRING
)
1799 JACK_DBUS_SIGNAL_ARGUMENT("port_name", DBUS_TYPE_STRING_AS_STRING
)
1800 JACK_DBUS_SIGNAL_ARGUMENT("port_flags", DBUS_TYPE_UINT32_AS_STRING
)
1801 JACK_DBUS_SIGNAL_ARGUMENT("port_type", DBUS_TYPE_UINT32_AS_STRING
)
1802 JACK_DBUS_SIGNAL_ARGUMENTS_END
1804 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(PortDisappeared
)
1805 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1806 JACK_DBUS_SIGNAL_ARGUMENT("client_id", DBUS_TYPE_UINT64_AS_STRING
)
1807 JACK_DBUS_SIGNAL_ARGUMENT("client_name", DBUS_TYPE_STRING_AS_STRING
)
1808 JACK_DBUS_SIGNAL_ARGUMENT("port_id", DBUS_TYPE_UINT64_AS_STRING
)
1809 JACK_DBUS_SIGNAL_ARGUMENT("port_name", DBUS_TYPE_STRING_AS_STRING
)
1810 JACK_DBUS_SIGNAL_ARGUMENTS_END
1812 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(PortsConnected
)
1813 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1814 JACK_DBUS_SIGNAL_ARGUMENT("client1_id", DBUS_TYPE_UINT64_AS_STRING
)
1815 JACK_DBUS_SIGNAL_ARGUMENT("client1_name", DBUS_TYPE_STRING_AS_STRING
)
1816 JACK_DBUS_SIGNAL_ARGUMENT("port1_id", DBUS_TYPE_UINT64_AS_STRING
)
1817 JACK_DBUS_SIGNAL_ARGUMENT("port1_name", DBUS_TYPE_STRING_AS_STRING
)
1818 JACK_DBUS_SIGNAL_ARGUMENT("client2_id", DBUS_TYPE_UINT64_AS_STRING
)
1819 JACK_DBUS_SIGNAL_ARGUMENT("client2_name", DBUS_TYPE_STRING_AS_STRING
)
1820 JACK_DBUS_SIGNAL_ARGUMENT("port2_id", DBUS_TYPE_UINT64_AS_STRING
)
1821 JACK_DBUS_SIGNAL_ARGUMENT("port2_name", DBUS_TYPE_STRING_AS_STRING
)
1822 JACK_DBUS_SIGNAL_ARGUMENT("connection_id", DBUS_TYPE_UINT64_AS_STRING
)
1823 JACK_DBUS_SIGNAL_ARGUMENTS_END
1825 JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(PortsDisconnected
)
1826 JACK_DBUS_SIGNAL_ARGUMENT("new_graph_version", DBUS_TYPE_UINT64_AS_STRING
)
1827 JACK_DBUS_SIGNAL_ARGUMENT("client1_id", DBUS_TYPE_UINT64_AS_STRING
)
1828 JACK_DBUS_SIGNAL_ARGUMENT("client1_name", DBUS_TYPE_STRING_AS_STRING
)
1829 JACK_DBUS_SIGNAL_ARGUMENT("port1_id", DBUS_TYPE_UINT64_AS_STRING
)
1830 JACK_DBUS_SIGNAL_ARGUMENT("port1_name", DBUS_TYPE_STRING_AS_STRING
)
1831 JACK_DBUS_SIGNAL_ARGUMENT("client2_id", DBUS_TYPE_UINT64_AS_STRING
)
1832 JACK_DBUS_SIGNAL_ARGUMENT("client2_name", DBUS_TYPE_STRING_AS_STRING
)
1833 JACK_DBUS_SIGNAL_ARGUMENT("port2_id", DBUS_TYPE_UINT64_AS_STRING
)
1834 JACK_DBUS_SIGNAL_ARGUMENT("port2_name", DBUS_TYPE_STRING_AS_STRING
)
1835 JACK_DBUS_SIGNAL_ARGUMENT("connection_id", DBUS_TYPE_UINT64_AS_STRING
)
1836 JACK_DBUS_SIGNAL_ARGUMENTS_END
1838 JACK_DBUS_SIGNALS_BEGIN
1839 JACK_DBUS_SIGNAL_DESCRIBE(GraphChanged
)
1840 JACK_DBUS_SIGNAL_DESCRIBE(ClientAppeared
)
1841 JACK_DBUS_SIGNAL_DESCRIBE(ClientDisappeared
)
1842 JACK_DBUS_SIGNAL_DESCRIBE(PortAppeared
)
1843 JACK_DBUS_SIGNAL_DESCRIBE(PortDisappeared
)
1844 JACK_DBUS_SIGNAL_DESCRIBE(PortsConnected
)
1845 JACK_DBUS_SIGNAL_DESCRIBE(PortsDisconnected
)
1846 JACK_DBUS_SIGNALS_END
1848 JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_patchbay
, JACK_DBUS_IFACE_NAME
)
1849 JACK_DBUS_IFACE_EXPOSE_METHODS
1850 JACK_DBUS_IFACE_EXPOSE_SIGNALS