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