Branch data Line data Source code
1 : : /***
2 : : This file is part of PulseAudio.
3 : :
4 : : Copyright 2004-2006 Lennart Poettering
5 : :
6 : : PulseAudio is free software; you can redistribute it and/or modify
7 : : it under the terms of the GNU Lesser General Public License as published
8 : : by the Free Software Foundation; either version 2.1 of the License,
9 : : or (at your option) any later version.
10 : :
11 : : PulseAudio is distributed in the hope that it will be useful, but
12 : : WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : : General Public License for more details.
15 : :
16 : : You should have received a copy of the GNU Lesser General Public License
17 : : along with PulseAudio; if not, write to the Free Software
18 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 : : USA.
20 : : ***/
21 : :
22 : : #ifdef HAVE_CONFIG_H
23 : : #include <config.h>
24 : : #endif
25 : :
26 : : #include <pulse/volume.h>
27 : : #include <pulse/xmalloc.h>
28 : : #include <pulse/timeval.h>
29 : :
30 : : #include <pulsecore/module.h>
31 : : #include <pulsecore/client.h>
32 : : #include <pulsecore/sink.h>
33 : : #include <pulsecore/source.h>
34 : : #include <pulsecore/sink-input.h>
35 : : #include <pulsecore/source-output.h>
36 : : #include <pulsecore/strbuf.h>
37 : : #include <pulsecore/core-scache.h>
38 : : #include <pulsecore/macro.h>
39 : : #include <pulsecore/core-util.h>
40 : :
41 : : #include "cli-text.h"
42 : :
43 : 0 : char *pa_module_list_to_string(pa_core *c) {
44 : : pa_strbuf *s;
45 : : pa_module *m;
46 : 0 : uint32_t idx = PA_IDXSET_INVALID;
47 [ # # ]: 0 : pa_assert(c);
48 : :
49 : 0 : s = pa_strbuf_new();
50 : :
51 : 0 : pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_size(c->modules));
52 : :
53 [ # # ]: 0 : PA_IDXSET_FOREACH(m, c->modules, idx) {
54 : : char *t;
55 : :
56 : 0 : pa_strbuf_printf(s, " index: %u\n"
57 : : "\tname: <%s>\n"
58 : : "\targument: <%s>\n"
59 : : "\tused: %i\n"
60 : : "\tload once: %s\n",
61 : : m->index,
62 : : m->name,
63 : 0 : pa_strempty(m->argument),
64 : : pa_module_get_n_used(m),
65 : 0 : pa_yes_no(m->load_once));
66 : :
67 : 0 : t = pa_proplist_to_string_sep(m->proplist, "\n\t\t");
68 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
69 : 0 : pa_xfree(t);
70 : : }
71 : :
72 : 0 : return pa_strbuf_tostring_free(s);
73 : : }
74 : :
75 : 0 : char *pa_client_list_to_string(pa_core *c) {
76 : : pa_strbuf *s;
77 : : pa_client *client;
78 : 0 : uint32_t idx = PA_IDXSET_INVALID;
79 [ # # ]: 0 : pa_assert(c);
80 : :
81 : 0 : s = pa_strbuf_new();
82 : :
83 : 0 : pa_strbuf_printf(s, "%u client(s) logged in.\n", pa_idxset_size(c->clients));
84 : :
85 [ # # ]: 0 : PA_IDXSET_FOREACH(client, c->clients, idx) {
86 : : char *t;
87 : 0 : pa_strbuf_printf(
88 : : s,
89 : : " index: %u\n"
90 : : "\tdriver: <%s>\n",
91 : : client->index,
92 : : client->driver);
93 : :
94 [ # # ]: 0 : if (client->module)
95 : 0 : pa_strbuf_printf(s, "\towner module: %u\n", client->module->index);
96 : :
97 : 0 : t = pa_proplist_to_string_sep(client->proplist, "\n\t\t");
98 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
99 : 0 : pa_xfree(t);
100 : : }
101 : :
102 : 0 : return pa_strbuf_tostring_free(s);
103 : : }
104 : :
105 : : static const char *port_available_to_string(pa_port_available_t a) {
106 [ # # # # ]: 0 : switch (a) {
107 : : case PA_PORT_AVAILABLE_UNKNOWN:
108 : : return "unknown";
109 : : case PA_PORT_AVAILABLE_NO:
110 : : return "no";
111 : : case PA_PORT_AVAILABLE_YES:
112 : : return "yes";
113 : : default:
114 : : return "invalid"; /* Should never happen! */
115 : : }
116 : : }
117 : :
118 : 0 : static void append_port_list(pa_strbuf *s, pa_hashmap *ports)
119 : : {
120 : : pa_device_port *p;
121 : : void *state;
122 : :
123 [ # # ]: 0 : pa_assert(ports);
124 : :
125 [ # # ]: 0 : if (pa_hashmap_isempty(ports))
126 : 0 : return;
127 : :
128 : 0 : pa_strbuf_puts(s, "\tports:\n");
129 [ # # ]: 0 : PA_HASHMAP_FOREACH(p, ports, state) {
130 : 0 : char *t = pa_proplist_to_string_sep(p->proplist, "\n\t\t\t\t");
131 : 0 : pa_strbuf_printf(s, "\t\t%s: %s (priority %u, latency offset %" PRId64 " usec, available: %s)\n",
132 : : p->name, p->description, p->priority, p->latency_offset,
133 : : port_available_to_string(p->available));
134 : 0 : pa_strbuf_printf(s, "\t\t\tproperties:\n\t\t\t\t%s\n", t);
135 : 0 : pa_xfree(t);
136 : : }
137 : : }
138 : :
139 : 0 : char *pa_card_list_to_string(pa_core *c) {
140 : : pa_strbuf *s;
141 : : pa_card *card;
142 : 0 : uint32_t idx = PA_IDXSET_INVALID;
143 [ # # ]: 0 : pa_assert(c);
144 : :
145 : 0 : s = pa_strbuf_new();
146 : :
147 : 0 : pa_strbuf_printf(s, "%u card(s) available.\n", pa_idxset_size(c->cards));
148 : :
149 [ # # ]: 0 : PA_IDXSET_FOREACH(card, c->cards, idx) {
150 : : char *t;
151 : : pa_sink *sink;
152 : : pa_source *source;
153 : : uint32_t sidx;
154 : : pa_card_profile *profile;
155 : : void *state;
156 : :
157 : 0 : pa_strbuf_printf(
158 : : s,
159 : : " index: %u\n"
160 : : "\tname: <%s>\n"
161 : : "\tdriver: <%s>\n",
162 : : card->index,
163 : : card->name,
164 : : card->driver);
165 : :
166 [ # # ]: 0 : if (card->module)
167 : 0 : pa_strbuf_printf(s, "\towner module: %u\n", card->module->index);
168 : :
169 : 0 : t = pa_proplist_to_string_sep(card->proplist, "\n\t\t");
170 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
171 : 0 : pa_xfree(t);
172 : :
173 : 0 : pa_strbuf_puts(s, "\tprofiles:\n");
174 [ # # ]: 0 : PA_HASHMAP_FOREACH(profile, card->profiles, state)
175 : 0 : pa_strbuf_printf(s, "\t\t%s: %s (priority %u)\n", profile->name, profile->description, profile->priority);
176 : :
177 : 0 : pa_strbuf_printf(
178 : : s,
179 : : "\tactive profile: <%s>\n",
180 : 0 : card->active_profile->name);
181 : :
182 [ # # ]: 0 : if (!pa_idxset_isempty(card->sinks)) {
183 : 0 : pa_strbuf_puts(s, "\tsinks:\n");
184 [ # # ]: 0 : PA_IDXSET_FOREACH(sink, card->sinks, sidx)
185 : 0 : pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)));
186 : : }
187 : :
188 [ # # ]: 0 : if (!pa_idxset_isempty(card->sources)) {
189 : 0 : pa_strbuf_puts(s, "\tsources:\n");
190 [ # # ]: 0 : PA_IDXSET_FOREACH(source, card->sources, sidx)
191 : 0 : pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)));
192 : : }
193 : :
194 : 0 : append_port_list(s, card->ports);
195 : : }
196 : :
197 : 0 : return pa_strbuf_tostring_free(s);
198 : : }
199 : :
200 : : static const char *sink_state_to_string(pa_sink_state_t state) {
201 [ # # # # : 0 : switch (state) {
# # ]
202 : : case PA_SINK_INIT:
203 : : return "INIT";
204 : : case PA_SINK_RUNNING:
205 : : return "RUNNING";
206 : : case PA_SINK_SUSPENDED:
207 : : return "SUSPENDED";
208 : : case PA_SINK_IDLE:
209 : : return "IDLE";
210 : : case PA_SINK_UNLINKED:
211 : : return "UNLINKED";
212 : : default:
213 : : return "INVALID";
214 : : }
215 : : }
216 : :
217 : : static const char *source_state_to_string(pa_source_state_t state) {
218 [ # # # # : 0 : switch (state) {
# # ]
219 : : case PA_SOURCE_INIT:
220 : : return "INIT";
221 : : case PA_SOURCE_RUNNING:
222 : : return "RUNNING";
223 : : case PA_SOURCE_SUSPENDED:
224 : : return "SUSPENDED";
225 : : case PA_SOURCE_IDLE:
226 : : return "IDLE";
227 : : case PA_SOURCE_UNLINKED:
228 : : return "UNLINKED";
229 : : default:
230 : : return "INVALID";
231 : : }
232 : : }
233 : :
234 : 0 : char *pa_sink_list_to_string(pa_core *c) {
235 : : pa_strbuf *s;
236 : : pa_sink *sink;
237 : 0 : uint32_t idx = PA_IDXSET_INVALID;
238 [ # # ]: 0 : pa_assert(c);
239 : :
240 : 0 : s = pa_strbuf_new();
241 : :
242 : 0 : pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_size(c->sinks));
243 : :
244 [ # # ]: 0 : PA_IDXSET_FOREACH(sink, c->sinks, idx) {
245 : : char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
246 : : cv[PA_CVOLUME_SNPRINT_MAX],
247 : : cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
248 : : v[PA_VOLUME_SNPRINT_MAX],
249 : : vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
250 : : cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
251 : : const char *cmn;
252 : :
253 : 0 : cmn = pa_channel_map_to_pretty_name(&sink->channel_map);
254 : :
255 : :
256 [ # # ][ # # ]: 0 : pa_strbuf_printf(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
257 : : s,
258 : : " %c index: %u\n"
259 : : "\tname: <%s>\n"
260 : : "\tdriver: <%s>\n"
261 : : "\tflags: %s%s%s%s%s%s%s%s\n"
262 : : "\tstate: %s\n"
263 : : "\tsuspend cause: %s%s%s%s\n"
264 : : "\tpriority: %u\n"
265 : : "\tvolume: %s%s%s\n"
266 : : "\t balance %0.2f\n"
267 : : "\tbase volume: %s%s%s\n"
268 : : "\tvolume steps: %u\n"
269 : : "\tmuted: %s\n"
270 : : "\tcurrent latency: %0.2f ms\n"
271 : : "\tmax request: %lu KiB\n"
272 : : "\tmax rewind: %lu KiB\n"
273 : : "\tmonitor source: %u\n"
274 : : "\tsample spec: %s\n"
275 : : "\tchannel map: %s%s%s\n"
276 : : "\tused by: %u\n"
277 : : "\tlinked by: %u\n",
278 : 0 : sink == c->default_sink ? '*' : ' ',
279 : : sink->index,
280 : : sink->name,
281 : : sink->driver,
282 : 0 : sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
283 : 0 : sink->flags & PA_SINK_NETWORK ? "NETWORK " : "",
284 : 0 : sink->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
285 : 0 : sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
286 : 0 : sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
287 : 0 : sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
288 : 0 : sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME " : "",
289 : 0 : sink->flags & PA_SINK_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
290 : : sink_state_to_string(pa_sink_get_state(sink)),
291 : 0 : sink->suspend_cause & PA_SUSPEND_USER ? "USER " : "",
292 : 0 : sink->suspend_cause & PA_SUSPEND_APPLICATION ? "APPLICATION " : "",
293 : 0 : sink->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
294 : 0 : sink->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
295 : : sink->priority,
296 : : pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
297 : 0 : sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
298 : 0 : sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
299 : 0 : pa_cvolume_get_balance(pa_sink_get_volume(sink, FALSE), &sink->channel_map),
300 : : pa_volume_snprint(v, sizeof(v), sink->base_volume),
301 : 0 : sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
302 : 0 : sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
303 : : sink->n_volume_steps,
304 : 0 : pa_yes_no(pa_sink_get_mute(sink, FALSE)),
305 : 0 : (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
306 : 0 : (unsigned long) pa_sink_get_max_request(sink) / 1024,
307 : 0 : (unsigned long) pa_sink_get_max_rewind(sink) / 1024,
308 : 0 : sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
309 : 0 : pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec),
310 : 0 : pa_channel_map_snprint(cm, sizeof(cm), &sink->channel_map),
311 : : cmn ? "\n\t " : "",
312 : : cmn ? cmn : "",
313 : : pa_sink_used_by(sink),
314 : : pa_sink_linked_by(sink));
315 : :
316 [ # # ]: 0 : if (sink->flags & PA_SINK_DYNAMIC_LATENCY) {
317 : : pa_usec_t min_latency, max_latency;
318 : 0 : pa_sink_get_latency_range(sink, &min_latency, &max_latency);
319 : :
320 : 0 : pa_strbuf_printf(
321 : : s,
322 : : "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n",
323 : 0 : (double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
324 : 0 : (double) min_latency / PA_USEC_PER_MSEC,
325 : 0 : (double) max_latency / PA_USEC_PER_MSEC);
326 : : } else
327 : 0 : pa_strbuf_printf(
328 : : s,
329 : : "\tfixed latency: %0.2f ms\n",
330 : 0 : (double) pa_sink_get_fixed_latency(sink) / PA_USEC_PER_MSEC);
331 : :
332 [ # # ]: 0 : if (sink->card)
333 : 0 : pa_strbuf_printf(s, "\tcard: %u <%s>\n", sink->card->index, sink->card->name);
334 [ # # ]: 0 : if (sink->module)
335 : 0 : pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
336 : :
337 : 0 : t = pa_proplist_to_string_sep(sink->proplist, "\n\t\t");
338 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
339 : 0 : pa_xfree(t);
340 : :
341 : 0 : append_port_list(s, sink->ports);
342 : :
343 [ # # ]: 0 : if (sink->active_port)
344 : 0 : pa_strbuf_printf(
345 : : s,
346 : : "\tactive port: <%s>\n",
347 : 0 : sink->active_port->name);
348 : : }
349 : :
350 : 0 : return pa_strbuf_tostring_free(s);
351 : : }
352 : :
353 : 0 : char *pa_source_list_to_string(pa_core *c) {
354 : : pa_strbuf *s;
355 : : pa_source *source;
356 : 0 : uint32_t idx = PA_IDXSET_INVALID;
357 [ # # ]: 0 : pa_assert(c);
358 : :
359 : 0 : s = pa_strbuf_new();
360 : :
361 : 0 : pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_size(c->sources));
362 : :
363 [ # # ]: 0 : PA_IDXSET_FOREACH(source, c->sources, idx) {
364 : : char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
365 : : cv[PA_CVOLUME_SNPRINT_MAX],
366 : : cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
367 : : v[PA_VOLUME_SNPRINT_MAX],
368 : : vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
369 : : cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
370 : : const char *cmn;
371 : :
372 : 0 : cmn = pa_channel_map_to_pretty_name(&source->channel_map);
373 : :
374 [ # # ][ # # ]: 0 : pa_strbuf_printf(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
375 : : s,
376 : : " %c index: %u\n"
377 : : "\tname: <%s>\n"
378 : : "\tdriver: <%s>\n"
379 : : "\tflags: %s%s%s%s%s%s%s\n"
380 : : "\tstate: %s\n"
381 : : "\tsuspend cause: %s%s%s%s\n"
382 : : "\tpriority: %u\n"
383 : : "\tvolume: %s%s%s\n"
384 : : "\t balance %0.2f\n"
385 : : "\tbase volume: %s%s%s\n"
386 : : "\tvolume steps: %u\n"
387 : : "\tmuted: %s\n"
388 : : "\tcurrent latency: %0.2f ms\n"
389 : : "\tmax rewind: %lu KiB\n"
390 : : "\tsample spec: %s\n"
391 : : "\tchannel map: %s%s%s\n"
392 : : "\tused by: %u\n"
393 : : "\tlinked by: %u\n",
394 : 0 : c->default_source == source ? '*' : ' ',
395 : : source->index,
396 : : source->name,
397 : : source->driver,
398 : 0 : source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
399 : 0 : source->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
400 : 0 : source->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
401 : 0 : source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
402 : 0 : source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
403 : 0 : source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
404 : 0 : source->flags & PA_SOURCE_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
405 : : source_state_to_string(pa_source_get_state(source)),
406 : 0 : source->suspend_cause & PA_SUSPEND_USER ? "USER " : "",
407 : 0 : source->suspend_cause & PA_SUSPEND_APPLICATION ? "APPLICATION " : "",
408 : 0 : source->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
409 : 0 : source->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
410 : : source->priority,
411 : : pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
412 : 0 : source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
413 : 0 : source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
414 : 0 : pa_cvolume_get_balance(pa_source_get_volume(source, FALSE), &source->channel_map),
415 : : pa_volume_snprint(v, sizeof(v), source->base_volume),
416 : 0 : source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
417 : 0 : source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
418 : : source->n_volume_steps,
419 : 0 : pa_yes_no(pa_source_get_mute(source, FALSE)),
420 : 0 : (double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
421 : 0 : (unsigned long) pa_source_get_max_rewind(source) / 1024,
422 : 0 : pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
423 : 0 : pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
424 : : cmn ? "\n\t " : "",
425 : : cmn ? cmn : "",
426 : : pa_source_used_by(source),
427 : : pa_source_linked_by(source));
428 : :
429 [ # # ]: 0 : if (source->flags & PA_SOURCE_DYNAMIC_LATENCY) {
430 : : pa_usec_t min_latency, max_latency;
431 : 0 : pa_source_get_latency_range(source, &min_latency, &max_latency);
432 : :
433 : 0 : pa_strbuf_printf(
434 : : s,
435 : : "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n",
436 : 0 : (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
437 : 0 : (double) min_latency / PA_USEC_PER_MSEC,
438 : 0 : (double) max_latency / PA_USEC_PER_MSEC);
439 : : } else
440 : 0 : pa_strbuf_printf(
441 : : s,
442 : : "\tfixed latency: %0.2f ms\n",
443 : 0 : (double) pa_source_get_fixed_latency(source) / PA_USEC_PER_MSEC);
444 : :
445 [ # # ]: 0 : if (source->monitor_of)
446 : 0 : pa_strbuf_printf(s, "\tmonitor_of: %u\n", source->monitor_of->index);
447 [ # # ]: 0 : if (source->card)
448 : 0 : pa_strbuf_printf(s, "\tcard: %u <%s>\n", source->card->index, source->card->name);
449 [ # # ]: 0 : if (source->module)
450 : 0 : pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
451 : :
452 : 0 : t = pa_proplist_to_string_sep(source->proplist, "\n\t\t");
453 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
454 : 0 : pa_xfree(t);
455 : :
456 : 0 : append_port_list(s, source->ports);
457 : :
458 [ # # ]: 0 : if (source->active_port)
459 : 0 : pa_strbuf_printf(
460 : : s,
461 : : "\tactive port: <%s>\n",
462 : 0 : source->active_port->name);
463 : : }
464 : :
465 : 0 : return pa_strbuf_tostring_free(s);
466 : : }
467 : :
468 : :
469 : 0 : char *pa_source_output_list_to_string(pa_core *c) {
470 : : pa_strbuf *s;
471 : : pa_source_output *o;
472 : 0 : uint32_t idx = PA_IDXSET_INVALID;
473 : : static const char* const state_table[] = {
474 : : [PA_SOURCE_OUTPUT_INIT] = "INIT",
475 : : [PA_SOURCE_OUTPUT_RUNNING] = "RUNNING",
476 : : [PA_SOURCE_OUTPUT_CORKED] = "CORKED",
477 : : [PA_SOURCE_OUTPUT_UNLINKED] = "UNLINKED"
478 : : };
479 [ # # ]: 0 : pa_assert(c);
480 : :
481 : 0 : s = pa_strbuf_new();
482 : :
483 : 0 : pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_size(c->source_outputs));
484 : :
485 [ # # ]: 0 : PA_IDXSET_FOREACH(o, c->source_outputs, idx) {
486 : : char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
487 : : pa_usec_t cl;
488 : : const char *cmn;
489 : : pa_cvolume v;
490 : 0 : char *volume_str = NULL;
491 : :
492 : 0 : cmn = pa_channel_map_to_pretty_name(&o->channel_map);
493 : :
494 [ # # ]: 0 : if ((cl = pa_source_output_get_requested_latency(o)) == (pa_usec_t) -1)
495 : 0 : pa_snprintf(clt, sizeof(clt), "n/a");
496 : : else
497 : 0 : pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
498 : :
499 [ # # ]: 0 : pa_assert(o->source);
500 : :
501 [ # # ]: 0 : if (pa_source_output_is_volume_readable(o)) {
502 : 0 : pa_source_output_get_volume(o, &v, TRUE);
503 : 0 : volume_str = pa_sprintf_malloc("%s\n\t %s\n\t balance %0.2f",
504 : : pa_cvolume_snprint(cv, sizeof(cv), &v),
505 : : pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
506 : 0 : pa_cvolume_get_balance(&v, &o->channel_map));
507 : : } else
508 : 0 : volume_str = pa_xstrdup("n/a");
509 : :
510 : :
511 [ # # ][ # # ]: 0 : pa_strbuf_printf(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
512 : : s,
513 : : " index: %u\n"
514 : : "\tdriver: <%s>\n"
515 : : "\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n"
516 : : "\tstate: %s\n"
517 : : "\tsource: %u <%s>\n"
518 : : "\tvolume: %s\n"
519 : : "\tmuted: %s\n"
520 : : "\tcurrent latency: %0.2f ms\n"
521 : : "\trequested latency: %s\n"
522 : : "\tsample spec: %s\n"
523 : : "\tchannel map: %s%s%s\n"
524 : : "\tresample method: %s\n",
525 : : o->index,
526 : : o->driver,
527 : 0 : o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
528 : 0 : o->flags & PA_SOURCE_OUTPUT_DONT_MOVE ? "DONT_MOVE " : "",
529 : 0 : o->flags & PA_SOURCE_OUTPUT_START_CORKED ? "START_CORKED " : "",
530 : 0 : o->flags & PA_SOURCE_OUTPUT_NO_REMAP ? "NO_REMAP " : "",
531 : 0 : o->flags & PA_SOURCE_OUTPUT_NO_REMIX ? "NO_REMIX " : "",
532 : 0 : o->flags & PA_SOURCE_OUTPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
533 : 0 : o->flags & PA_SOURCE_OUTPUT_FIX_RATE ? "FIX_RATE " : "",
534 : 0 : o->flags & PA_SOURCE_OUTPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
535 : 0 : o->flags & PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND ? "DONT_INHIBIT_AUTO_SUSPEND " : "",
536 : 0 : o->flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_ON_SUSPEND " : "",
537 : 0 : o->flags & PA_SOURCE_OUTPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
538 : 0 : o->flags & PA_SOURCE_OUTPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
539 : 0 : state_table[pa_source_output_get_state(o)],
540 : 0 : o->source->index, o->source->name,
541 : : volume_str,
542 : 0 : pa_yes_no(pa_source_output_get_mute(o)),
543 : 0 : (double) pa_source_output_get_latency(o, NULL) / PA_USEC_PER_MSEC,
544 : : clt,
545 : 0 : pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
546 : 0 : pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
547 : : cmn ? "\n\t " : "",
548 : : cmn ? cmn : "",
549 : : pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
550 : :
551 : 0 : pa_xfree(volume_str);
552 : :
553 [ # # ]: 0 : if (o->module)
554 : 0 : pa_strbuf_printf(s, "\towner module: %u\n", o->module->index);
555 [ # # ]: 0 : if (o->client)
556 : 0 : pa_strbuf_printf(s, "\tclient: %u <%s>\n", o->client->index, pa_strnull(pa_proplist_gets(o->client->proplist, PA_PROP_APPLICATION_NAME)));
557 [ # # ]: 0 : if (o->direct_on_input)
558 : 0 : pa_strbuf_printf(s, "\tdirect on input: %u\n", o->direct_on_input->index);
559 : :
560 : 0 : t = pa_proplist_to_string_sep(o->proplist, "\n\t\t");
561 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
562 : 0 : pa_xfree(t);
563 : : }
564 : :
565 : 0 : return pa_strbuf_tostring_free(s);
566 : : }
567 : :
568 : 0 : char *pa_sink_input_list_to_string(pa_core *c) {
569 : : pa_strbuf *s;
570 : : pa_sink_input *i;
571 : 0 : uint32_t idx = PA_IDXSET_INVALID;
572 : : static const char* const state_table[] = {
573 : : [PA_SINK_INPUT_INIT] = "INIT",
574 : : [PA_SINK_INPUT_RUNNING] = "RUNNING",
575 : : [PA_SINK_INPUT_DRAINED] = "DRAINED",
576 : : [PA_SINK_INPUT_CORKED] = "CORKED",
577 : : [PA_SINK_INPUT_UNLINKED] = "UNLINKED"
578 : : };
579 : :
580 [ # # ]: 0 : pa_assert(c);
581 : 0 : s = pa_strbuf_new();
582 : :
583 : 0 : pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
584 : :
585 [ # # ]: 0 : PA_IDXSET_FOREACH(i, c->sink_inputs, idx) {
586 : : char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
587 : : pa_usec_t cl;
588 : : const char *cmn;
589 : : pa_cvolume v;
590 : 0 : char *volume_str = NULL;
591 : :
592 : 0 : cmn = pa_channel_map_to_pretty_name(&i->channel_map);
593 : :
594 [ # # ]: 0 : if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
595 : 0 : pa_snprintf(clt, sizeof(clt), "n/a");
596 : : else
597 : 0 : pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
598 : :
599 [ # # ]: 0 : pa_assert(i->sink);
600 : :
601 [ # # ]: 0 : if (pa_sink_input_is_volume_readable(i)) {
602 : 0 : pa_sink_input_get_volume(i, &v, TRUE);
603 : 0 : volume_str = pa_sprintf_malloc("%s\n\t %s\n\t balance %0.2f",
604 : : pa_cvolume_snprint(cv, sizeof(cv), &v),
605 : : pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
606 : 0 : pa_cvolume_get_balance(&v, &i->channel_map));
607 : : } else
608 : 0 : volume_str = pa_xstrdup("n/a");
609 : :
610 [ # # ][ # # ]: 0 : pa_strbuf_printf(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
611 : : s,
612 : : " index: %u\n"
613 : : "\tdriver: <%s>\n"
614 : : "\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n"
615 : : "\tstate: %s\n"
616 : : "\tsink: %u <%s>\n"
617 : : "\tvolume: %s\n"
618 : : "\tmuted: %s\n"
619 : : "\tcurrent latency: %0.2f ms\n"
620 : : "\trequested latency: %s\n"
621 : : "\tsample spec: %s\n"
622 : : "\tchannel map: %s%s%s\n"
623 : : "\tresample method: %s\n",
624 : : i->index,
625 : : i->driver,
626 : 0 : i->flags & PA_SINK_INPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
627 : 0 : i->flags & PA_SINK_INPUT_DONT_MOVE ? "DONT_MOVE " : "",
628 : 0 : i->flags & PA_SINK_INPUT_START_CORKED ? "START_CORKED " : "",
629 : 0 : i->flags & PA_SINK_INPUT_NO_REMAP ? "NO_REMAP " : "",
630 : 0 : i->flags & PA_SINK_INPUT_NO_REMIX ? "NO_REMIX " : "",
631 : 0 : i->flags & PA_SINK_INPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
632 : 0 : i->flags & PA_SINK_INPUT_FIX_RATE ? "FIX_RATE " : "",
633 : 0 : i->flags & PA_SINK_INPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
634 : 0 : i->flags & PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND ? "DONT_INHIBIT_AUTO_SUSPEND " : "",
635 : 0 : i->flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_SUSPEND " : "",
636 : 0 : i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
637 : 0 : i->flags & PA_SINK_INPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
638 : 0 : state_table[pa_sink_input_get_state(i)],
639 : 0 : i->sink->index, i->sink->name,
640 : : volume_str,
641 : 0 : pa_yes_no(pa_sink_input_get_mute(i)),
642 : 0 : (double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
643 : : clt,
644 : 0 : pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec),
645 : 0 : pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
646 : : cmn ? "\n\t " : "",
647 : : cmn ? cmn : "",
648 : : pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
649 : :
650 : 0 : pa_xfree(volume_str);
651 : :
652 [ # # ]: 0 : if (i->module)
653 : 0 : pa_strbuf_printf(s, "\tmodule: %u\n", i->module->index);
654 [ # # ]: 0 : if (i->client)
655 : 0 : pa_strbuf_printf(s, "\tclient: %u <%s>\n", i->client->index, pa_strnull(pa_proplist_gets(i->client->proplist, PA_PROP_APPLICATION_NAME)));
656 : :
657 : 0 : t = pa_proplist_to_string_sep(i->proplist, "\n\t\t");
658 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
659 : 0 : pa_xfree(t);
660 : : }
661 : :
662 : 0 : return pa_strbuf_tostring_free(s);
663 : : }
664 : :
665 : 0 : char *pa_scache_list_to_string(pa_core *c) {
666 : : pa_strbuf *s;
667 [ # # ]: 0 : pa_assert(c);
668 : :
669 : 0 : s = pa_strbuf_new();
670 : :
671 [ # # ]: 0 : pa_strbuf_printf(s, "%u cache entrie(s) available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
672 : :
673 [ # # ]: 0 : if (c->scache) {
674 : : pa_scache_entry *e;
675 : 0 : uint32_t idx = PA_IDXSET_INVALID;
676 : :
677 [ # # ]: 0 : PA_IDXSET_FOREACH(e, c->scache, idx) {
678 : 0 : double l = 0;
679 : 0 : char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
680 : : const char *cmn;
681 : :
682 : 0 : cmn = pa_channel_map_to_pretty_name(&e->channel_map);
683 : :
684 [ # # ]: 0 : if (e->memchunk.memblock) {
685 : 0 : pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
686 : 0 : pa_channel_map_snprint(cm, sizeof(cm), &e->channel_map);
687 : 0 : l = (double) e->memchunk.length / (double) pa_bytes_per_second(&e->sample_spec);
688 : : }
689 : :
690 [ # # ][ # # ]: 0 : pa_strbuf_printf(
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
691 : : s,
692 : : " name: <%s>\n"
693 : : "\tindex: %u\n"
694 : : "\tsample spec: %s\n"
695 : : "\tchannel map: %s%s%s\n"
696 : : "\tlength: %lu\n"
697 : : "\tduration: %0.1f s\n"
698 : : "\tvolume: %s\n"
699 : : "\t %s\n"
700 : : "\t balance %0.2f\n"
701 : : "\tlazy: %s\n"
702 : : "\tfilename: <%s>\n",
703 : : e->name,
704 : : e->index,
705 : : ss,
706 : : cm,
707 : : cmn ? "\n\t " : "",
708 : : cmn ? cmn : "",
709 : 0 : (long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
710 : : l,
711 : 0 : e->volume_is_set ? pa_cvolume_snprint(cv, sizeof(cv), &e->volume) : "n/a",
712 : 0 : e->volume_is_set ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume) : "n/a",
713 [ # # ]: 0 : (e->memchunk.memblock && e->volume_is_set) ? pa_cvolume_get_balance(&e->volume, &e->channel_map) : 0.0f,
714 : 0 : pa_yes_no(e->lazy),
715 : 0 : e->filename ? e->filename : "n/a");
716 : :
717 : 0 : t = pa_proplist_to_string_sep(e->proplist, "\n\t\t");
718 : 0 : pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
719 : 0 : pa_xfree(t);
720 : : }
721 : : }
722 : :
723 : 0 : return pa_strbuf_tostring_free(s);
724 : : }
725 : :
726 : 0 : char *pa_full_status_string(pa_core *c) {
727 : : pa_strbuf *s;
728 : : int i;
729 : :
730 : 0 : s = pa_strbuf_new();
731 : :
732 [ # # ]: 0 : for (i = 0; i < 8; i++) {
733 : 0 : char *t = NULL;
734 : :
735 [ # # # # : 0 : switch (i) {
# # # #
# ]
736 : : case 0:
737 : 0 : t = pa_sink_list_to_string(c);
738 : 0 : break;
739 : : case 1:
740 : 0 : t = pa_source_list_to_string(c);
741 : 0 : break;
742 : : case 2:
743 : 0 : t = pa_sink_input_list_to_string(c);
744 : 0 : break;
745 : : case 3:
746 : 0 : t = pa_source_output_list_to_string(c);
747 : 0 : break;
748 : : case 4:
749 : 0 : t = pa_client_list_to_string(c);
750 : 0 : break;
751 : : case 5:
752 : 0 : t = pa_card_list_to_string(c);
753 : 0 : break;
754 : : case 6:
755 : 0 : t = pa_module_list_to_string(c);
756 : 0 : break;
757 : : case 7:
758 : 0 : t = pa_scache_list_to_string(c);
759 : 0 : break;
760 : : }
761 : :
762 : 0 : pa_strbuf_puts(s, t);
763 : 0 : pa_xfree(t);
764 : : }
765 : :
766 : 0 : return pa_strbuf_tostring_free(s);
767 : : }
|