Allow read-only or non-existing sink input volume.

There are two known cases where read-only or non-existing sink input volume is
relevant: passthrough streams and the planned volume sharing logic.
Passthrough streams don't have volume at all, and the volume sharing logic
requires read-only sink input volume. This commit is primarily working towards
the volume sharing feature, but support for non-existing sink input volume is
also added, because it is so closely related to read-only volume.

Some unrelated refactoring in iface-stream.c creeped into this commit too (new
function: stream_to_string()).
This commit is contained in:
Tanu Kaskinen 2011-02-14 13:41:06 +02:00 committed by Colin Guthrie
parent fa12d2a8a8
commit 99ddca89cd
9 changed files with 156 additions and 63 deletions

View file

@ -553,8 +553,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
pa_usec_t cl;
const char *cmn;
pa_cvolume v;
pa_sink_input_get_volume(i, &v, TRUE);
char *volume_str = NULL;
cmn = pa_channel_map_to_pretty_name(&i->channel_map);
@ -565,6 +564,15 @@ char *pa_sink_input_list_to_string(pa_core *c) {
pa_assert(i->sink);
if (pa_sink_input_is_volume_readable(i)) {
pa_sink_input_get_volume(i, &v, TRUE);
volume_str = pa_sprintf_malloc("%s\n\t %s\n\t balance %0.2f",
pa_cvolume_snprint(cv, sizeof(cv), &v),
pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
pa_cvolume_get_balance(&v, &i->channel_map));
} else
volume_str = pa_xstrdup("n/a");
pa_strbuf_printf(
s,
" index: %u\n"
@ -573,8 +581,6 @@ char *pa_sink_input_list_to_string(pa_core *c) {
"\tstate: %s\n"
"\tsink: %u <%s>\n"
"\tvolume: %s\n"
"\t %s\n"
"\t balance %0.2f\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
"\trequested latency: %s\n"
@ -596,9 +602,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
state_table[pa_sink_input_get_state(i)],
i->sink->index, i->sink->name,
pa_cvolume_snprint(cv, sizeof(cv), &v),
pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
pa_cvolume_get_balance(&v, &i->channel_map),
volume_str,
pa_yes_no(pa_sink_input_get_mute(i)),
(double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
clt,
@ -608,6 +612,8 @@ char *pa_sink_input_list_to_string(pa_core *c) {
cmn ? cmn : "",
pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
pa_xfree(volume_str);
if (i->module)
pa_strbuf_printf(s, "\tmodule: %u\n", i->module->index);
if (i->client)