mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-15 08:56:34 -05:00
pactl: add get_source_volume command
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/430>
This commit is contained in:
parent
258bc97fb1
commit
bc8d615c1b
2 changed files with 42 additions and 1 deletions
|
|
@ -211,6 +211,11 @@ License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||||
volume values are given their number has to match the sink's number of channels.</p></optdesc>
|
volume values are given their number has to match the sink's number of channels.</p></optdesc>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<p><opt>get-source-volume</opt> <arg>SINK</arg></p>
|
||||||
|
<optdesc><p>Get the volume of the specified source (identified by its symbolic name or numerical index) displayed in the same format as the `info` command.</p></optdesc>
|
||||||
|
</option>
|
||||||
|
|
||||||
<option>
|
<option>
|
||||||
<p><opt>set-source-volume</opt> <arg>SOURCE</arg> <arg>VOLUME [VOLUME ...]</arg></p>
|
<p><opt>set-source-volume</opt> <arg>SOURCE</arg> <arg>VOLUME [VOLUME ...]</arg></p>
|
||||||
<optdesc><p>Set the volume of the specified source (identified by its symbolic name or numerical index).
|
<optdesc><p>Set the volume of the specified source (identified by its symbolic name or numerical index).
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,7 @@ static enum {
|
||||||
SET_DEFAULT_SOURCE,
|
SET_DEFAULT_SOURCE,
|
||||||
GET_SINK_VOLUME,
|
GET_SINK_VOLUME,
|
||||||
SET_SINK_VOLUME,
|
SET_SINK_VOLUME,
|
||||||
|
GET_SOURCE_VOLUME,
|
||||||
SET_SOURCE_VOLUME,
|
SET_SOURCE_VOLUME,
|
||||||
SET_SINK_INPUT_VOLUME,
|
SET_SINK_INPUT_VOLUME,
|
||||||
SET_SOURCE_OUTPUT_VOLUME,
|
SET_SOURCE_OUTPUT_VOLUME,
|
||||||
|
|
@ -1101,6 +1102,27 @@ static void set_sink_volume_callback(pa_context *c, const pa_sink_info *i, int i
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_source_volume_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
|
static void get_source_volume_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
|
||||||
|
if (is_last < 0) {
|
||||||
|
pa_log(_("Failed to get source information: %s"), pa_strerror(pa_context_errno(c)));
|
||||||
|
quit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_last)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pa_assert(i);
|
||||||
|
|
||||||
|
char cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
|
||||||
|
printf(("Volume: %s\n"
|
||||||
|
" balance %0.2f\n"),
|
||||||
|
pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, true),
|
||||||
|
pa_cvolume_get_balance(&i->volume, &i->channel_map));
|
||||||
|
|
||||||
|
complete_action();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_source_volume_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
|
||||||
pa_cvolume cv;
|
pa_cvolume cv;
|
||||||
|
|
||||||
if (is_last < 0) {
|
if (is_last < 0) {
|
||||||
|
|
@ -1585,10 +1607,14 @@ static void context_state_callback(pa_context *c, void *userdata) {
|
||||||
o = pa_context_get_sink_info_by_name(c, sink_name, set_sink_volume_callback, NULL);
|
o = pa_context_get_sink_info_by_name(c, sink_name, set_sink_volume_callback, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SET_SOURCE_VOLUME:
|
case GET_SOURCE_VOLUME:
|
||||||
o = pa_context_get_source_info_by_name(c, source_name, get_source_volume_callback, NULL);
|
o = pa_context_get_source_info_by_name(c, source_name, get_source_volume_callback, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SET_SOURCE_VOLUME:
|
||||||
|
o = pa_context_get_source_info_by_name(c, source_name, set_source_volume_callback, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
case SET_SINK_INPUT_VOLUME:
|
case SET_SINK_INPUT_VOLUME:
|
||||||
o = pa_context_get_sink_input_info(c, sink_input_idx, get_sink_input_volume_callback, NULL);
|
o = pa_context_get_sink_input_info(c, sink_input_idx, get_sink_input_volume_callback, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2129,6 +2155,16 @@ int main(int argc, char *argv[]) {
|
||||||
if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
|
if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
|
||||||
goto quit;
|
goto quit;
|
||||||
|
|
||||||
|
} else if (pa_streq(argv[optind], "get-source-volume")) {
|
||||||
|
action = GET_SOURCE_VOLUME;
|
||||||
|
|
||||||
|
if (argc < optind+2) {
|
||||||
|
pa_log(_("You have to specify a source name/index"));
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
|
||||||
|
sink_name = pa_xstrdup(argv[optind+1]);
|
||||||
|
|
||||||
} else if (pa_streq(argv[optind], "set-source-volume")) {
|
} else if (pa_streq(argv[optind], "set-source-volume")) {
|
||||||
action = SET_SOURCE_VOLUME;
|
action = SET_SOURCE_VOLUME;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue