+ t = pa_proplist_to_string_sep(client->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
+ pa_xfree(t);
+ }
+
+ return pa_strbuf_tostring_free(s);
+}
+
+static const char *available_to_string(pa_available_t a) {
+ switch (a) {
+ case PA_AVAILABLE_UNKNOWN:
+ return "unknown";
+ case PA_AVAILABLE_NO:
+ return "no";
+ case PA_AVAILABLE_YES:
+ return "yes";
+ default:
+ return "invalid"; /* Should never happen! */
+ }
+}
+
+static void append_port_list(pa_strbuf *s, pa_hashmap *ports) {
+ pa_device_port *p;
+ void *state;
+
+ pa_assert(ports);
+
+ if (pa_hashmap_isempty(ports))
+ return;
+
+ pa_strbuf_puts(s, "\tports:\n");
+ PA_HASHMAP_FOREACH(p, ports, state) {
+ char *t = pa_proplist_to_string_sep(p->proplist, "\n\t\t\t\t");
+ pa_strbuf_printf(s, "\t\t%s: %s (priority %u, latency offset %" PRId64 " usec, available: %s)\n",
+ p->name, p->description, p->priority, p->latency_offset,
+ available_to_string(p->available));
+ pa_strbuf_printf(s, "\t\t\tproperties:\n\t\t\t\t%s\n", t);
+ pa_xfree(t);
+ }
+}
+
+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.\n", pa_idxset_size(c->cards));
+
+ PA_IDXSET_FOREACH(card, c->cards, idx) {
+ char *t;
+ pa_sink *sink;
+ pa_source *source;
+ uint32_t sidx;
+ pa_card_profile *profile;
+ void *state;
+
+ 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_sep(card->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);