]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/cli-text.c
Allow read-only or non-existing sink input volume.
[pulseaudio] / src / pulsecore / cli-text.c
index 23a57d370f24268143deb2152c9555160173cf26..e6018da24a869dc76ce1c4afa4a03b140ef53733 100644 (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)