]> code.delx.au - pulseaudio/commitdiff
add functionality to dump list of cards
authorLennart Poettering <lennart@poettering.net>
Thu, 15 Jan 2009 17:52:11 +0000 (18:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 15 Jan 2009 17:52:11 +0000 (18:52 +0100)
src/pulsecore/cli-command.c
src/pulsecore/cli-text.c
src/pulsecore/cli-text.h

index 07d55d071f9f619d31ce77c7bff2940b513bd1de..93d6bbe6bb612f5d7bae516f8bce7aa6b81b2c2f 100644 (file)
@@ -80,6 +80,7 @@ static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b
 static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_modules(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_cards(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_sources(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_sink_inputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
@@ -137,6 +138,7 @@ static const struct command commands[] = {
     { "list-clients",            pa_cli_command_clients,            "List loaded clients",          1 },
     { "list-sink-inputs",        pa_cli_command_sink_inputs,        "List sink inputs",             1 },
     { "list-source-outputs",     pa_cli_command_source_outputs,     "List source outputs",          1 },
+    { "list-cards",              pa_cli_command_cards,              "List cards",                   1 },
     { "stat",                    pa_cli_command_stat,               "Show memory block statistics", 1 },
     { "info",                    pa_cli_command_info,               "Show comprehensive status",    1 },
     { "ls",                      pa_cli_command_info,               NULL,                           1 },
@@ -254,6 +256,20 @@ static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, p
     return 0;
 }
 
+static int pa_cli_command_cards(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+    char *s;
+
+    pa_core_assert_ref(c);
+    pa_assert(t);
+    pa_assert(buf);
+    pa_assert(fail);
+
+    pa_assert_se(s = pa_card_list_to_string(c));
+    pa_strbuf_puts(buf, s);
+    pa_xfree(s);
+    return 0;
+}
+
 static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
     char *s;
 
@@ -382,6 +398,7 @@ static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b
     pa_cli_command_sinks(c, t, buf, fail);
     pa_cli_command_sources(c, t, buf, fail);
     pa_cli_command_clients(c, t, buf, fail);
+    pa_cli_command_cards(c, t, buf, fail);
     pa_cli_command_sink_inputs(c, t, buf, fail);
     pa_cli_command_source_outputs(c, t, buf, fail);
     pa_cli_command_scache_list(c, t, buf, fail);
index 362a97911e1a03dcf9c81df8087d76c660f2108d..5d78ce64691a9de82cb02118d4b20a2a09cd9fd0 100644 (file)
@@ -97,6 +97,38 @@ char *pa_client_list_to_string(pa_core *c) {
     return pa_strbuf_tostring_free(s);
 }
 
+char *pa_card_list_to_string(pa_core *c) {
+    pa_strbuf *s;
+    pa_card *card;
+    uint32_t idx = PA_IDXSET_INVALID;
+    pa_assert(c);
+
+    s = pa_strbuf_new();
+
+    pa_strbuf_printf(s, "%u card(s) available in.\n", pa_idxset_size(c->cards));
+
+    for (card = pa_idxset_first(c->cards, &idx); card; card = pa_idxset_next(c->cards, &idx)) {
+        char *t;
+        pa_strbuf_printf(
+                s,
+                "    index: %u\n"
+                "\tname: <%s>\n"
+                "\tdriver: <%s>\n",
+                card->index,
+                card->name,
+                card->driver);
+
+        if (card->module)
+            pa_strbuf_printf(s, "\towner module: %u\n", card->module->index);
+
+        t = pa_proplist_to_string(card->proplist);
+        pa_strbuf_printf(s, "\tproperties:\n%s", t);
+        pa_xfree(t);
+    }
+
+    return pa_strbuf_tostring_free(s);
+}
+
 char *pa_sink_list_to_string(pa_core *c) {
     pa_strbuf *s;
     pa_sink *sink;
@@ -174,6 +206,8 @@ char *pa_sink_list_to_string(pa_core *c) {
             pa_sink_used_by(sink),
             pa_sink_linked_by(sink));
 
+        if (sink->card)
+            pa_strbuf_printf(s, "\tcard: %u <%s>\n", sink->card->index, sink->card->name);
         if (sink->module)
             pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
 
@@ -260,6 +294,8 @@ char *pa_source_list_to_string(pa_core *c) {
 
         if (source->monitor_of)
             pa_strbuf_printf(s, "\tmonitor_of: %u\n", source->monitor_of->index);
+        if (source->card)
+            pa_strbuf_printf(s, "\tcard: %u <%s>\n", source->card->index, source->card->name);
         if (source->module)
             pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
 
@@ -508,7 +544,7 @@ char *pa_full_status_string(pa_core *c) {
 
     s = pa_strbuf_new();
 
-    for (i = 0; i < 8; i++) {
+    for (i = 0; i < 9; i++) {
         char *t = NULL;
 
         switch (i) {
@@ -528,12 +564,15 @@ char *pa_full_status_string(pa_core *c) {
                 t = pa_client_list_to_string(c);
                 break;
             case 5:
-                t = pa_module_list_to_string(c);
+                t = pa_card_list_to_string(c);
                 break;
             case 6:
-                t = pa_scache_list_to_string(c);
+                t = pa_module_list_to_string(c);
                 break;
             case 7:
+                t = pa_scache_list_to_string(c);
+                break;
+            case 8:
                 t = pa_autoload_list_to_string(c);
                 break;
         }
index f4cb97a5fbac3cefbd5aca8873d95d8d18dc63b2..167565e5cf199d853c9d176faf835a537c176e0e 100644 (file)
@@ -31,6 +31,7 @@ char *pa_sink_input_list_to_string(pa_core *c);
 char *pa_source_output_list_to_string(pa_core *c);
 char *pa_sink_list_to_string(pa_core *core);
 char *pa_source_list_to_string(pa_core *c);
+char *pa_card_list_to_string(pa_core *c);
 char *pa_client_list_to_string(pa_core *c);
 char *pa_module_list_to_string(pa_core *c);
 char *pa_scache_list_to_string(pa_core *c);
@@ -39,4 +40,3 @@ char *pa_autoload_list_to_string(pa_core *c);
 char *pa_full_status_string(pa_core *c);
 
 #endif
-