1 From: Jaska Uimonen <jaska.uimonen@intel.com>
2 Date: Wed, 5 Dec 2012 09:53:12 +0200
3 Subject: node-manager: adding node support for pactl
5 Change-Id: Id6badeba2181ef4afa9842307e4c6c60f72c472f
6 Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
8 src/utils/pactl.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
9 1 file changed, 72 insertions(+), 3 deletions(-)
11 diff --git a/src/utils/pactl.c b/src/utils/pactl.c
12 index 40e6689..1d8faa4 100644
13 --- a/src/utils/pactl.c
14 +++ b/src/utils/pactl.c
17 #include <pulse/pulseaudio.h>
18 #include <pulse/ext-device-restore.h>
19 +#include <pulse/ext-node-manager.h>
21 #include <pulsecore/i18n.h>
22 #include <pulsecore/macro.h>
23 @@ -97,6 +98,10 @@ static int actions = 1;
25 static bool nl = false;
27 +static uint32_t src_node_id;
28 +static uint32_t dst_node_id;
29 +static uint32_t conn_id;
34 @@ -127,7 +132,9 @@ static enum {
35 SET_SOURCE_OUTPUT_MUTE,
37 SET_PORT_LATENCY_OFFSET,
44 static void quit(int ret) {
45 @@ -1007,6 +1014,30 @@ static void source_output_toggle_mute_callback(pa_context *c, const pa_source_ou
46 pa_operation_unref(pa_context_set_source_output_mute(c, o->index, !o->mute, simple_callback, NULL));
49 +static void node_list_callback(pa_context *c,
50 + const pa_ext_node_manager_info *info,
55 + const char *node_id = pa_proplist_gets(info->props, "index");
56 + if (node_id != NULL) {
57 + printf("Node #%s (%s)\n", node_id, info->name);
58 + printf("%s\n", pa_proplist_to_string(info->props));
64 +static void node_connect_callback(pa_context *c,
68 + printf("New connection id: %d\n", conne_id);
73 /* PA_MAX_FORMATS is defined in internal.h so we just define a sane value here */
74 #define MAX_FORMATS 256
76 @@ -1212,6 +1243,8 @@ static void context_state_callback(pa_context *c, void *userdata) {
77 pa_operation_unref(pa_context_get_sample_info_list(c, get_sample_info_callback, NULL));
78 else if (pa_streq(list_type, "cards"))
79 pa_operation_unref(pa_context_get_card_info_list(c, get_card_info_callback, NULL));
80 + else if (pa_streq(list_type, "nodes"))
81 + pa_operation_unref(pa_ext_node_manager_read_nodes(c, node_list_callback, NULL));
83 pa_assert_not_reached();
85 @@ -1373,6 +1406,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
90 + pa_operation_unref(pa_ext_node_manager_connect_nodes(c,
93 + node_connect_callback,
96 + case NODE_DISCONNECT:
97 + pa_operation_unref(pa_ext_node_manager_disconnect_nodes(c, conn_id,
103 pa_assert_not_reached();
104 @@ -1494,6 +1539,9 @@ static void help(const char *argv0) {
105 printf("%s %s %s\n", argv0, _("[options]"), "subscribe");
106 printf(_("\nThe special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and @DEFAULT_MONITOR@\n"
107 "can be used to specify the default sink, source and monitor.\n"));
108 + printf("%s %s %s\n", argv0, _("[options]"), "node-list ");
109 + printf("%s %s %s %s %s\n", argv0, _("[options]"), "node-connect ", _("#N"), _("#N"));
110 + printf("%s %s %s %s\n", argv0, _("[options]"), "node-disconnect ", _("#N"));
113 " -h, --help Show this help\n"
114 @@ -1590,7 +1638,7 @@ int main(int argc, char *argv[]) {
115 if (pa_streq(argv[i], "modules") || pa_streq(argv[i], "clients") ||
116 pa_streq(argv[i], "sinks") || pa_streq(argv[i], "sink-inputs") ||
117 pa_streq(argv[i], "sources") || pa_streq(argv[i], "source-outputs") ||
118 - pa_streq(argv[i], "samples") || pa_streq(argv[i], "cards")) {
119 + pa_streq(argv[i], "samples") || pa_streq(argv[i], "cards") || pa_streq(argv[i], "nodes")) {
120 list_type = pa_xstrdup(argv[i]);
121 } else if (pa_streq(argv[i], "short")) {
122 short_list_format = true;
123 @@ -1960,7 +2008,28 @@ int main(int argc, char *argv[]) {
127 - } else if (pa_streq(argv[optind], "help")) {
128 + } else if (pa_streq(argv[optind], "node-connect")) {
129 + action = NODE_CONNECT;
131 + if (argc != optind+3) {
132 + pa_log(_("You have to specify a source and destination node indexes"));
136 + src_node_id = (uint32_t) atoi(argv[optind+1]);
137 + dst_node_id = (uint32_t) atoi(argv[optind+2]);
139 + } else if (pa_streq(argv[optind], "node-disconnect")) {
140 + action = NODE_DISCONNECT;
142 + if (argc != optind+2) {
143 + pa_log(_("You have to specify a connection id"));
147 + conn_id = (uint32_t) atoi(argv[optind+1]);
149 + } else if (pa_streq(argv[optind], "help")) {