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