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"
42 char *pa_module_list_to_string(struct pa_core
*c
) {
45 uint32_t index
= PA_IDXSET_INVALID
;
51 pa_strbuf_printf(s
, "%u module(s) loaded.\n", pa_idxset_ncontents(c
->modules
));
53 for (m
= pa_idxset_first(c
->modules
, &index
); m
; m
= pa_idxset_next(c
->modules
, &index
))
54 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");
56 return pa_strbuf_tostring_free(s
);
59 char *pa_client_list_to_string(struct pa_core
*c
) {
61 struct pa_client
*client
;
62 uint32_t index
= PA_IDXSET_INVALID
;
69 pa_strbuf_printf(s
, "%u client(s) logged in.\n", pa_idxset_ncontents(c
->clients
));
71 for (client
= pa_idxset_first(c
->clients
, &index
); client
; client
= pa_idxset_next(c
->clients
, &index
)) {
72 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\ttype: <%s>\n", client
->index
, client
->name
, pa_typeid_to_string(client
->typeid, tid
, sizeof(tid
)));
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(struct pa_core
*c
) {
84 uint32_t index
= PA_IDXSET_INVALID
;
91 pa_strbuf_printf(s
, "%u sink(s) available.\n", pa_idxset_ncontents(c
->sinks
));
93 for (sink
= pa_idxset_first(c
->sinks
, &index
); sink
; sink
= pa_idxset_next(c
->sinks
, &index
)) {
94 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
95 pa_sample_spec_snprint(ss
, sizeof(ss
), &sink
->sample_spec
);
96 assert(sink
->monitor_source
);
99 " %c index: %u\n\tname: <%s>\n\ttype: <%s>\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%0.0f usec>\n\tmonitor_source: <%u>\n\tsample_spec: <%s>\n",
100 c
->default_sink_name
&& !strcmp(sink
->name
, c
->default_sink_name
) ? '*' : ' ',
101 sink
->index
, sink
->name
,
102 pa_typeid_to_string(sink
->typeid, tid
, sizeof(tid
)),
103 (unsigned) sink
->volume
,
104 pa_volume_to_dB(sink
->volume
),
105 (float) pa_sink_get_latency(sink
),
106 sink
->monitor_source
->index
,
110 pa_strbuf_printf(s
, "\towner module: <%u>\n", sink
->owner
->index
);
111 if (sink
->description
)
112 pa_strbuf_printf(s
, "\tdescription: <%s>\n", sink
->description
);
115 return pa_strbuf_tostring_free(s
);
118 char *pa_source_list_to_string(struct pa_core
*c
) {
120 struct pa_source
*source
;
121 uint32_t index
= PA_IDXSET_INVALID
;
128 pa_strbuf_printf(s
, "%u source(s) available.\n", pa_idxset_ncontents(c
->sources
));
130 for (source
= pa_idxset_first(c
->sources
, &index
); source
; source
= pa_idxset_next(c
->sources
, &index
)) {
131 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
132 pa_sample_spec_snprint(ss
, sizeof(ss
), &source
->sample_spec
);
133 pa_strbuf_printf(s
, " %c index: %u\n\tname: <%s>\n\ttype: <%s>\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
134 c
->default_source_name
&& !strcmp(source
->name
, c
->default_source_name
) ? '*' : ' ',
137 pa_typeid_to_string(source
->typeid, tid
, sizeof(tid
)),
138 (float) pa_source_get_latency(source
),
141 if (source
->monitor_of
)
142 pa_strbuf_printf(s
, "\tmonitor_of: <%u>\n", source
->monitor_of
->index
);
144 pa_strbuf_printf(s
, "\towner module: <%u>\n", source
->owner
->index
);
145 if (source
->description
)
146 pa_strbuf_printf(s
, "\tdescription: <%s>\n", source
->description
);
149 return pa_strbuf_tostring_free(s
);
153 char *pa_source_output_list_to_string(struct pa_core
*c
) {
155 struct pa_source_output
*o
;
156 uint32_t index
= PA_IDXSET_INVALID
;
158 static const char* const state_table
[] = {
168 pa_strbuf_printf(s
, "%u source outputs(s) available.\n", pa_idxset_ncontents(c
->source_outputs
));
170 for (o
= pa_idxset_first(c
->source_outputs
, &index
); o
; o
= pa_idxset_next(c
->source_outputs
, &index
)) {
171 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
173 pa_sample_spec_snprint(ss
, sizeof(ss
), &o
->sample_spec
);
176 if (!(rm
= pa_resample_method_to_string(pa_source_output_get_resample_method(o
))))
180 s
, " index: %u\n\tname: '%s'\n\ttype: <%s>\n\tstate: %s\n\tsource: <%u> '%s'\n\tsample_spec: <%s>\n\tresample method: %s\n",
183 pa_typeid_to_string(o
->typeid, tid
, sizeof(tid
)),
184 state_table
[o
->state
],
185 o
->source
->index
, o
->source
->name
,
189 pa_strbuf_printf(s
, "\towner module: <%u>\n", o
->owner
->index
);
191 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", o
->client
->index
, o
->client
->name
);
194 return pa_strbuf_tostring_free(s
);
197 char *pa_sink_input_list_to_string(struct pa_core
*c
) {
199 struct pa_sink_input
*i
;
200 uint32_t index
= PA_IDXSET_INVALID
;
202 static const char* const state_table
[] = {
212 pa_strbuf_printf(s
, "%u sink input(s) available.\n", pa_idxset_ncontents(c
->sink_inputs
));
214 for (i
= pa_idxset_first(c
->sink_inputs
, &index
); i
; i
= pa_idxset_next(c
->sink_inputs
, &index
)) {
215 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
218 if (!(rm
= pa_resample_method_to_string(pa_sink_input_get_resample_method(i
))))
221 pa_sample_spec_snprint(ss
, sizeof(ss
), &i
->sample_spec
);
224 s
, " index: %u\n\tname: <%s>\n\ttype: <%s>\n\tstate: %s\n\tsink: <%u> '%s'\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n\tresample method: %s\n",
227 pa_typeid_to_string(i
->typeid, tid
, sizeof(tid
)),
228 state_table
[i
->state
],
229 i
->sink
->index
, i
->sink
->name
,
230 (unsigned) i
->volume
,
231 pa_volume_to_dB(i
->volume
),
232 (float) pa_sink_input_get_latency(i
),
237 pa_strbuf_printf(s
, "\towner module: <%u>\n", i
->owner
->index
);
239 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", i
->client
->index
, i
->client
->name
);
242 return pa_strbuf_tostring_free(s
);
245 char *pa_scache_list_to_string(struct pa_core
*c
) {
252 pa_strbuf_printf(s
, "%u cache entries available.\n", c
->scache
? pa_idxset_ncontents(c
->scache
) : 0);
255 struct pa_scache_entry
*e
;
256 uint32_t index
= PA_IDXSET_INVALID
;
258 for (e
= pa_idxset_first(c
->scache
, &index
); e
; e
= pa_idxset_next(c
->scache
, &index
)) {
260 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
] = "n/a";
262 if (e
->memchunk
.memblock
) {
263 pa_sample_spec_snprint(ss
, sizeof(ss
), &e
->sample_spec
);
264 l
= (double) e
->memchunk
.length
/ pa_bytes_per_second(&e
->sample_spec
);
268 s
, " name: <%s>\n\tindex: <%u>\n\tsample_spec: <%s>\n\tlength: <%u>\n\tduration: <%0.1fs>\n\tvolume: <0x%04x>\n\tlazy: %s\n\tfilename: %s\n",
272 e
->memchunk
.memblock
? e
->memchunk
.length
: 0,
275 e
->lazy
? "yes" : "no",
276 e
->filename
? e
->filename
: "n/a");
280 return pa_strbuf_tostring_free(s
);
283 char *pa_autoload_list_to_string(struct pa_core
*c
) {
290 pa_strbuf_printf(s
, "%u autoload entries available.\n", c
->autoload_hashmap
? pa_hashmap_ncontents(c
->autoload_hashmap
) : 0);
292 if (c
->autoload_hashmap
) {
293 struct pa_autoload_entry
*e
;
296 while ((e
= pa_hashmap_iterate(c
->autoload_hashmap
, &state
, NULL
))) {
298 s
, " name: <%s>\n\ttype: <%s>\n\tindex: <%u>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
300 e
->type
== PA_NAMEREG_SOURCE
? "source" : "sink",
308 return pa_strbuf_tostring_free(s
);
311 char *pa_full_status_string(struct pa_core
*c
) {
317 for (i
= 0; i
< 8; i
++) {
322 t
= pa_sink_list_to_string(c
);
325 t
= pa_source_list_to_string(c
);
328 t
= pa_sink_input_list_to_string(c
);
331 t
= pa_source_output_list_to_string(c
);
334 t
= pa_client_list_to_string(c
);
337 t
= pa_module_list_to_string(c
);
340 t
= pa_scache_list_to_string(c
);
343 t
= pa_autoload_list_to_string(c
);
347 pa_strbuf_puts(s
, t
);
351 return pa_strbuf_tostring_free(s
);