[pulseaudio-discuss] [PATCH v3 18/18] pactl: Add "pactl list nodes" functionality
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Wed Jul 3 04:09:21 PDT 2013
---
man/pactl.1.xml.in | 8 +++++---
src/utils/pactl.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/man/pactl.1.xml.in b/man/pactl.1.xml.in
index 29071b3..1d1d4f9 100644
--- a/man/pactl.1.xml.in
+++ b/man/pactl.1.xml.in
@@ -80,9 +80,11 @@ USA.
<option>
<p><opt>list</opt> [<arg>short</arg>] [<arg>TYPE</arg>]</p>
- <optdesc><p>Dump all currently loaded modules, available sinks, sources, streams, etc. <arg>TYPE</arg> must be one of:
- modules, sinks, sources, sink-inputs, source-outputs, clients, samples, cards. If not specified, all info is listed. If
- short is given, output is in a tabular format, for easy parsing by scripts.</p></optdesc>
+ <optdesc><p>Dump all currently loaded modules, available sinks, sources,
+ streams, etc. <arg>TYPE</arg> must be one of: modules, sinks, sources,
+ sink-inputs, source-outputs, clients, samples, cards, nodes. If not
+ specified, all info is listed. If short is given, output is in a tabular
+ format, for easy parsing by scripts.</p></optdesc>
</option>
<option>
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index b3dca78..40f0084 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -826,6 +826,42 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
pa_xfree(pl);
}
+static void get_node_info_callback(pa_context *c, const pa_node_info *info, int is_last, void *userdata) {
+ if (is_last < 0) {
+ pa_log(_("Failed to get node information: %s"), pa_strerror(pa_context_errno(c)));
+ quit(1);
+ return;
+ }
+
+ if (is_last) {
+ complete_action();
+ return;
+ }
+
+ pa_assert(info);
+
+ if (nl && !short_list_format)
+ printf("\n");
+ nl = true;
+
+ if (short_list_format) {
+ printf("%" PRIu32 "\t%s\t%s\n",
+ info->index,
+ info->name,
+ info->direction == PA_DIRECTION_OUTPUT ? "output" : "input");
+ return;
+ }
+
+ printf(_("Node #%" PRIu32 "\n"
+ "\tName: %s\n"
+ "\tDescription: %s\n"
+ "\tDirection: %s\n"),
+ info->index,
+ info->name,
+ info->description,
+ info->direction == PA_DIRECTION_OUTPUT ? "output" : "input");
+}
+
static void simple_callback(pa_context *c, int success, void *userdata) {
if (!success) {
pa_log(_("Failure: %s"), pa_strerror(pa_context_errno(c)));
@@ -1229,10 +1265,12 @@ static void context_state_callback(pa_context *c, void *userdata) {
pa_operation_unref(pa_context_get_sample_info_list(c, get_sample_info_callback, NULL));
else if (pa_streq(list_type, "cards"))
pa_operation_unref(pa_context_get_card_info_list(c, get_card_info_callback, NULL));
+ else if (pa_streq(list_type, "nodes"))
+ pa_operation_unref(pa_context_get_node_info_list(c, get_node_info_callback, NULL));
else
pa_assert_not_reached();
} else {
- actions = 8;
+ actions = 9;
pa_operation_unref(pa_context_get_module_info_list(c, get_module_info_callback, NULL));
pa_operation_unref(pa_context_get_sink_info_list(c, get_sink_info_callback, NULL));
pa_operation_unref(pa_context_get_source_info_list(c, get_source_info_callback, NULL));
@@ -1241,6 +1279,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
pa_operation_unref(pa_context_get_client_info_list(c, get_client_info_callback, NULL));
pa_operation_unref(pa_context_get_sample_info_list(c, get_sample_info_callback, NULL));
pa_operation_unref(pa_context_get_card_info_list(c, get_card_info_callback, NULL));
+ pa_operation_unref(pa_context_get_node_info_list(c, get_node_info_callback, NULL));
}
break;
@@ -1607,12 +1646,13 @@ int main(int argc, char *argv[]) {
if (pa_streq(argv[i], "modules") || pa_streq(argv[i], "clients") ||
pa_streq(argv[i], "sinks") || pa_streq(argv[i], "sink-inputs") ||
pa_streq(argv[i], "sources") || pa_streq(argv[i], "source-outputs") ||
- pa_streq(argv[i], "samples") || pa_streq(argv[i], "cards")) {
+ pa_streq(argv[i], "samples") || pa_streq(argv[i], "cards") ||
+ pa_streq(argv[i], "nodes")) {
list_type = pa_xstrdup(argv[i]);
} else if (pa_streq(argv[i], "short")) {
short_list_format = TRUE;
} else {
- pa_log(_("Specify nothing, or one of: %s"), "modules, sinks, sources, sink-inputs, source-outputs, clients, samples, cards");
+ pa_log(_("Specify nothing, or one of: %s"), "modules, sinks, sources, sink-inputs, source-outputs, clients, samples, cards, nodes");
goto quit;
}
}
--
1.8.1.2
More information about the pulseaudio-discuss
mailing list