3 #include <pulsecore/pulsecore-config.h>
5 #include <pulsecore/hashmap.h>
6 #include <pulsecore/idxset.h>
7 #include <pulsecore/strbuf.h>
19 pa_nodeset *pa_nodeset_init(struct userdata *u)
25 ns = pa_xnew0(pa_nodeset, 1);
26 ns->nodes = pa_idxset_new(pa_idxset_trivial_hash_func,
27 pa_idxset_trivial_compare_func);
31 void pa_nodeset_done(struct userdata *u)
35 if (u && (ns = u->nodeset)) {
36 pa_idxset_free(ns->nodes, NULL, NULL);
42 mir_node *mir_node_create(struct userdata *u, mir_node *data)
49 pa_assert_se((ns = u->nodeset));
51 pa_assert(data->paname);
53 node = pa_xnew0(mir_node, 1);
55 node->key = pa_xstrdup(data->key);
56 node->direction = data->direction;
57 node->implement = data->implement;
58 node->channels = data->channels;
59 node->location = data->location;
60 node->privacy = data->privacy;
61 node->type = data->type;
62 node->visible = data->visible;
63 node->available = data->available;
64 node->amname = pa_xstrdup(data->amname ? data->amname : data->paname);
65 node->amdescr = pa_xstrdup(data->amdescr ? data->amdescr : "");
66 node->amid = data->amid;
67 node->paname = pa_xstrdup(data->paname);
68 node->paidx = data->paidx;
69 node->mux = data->mux;
70 node->stamp = data->stamp;
71 MIR_DLIST_INIT(node->rtentries);
73 if (node->implement == mir_device) {
74 node->pacard.index = data->pacard.index;
75 if (data->pacard.profile)
76 node->pacard.profile = pa_xstrdup(data->pacard.profile);
78 node->paport = pa_xstrdup(data->paport);
81 pa_idxset_put(ns->nodes, node, &node->index);
83 mir_router_register_node(u, node);
88 void mir_node_destroy(struct userdata *u, mir_node *node)
93 pa_assert_se((ns = u->nodeset));
96 mir_router_unregister_node(u, node);
98 pa_idxset_remove_by_index(ns->nodes, node->index);
101 pa_xfree(node->amname);
102 pa_xfree(node->amdescr);
103 pa_xfree(node->paname);
104 pa_xfree(node->pacard.profile);
105 pa_xfree(node->paport);
111 mir_node *mir_node_find_by_index(struct userdata *u, uint32_t nodidx)
117 pa_assert_se((ns = u->nodeset));
119 node = pa_idxset_get_by_index(ns->nodes, nodidx);
124 int mir_node_print(mir_node *node, char *buf, int len)
133 pa_multiplex_print(node->mux, mux, sizeof(mux));
137 #define PRINT(f,v) if (p < e) p += snprintf(p, e-p, f "\n", v)
139 PRINT(" index : %u" , node->index);
140 PRINT(" key : '%s'", node->key ? node->key : "");
141 PRINT(" direction : %s" , mir_direction_str(node->direction));
142 PRINT(" implement : %s" , mir_implement_str(node->implement));
143 PRINT(" channels : %u" , node->channels);
144 PRINT(" location : %s" , mir_location_str(node->location));
145 PRINT(" privacy : %s" , mir_privacy_str(node->privacy));
146 PRINT(" type : %s" , mir_node_type_str(node->type));
147 PRINT(" visible : %s" , node->visible ? "yes" : "no");
148 PRINT(" available : %s" , node->available ? "yes" : "no");
149 PRINT(" amname : '%s'", node->amname ? node->amname : "");
150 PRINT(" amdescr : '%s'", node->amdescr ? node->amdescr : "");
151 PRINT(" amid : %u" , node->amid);
152 PRINT(" paname : '%s'", node->paname ? node->paname : "");
153 PRINT(" paidx : %u" , node->paidx);
154 PRINT(" pacard.index : %u" , node->pacard.index);
155 PRINT(" pacard.profile: '%s'", node->pacard.profile ?
156 node->pacard.profile : "");
157 PRINT(" paport : '%s'", node->paport ? node->paport : "");
158 PRINT(" mux : %s" , mux);
159 PRINT(" stamp : %u" , node->stamp);
166 const char *mir_direction_str(mir_direction direction)
169 case mir_direction_unknown: return "unknown";
170 case mir_input: return "input";
171 case mir_output: return "output";
172 default: return "< ??? >";
176 const char *mir_implement_str(mir_implement implement)
179 case mir_implementation_unknown: return "unknown";
180 case mir_device: return "device";
181 case mir_stream: return "stream";
182 default: return "< ??? >";
186 const char *mir_location_str(mir_location location)
189 case mir_location_unknown: return "unknown";
190 case mir_internal: return "internal";
191 case mir_external: return "external";
192 default: return "< ??? >";
197 const char *mir_node_type_str(mir_node_type type)
200 case mir_node_type_unknown: return "Unknown";
201 case mir_radio: return "Radio";
202 case mir_player: return "Player";
203 case mir_navigator: return "Navigator";
204 case mir_game: return "Game";
205 case mir_browser: return "Browser";
206 case mir_phone: return "Phone";
207 case mir_event: return "Event";
208 case mir_speakers: return "Speakers";
209 case mir_microphone: return "Microphone";
210 case mir_jack: return "Line";
211 case mir_spdif: return "SPDIF";
212 case mir_hdmi: return "HDMI";
213 case mir_wired_headset: return "Wired Headset";
214 case mir_wired_headphone: return "Wired Headphone";
215 case mir_usb_headset: return "USB Headset";
216 case mir_bluetooth_sco: return "Bluetooth Handsfree";
217 case mir_bluetooth_a2dp: return "Bluetooth Stereo";
218 default: return "<user defined>";
223 const char *mir_privacy_str(mir_privacy privacy)
226 case mir_privacy_unknown: return "<unknown>";
227 case mir_public: return "public";
228 case mir_private: return "private";
229 default: return "< ??? >";
237 * indent-tabs-mode: nil