9 #include "sourceoutput.h"
11 #include "sample-util.h"
13 char *pa_module_list_to_string(struct pa_core
*c
) {
16 uint32_t index
= PA_IDXSET_INVALID
;
22 pa_strbuf_printf(s
, "%u module(s) loaded.\n", pa_idxset_ncontents(c
->modules
));
24 for (m
= pa_idxset_first(c
->modules
, &index
); m
; m
= pa_idxset_next(c
->modules
, &index
))
25 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\targument: <%s>\n", m
->index
, m
->name
, m
->argument
);
27 return pa_strbuf_tostring_free(s
);
30 char *pa_client_list_to_string(struct pa_core
*c
) {
32 struct pa_client
*client
;
33 uint32_t index
= PA_IDXSET_INVALID
;
39 pa_strbuf_printf(s
, "%u client(s).\n", pa_idxset_ncontents(c
->clients
));
41 for (client
= pa_idxset_first(c
->clients
, &index
); client
; client
= pa_idxset_next(c
->clients
, &index
)) {
42 pa_strbuf_printf(s
, " index: %u\n\tname: <%s>\n\tprotocol_name: <%s>\n", client
->index
, client
->name
, client
->protocol_name
);
45 pa_strbuf_printf(s
, "\towner module: <%u>\n", client
->owner
->index
);
48 return pa_strbuf_tostring_free(s
);
51 char *pa_sink_list_to_string(struct pa_core
*c
) {
53 struct pa_sink
*sink
, *default_sink
;
54 uint32_t index
= PA_IDXSET_INVALID
;
60 pa_strbuf_printf(s
, "%u sink(s) available.\n", pa_idxset_ncontents(c
->sinks
));
62 default_sink
= pa_sink_get_default(c
);
64 for (sink
= pa_idxset_first(c
->sinks
, &index
); sink
; sink
= pa_idxset_next(c
->sinks
, &index
)) {
65 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
66 pa_sample_snprint(ss
, sizeof(ss
), &sink
->sample_spec
);
67 assert(sink
->monitor_source
);
70 " %c index: %u\n\tname: <%s>\n\tvolume: <0x%04x>\n\tlatency: <%u usec>\n\tmonitor_source: <%u>\n\tsample_spec: <%s>\n",
71 sink
== default_sink
? '*' : ' ',
72 sink
->index
, sink
->name
,
73 (unsigned) sink
->volume
,
74 pa_sink_get_latency(sink
),
75 sink
->monitor_source
->index
,
79 pa_strbuf_printf(s
, "\towner module: <%u>\n", sink
->owner
->index
);
80 if (sink
->description
)
81 pa_strbuf_printf(s
, "\tdescription: <%s>\n", sink
->description
);
84 return pa_strbuf_tostring_free(s
);
87 char *pa_source_list_to_string(struct pa_core
*c
) {
89 struct pa_source
*source
, *default_source
;
90 uint32_t index
= PA_IDXSET_INVALID
;
96 pa_strbuf_printf(s
, "%u source(s) available.\n", pa_idxset_ncontents(c
->sources
));
98 default_source
= pa_source_get_default(c
);
100 for (source
= pa_idxset_first(c
->sources
, &index
); source
; source
= pa_idxset_next(c
->sources
, &index
)) {
101 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
102 pa_sample_snprint(ss
, sizeof(ss
), &source
->sample_spec
);
103 pa_strbuf_printf(s
, " %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>\n", source
== default_source
? '*' : ' ', source
->index
, source
->name
, ss
);
105 if (source
->monitor_of
)
106 pa_strbuf_printf(s
, "\tmonitor_of: <%u>\n", source
->monitor_of
->index
);
108 pa_strbuf_printf(s
, "\towner module: <%u>\n", source
->owner
->index
);
109 if (source
->description
)
110 pa_strbuf_printf(s
, "\tdescription: <%s>\n", source
->description
);
113 return pa_strbuf_tostring_free(s
);
117 char *pa_source_output_list_to_string(struct pa_core
*c
) {
119 struct pa_source_output
*o
;
120 uint32_t index
= PA_IDXSET_INVALID
;
126 pa_strbuf_printf(s
, "%u source outputs(s) available.\n", pa_idxset_ncontents(c
->source_outputs
));
128 for (o
= pa_idxset_first(c
->source_outputs
, &index
); o
; o
= pa_idxset_next(c
->source_outputs
, &index
)) {
129 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
130 pa_sample_snprint(ss
, sizeof(ss
), &o
->sample_spec
);
133 s
, " index: %u\n\tname: <%s>\n\tsource: <%u>\n\tsample_spec: <%s>\n",
139 pa_strbuf_printf(s
, "\towner module: <%u>\n", o
->owner
->index
);
141 pa_strbuf_printf(s
, "\tclient: <%u>\n", o
->client
->index
);
144 return pa_strbuf_tostring_free(s
);
147 char *pa_sink_input_list_to_string(struct pa_core
*c
) {
149 struct pa_sink_input
*i
;
150 uint32_t index
= PA_IDXSET_INVALID
;
156 pa_strbuf_printf(s
, "%u sink input(s) available.\n", pa_idxset_ncontents(c
->sink_inputs
));
158 for (i
= pa_idxset_first(c
->sink_inputs
, &index
); i
; i
= pa_idxset_next(c
->sink_inputs
, &index
)) {
159 char ss
[PA_SAMPLE_SNPRINT_MAX_LENGTH
];
160 pa_sample_snprint(ss
, sizeof(ss
), &i
->sample_spec
);
163 s
, " index: %u\n\tname: <%s>\n\tsink: <%u>\n\tvolume: <0x%04x>\n\tlatency: <%u usec>\n\tsample_spec: <%s>\n",
167 (unsigned) i
->volume
,
168 pa_sink_input_get_latency(i
),
172 pa_strbuf_printf(s
, "\towner module: <%u>\n", i
->owner
->index
);
174 pa_strbuf_printf(s
, "\tclient: <%u>\n", i
->client
->index
);
177 return pa_strbuf_tostring_free(s
);