4 This file is part of polypaudio.
6 polypaudio 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.
11 polypaudio 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.
16 You should have received a copy of the GNU Lesser General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
34 #include "sink-input.h"
35 #include "source-output.h"
37 #include "sample-util.h"
43 char *pa_module_list_to_string(pa_core
*c
) {
46 uint32_t idx
= PA_IDXSET_INVALID
;
52 pa_strbuf_printf(s
, "%u module(s) loaded.\n", pa_idxset_size(c
->modules
));
54 for (m
= pa_idxset_first(c
->modules
, &idx
); m
; m
= pa_idxset_next(c
->modules
, &idx
))
55 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\targument: <%s>\n\tused: %i\n\tauto unload: %s\n", m
->index
, m
->name
, m
->argument
, m
->n_used
, m
->auto_unload
? "yes" : "no");
57 return pa_strbuf_tostring_free(s
);
60 char *pa_client_list_to_string(pa_core
*c
) {
63 uint32_t idx
= PA_IDXSET_INVALID
;
69 pa_strbuf_printf(s
, "%u client(s) logged in.\n", pa_idxset_size(c
->clients
));
71 for (client
= pa_idxset_first(c
->clients
, &idx
); client
; client
= pa_idxset_next(c
->clients
, &idx
)) {
72 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\tdriver: <%s>\n", client
->index
, client
->name
, client
->driver
);
75 pa_strbuf_printf(s
, "\towner module: <%u>\n", client
->owner
->index
);
78 return pa_strbuf_tostring_free(s
);
81 char *pa_sink_list_to_string(pa_core
*c
) {
84 uint32_t idx
= PA_IDXSET_INVALID
;
90 pa_strbuf_printf(s
, "%u sink(s) available.\n", pa_idxset_size(c
->sinks
));
92 for (sink
= pa_idxset_first(c
->sinks
, &idx
); sink
; sink
= pa_idxset_next(c
->sinks
, &idx
)) {
93 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
101 "\tlatency: <%0.0f usec>\n"
102 "\tmonitor_source: <%u>\n"
103 "\tsample spec: <%s>\n"
104 "\tchannel map: <%s>\n",
105 c
->default_sink_name
&& !strcmp(sink
->name
, c
->default_sink_name
) ? '*' : ' ',
106 sink
->index
, sink
->name
,
108 pa_cvolume_snprint(cv
, sizeof(cv
), pa_sink_get_volume(sink
, PA_MIXER_HARDWARE
)),
109 (double) pa_sink_get_latency(sink
),
110 sink
->monitor_source
->index
,
111 pa_sample_spec_snprint(ss
, sizeof(ss
), &sink
->sample_spec
),
112 pa_channel_map_snprint(cm
, sizeof(cm
), &sink
->channel_map
));
115 pa_strbuf_printf(s
, "\towner module: <%u>\n", sink
->owner
->index
);
116 if (sink
->description
)
117 pa_strbuf_printf(s
, "\tdescription: <%s>\n", sink
->description
);
120 return pa_strbuf_tostring_free(s
);
123 char *pa_source_list_to_string(pa_core
*c
) {
126 uint32_t idx
= PA_IDXSET_INVALID
;
132 pa_strbuf_printf(s
, "%u source(s) available.\n", pa_idxset_size(c
->sources
));
134 for (source
= pa_idxset_first(c
->sources
, &idx
); source
; source
= pa_idxset_next(c
->sources
, &idx
)) {
135 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
143 "\tlatency: <%0.0f usec>\n"
144 "\tsample spec: <%s>\n"
145 "\tchannel map: <%s>\n",
146 c
->default_source_name
&& !strcmp(source
->name
, c
->default_source_name
) ? '*' : ' ',
150 (double) pa_source_get_latency(source
),
151 pa_sample_spec_snprint(ss
, sizeof(ss
), &source
->sample_spec
),
152 pa_channel_map_snprint(cm
, sizeof(cm
), &source
->channel_map
));
154 if (source
->monitor_of
)
155 pa_strbuf_printf(s
, "\tmonitor_of: <%u>\n", source
->monitor_of
->index
);
157 pa_strbuf_printf(s
, "\towner module: <%u>\n", source
->owner
->index
);
158 if (source
->description
)
159 pa_strbuf_printf(s
, "\tdescription: <%s>\n", source
->description
);
162 return pa_strbuf_tostring_free(s
);
166 char *pa_source_output_list_to_string(pa_core
*c
) {
169 uint32_t idx
= PA_IDXSET_INVALID
;
170 static const char* const state_table
[] = {
180 pa_strbuf_printf(s
, "%u source outputs(s) available.\n", pa_idxset_size(c
->source_outputs
));
182 for (o
= pa_idxset_first(c
->source_outputs
, &idx
); o
; o
= pa_idxset_next(c
->source_outputs
, &idx
)) {
183 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
193 "\tsource: <%u> '%s'\n"
194 "\tsample spec: <%s>\n"
195 "\tchannel map: <%s>\n"
196 "\tresample method: %s\n",
200 state_table
[o
->state
],
201 o
->source
->index
, o
->source
->name
,
202 pa_sample_spec_snprint(ss
, sizeof(ss
), &o
->sample_spec
),
203 pa_channel_map_snprint(cm
, sizeof(cm
), &o
->channel_map
),
204 pa_resample_method_to_string(pa_source_output_get_resample_method(o
)));
206 pa_strbuf_printf(s
, "\towner module: <%u>\n", o
->owner
->index
);
208 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", o
->client
->index
, o
->client
->name
);
211 return pa_strbuf_tostring_free(s
);
214 char *pa_sink_input_list_to_string(pa_core
*c
) {
217 uint32_t idx
= PA_IDXSET_INVALID
;
218 static const char* const state_table
[] = {
228 pa_strbuf_printf(s
, "%u sink input(s) available.\n", pa_idxset_size(c
->sink_inputs
));
230 for (i
= pa_idxset_first(c
->sink_inputs
, &idx
); i
; i
= pa_idxset_next(c
->sink_inputs
, &idx
)) {
231 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
], cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
241 "\tsink: <%u> '%s'\n"
243 "\tlatency: <%0.0f usec>\n"
244 "\tsample spec: <%s>\n"
245 "\tchannel map: <%s>\n"
246 "\tresample method: %s\n",
250 state_table
[i
->state
],
251 i
->sink
->index
, i
->sink
->name
,
252 pa_cvolume_snprint(cv
, sizeof(cv
), pa_sink_input_get_volume(i
)),
253 (double) pa_sink_input_get_latency(i
),
254 pa_sample_spec_snprint(ss
, sizeof(ss
), &i
->sample_spec
),
255 pa_channel_map_snprint(cm
, sizeof(cm
), &i
->channel_map
),
256 pa_resample_method_to_string(pa_sink_input_get_resample_method(i
)));
259 pa_strbuf_printf(s
, "\towner module: <%u>\n", i
->owner
->index
);
261 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", i
->client
->index
, i
->client
->name
);
264 return pa_strbuf_tostring_free(s
);
267 char *pa_scache_list_to_string(pa_core
*c
) {
274 pa_strbuf_printf(s
, "%u cache entries available.\n", c
->scache
? pa_idxset_size(c
->scache
) : 0);
278 uint32_t idx
= PA_IDXSET_INVALID
;
280 for (e
= pa_idxset_first(c
->scache
, &idx
); e
; e
= pa_idxset_next(c
->scache
, &idx
)) {
282 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
] = "n/a", cv
[PA_CVOLUME_SNPRINT_MAX
], cm
[PA_CHANNEL_MAP_SNPRINT_MAX
];
284 if (e
->memchunk
.memblock
) {
285 pa_sample_spec_snprint(ss
, sizeof(ss
), &e
->sample_spec
);
286 pa_channel_map_snprint(cm
, sizeof(cm
), &e
->channel_map
);
287 l
= (double) e
->memchunk
.length
/ pa_bytes_per_second(&e
->sample_spec
);
294 "\tsample spec: <%s>\n"
295 "\tchannel map: <%s>\n"
297 "\tduration: <%0.1fs>\n"
305 e
->memchunk
.memblock
? e
->memchunk
.length
: 0,
307 pa_cvolume_snprint(cv
, sizeof(cv
), &e
->volume
),
308 e
->lazy
? "yes" : "no",
309 e
->filename
? e
->filename
: "n/a");
313 return pa_strbuf_tostring_free(s
);
316 char *pa_autoload_list_to_string(pa_core
*c
) {
323 pa_strbuf_printf(s
, "%u autoload entries available.\n", c
->autoload_hashmap
? pa_hashmap_size(c
->autoload_hashmap
) : 0);
325 if (c
->autoload_hashmap
) {
326 pa_autoload_entry
*e
;
329 while ((e
= pa_hashmap_iterate(c
->autoload_hashmap
, &state
, NULL
))) {
331 s
, " name: <%s>\n\ttype: <%s>\n\tindex: <%u>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
333 e
->type
== PA_NAMEREG_SOURCE
? "source" : "sink",
341 return pa_strbuf_tostring_free(s
);
344 char *pa_full_status_string(pa_core
*c
) {
350 for (i
= 0; i
< 8; i
++) {
355 t
= pa_sink_list_to_string(c
);
358 t
= pa_source_list_to_string(c
);
361 t
= pa_sink_input_list_to_string(c
);
364 t
= pa_source_output_list_to_string(c
);
367 t
= pa_client_list_to_string(c
);
370 t
= pa_module_list_to_string(c
);
373 t
= pa_scache_list_to_string(c
);
376 t
= pa_autoload_list_to_string(c
);
380 pa_strbuf_puts(s
, t
);
384 return pa_strbuf_tostring_free(s
);