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