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