]> code.delx.au - pulseaudio/blob - src/pulsecore/cli-text.c
show dB and balance for cached samples
[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_strbuf_printf(
121 s,
122 " index: %u\n"
123 "\tname: <%s>\n"
124 "\tdriver: <%s>\n",
125 card->index,
126 card->name,
127 card->driver);
128
129 if (card->module)
130 pa_strbuf_printf(s, "\towner module: %u\n", card->module->index);
131
132 t = pa_proplist_to_string_sep(card->proplist, "\n\t\t");
133 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
134 pa_xfree(t);
135
136 if (card->profiles) {
137 pa_card_profile *p;
138 void *state = NULL;
139
140 pa_strbuf_puts(
141 s,
142 "\tprofiles:\n");
143
144 while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
145 pa_strbuf_printf(s, "\t\t%s: %s\n", p->name, p->description);
146 }
147
148 }
149
150 return pa_strbuf_tostring_free(s);
151 }
152
153 char *pa_sink_list_to_string(pa_core *c) {
154 pa_strbuf *s;
155 pa_sink *sink;
156 uint32_t idx = PA_IDXSET_INVALID;
157 static const char* const state_table[] = {
158 [PA_SINK_INIT] = "INIT",
159 [PA_SINK_RUNNING] = "RUNNING",
160 [PA_SINK_SUSPENDED] = "SUSPENDED",
161 [PA_SINK_IDLE] = "IDLE",
162 [PA_SINK_UNLINKED] = "UNLINKED"
163 };
164 pa_assert(c);
165
166 s = pa_strbuf_new();
167
168 pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_size(c->sinks));
169
170 for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx)) {
171 char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
172 cv[PA_CVOLUME_SNPRINT_MAX],
173 cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
174 v[PA_VOLUME_SNPRINT_MAX],
175 vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
176 cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
177 pa_usec_t min_latency, max_latency;
178
179 pa_sink_get_latency_range(sink, &min_latency, &max_latency);
180
181 pa_strbuf_printf(
182 s,
183 " %c index: %u\n"
184 "\tname: <%s>\n"
185 "\tdriver: <%s>\n"
186 "\tflags: %s%s%s%s%s%s\n"
187 "\tstate: %s\n"
188 "\tvolume: %s%s%s\n"
189 "\t balance %0.2f\n"
190 "\tbase volume: %s%s%s\n"
191 "\tmuted: %s\n"
192 "\tcurrent latency: %0.2f ms\n"
193 "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
194 "\tmax request: %lu KiB\n"
195 "\tmax rewind: %lu KiB\n"
196 "\tmonitor source: %u\n"
197 "\tsample spec: %s\n"
198 "\tchannel map: %s\n"
199 "\tused by: %u\n"
200 "\tlinked by: %u\n",
201 c->default_sink_name && !strcmp(sink->name, c->default_sink_name) ? '*' : ' ',
202 sink->index,
203 sink->name,
204 sink->driver,
205 sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
206 sink->flags & PA_SINK_NETWORK ? "NETWORK " : "",
207 sink->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
208 sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
209 sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
210 sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
211 state_table[pa_sink_get_state(sink)],
212 pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
213 sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
214 sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
215 pa_cvolume_get_balance(&sink->channel_map, pa_sink_get_volume(sink, FALSE)),
216 pa_volume_snprint(v, sizeof(v), sink->base_volume),
217 sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
218 sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
219 pa_yes_no(pa_sink_get_mute(sink, FALSE)),
220 (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
221 (double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
222 (double) min_latency / PA_USEC_PER_MSEC,
223 (double) max_latency / PA_USEC_PER_MSEC,
224 (unsigned long) pa_sink_get_max_request(sink) / 1024,
225 (unsigned long) pa_sink_get_max_rewind(sink) / 1024,
226 sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
227 pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec),
228 pa_channel_map_snprint(cm, sizeof(cm), &sink->channel_map),
229 pa_sink_used_by(sink),
230 pa_sink_linked_by(sink));
231
232 if (sink->card)
233 pa_strbuf_printf(s, "\tcard: %u <%s>\n", sink->card->index, sink->card->name);
234 if (sink->module)
235 pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
236
237 t = pa_proplist_to_string_sep(sink->proplist, "\n\t\t");
238 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
239 pa_xfree(t);
240 }
241
242 return pa_strbuf_tostring_free(s);
243 }
244
245 char *pa_source_list_to_string(pa_core *c) {
246 pa_strbuf *s;
247 pa_source *source;
248 uint32_t idx = PA_IDXSET_INVALID;
249 static const char* const state_table[] = {
250 [PA_SOURCE_INIT] = "INIT",
251 [PA_SOURCE_RUNNING] = "RUNNING",
252 [PA_SOURCE_SUSPENDED] = "SUSPENDED",
253 [PA_SOURCE_IDLE] = "IDLE",
254 [PA_SOURCE_UNLINKED] = "UNLINKED"
255 };
256 pa_assert(c);
257
258 s = pa_strbuf_new();
259
260 pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_size(c->sources));
261
262 for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) {
263 char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
264 cv[PA_CVOLUME_SNPRINT_MAX],
265 cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
266 v[PA_VOLUME_SNPRINT_MAX],
267 vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
268 cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
269 pa_usec_t min_latency, max_latency;
270
271 pa_source_get_latency_range(source, &min_latency, &max_latency);
272
273 pa_strbuf_printf(
274 s,
275 " %c index: %u\n"
276 "\tname: <%s>\n"
277 "\tdriver: <%s>\n"
278 "\tflags: %s%s%s%s%s%s\n"
279 "\tstate: %s\n"
280 "\tvolume: %s%s%s\n"
281 "\t balance %0.2f\n"
282 "\tbase volume: %s%s%s\n"
283 "\tmuted: %s\n"
284 "\tcurrent latency: %0.2f ms\n"
285 "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
286 "\tmax rewind: %lu KiB\n"
287 "\tsample spec: %s\n"
288 "\tchannel map: %s\n"
289 "\tused by: %u\n"
290 "\tlinked by: %u\n",
291 c->default_source_name && !strcmp(source->name, c->default_source_name) ? '*' : ' ',
292 source->index,
293 source->name,
294 source->driver,
295 source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
296 source->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
297 source->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
298 source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
299 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
300 source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
301 state_table[pa_source_get_state(source)],
302 pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
303 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
304 source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
305 pa_cvolume_get_balance(&source->channel_map, pa_source_get_volume(source, FALSE)),
306 pa_volume_snprint(v, sizeof(v), source->base_volume),
307 source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
308 source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
309 pa_yes_no(pa_source_get_mute(source, FALSE)),
310 (double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
311 (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
312 (double) min_latency / PA_USEC_PER_MSEC,
313 (double) max_latency / PA_USEC_PER_MSEC,
314 (unsigned long) pa_source_get_max_rewind(source) / 1024,
315 pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
316 pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
317 pa_source_used_by(source),
318 pa_source_linked_by(source));
319
320 if (source->monitor_of)
321 pa_strbuf_printf(s, "\tmonitor_of: %u\n", source->monitor_of->index);
322 if (source->card)
323 pa_strbuf_printf(s, "\tcard: %u <%s>\n", source->card->index, source->card->name);
324 if (source->module)
325 pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
326
327 t = pa_proplist_to_string_sep(source->proplist, "\n\t\t");
328 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
329 pa_xfree(t);
330 }
331
332 return pa_strbuf_tostring_free(s);
333 }
334
335
336 char *pa_source_output_list_to_string(pa_core *c) {
337 pa_strbuf *s;
338 pa_source_output *o;
339 uint32_t idx = PA_IDXSET_INVALID;
340 static const char* const state_table[] = {
341 [PA_SOURCE_OUTPUT_INIT] = "INIT",
342 [PA_SOURCE_OUTPUT_RUNNING] = "RUNNING",
343 [PA_SOURCE_OUTPUT_CORKED] = "CORKED",
344 [PA_SOURCE_OUTPUT_UNLINKED] = "UNLINKED"
345 };
346 pa_assert(c);
347
348 s = pa_strbuf_new();
349
350 pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_size(c->source_outputs));
351
352 for (o = pa_idxset_first(c->source_outputs, &idx); o; o = pa_idxset_next(c->source_outputs, &idx)) {
353 char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
354 pa_usec_t cl;
355
356 if ((cl = pa_source_output_get_requested_latency(o)) == (pa_usec_t) -1)
357 pa_snprintf(clt, sizeof(clt), "n/a");
358 else
359 pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
360
361 pa_assert(o->source);
362
363 pa_strbuf_printf(
364 s,
365 " index: %u\n"
366 "\tdriver: <%s>\n"
367 "\tflags: %s%s%s%s%s%s%s%s\n"
368 "\tstate: %s\n"
369 "\tsource: %u <%s>\n"
370 "\tcurrent latency: %0.2f ms\n"
371 "\trequested latency: %s\n"
372 "\tsample spec: %s\n"
373 "\tchannel map: %s\n"
374 "\tresample method: %s\n",
375 o->index,
376 o->driver,
377 o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
378 o->flags & PA_SOURCE_OUTPUT_DONT_MOVE ? "DONT_MOVE " : "",
379 o->flags & PA_SOURCE_OUTPUT_START_CORKED ? "START_CORKED " : "",
380 o->flags & PA_SOURCE_OUTPUT_NO_REMAP ? "NO_REMAP " : "",
381 o->flags & PA_SOURCE_OUTPUT_NO_REMIX ? "NO_REMIX " : "",
382 o->flags & PA_SOURCE_OUTPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
383 o->flags & PA_SOURCE_OUTPUT_FIX_RATE ? "FIX_RATE " : "",
384 o->flags & PA_SOURCE_OUTPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
385 state_table[pa_source_output_get_state(o)],
386 o->source->index, o->source->name,
387 (double) pa_source_output_get_latency(o, NULL) / PA_USEC_PER_MSEC,
388 clt,
389 pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
390 pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
391 pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
392 if (o->module)
393 pa_strbuf_printf(s, "\towner module: %u\n", o->module->index);
394 if (o->client)
395 pa_strbuf_printf(s, "\tclient: %u <%s>\n", o->client->index, pa_strnull(pa_proplist_gets(o->client->proplist, PA_PROP_APPLICATION_NAME)));
396 if (o->direct_on_input)
397 pa_strbuf_printf(s, "\tdirect on input: %u\n", o->direct_on_input->index);
398
399 t = pa_proplist_to_string_sep(o->proplist, "\n\t\t");
400 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
401 pa_xfree(t);
402 }
403
404 return pa_strbuf_tostring_free(s);
405 }
406
407 char *pa_sink_input_list_to_string(pa_core *c) {
408 pa_strbuf *s;
409 pa_sink_input *i;
410 uint32_t idx = PA_IDXSET_INVALID;
411 static const char* const state_table[] = {
412 [PA_SINK_INPUT_INIT] = "INIT",
413 [PA_SINK_INPUT_RUNNING] = "RUNNING",
414 [PA_SINK_INPUT_DRAINED] = "DRAINED",
415 [PA_SINK_INPUT_CORKED] = "CORKED",
416 [PA_SINK_INPUT_UNLINKED] = "UNLINKED"
417 };
418
419 pa_assert(c);
420 s = pa_strbuf_new();
421
422 pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
423
424 for (i = pa_idxset_first(c->sink_inputs, &idx); i; i = pa_idxset_next(c->sink_inputs, &idx)) {
425 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];
426 pa_usec_t cl;
427
428 if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
429 pa_snprintf(clt, sizeof(clt), "n/a");
430 else
431 pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
432
433 pa_assert(i->sink);
434
435 pa_strbuf_printf(
436 s,
437 " index: %u\n"
438 "\tdriver: <%s>\n"
439 "\tflags: %s%s%s%s%s%s%s%s\n"
440 "\tstate: %s\n"
441 "\tsink: %u <%s>\n"
442 "\tvolume: %s\n"
443 "\t %s\n"
444 "\t balance %0.2f\n"
445 "\tmuted: %s\n"
446 "\tcurrent latency: %0.2f ms\n"
447 "\trequested latency: %s\n"
448 "\tsample spec: %s\n"
449 "\tchannel map: %s\n"
450 "\tresample method: %s\n",
451 i->index,
452 i->driver,
453 i->flags & PA_SINK_INPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
454 i->flags & PA_SINK_INPUT_DONT_MOVE ? "DONT_MOVE " : "",
455 i->flags & PA_SINK_INPUT_START_CORKED ? "START_CORKED " : "",
456 i->flags & PA_SINK_INPUT_NO_REMAP ? "NO_REMAP " : "",
457 i->flags & PA_SINK_INPUT_NO_REMIX ? "NO_REMIX " : "",
458 i->flags & PA_SINK_INPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
459 i->flags & PA_SINK_INPUT_FIX_RATE ? "FIX_RATE " : "",
460 i->flags & PA_SINK_INPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
461 state_table[pa_sink_input_get_state(i)],
462 i->sink->index, i->sink->name,
463 pa_cvolume_snprint(cv, sizeof(cv), pa_sink_input_get_volume(i)),
464 pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_input_get_volume(i)),
465 pa_cvolume_get_balance(&i->channel_map, pa_sink_input_get_volume(i)),
466 pa_yes_no(pa_sink_input_get_mute(i)),
467 (double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
468 clt,
469 pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec),
470 pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
471 pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
472
473 if (i->module)
474 pa_strbuf_printf(s, "\tmodule: %u\n", i->module->index);
475 if (i->client)
476 pa_strbuf_printf(s, "\tclient: %u <%s>\n", i->client->index, pa_strnull(pa_proplist_gets(i->client->proplist, PA_PROP_APPLICATION_NAME)));
477
478 t = pa_proplist_to_string_sep(i->proplist, "\n\t\t");
479 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
480 pa_xfree(t);
481 }
482
483 return pa_strbuf_tostring_free(s);
484 }
485
486 char *pa_scache_list_to_string(pa_core *c) {
487 pa_strbuf *s;
488 pa_assert(c);
489
490 s = pa_strbuf_new();
491
492 pa_strbuf_printf(s, "%u cache entrie(s) available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
493
494 if (c->scache) {
495 pa_scache_entry *e;
496 uint32_t idx = PA_IDXSET_INVALID;
497
498 for (e = pa_idxset_first(c->scache, &idx); e; e = pa_idxset_next(c->scache, &idx)) {
499 double l = 0;
500 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;
501
502 if (e->memchunk.memblock) {
503 pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
504 pa_channel_map_snprint(cm, sizeof(cm), &e->channel_map);
505 l = (double) e->memchunk.length / (double) pa_bytes_per_second(&e->sample_spec);
506 }
507
508 pa_strbuf_printf(
509 s,
510 " name: <%s>\n"
511 "\tindex: %u\n"
512 "\tsample spec: %s\n"
513 "\tchannel map: %s\n"
514 "\tlength: %lu\n"
515 "\tduration: %0.1f s\n"
516 "\tvolume: %s\n"
517 "\t %s\n"
518 "\t balance %0.2f\n"
519 "\tlazy: %s\n"
520 "\tfilename: <%s>\n",
521 e->name,
522 e->index,
523 ss,
524 cm,
525 (long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
526 l,
527 pa_cvolume_snprint(cv, sizeof(cv), &e->volume),
528 pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume),
529 e->memchunk.memblock ? pa_cvolume_get_balance(&e->channel_map, &e->volume) : 0.0f,
530 pa_yes_no(e->lazy),
531 e->filename ? e->filename : "n/a");
532
533 t = pa_proplist_to_string_sep(e->proplist, "\n\t\t");
534 pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
535 pa_xfree(t);
536 }
537 }
538
539 return pa_strbuf_tostring_free(s);
540 }
541
542 char *pa_full_status_string(pa_core *c) {
543 pa_strbuf *s;
544 int i;
545
546 s = pa_strbuf_new();
547
548 for (i = 0; i < 8; i++) {
549 char *t = NULL;
550
551 switch (i) {
552 case 0:
553 t = pa_sink_list_to_string(c);
554 break;
555 case 1:
556 t = pa_source_list_to_string(c);
557 break;
558 case 2:
559 t = pa_sink_input_list_to_string(c);
560 break;
561 case 3:
562 t = pa_source_output_list_to_string(c);
563 break;
564 case 4:
565 t = pa_client_list_to_string(c);
566 break;
567 case 5:
568 t = pa_card_list_to_string(c);
569 break;
570 case 6:
571 t = pa_module_list_to_string(c);
572 break;
573 case 7:
574 t = pa_scache_list_to_string(c);
575 break;
576 }
577
578 pa_strbuf_puts(s, t);
579 pa_xfree(t);
580 }
581
582 return pa_strbuf_tostring_free(s);
583 }