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 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 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
;
67 pa_strbuf_printf(s
, "%u client(s).\n", pa_idxset_ncontents(c
->clients
));
69 for (client
= pa_idxset_first(c
->clients
, &index
); client
; client
= pa_idxset_next(c
->clients
, &index
)) {
70 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\tprotocol_name: <%s>\n", client
->index
, client
->name
, client
->protocol_name
);
73 pa_strbuf_printf(s
, "\towner module: <%u>\n", client
->owner
->index
);
76 return pa_strbuf_tostring_free(s
);
79 char *pa_sink_list_to_string(struct pa_core
*c
) {
82 uint32_t index
= PA_IDXSET_INVALID
;
88 pa_strbuf_printf(s
, "%u sink(s) available.\n", pa_idxset_ncontents(c
->sinks
));
90 for (sink
= pa_idxset_first(c
->sinks
, &index
); sink
; sink
= pa_idxset_next(c
->sinks
, &index
)) {
91 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
92 pa_sample_spec_snprint(ss
, sizeof(ss
), &sink
->sample_spec
);
93 assert(sink
->monitor_source
);
96 " %c index: %u\n\tname: <%s>\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%f usec>\n\tmonitor_source: <%u>\n\tsample_spec: <%s>\n",
97 c
->default_sink_name
&& !strcmp(sink
->name
, c
->default_sink_name
) ? '*' : ' ',
98 sink
->index
, sink
->name
,
99 (unsigned) sink
->volume
,
100 pa_volume_to_dB(sink
->volume
),
101 (float) pa_sink_get_latency(sink
),
102 sink
->monitor_source
->index
,
106 pa_strbuf_printf(s
, "\towner module: <%u>\n", sink
->owner
->index
);
107 if (sink
->description
)
108 pa_strbuf_printf(s
, "\tdescription: <%s>\n", sink
->description
);
111 return pa_strbuf_tostring_free(s
);
114 char *pa_source_list_to_string(struct pa_core
*c
) {
116 struct pa_source
*source
;
117 uint32_t index
= PA_IDXSET_INVALID
;
123 pa_strbuf_printf(s
, "%u source(s) available.\n", pa_idxset_ncontents(c
->sources
));
125 for (source
= pa_idxset_first(c
->sources
, &index
); source
; source
= pa_idxset_next(c
->sources
, &index
)) {
126 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
127 pa_sample_spec_snprint(ss
, sizeof(ss
), &source
->sample_spec
);
128 pa_strbuf_printf(s
, " %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>\n",
129 c
->default_source_name
&& !strcmp(source
->name
, c
->default_source_name
) ? '*' : ' ',
134 if (source
->monitor_of
)
135 pa_strbuf_printf(s
, "\tmonitor_of: <%u>\n", source
->monitor_of
->index
);
137 pa_strbuf_printf(s
, "\towner module: <%u>\n", source
->owner
->index
);
138 if (source
->description
)
139 pa_strbuf_printf(s
, "\tdescription: <%s>\n", source
->description
);
142 return pa_strbuf_tostring_free(s
);
146 char *pa_source_output_list_to_string(struct pa_core
*c
) {
148 struct pa_source_output
*o
;
149 uint32_t index
= PA_IDXSET_INVALID
;
155 pa_strbuf_printf(s
, "%u source outputs(s) available.\n", pa_idxset_ncontents(c
->source_outputs
));
157 for (o
= pa_idxset_first(c
->source_outputs
, &index
); o
; o
= pa_idxset_next(c
->source_outputs
, &index
)) {
158 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
159 pa_sample_spec_snprint(ss
, sizeof(ss
), &o
->sample_spec
);
162 s
, " index: %u\n\tname: <%s>\n\tsource: <%u>\n\tsample_spec: <%s>\n",
168 pa_strbuf_printf(s
, "\towner module: <%u>\n", o
->owner
->index
);
170 pa_strbuf_printf(s
, "\tclient: <%u>\n", o
->client
->index
);
173 return pa_strbuf_tostring_free(s
);
176 char *pa_sink_input_list_to_string(struct pa_core
*c
) {
178 struct pa_sink_input
*i
;
179 uint32_t index
= PA_IDXSET_INVALID
;
185 pa_strbuf_printf(s
, "%u sink input(s) available.\n", pa_idxset_ncontents(c
->sink_inputs
));
187 for (i
= pa_idxset_first(c
->sink_inputs
, &index
); i
; i
= pa_idxset_next(c
->sink_inputs
, &index
)) {
188 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
189 pa_sample_spec_snprint(ss
, sizeof(ss
), &i
->sample_spec
);
192 s
, " index: %u\n\tname: <%s>\n\tsink: <%u>\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%f usec>\n\tsample_spec: <%s>\n",
196 (unsigned) i
->volume
,
197 pa_volume_to_dB(i
->volume
),
198 (float) pa_sink_input_get_latency(i
),
202 pa_strbuf_printf(s
, "\towner module: <%u>\n", i
->owner
->index
);
204 pa_strbuf_printf(s
, "\tclient: <%u>\n", i
->client
->index
);
207 return pa_strbuf_tostring_free(s
);
210 char *pa_scache_list_to_string(struct pa_core
*c
) {
217 pa_strbuf_printf(s
, "%u cache entries available.\n", c
->scache
? pa_idxset_ncontents(c
->scache
) : 0);
220 struct pa_scache_entry
*e
;
221 uint32_t index
= PA_IDXSET_INVALID
;
223 for (e
= pa_idxset_first(c
->scache
, &index
); e
; e
= pa_idxset_next(c
->scache
, &index
)) {
225 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
226 pa_sample_spec_snprint(ss
, sizeof(ss
), &e
->sample_spec
);
228 l
= (double) e
->memchunk
.length
/ pa_bytes_per_second(&e
->sample_spec
);
231 s
, " name: <%s>\n\tindex: <%i>\n\tsample_spec: <%s>\n\tlength: <%u>\n\tduration: <%0.1fs>\n\tvolume: <0x%04x>\n",
241 return pa_strbuf_tostring_free(s
);
244 char *pa_autoload_list_to_string(struct pa_core
*c
) {
251 pa_strbuf_printf(s
, "%u autoload entries available.\n", c
->autoload_hashmap
? pa_hashmap_ncontents(c
->autoload_hashmap
) : 0);
253 if (c
->autoload_hashmap
) {
254 struct pa_autoload_entry
*e
;
257 while ((e
= pa_hashmap_iterate(c
->autoload_hashmap
, &state
))) {
259 s
, " name: <%s>\n\ttype: <%s>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
261 e
->type
== PA_NAMEREG_SOURCE
? "source" : "sink",
267 return pa_strbuf_tostring_free(s
);