]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/cli-text.c
move flat volume logic into the core. while doing so add n_volume_steps field to...
[pulseaudio] / src / pulsecore / cli-text.c
index 947598b51ed4ded6c85de6a47ff0f51d17bdefd1..647fc1b5a7754cb47d2202ca0cb2f3db05bb8948 100644 (file)
@@ -117,6 +117,10 @@ char *pa_card_list_to_string(pa_core *c) {
 
     for (card = pa_idxset_first(c->cards, &idx); card; card = pa_idxset_next(c->cards, &idx)) {
         char *t;
+        pa_sink *sink;
+        pa_source *source;
+        uint32_t sidx;
+
         pa_strbuf_printf(
                 s,
                 "    index: %u\n"
@@ -137,9 +141,7 @@ char *pa_card_list_to_string(pa_core *c) {
             pa_card_profile *p;
             void *state = NULL;
 
-            pa_strbuf_puts(
-                    s,
-                    "\tprofiles:\n");
+            pa_strbuf_puts(s, "\tprofiles:\n");
 
             while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
                 pa_strbuf_printf(s, "\t\t%s: %s (priority %u)\n", p->name, p->description, p->priority);
@@ -150,6 +152,18 @@ char *pa_card_list_to_string(pa_core *c) {
                     s,
                     "\tactive profile: <%s>\n",
                     card->active_profile->name);
+
+        if (!pa_idxset_isempty(card->sinks)) {
+            pa_strbuf_puts(s, "\tsinks:\n");
+            for (sink = pa_idxset_first(card->sinks, &sidx); sink; sink = pa_idxset_next(card->sinks, &sidx))
+                pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)));
+        }
+
+        if (!pa_idxset_isempty(card->sources)) {
+            pa_strbuf_puts(s, "\tsources:\n");
+            for (source = pa_idxset_first(card->sources, &sidx); source; source = pa_idxset_next(card->sources, &sidx))
+                pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)));
+        }
     }
 
     return pa_strbuf_tostring_free(s);
