From 99ddca89cdca9b0b92ab9870764f9211e6a82e31 Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Mon, 14 Feb 2011 13:41:06 +0200 Subject: 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()). --- src/pulsecore/cli-text.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/pulsecore/cli-text.c') diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c index 23a57d37..e6018da2 100644 --- a/src/pulsecore/cli-text.c +++ b/src/pulsecore/cli-text.c @@ -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) -- cgit