#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include <limits.h>
#include <getopt.h>
#include <locale.h>
SET_SINK_VOLUME,
SET_SOURCE_VOLUME,
SET_SINK_INPUT_VOLUME,
+ SET_SOURCE_OUTPUT_VOLUME,
SET_SINK_MUTE,
SET_SOURCE_MUTE,
SET_SINK_INPUT_MUTE,
}
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 t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], f[PA_FORMAT_INFO_SNPRINT_MAX];
char *pl;
if (is_last < 0) {
"\tSource: %u\n"
"\tSample Specification: %s\n"
"\tChannel Map: %s\n"
+ "\tFormat: %s\n"
+ "\tMute: %s\n"
+ "\tVolume: %s\n"
+ "\t %s\n"
+ "\t balance %0.2f\n"
"\tBuffer Latency: %0.0f usec\n"
"\tSource Latency: %0.0f usec\n"
"\tResample method: %s\n"
i->source,
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
+ pa_format_info_snprint(f, sizeof(f), i->format),
+ pa_yes_no(i->mute),
+ pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
+ pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume),
+ pa_cvolume_get_balance(&i->volume, &i->channel_map),
(double) i->buffer_usec,
(double) i->source_usec,
i->resample_method ? i->resample_method : _("n/a"),
pa_operation_unref(pa_context_set_sink_input_volume(c, sink_input_idx, &cv, simple_callback, NULL));
}
+static void get_source_output_volume_callback(pa_context *c, const pa_source_output_info *o, int is_last, void *userdata) {
+ pa_cvolume cv;
+
+ if (is_last < 0) {
+ pa_log(_("Failed to get source output information: %s"), pa_strerror(pa_context_errno(c)));
+ quit(1);
+ return;
+ }
+
+ if (is_last)
+ return;
+
+ pa_assert(o);
+
+ cv = o->volume;
+ volume_relative_adjust(&cv);
+ pa_operation_unref(pa_context_set_source_output_volume(c, source_output_idx, &cv, simple_callback, NULL));
+}
+
static void stream_state_callback(pa_stream *s, void *userdata) {
pa_assert(s);
}
break;
+ case SET_SOURCE_OUTPUT_VOLUME:
+ if ((volume_flags & VOL_RELATIVE) == VOL_RELATIVE) {
+ pa_operation_unref(pa_context_get_source_output_info(c, source_output_idx, get_source_output_volume_callback, NULL));
+ } else {
+ pa_cvolume v;
+ pa_cvolume_set(&v, 1, volume);
+ pa_operation_unref(pa_context_set_source_output_volume(c, source_output_idx, &v, simple_callback, NULL));
+ }
+ break;
+
case SUBSCRIBE:
pa_context_set_subscribe_callback(c, context_subscribe_callback, NULL);
"%s [options] set-sink-volume SINK VOLUME\n"
"%s [options] set-source-volume SOURCE VOLUME\n"
"%s [options] set-sink-input-volume SINKINPUT VOLUME\n"
+ "%s [options] set-source-output-volume SOURCEOUTPUT VOLUME\n"
"%s [options] set-sink-mute SINK 1|0\n"
"%s [options] set-source-mute SOURCE 1|0\n"
"%s [options] set-sink-input-mute SINKINPUT 1|0\n"
argv0, argv0, argv0, argv0, argv0,
argv0, argv0, argv0, argv0, argv0,
argv0, argv0, argv0, argv0, argv0,
- argv0, argv0, argv0);
+ argv0, argv0, argv0, argv0);
}
enum {
if (parse_volume(argv[optind+2], &volume, &volume_flags) < 0)
goto quit;
+ } else if (pa_streq(argv[optind], "set-source-output-volume")) {
+ action = SET_SOURCE_OUTPUT_VOLUME;
+
+ if (argc != optind+3) {
+ pa_log(_("You have to specify a source output index and a volume"));
+ goto quit;
+ }
+
+ if (pa_atou(argv[optind+1], &source_output_idx) < 0) {
+ pa_log(_("Invalid source output index"));
+ goto quit;
+ }
+
+ if (parse_volume(argv[optind+2], &volume, &volume_flags) < 0)
+ goto quit;
+
} else if (pa_streq(argv[optind], "set-sink-mute")) {
int b;
action = SET_SINK_MUTE;