]> code.delx.au - pulseaudio/blobdiff - polyp/cli-text.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / cli-text.c
index fa1ccdf944c632ae5ae64cb1bb087dbcc77f5b3f..7974275a5e5d1ec32d7d84188e1291f269c7c29e 100644 (file)
@@ -4,7 +4,7 @@
   This file is part of polypaudio.
  
   polypaudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published
+  it under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 2 of the License,
   or (at your option) any later version.
  
@@ -13,7 +13,7 @@
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
  
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with polypaudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
@@ -64,7 +64,7 @@ char *pa_client_list_to_string(struct pa_core *c) {
     s = pa_strbuf_new();
     assert(s);
 
-    pa_strbuf_printf(s, "%u client(s).\n", pa_idxset_ncontents(c->clients));
+    pa_strbuf_printf(s, "%u client(s) logged in.\n", pa_idxset_ncontents(c->clients));
     
     for (client = pa_idxset_first(c->clients, &index); client; client = pa_idxset_next(c->clients, &index)) {
         pa_strbuf_printf(s, "    index: %u\n\tname: <%s>\n\tprotocol_name: <%s>\n", client->index, client->name, client->protocol_name);
@@ -88,16 +88,17 @@ char *pa_sink_list_to_string(struct pa_core *c) {
     pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_ncontents(c->sinks));
 
     for (sink = pa_idxset_first(c->sinks, &index); sink; sink = pa_idxset_next(c->sinks, &index)) {
-        char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
+        char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
         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);
 
@@ -122,12 +123,13 @@ char *pa_source_list_to_string(struct pa_core *c) {
     pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_ncontents(c->sources));
 
     for (source = pa_idxset_first(c->sources, &index); source; source = pa_idxset_next(c->sources, &index)) {
-        char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
+        char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
         pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec);
-        pa_strbuf_printf(s, "  %c index: %u\n\tname: <%s>\n\tsample_spec: <%s>\n",
+        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) 
@@ -146,6 +148,11 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
     struct pa_strbuf *s;
     struct pa_source_output *o;
     uint32_t index = PA_IDXSET_INVALID;
+    static const char* const state_table[] = {
+        "RUNNING",
+        "CORKED",
+        "DISCONNECTED"
+    };
     assert(c);
 
     s = pa_strbuf_new();
@@ -154,19 +161,20 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
     pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_ncontents(c->source_outputs));
 
     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];
+        char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
         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",
+            s, "  index: %u\n\tname: '%s'\n\tstate: %s\n\tsource: <%u> '%s'\n\tsample_spec: <%s>\n",
             o->index,
             o->name,
-            o->source->index,
+            state_table[o->state],
+            o->source->index, o->source->name,
             ss);
         if (o->owner)
             pa_strbuf_printf(s, "\towner module: <%u>\n", o->owner->index);
         if (o->client)
-            pa_strbuf_printf(s, "\tclient: <%u>\n", o->client->index);
+            pa_strbuf_printf(s, "\tclient: <%u> '%s'\n", o->client->index, o->client->name);
     }
     
     return pa_strbuf_tostring_free(s);
@@ -176,30 +184,37 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
     struct pa_strbuf *s;
     struct pa_sink_input *i;
     uint32_t index = PA_IDXSET_INVALID;
-    assert(c);
+    static const char* const state_table[] = {
+        "RUNNING",
+        "CORKED",
+        "DISCONNECTED"
+    };
 
+    assert(c);
     s = pa_strbuf_new();
     assert(s);
 
     pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_ncontents(c->sink_inputs));
 
     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];
+        char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
         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\tstate: %s\n\tsink: <%u> '%s'\n\tvolume: <0x%04x> (%0.2fdB)\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
             i->index,
             i->name,
-            i->sink->index,
+            state_table[i->state],
+            i->sink->index, i->sink->name,
             (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)
             pa_strbuf_printf(s, "\towner module: <%u>\n", i->owner->index);
         if (i->client)
-            pa_strbuf_printf(s, "\tclient: <%u>\n", i->client->index);
+            pa_strbuf_printf(s, "\tclient: <%u> '%s'\n", i->client->index, i->client->name);
     }
     
     return pa_strbuf_tostring_free(s);
@@ -219,20 +234,24 @@ char *pa_scache_list_to_string(struct pa_core *c) {
         uint32_t index = PA_IDXSET_INVALID;
 
         for (e = pa_idxset_first(c->scache, &index); e; e = pa_idxset_next(c->scache, &index)) {
-            double l;
-            char ss[PA_SAMPLE_SNPRINT_MAX_LENGTH];
-            pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
+            double l = 0;
+            char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "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: <%u>\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");
         }
     }
 
@@ -252,13 +271,15 @@ char *pa_autoload_list_to_string(struct pa_core *c) {
         struct pa_autoload_entry *e;
         void *state = NULL;
 
-        while ((e = pa_hashmap_iterate(c->autoload_hashmap, &state))) {
+        while ((e = pa_hashmap_iterate(c->autoload_hashmap, &state, NULL))) {
             pa_strbuf_printf(
-                s, "    name: <%s>\n\ttype: <%s>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
+                s, "    name: <%s>\n\ttype: <%s>\n\tindex: <%u>\n\tmodule_name: <%s>\n\targuments: <%s>\n",
                 e->name,
                 e->type == PA_NAMEREG_SOURCE ? "source" : "sink",
+                e->index,
                 e->module,
                 e->argument);
+
         }
     }