]> code.delx.au - pulseaudio/blob - src/pulsecore/cli-text.c
include list of sinks/source in card dump
[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 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
225 pa_sink_get_latency_range(sink, &min_latency, &max_latency);
226
227 pa_strbuf_printf(
228 s,
229 " %c index: %u\n"
230 "\tname: <%s>\n"
231 "\tdriver: <%s>\n"
232 "\tflags: %s%s%s%s%s%s\n"
233 "\tstate: %s\n"
234 "\tvolume: %s%s%s\n"
235 "\t balance %0.2f\n"
236 "\tbase volume: %s%s%s\n"
237 "\tmuted: %s\n"
238 "\tcurrent latency: %0.2f ms\n"
239 "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
240 "\tmax request: %lu KiB\n"
241 "\tmax rewind: %lu KiB\n"
242 "\tmonitor source: %u\n"
243 "\tsample spec: %s\n"
244 "\tchannel map: %s\n"
245 "\tused by: %u\n"
246 "\tlinked by: %u\n",
247 c->default_sink_name && !strcmp(sink->name, c->default_sink_name) ? '*' : ' ',
248 sink->index,
249 sink->name,
250 sink->driver,
251 sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
252 sink->flags & PA_SINK_NETWORK ? "NETWORK " : "",
253 sink->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
254 sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
255 sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
256 sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
257 sink_state_to_string(pa_sink_get_state(sink)),
258 pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
259 sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
260 sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
261 pa_cvolume_get_balance(&sink->channel_map, pa_sink_get_volume(sink, FALSE)),
262 pa_volume_snprint(v, sizeof(v), sink->base_volume),
263 sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
264 sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
265 pa_yes_no(pa_sink_get_mute(sink, FALSE)),
266 (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
267 (double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
268 (double) min_latency / PA_USEC_PER_MSEC,
269 (double) max_latency / PA_USEC_PER_MSEC,
270 (unsigned long) pa_sink_get_max_request(sink) / 1024,
271 (unsigned long) pa_sink_get_max_rewind(sink) / 1024,
272 sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
273 pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec),
274 pa_channel_map_snprint(cm, sizeof(cm), &sink->channel_map),
275 pa_sink_used_by(sink),
276 pa_sink_linked_by(sink));
277
278 if (sink->card)
279 pa_strbuf_printf(s, "\tcard: %u <%s>\n", sink->card->index, sink->card->name);
280 if (sink->module)
281 pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
282
283 t = pa_proplist_to_string_sep(sink->proplist, "\n\t\t");
284 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
285 pa_xfree(t);
286 }
287
288 return pa_strbuf_tostring_free(s);
289 }
290
291 char *pa_source_list_to_string(pa_core *c) {
292 pa_strbuf *s;
293 pa_source *source;
294 uint32_t idx = PA_IDXSET_INVALID;
295 pa_assert(c);
296
297 s = pa_strbuf_new();
298
299 pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_size(c->sources));
300
301 for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) {
302 char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
303 cv[PA_CVOLUME_SNPRINT_MAX],
304 cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
305 v[PA_VOLUME_SNPRINT_MAX],
306 vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
307 cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
308 pa_usec_t min_latency, max_latency;
309
310 pa_source_get_latency_range(source, &min_latency, &max_latency);
311
312 pa_strbuf_printf(
313 s,
314 " %c index: %u\n"
315 "\tname: <%s>\n"
316 "\tdriver: <%s>\n"
317 "\tflags: %s%s%s%s%s%s\n"
318 "\tstate: %s\n"
319 "\tvolume: %s%s%s\n"
320 "\t balance %0.2f\n"
321 "\tbase volume: %s%s%s\n"
322 "\tmuted: %s\n"
323 "\tcurrent latency: %0.2f ms\n"
324 "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
325 "\tmax rewind: %lu KiB\n"
326 "\tsample spec: %s\n"
327 "\tchannel map: %s\n"
328 "\tused by: %u\n"
329 "\tlinked by: %u\n",
330 c->default_source_name && !strcmp(source->name, c->default_source_name) ? '*' : ' ',
331 source->index,
332 source->name,
333 source->driver,
334 source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
335 source->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
336 source->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
337 source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
338 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
339 source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
340 source_state_to_string(pa_source_get_state(source)),
341 pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
342 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
343 source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
344 pa_cvolume_get_balance(&source->channel_map, pa_source_get_volume(source, FALSE)),
345 pa_volume_snprint(v, sizeof(v), source->base_volume),
346 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
347 source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
348 pa_yes_no(pa_source_get_mute(source, FALSE)),
349 (double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
350 (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
351 (double) min_latency / PA_USEC_PER_MSEC,
352 (double) max_latency / PA_USEC_PER_MSEC,
353 (unsigned long) pa_source_get_max_rewind(source) / 1024,
354 pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
355 pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
356 pa_source_used_by(source),
357 pa_source_linked_by(source));
358
359 if (source->monitor_of)
360 pa_strbuf_printf(s, "\tmonitor_of: %u\n", source->monitor_of->index);
361 if (source->card)
362 pa_strbuf_printf(s, "\tcard: %u <%s>\n", source->card->index, source->card->name);
363 if (source->module)
364 pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
365
366 t = pa_proplist_to_string_sep(source->proplist, "\n\t\t");
367 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
368 pa_xfree(t);
369 }
370
371 return pa_strbuf_tostring_free(s);
372 }
373
374
375 char *pa_source_output_list_to_string(pa_core *c) {
376 pa_strbuf *s;
377 pa_source_output *o;
378 uint32_t idx = PA_IDXSET_INVALID;
379 static const char* const state_table[] = {
380 [PA_SOURCE_OUTPUT_INIT] = "INIT",
381 [PA_SOURCE_OUTPUT_RUNNING] = "RUNNING",
382 [PA_SOURCE_OUTPUT_CORKED] = "CORKED",
383 [PA_SOURCE_OUTPUT_UNLINKED] = "UNLINKED"
384 };
385 pa_assert(c);
386
387 s = pa_strbuf_new();
388
389 pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_size(c->source_outputs));
390
391 for (o = pa_idxset_first(c->source_outputs, &idx); o; o = pa_idxset_next(c->source_outputs, &idx)) {
392 char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
393 pa_usec_t cl;
394
395 if ((cl = pa_source_output_get_requested_latency(o)) == (pa_usec_t) -1)
396 pa_snprintf(clt, sizeof(clt), "n/a");
397 else
398 pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
399
400 pa_assert(o->source);
401
402 pa_strbuf_printf(
403 s,
404 " index: %u\n"
405 "\tdriver: <%s>\n"
406 "\tflags: %s%s%s%s%s%s%s%s\n"
407 "\tstate: %s\n"
408 "\tsource: %u <%s>\n"
409 "\tcurrent latency: %0.2f ms\n"
410 "\trequested latency: %s\n"
411 "\tsample spec: %s\n"
412 "\tchannel map: %s\n"
413 "\tresample method: %s\n",
414 o->index,
415 o->driver,
416 o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
417 o->flags & PA_SOURCE_OUTPUT_DONT_MOVE ? "DONT_MOVE " : "",
418 o->flags & PA_SOURCE_OUTPUT_START_CORKED ? "START_CORKED " : "",
419 o->flags & PA_SOURCE_OUTPUT_NO_REMAP ? "NO_REMAP " : "",
420 o->flags & PA_SOURCE_OUTPUT_NO_REMIX ? "NO_REMIX " : "",
421 o->flags & PA_SOURCE_OUTPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
422 o->flags & PA_SOURCE_OUTPUT_FIX_RATE ? "FIX_RATE " : "",
423 o->flags & PA_SOURCE_OUTPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
424 state_table[pa_source_output_get_state(o)],
425 o->source->index, o->source->name,
426 (double) pa_source_output_get_latency(o, NULL) / PA_USEC_PER_MSEC,
427 clt,
428 pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
429 pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
430 pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
431 if (o->module)
432 pa_strbuf_printf(s, "\towner module: %u\n", o->module->index);
433 if (o->client)
434 pa_strbuf_printf(s, "\tclient: %u <%s>\n", o->client->index, pa_strnull(pa_proplist_gets(o->client->proplist, PA_PROP_APPLICATION_NAME)));
435 if (o->direct_on_input)
436 pa_strbuf_printf(s, "\tdirect on input: %u\n", o->direct_on_input->index);
437
438 t = pa_proplist_to_string_sep(o->proplist, "\n\t\t");
439 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
440 pa_xfree(t);
441 }
442
443 return pa_strbuf_tostring_free(s);
444 }
445
446 char *pa_sink_input_list_to_string(pa_core *c) {
447 pa_strbuf *s;
448 pa_sink_input *i;
449 uint32_t idx = PA_IDXSET_INVALID;
450 static const char* const state_table[] = {
451 [PA_SINK_INPUT_INIT] = "INIT",
452 [PA_SINK_INPUT_RUNNING] = "RUNNING",
453 [PA_SINK_INPUT_DRAINED] = "DRAINED",
454 [PA_SINK_INPUT_CORKED] = "CORKED",
455 [PA_SINK_INPUT_UNLINKED] = "UNLINKED"
456 };
457
458 pa_assert(c);
459 s = pa_strbuf_new();
460
461 pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
462
463 for (i = pa_idxset_first(c->sink_inputs, &idx); i; i = pa_idxset_next(c->sink_inputs, &idx)) {
464 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];
465 pa_usec_t cl;
466
467 if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
468 pa_snprintf(clt, sizeof(clt), "n/a");
469 else
470 pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
471
472 pa_assert(i->sink);
473
474 pa_strbuf_printf(
475 s,
476 " index: %u\n"
477 "\tdriver: <%s>\n"
478 "\tflags: %s%s%s%s%s%s%s%s\n"
479 "\tstate: %s\n"
480 "\tsink: %u <%s>\n"
481 "\tvolume: %s\n"
482 "\t %s\n"
483 "\t balance %0.2f\n"
484 "\tmuted: %s\n"
485 "\tcurrent latency: %0.2f ms\n"
486 "\trequested latency: %s\n"
487 "\tsample spec: %s\n"
488 "\tchannel map: %s\n"
489 "\tresample method: %s\n",
490 i->index,
491 i->driver,
492 i->flags & PA_SINK_INPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
493 i->flags & PA_SINK_INPUT_DONT_MOVE ? "DONT_MOVE " : "",
494 i->flags & PA_SINK_INPUT_START_CORKED ? "START_CORKED " : "",
495 i->flags & PA_SINK_INPUT_NO_REMAP ? "NO_REMAP " : "",
496 i->flags & PA_SINK_INPUT_NO_REMIX ? "NO_REMIX " : "",
497 i->flags & PA_SINK_INPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
498 i->flags & PA_SINK_INPUT_FIX_RATE ? "FIX_RATE " : "",
499 i->flags & PA_SINK_INPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
500 state_table[pa_sink_input_get_state(i)],
501 i->sink->index, i->sink->name,
502 pa_cvolume_snprint(cv, sizeof(cv), pa_sink_input_get_volume(i)),
503 pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_input_get_volume(i)),
504 pa_cvolume_get_balance(&i->channel_map, pa_sink_input_get_volume(i)),
505 pa_yes_no(pa_sink_input_get_mute(i)),
506 (double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
507 clt,
508 pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec),
509 pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
510 pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
511
512 if (i->module)
513 pa_strbuf_printf(s, "\tmodule: %u\n", i->module->index);
514 if (i->client)
515 pa_strbuf_printf(s, "\tclient: %u <%s>\n", i->client->index, pa_strnull(pa_proplist_gets(i->client->proplist, PA_PROP_APPLICATION_NAME)));
516
517 t = pa_proplist_to_string_sep(i->proplist, "\n\t\t");
518 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
519 pa_xfree(t);
520 }
521
522 return pa_strbuf_tostring_free(s);
523 }
524
525 char *pa_scache_list_to_string(pa_core *c) {
526 pa_strbuf *s;
527 pa_assert(c);
528
529 s = pa_strbuf_new();
530
531 pa_strbuf_printf(s, "%u cache entrie(s) available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
532
533 if (c->scache) {
534 pa_scache_entry *e;
535 uint32_t idx = PA_IDXSET_INVALID;
536
537 for (e = pa_idxset_first(c->scache, &idx); e; e = pa_idxset_next(c->scache, &idx)) {
538 double l = 0;
539 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;
540
541 if (e->memchunk.memblock) {
542 pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
543 pa_channel_map_snprint(cm, sizeof(cm), &e->channel_map);
544 l = (double) e->memchunk.length / (double) pa_bytes_per_second(&e->sample_spec);
545 }
546
547 pa_strbuf_printf(
548 s,
549 " name: <%s>\n"
550 "\tindex: %u\n"
551 "\tsample spec: %s\n"
552 "\tchannel map: %s\n"
553 "\tlength: %lu\n"
554 "\tduration: %0.1f s\n"
555 "\tvolume: %s\n"
556 "\t %s\n"
557 "\t balance %0.2f\n"
558 "\tlazy: %s\n"
559 "\tfilename: <%s>\n",
560 e->name,
561 e->index,
562 ss,
563 cm,
564 (long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
565 l,
566 pa_cvolume_snprint(cv, sizeof(cv), &e->volume),
567 pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume),
568 e->memchunk.memblock ? pa_cvolume_get_balance(&e->channel_map, &e->volume) : 0.0f,
569 pa_yes_no(e->lazy),
570 e->filename ? e->filename : "n/a");
571
572 t = pa_proplist_to_string_sep(e->proplist, "\n\t\t");
573 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
574 pa_xfree(t);
575 }
576 }
577
578 return pa_strbuf_tostring_free(s);
579 }
580
581 char *pa_full_status_string(pa_core *c) {
582 pa_strbuf *s;
583 int i;
584
585 s = pa_strbuf_new();
586
587 for (i = 0; i < 8; i++) {
588 char *t = NULL;
589
590 switch (i) {
591 case 0:
592 t = pa_sink_list_to_string(c);
593 break;
594 case 1:
595 t = pa_source_list_to_string(c);
596 break;
597 case 2:
598 t = pa_sink_input_list_to_string(c);
599 break;
600 case 3:
601 t = pa_source_output_list_to_string(c);
602 break;
603 case 4:
604 t = pa_client_list_to_string(c);
605 break;
606 case 5:
607 t = pa_card_list_to_string(c);
608 break;
609 case 6:
610 t = pa_module_list_to_string(c);
611 break;
612 case 7:
613 t = pa_scache_list_to_string(c);
614 break;
615 }
616
617 pa_strbuf_puts(s, t);
618 pa_xfree(t);
619 }
620
621 return pa_strbuf_tostring_free(s);
622 }