clean pulseaudio recipes
[scm/bb/meta-tizen.git] / recipes-multimedia / pulseaudio / pulseaudio_5.0 / 0008-node-manager-adding-node-support-for-pactl.patch
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
4
5 Change-Id: Id6badeba2181ef4afa9842307e4c6c60f72c472f
6 Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
7 ---
8  src/utils/pactl.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
9  1 file changed, 72 insertions(+), 3 deletions(-)
10
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
15 @@ -38,6 +38,7 @@
16  
17  #include <pulse/pulseaudio.h>
18  #include <pulse/ext-device-restore.h>
19 +#include <pulse/ext-node-manager.h>
20  
21  #include <pulsecore/i18n.h>
22  #include <pulsecore/macro.h>
23 @@ -97,6 +98,10 @@ static int actions = 1;
24  
25  static bool nl = false;
26  
27 +static uint32_t src_node_id;
28 +static uint32_t dst_node_id;
29 +static uint32_t conn_id;
30 +
31  static enum {
32      NONE,
33      EXIT,
34 @@ -127,7 +132,9 @@ static enum {
35      SET_SOURCE_OUTPUT_MUTE,
36      SET_SINK_FORMATS,
37      SET_PORT_LATENCY_OFFSET,
38 -    SUBSCRIBE
39 +    SUBSCRIBE,
40 +    NODE_CONNECT,
41 +    NODE_DISCONNECT
42  } action = NONE;
43  
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));
47  }
48  
49 +static void node_list_callback(pa_context *c,
50 +                              const pa_ext_node_manager_info *info,
51 +                              int eol,
52 +                              void *userdata) {
53 +
54 +    if (!eol) {
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));
59 +       }
60 +    } else
61 +       complete_action();
62 +}
63 +
64 +static void node_connect_callback(pa_context *c,
65 +                           uint32_t conne_id,
66 +                           void *userdata) {
67 +
68 +    printf("New connection id: %d\n", conne_id);
69 +
70 +    complete_action();
71 +}
72 +
73  /* PA_MAX_FORMATS is defined in internal.h so we just define a sane value here */
74  #define MAX_FORMATS 256
75  
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));
82                          else
83                              pa_assert_not_reached();
84                      } else {
85 @@ -1373,6 +1406,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
86                                                NULL,
87                                                NULL));
88                      break;
89 +               case NODE_CONNECT:
90 +                   pa_operation_unref(pa_ext_node_manager_connect_nodes(c,
91 +                                                                        src_node_id,
92 +                                                                        dst_node_id,
93 +                                                                        node_connect_callback,
94 +                                                                        NULL));
95 +                   break;
96 +               case NODE_DISCONNECT:
97 +                   pa_operation_unref(pa_ext_node_manager_disconnect_nodes(c, conn_id,
98 +                                                                       simple_callback,
99 +                                                                       NULL));
100 +                   break;
101  
102                  default:
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"));
111  
112      printf(_("\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[]) {
124                  goto quit;
125              }
126  
127 -        } else if (pa_streq(argv[optind], "help")) {
128 +        } else if (pa_streq(argv[optind], "node-connect")) {
129 +           action = NODE_CONNECT;
130 +
131 +           if (argc != optind+3) {
132 +               pa_log(_("You have to specify a source and destination node indexes"));
133 +               goto quit;
134 +           }
135 +
136 +           src_node_id = (uint32_t) atoi(argv[optind+1]);
137 +           dst_node_id = (uint32_t) atoi(argv[optind+2]);
138 +
139 +       } else if (pa_streq(argv[optind], "node-disconnect")) {
140 +           action = NODE_DISCONNECT;
141 +
142 +           if (argc != optind+2) {
143 +               pa_log(_("You have to specify a connection id"));
144 +               goto quit;
145 +           }
146 +
147 +           conn_id = (uint32_t) atoi(argv[optind+1]);
148 +
149 +       } else if (pa_streq(argv[optind], "help")) {
150              help(bn);
151              ret = 0;
152              goto quit;