summaryrefslogtreecommitdiffstats
path: root/src/utils/pactl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/pactl.c')
-rw-r--r--src/utils/pactl.c138
1 files changed, 81 insertions, 57 deletions
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index 7c49007c..4cca2f86 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
/***
This file is part of PulseAudio.
@@ -38,6 +36,7 @@
#include <sndfile.h>
#include <pulse/pulseaudio.h>
+#include <pulsecore/core-util.h>
#if PA_API_VERSION < 10
#error Invalid PulseAudio API version
@@ -157,6 +156,7 @@ static void get_server_info_callback(pa_context *c, const pa_server_info *i, voi
static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata) {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -178,32 +178,37 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
printf("*** Sink #%u ***\n"
"Name: %s\n"
"Driver: %s\n"
- "Description: %s\n"
"Sample Specification: %s\n"
"Channel Map: %s\n"
"Owner Module: %u\n"
"Volume: %s\n"
- "Monitor Source: %u\n"
- "Latency: %0.0f usec\n"
- "Flags: %s%s%s\n",
+ "Monitor Source: %s\n"
+ "Latency: %0.0f usec, configured %0.0f usec\n"
+ "Flags: %s%s%s%s%s%s\n"
+ "Properties:\n%s",
i->index,
i->name,
- i->driver,
- i->description,
+ pa_strnull(i->driver),
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
i->owner_module,
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
- i->monitor_source,
- (double) i->latency,
+ pa_strnull(i->monitor_source_name),
+ (double) i->latency, (double) i->configured_latency,
+ i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
+ i->flags & PA_SINK_NETWORK ? "NETWORK " : "",
+ i->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
i->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
+ i->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
i->flags & PA_SINK_LATENCY ? "LATENCY " : "",
- i->flags & PA_SINK_HARDWARE ? "HARDWARE" : "");
+ pl = pa_proplist_to_string(i->proplist));
+ pa_xfree(pl);
}
static void get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
- char s[PA_SAMPLE_SPEC_SNPRINT_MAX], t[32], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get source information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -222,33 +227,35 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
printf("\n");
nl = 1;
- snprintf(t, sizeof(t), "%u", i->monitor_of_sink);
-
printf("*** Source #%u ***\n"
"Name: %s\n"
"Driver: %s\n"
- "Description: %s\n"
"Sample Specification: %s\n"
"Channel Map: %s\n"
"Owner Module: %u\n"
"Volume: %s\n"
"Monitor of Sink: %s\n"
- "Latency: %0.0f usec\n"
- "Flags: %s%s%s\n",
+ "Latency: %0.0f usec, configured %0.0f usec\n"
+ "Flags: %s%s%s%s%s%s\n"
+ "Properties:\n%s",
i->index,
i->name,
- i->driver,
- i->description,
+ pa_strnull(i->driver),
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
i->owner_module,
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
- i->monitor_of_sink != PA_INVALID_INDEX ? t : "no",
- (double) i->latency,
+ i->monitor_of_sink_name ? i->monitor_of_sink_name : "n/a",
+ (double) i->latency, (double) i->configured_latency,
+ i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
+ i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
+ i->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
i->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
+ i->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
- i->flags & PA_SOURCE_HARDWARE ? "HARDWARE" : "");
+ pl = pa_proplist_to_string(i->proplist));
+ pa_xfree(pl);
}
static void get_module_info_callback(pa_context *c, const pa_module_info *i, int is_last, void *userdata) {
@@ -280,13 +287,14 @@ static void get_module_info_callback(pa_context *c, const pa_module_info *i, int
"Auto unload: %s\n",
i->index,
i->name,
- i->argument,
+ i->argument ? i->argument : "",
i->n_used != PA_INVALID_INDEX ? t : "n/a",
- i->auto_unload ? "yes" : "no");
+ pa_yes_no(i->auto_unload));
}
static void get_client_info_callback(pa_context *c, const pa_client_info *i, int is_last, void *userdata) {
char t[32];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get client information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -308,17 +316,20 @@ static void get_client_info_callback(pa_context *c, const pa_client_info *i, int
snprintf(t, sizeof(t), "%u", i->owner_module);
printf("*** Client #%u ***\n"
- "Name: %s\n"
"Driver: %s\n"
- "Owner Module: %s\n",
+ "Owner Module: %s\n"
+ "Properties:\n%s",
i->index,
- i->name,
- i->driver,
- i->owner_module != PA_INVALID_INDEX ? t : "n/a");
+ pa_strnull(i->driver),
+ i->owner_module != PA_INVALID_INDEX ? t : "n/a",
+ pl = pa_proplist_to_string(i->proplist));
+
+ pa_xfree(pl);
}
static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, int is_last, void *userdata) {
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get sink input information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -341,7 +352,6 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
snprintf(k, sizeof(k), "%u", i->client);
printf("*** Sink Input #%u ***\n"
- "Name: %s\n"
"Driver: %s\n"
"Owner Module: %s\n"
"Client: %s\n"
@@ -351,10 +361,10 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
"Volume: %s\n"
"Buffer Latency: %0.0f usec\n"
"Sink Latency: %0.0f usec\n"
- "Resample method: %s\n",
+ "Resample method: %s\n"
+ "Properties:\n%s",
i->index,
- i->name,
- i->driver,
+ pa_strnull(i->driver),
i->owner_module != PA_INVALID_INDEX ? t : "n/a",
i->client != PA_INVALID_INDEX ? k : "n/a",
i->sink,
@@ -363,12 +373,15 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
(double) i->buffer_usec,
(double) i->sink_usec,
- i->resample_method ? i->resample_method : "n/a");
-}
+ i->resample_method ? i->resample_method : "n/a",
+ pl = pa_proplist_to_string(i->proplist));
+ pa_xfree(pl);
+}
static void get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int is_last, void *userdata) {
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get source output information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -392,7 +405,6 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
snprintf(k, sizeof(k), "%u", i->client);
printf("*** Source Output #%u ***\n"
- "Name: %s\n"
"Driver: %s\n"
"Owner Module: %s\n"
"Client: %s\n"
@@ -401,10 +413,10 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
"Channel Map: %s\n"
"Buffer Latency: %0.0f usec\n"
"Source Latency: %0.0f usec\n"
- "Resample method: %s\n",
+ "Resample method: %s\n"
+ "Properties:\n%s",
i->index,
- i->name,
- i->driver,
+ pa_strnull(i->driver),
i->owner_module != PA_INVALID_INDEX ? t : "n/a",
i->client != PA_INVALID_INDEX ? k : "n/a",
i->source,
@@ -412,11 +424,15 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
(double) i->buffer_usec,
(double) i->source_usec,
- i->resample_method ? i->resample_method : "n/a");
+ i->resample_method ? i->resample_method : "n/a",
+ pl = pa_proplist_to_string(i->proplist));
+
+ pa_xfree(pl);
}
static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int is_last, void *userdata) {
char t[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ char *pl;
if (is_last < 0) {
fprintf(stderr, "Failed to get sample information: %s\n", pa_strerror(pa_context_errno(c)));
@@ -446,7 +462,8 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
"Duration: %0.1fs\n"
"Size: %s\n"
"Lazy: %s\n"
- "Filename: %s\n",
+ "Filename: %s\n"
+ "Properties:\n%s",
i->index,
i->name,
pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
@@ -454,8 +471,11 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int
pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : "n/a",
(double) i->duration/1000000,
t,
- i->lazy ? "yes" : "no",
- i->filename ? i->filename : "n/a");
+ pa_yes_no(i->lazy),
+ i->filename ? i->filename : "n/a",
+ pl = pa_proplist_to_string(i->proplist));
+
+ pa_xfree(pl);
}
static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata) {
@@ -485,7 +505,7 @@ static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i,
i->name,
i->type == PA_AUTOLOAD_SINK ? "sink" : "source",
i->module,
- i->argument);
+ i->argument ? i->argument : "");
}
static void simple_callback(pa_context *c, int success, void *userdata) {
@@ -506,7 +526,7 @@ static void index_callback(pa_context *c, uint32_t idx, void *userdata) {
}
printf("%u\n", idx);
-
+
complete_action();
}
@@ -633,7 +653,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
else
pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, suspend, simple_callback, NULL));
break;
-
+
default:
assert(0);
}
@@ -662,9 +682,9 @@ static void help(const char *argv0) {
"%s [options] exit\n"
"%s [options] upload-sample FILENAME [NAME]\n"
"%s [options] play-sample NAME [SINK]\n"
+ "%s [options] remove-sample NAME\n"
"%s [options] move-sink-input ID SINK\n"
"%s [options] move-source-output ID SOURCE\n"
- "%s [options] remove-sample NAME\n"
"%s [options] load-module NAME [ARGS ...]\n"
"%s [options] unload-module ID\n"
"%s [options] suspend-sink [SINK] 1|0\n"
@@ -814,34 +834,34 @@ int main(int argc, char *argv[]) {
char *p;
action = LOAD_MODULE;
-
+
if (argc <= optind+1) {
fprintf(stderr, "You have to specify a module name and arguments.\n");
goto quit;
}
module_name = argv[optind+1];
-
+
for (i = optind+2; i < argc; i++)
n += strlen(argv[i])+1;
if (n > 0) {
p = module_args = pa_xnew0(char, n);
-
+
for (i = optind+2; i < argc; i++)
p += sprintf(p, "%s%s", p == module_args ? "" : " ", argv[i]);
}
} else if (!strcmp(argv[optind], "unload-module")) {
action = UNLOAD_MODULE;
-
+
if (argc != optind+2) {
fprintf(stderr, "You have to specify a module index\n");
goto quit;
}
module_index = atoi(argv[optind+1]);
-
+
} else if (!strcmp(argv[optind], "suspend-sink")) {
action = SUSPEND_SINK;
@@ -849,12 +869,12 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "You may not specify more than one sink. You have to specify at least one boolean value.\n");
goto quit;
}
-
- suspend = !!atoi(argv[argc-1]);
-
+
+ suspend = pa_parse_boolean(argv[argc-1]);
+
if (argc > optind+2)
sink_name = pa_xstrdup(argv[optind+1]);
-
+
} else if (!strcmp(argv[optind], "suspend-source")) {
action = SUSPEND_SOURCE;
@@ -863,10 +883,14 @@ int main(int argc, char *argv[]) {
goto quit;
}
- suspend = !!atoi(argv[argc-1]);
+ suspend = pa_parse_boolean(argv[argc-1]);
if (argc > optind+2)
source_name = pa_xstrdup(argv[optind+1]);
+ } else if (!strcmp(argv[optind], "help")) {
+ help(bn);
+ ret = 0;
+ goto quit;
}
}