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"
41 char *pa_module_list_to_string(struct pa_core
*c
) {
44 uint32_t index
= PA_IDXSET_INVALID
;
50 pa_strbuf_printf(s
, "%u module(s) loaded.\n", pa_idxset_ncontents(c
->modules
));
52 for (m
= pa_idxset_first(c
->modules
, &index
); m
; m
= pa_idxset_next(c
->modules
, &index
))
53 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");
55 return pa_strbuf_tostring_free(s
);
58 char *pa_client_list_to_string(struct pa_core
*c
) {
60 struct pa_client
*client
;
61 uint32_t index
= PA_IDXSET_INVALID
;
68 pa_strbuf_printf(s
, "%u client(s) logged in.\n", pa_idxset_ncontents(c
->clients
));
70 for (client
= pa_idxset_first(c
->clients
, &index
); client
; client
= pa_idxset_next(c
->clients
, &index
)) {
71 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
)));
74 pa_strbuf_printf(s
, "\towner module: <%u>\n", client
->owner
->index
);
77 return pa_strbuf_tostring_free(s
);
80 char *pa_sink_list_to_string(struct pa_core
*c
) {
83 uint32_t index
= PA_IDXSET_INVALID
;
90 pa_strbuf_printf(s
, "%u sink(s) available.\n", pa_idxset_ncontents(c
->sinks
));
92 for (sink
= pa_idxset_first(c
->sinks
, &index
); sink
; sink
= pa_idxset_next(c
->sinks
, &index
)) {
93 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
94 pa_sample_spec_snprint(ss
, sizeof(ss
), &sink
->sample_spec
);
95 assert(sink
->monitor_source
);
98 " %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",
99 c
->default_sink_name
&& !strcmp(sink
->name
, c
->default_sink_name
) ? '*' : ' ',
100 sink
->index
, sink
->name
,
101 pa_typeid_to_string(sink
->typeid, tid
, sizeof(tid
)),
102 (unsigned) sink
->volume
,
103 pa_volume_to_dB(sink
->volume
),
104 (float) pa_sink_get_latency(sink
),
105 sink
->monitor_source
->index
,
109 pa_strbuf_printf(s
, "\towner module: <%u>\n", sink
->owner
->index
);
110 if (sink
->description
)
111 pa_strbuf_printf(s
, "\tdescription: <%s>\n", sink
->description
);
114 return pa_strbuf_tostring_free(s
);
117 char *pa_source_list_to_string(struct pa_core
*c
) {
119 struct pa_source
*source
;
120 uint32_t index
= PA_IDXSET_INVALID
;
127 pa_strbuf_printf(s
, "%u source(s) available.\n", pa_idxset_ncontents(c
->sources
));
129 for (source
= pa_idxset_first(c
->sources
, &index
); source
; source
= pa_idxset_next(c
->sources
, &index
)) {
130 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
131 pa_sample_spec_snprint(ss
, sizeof(ss
), &source
->sample_spec
);
132 pa_strbuf_printf(s
, " %c index: %u\n\tname: <%s>\n\ttype: <%s>\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
133 c
->default_source_name
&& !strcmp(source
->name
, c
->default_source_name
) ? '*' : ' ',
136 pa_typeid_to_string(source
->typeid, tid
, sizeof(tid
)),
137 (float) pa_source_get_latency(source
),
140 if (source
->monitor_of
)
141 pa_strbuf_printf(s
, "\tmonitor_of: <%u>\n", source
->monitor_of
->index
);
143 pa_strbuf_printf(s
, "\towner module: <%u>\n", source
->owner
->index
);
144 if (source
->description
)
145 pa_strbuf_printf(s
, "\tdescription: <%s>\n", source
->description
);
148 return pa_strbuf_tostring_free(s
);
152 char *pa_source_output_list_to_string(struct pa_core
*c
) {
154 struct pa_source_output
*o
;
155 uint32_t index
= PA_IDXSET_INVALID
;
157 static const char* const state_table
[] = {
167 pa_strbuf_printf(s
, "%u source outputs(s) available.\n", pa_idxset_ncontents(c
->source_outputs
));
169 for (o
= pa_idxset_first(c
->source_outputs
, &index
); o
; o
= pa_idxset_next(c
->source_outputs
, &index
)) {
170 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
172 pa_sample_spec_snprint(ss
, sizeof(ss
), &o
->sample_spec
);
175 if (!(rm
= pa_resample_method_to_string(pa_source_output_get_resample_method(o
))))
179 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",
182 pa_typeid_to_string(o
->typeid, tid
, sizeof(tid
)),
183 state_table
[o
->state
],
184 o
->source
->index
, o
->source
->name
,
188 pa_strbuf_printf(s
, "\towner module: <%u>\n", o
->owner
->index
);
190 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", o
->client
->index
, o
->client
->name
);
193 return pa_strbuf_tostring_free(s
);
196 char *pa_sink_input_list_to_string(struct pa_core
*c
) {
198 struct pa_sink_input
*i
;
199 uint32_t index
= PA_IDXSET_INVALID
;
201 static const char* const state_table
[] = {
211 pa_strbuf_printf(s
, "%u sink input(s) available.\n", pa_idxset_ncontents(c
->sink_inputs
));
213 for (i
= pa_idxset_first(c
->sink_inputs
, &index
); i
; i
= pa_idxset_next(c
->sink_inputs
, &index
)) {
214 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
];
217 if (!(rm
= pa_resample_method_to_string(pa_sink_input_get_resample_method(i
))))
220 pa_sample_spec_snprint(ss
, sizeof(ss
), &i
->sample_spec
);
223 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",
226 pa_typeid_to_string(i
->typeid, tid
, sizeof(tid
)),
227 state_table
[i
->state
],
228 i
->sink
->index
, i
->sink
->name
,
229 (unsigned) i
->volume
,
230 pa_volume_to_dB(i
->volume
),
231 (float) pa_sink_input_get_latency(i
),
236 pa_strbuf_printf(s
, "\towner module: <%u>\n", i
->owner
->index
);
238 pa_strbuf_printf(s
, "\tclient: <%u> '%s'\n", i
->client
->index
, i
->client
->name
);
241 return pa_strbuf_tostring_free(s
);
244 char *pa_scache_list_to_string(struct pa_core
*c
) {
251 pa_strbuf_printf(s
, "%u cache entries available.\n", c
->scache
? pa_idxset_ncontents(c
->scache
) : 0);
254 struct pa_scache_entry
*e
;
255 uint32_t index
= PA_IDXSET_INVALID
;
257 for (e
= pa_idxset_first(c
->scache
, &index
); e
; e
= pa_idxset_next(c
->scache
, &index
)) {
259 char ss
[PA_SAMPLE_SPEC_SNPRINT_MAX
] = "n/a";
261 if (e
->memchunk
.memblock
) {
262 pa_sample_spec_snprint(ss
, sizeof(ss
), &e
->sample_spec
);
263 l
= (double) e
->memchunk
.length
/ pa_bytes_per_second(&e
->sample_spec
);
267 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",
271 e
->memchunk
.memblock
? e
->memchunk
.length
: 0,
274 e
->lazy
? "yes" : "no",
275 e
->filename
? e
->filename
: "n/a");
279 return pa_strbuf_tostring_free(s
);
282 char *pa_autoload_list_to_string(struct pa_core
*c
) {
289 pa_strbuf_printf(s
, "%u autoload entries available.\n", c
->autoload_hashmap
? pa_hashmap_ncontents(c
->autoload_hashmap
) : 0);
291 if (c
->autoload_hashmap
) {
292 struct pa_autoload_entry
*e
;
295 while ((e
= pa_hashmap_iterate(c
->autoload_hashmap
, &state
, NULL
))) {
297 s
, " name: <%s>\n\ttype: <%s>\n\tindex: <%u>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
299 e
->type
== PA_NAMEREG_SOURCE
? "source" : "sink",
307 return pa_strbuf_tostring_free(s
);