]> code.delx.au - pulseaudio/blobdiff - polyp/cli-text.c
add input latency measurement
[pulseaudio] / polyp / cli-text.c
index a530238fb00ef6e543198f3c3b3140df9fb4aa3d..9932e5689dcce522fbf33460e11d7d8553cffdb1 100644 (file)
@@ -26,7 +26,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "clitext.h"
+#include "cli-text.h"
 #include "module.h"
 #include "client.h"
 #include "sink.h"
@@ -89,15 +89,16 @@ char *pa_sink_list_to_string(struct pa_core *c) {
 
     for (sink = pa_idxset_first(c->sinks, &index); sink; sink = pa_idxset_next(c->sinks, &index)) {
         char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-        pa_sample_snprint(ss, sizeof(ss), &sink->sample_spec);
+        pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec);
         assert(sink->monitor_source);
         pa_strbuf_printf(
             s,
-            "  %c index: %u\n\tname: <%s>\n\tvolume: <0x%04x>\n\tlatency: <%u usec>\n\tmonitor_source: <%u>\n\tsample_spec: <%s>\n",
+            "  %c index: %u\n\tname: <%s>\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%0.0f usec>\n\tmonitor_source: <%u>\n\tsample_spec: <%s>\n",
             c->default_sink_name && !strcmp(sink->name, c->default_sink_name) ? '*' : ' ',
             sink->index, sink->name,
             (unsigned) sink->volume,
-            pa_sink_get_latency(sink),
+            pa_volume_to_dB(sink->volume),
+            (float) pa_sink_get_latency(sink),
             sink->monitor_source->index,
             ss);
 
@@ -123,11 +124,12 @@ char *pa_source_list_to_string(struct pa_core *c) {
 
     for (source = pa_idxset_first(c->sources, &index); source; source = pa_idxset_next(c->sources, &index)) {
         char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-        pa_sample_snprint(ss, sizeof(ss), &source->sample_spec);
-        pa_strbuf_printf(s, "  %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>\n",
+        pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec);
+        pa_strbuf_printf(s, "  %c index: %u\n\tname: <%s>\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
                          c->default_source_name && !strcmp(source->name, c->default_source_name) ? '*' : ' ',
                          source->index,
                          source->name,
+                         (float) pa_source_get_latency(source),
                          ss);
 
         if (source->monitor_of) 
@@ -155,7 +157,7 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
 
     for (o = pa_idxset_first(c->source_outputs, &index); o; o = pa_idxset_next(c->source_outputs, &index)) {
         char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-        pa_sample_snprint(ss, sizeof(ss), &o->sample_spec);
+        pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec);
         assert(o->source);
         pa_strbuf_printf(
             s, "  index: %u\n\tname: <%s>\n\tsource: <%u>\n\tsample_spec: <%s>\n",
@@ -185,15 +187,16 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
 
     for (i = pa_idxset_first(c->sink_inputs, &index); i; i = pa_idxset_next(c->sink_inputs, &index)) {
         char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-        pa_sample_snprint(ss, sizeof(ss), &i->sample_spec);
+        pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec);
         assert(i->sink);
         pa_strbuf_printf(
-            s, "    index: %u\n\tname: <%s>\n\tsink: <%u>\n\tvolume: <0x%04x>\n\tlatency: <%u usec>\n\tsample_spec: <%s>\n",
+            s, "    index: %u\n\tname: <%s>\n\tsink: <%u>\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
             i->index,
             i->name,
             i->sink->index,
             (unsigned) i->volume,
-            pa_sink_input_get_latency(i),
+            pa_volume_to_dB(i->volume),
+            (float) pa_sink_input_get_latency(i),
             ss);
 
         if (i->owner)
@@ -212,27 +215,31 @@ char *pa_scache_list_to_string(struct pa_core *c) {
     s = pa_strbuf_new();
     assert(s);
 
-    pa_strbuf_printf(s, "%u cache entries available.\n", c->scache_hashmap ? pa_hashmap_ncontents(c->scache_hashmap) : 0);
+    pa_strbuf_printf(s, "%u cache entries available.\n", c->scache ? pa_idxset_ncontents(c->scache) : 0);
 
-    if (c->scache_hashmap) {
+    if (c->scache) {
         struct pa_scache_entry *e;
-        void *state = NULL;
+        uint32_t index = PA_IDXSET_INVALID;
 
-        while ((e = pa_hashmap_iterate(c->scache_hashmap, &state))) {
-            double l;
-            char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-            pa_sample_snprint(ss, sizeof(ss), &e->sample_spec);
+        for (e = pa_idxset_first(c->scache, &index); e; e = pa_idxset_next(c->scache, &index)) {
+            double l = 0;
+            char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH] = "n/a";
             
-            l = (double) e->memchunk.length / pa_bytes_per_second(&e->sample_spec);
+            if (e->memchunk.memblock) {
+                pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
+                l = (double) e->memchunk.length / pa_bytes_per_second(&e->sample_spec);
+            }
             
             pa_strbuf_printf(
-                s, "    name: <%s>\n\tindex: <%i>\n\tsample_spec: <%s>\n\tlength: <%u>\n\tduration: <%0.1fs>\n\tvolume: <0x%04x>\n",
+                s, "    name: <%s>\n\tindex: <%i>\n\tsample_spec: <%s>\n\tlength: <%u>\n\tduration: <%0.1fs>\n\tvolume: <0x%04x>\n\tlazy: %s\n\tfilename: %s\n",
                 e->name,
                 e->index,
                 ss,
-                e->memchunk.length,
+                e->memchunk.memblock ? e->memchunk.length : 0,
                 l,
-                e->volume);
+                e->volume,
+                e->lazy ? "yes" : "no",
+                e->filename ? e->filename : "n/a");
         }
     }
 
@@ -259,6 +266,7 @@ char *pa_autoload_list_to_string(struct pa_core *c) {
                 e->type == PA_NAMEREG_SOURCE ? "source" : "sink",
                 e->module,
                 e->argument);
+
         }
     }