@@ -207,6 +221,9 @@ char *pa_sink_list_to_string(pa_core *c) {
             vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
             cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
         pa_usec_t min_latency, max_latency;
+        const char *cmn;
+
+        cmn = pa_channel_map_to_pretty_name(&sink->channel_map);
 
         pa_sink_get_latency_range(sink, &min_latency, &max_latency);
 
@@ -215,11 +232,12 @@ char *pa_sink_list_to_string(pa_core *c) {
             "  %c index: %u\n"
             "\tname: <%s>\n"
             "\tdriver: <%s>\n"
-            "\tflags: %s%s%s%s%s%s\n"
+            "\tflags: %s%s%s%s%s%s%s\n"
             "\tstate: %s\n"
             "\tvolume: %s%s%s\n"
             "\t        balance %0.2f\n"
             "\tbase volume: %s%s%s\n"
+            "\tvolume steps: %u\n"
             "\tmuted: %s\n"
             "\tcurrent latency: %0.2f ms\n"
             "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
@@ -227,7 +245,7 @@ char *pa_sink_list_to_string(pa_core *c) {
             "\tmax rewind: %lu KiB\n"
             "\tmonitor source: %u\n"
             "\tsample spec: %s\n"
-            "\tchannel map: %s\n"
+            "\tchannel map: %s%s%s\n"
             "\tused by: %u\n"
             "\tlinked by: %u\n",
             c->default_sink_name && !strcmp(sink->name, c->default_sink_name) ? '*' : ' ',
@@ -240,14 +258,16 @@ char *pa_sink_list_to_string(pa_core *c) {
             sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
             sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
             sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
+            sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME" : "",
             sink_state_to_string(pa_sink_get_state(sink)),
             pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
             sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t        " : "",
             sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
-            pa_cvolume_get_balance(&sink->channel_map, pa_sink_get_volume(sink, FALSE)),
+            pa_cvolume_get_balance(pa_sink_get_volume(sink, FALSE), &sink->channel_map),
             pa_volume_snprint(v, sizeof(v), sink->base_volume),
             sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t             " : "",
             sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
+            sink->n_volume_steps,
             pa_yes_no(pa_sink_get_mute(sink, FALSE)),
             (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
             (double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
@@ -258,6 +278,8 @@ char *pa_sink_list_to_string(pa_core *c) {
             sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
             pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec),
             pa_channel_map_snprint(cm, sizeof(cm), &sink->channel_map),
+            cmn ? "\n\t             " : "",
+            cmn ? cmn : "",
             pa_sink_used_by(sink),
             pa_sink_linked_by(sink));
 
@@ -292,6 +314,9 @@ char *pa_source_list_to_string(pa_core *c) {
             vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
             cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
         pa_usec_t min_latency, max_latency;
+        const char *cmn;
+
+        cmn = pa_channel_map_to_pretty_name(&source->channel_map);
 
         pa_source_get_latency_range(source, &min_latency, &max_latency);
 
@@ -305,12 +330,13 @@ char *pa_source_list_to_string(pa_core *c) {
             "\tvolume: %s%s%s\n"
             "\t        balance %0.2f\n"
             "\tbase volume: %s%s%s\n"
+            "\tvolume steps: %u\n"
             "\tmuted: %s\n"
             "\tcurrent latency: %0.2f ms\n"
             "\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n"
             "\tmax rewind: %lu KiB\n"
             "\tsample spec: %s\n"
-            "\tchannel map: %s\n"
+            "\tchannel map: %s%s%s\n"
             "\tused by: %u\n"
             "\tlinked by: %u\n",
             c->default_source_name && !strcmp(source->name, c->default_source_name) ? '*' : ' ',
@@ -327,10 +353,11 @@ char *pa_source_list_to_string(pa_core *c) {
             pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
             source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t        " : "",
             source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
-            pa_cvolume_get_balance(&source->channel_map, pa_source_get_volume(source, FALSE)),
+            pa_cvolume_get_balance(pa_source_get_volume(source, FALSE), &source->channel_map),
             pa_volume_snprint(v, sizeof(v), source->base_volume),
             source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t             " : "",
             source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
+            source->n_volume_steps,
             pa_yes_no(pa_source_get_mute(source, FALSE)),
             (double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
             (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
@@ -339,6 +366,8 @@ char *pa_source_list_to_string(pa_core *c) {
             (unsigned long) pa_source_get_max_rewind(source) / 1024,
             pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
             pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
+            cmn ? "\n\t             " : "",
+            cmn ? cmn : "",
             pa_source_used_by(source),
             pa_source_linked_by(source));
 
@@ -377,6 +406,9 @@ char *pa_source_output_list_to_string(pa_core *c) {
     for (o = pa_idxset_first(c->source_outputs, &idx); o; o = pa_idxset_next(c->source_outputs, &idx)) {
         char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
         pa_usec_t cl;
+        const char *cmn;
+
+        cmn = pa_channel_map_to_pretty_name(&o->channel_map);
 
         if ((cl = pa_source_output_get_requested_latency(o)) == (pa_usec_t) -1)
             pa_snprintf(clt, sizeof(clt), "n/a");
@@ -395,7 +427,7 @@ char *pa_source_output_list_to_string(pa_core *c) {
             "\tcurrent latency: %0.2f ms\n"
             "\trequested latency: %s\n"
             "\tsample spec: %s\n"
-            "\tchannel map: %s\n"
+            "\tchannel map: %s%s%s\n"
             "\tresample method: %s\n",
             o->index,
             o->driver,
@@ -413,6 +445,8 @@ char *pa_source_output_list_to_string(pa_core *c) {
             clt,
             pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
             pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
+            cmn ? "\n\t             " : "",
+            cmn ? cmn : "",
             pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
         if (o->module)
             pa_strbuf_printf(s, "\towner module: %u\n", o->module->index);
@@ -449,6 +483,9 @@ char *pa_sink_input_list_to_string(pa_core *c) {
     for (i = pa_idxset_first(c->sink_inputs, &idx); i; i = pa_idxset_next(c->sink_inputs, &idx)) {
         char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
         pa_usec_t cl;
+        const char *cmn;
+
+        cmn = pa_channel_map_to_pretty_name(&i->channel_map);
 
         if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
             pa_snprintf(clt, sizeof(clt), "n/a");
@@ -471,7 +508,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
             "\tcurrent latency: %0.2f ms\n"
             "\trequested latency: %s\n"
             "\tsample spec: %s\n"
-            "\tchannel map: %s\n"
+            "\tchannel map: %s%s%s\n"
             "\tresample method: %s\n",
             i->index,
             i->driver,
@@ -487,12 +524,14 @@ char *pa_sink_input_list_to_string(pa_core *c) {
             i->sink->index, i->sink->name,
             pa_cvolume_snprint(cv, sizeof(cv), pa_sink_input_get_volume(i)),
             pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_input_get_volume(i)),
-            pa_cvolume_get_balance(&i->channel_map, pa_sink_input_get_volume(i)),
+            pa_cvolume_get_balance(pa_sink_input_get_volume(i), &i->channel_map),
             pa_yes_no(pa_sink_input_get_mute(i)),
             (double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
             clt,
             pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec),
             pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
+            cmn ? "\n\t             " : "",
+            cmn ? cmn : "",
             pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
 
         if (i->module)
@@ -523,6 +562,9 @@ char *pa_scache_list_to_string(pa_core *c) {
         for (e = pa_idxset_first(c->scache, &idx); e; e = pa_idxset_next(c->scache, &idx)) {
             double l = 0;
             char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
+            const char *cmn;
+
+            cmn = pa_channel_map_to_pretty_name(&e->channel_map);
 
             if (e->memchunk.memblock) {
                 pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
@@ -535,7 +577,7 @@ char *pa_scache_list_to_string(pa_core *c) {
                 "    name: <%s>\n"
                 "\tindex: %u\n"
                 "\tsample spec: %s\n"
-                "\tchannel map: %s\n"
+                "\tchannel map: %s%s%s\n"
                 "\tlength: %lu\n"
                 "\tduration: %0.1f s\n"
                 "\tvolume: %s\n"
@@ -547,11 +589,13 @@ char *pa_scache_list_to_string(pa_core *c) {
                 e->index,
                 ss,
                 cm,
+                cmn ? "\n\t             " : "",
+                cmn ? cmn : "",
                 (long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
                 l,
-                pa_cvolume_snprint(cv, sizeof(cv), &e->volume),
-                pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume),
-                e->memchunk.memblock ? pa_cvolume_get_balance(&e->channel_map, &e->volume) : 0.0f,
+                e->volume_is_set ? pa_cvolume_snprint(cv, sizeof(cv), &e->volume) : "n/a",
+                e->volume_is_set ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume) : "n/a",
+                (e->memchunk.memblock && e->volume_is_set) ? pa_cvolume_get_balance(&e->volume, &e->channel_map) : 0.0f,
                 pa_yes_no(e->lazy),
                 e->filename ? e->filename : "n/a");