├── .gitignore ├── CONTRIBUTORS ├── contrib ├── README.txt └── pa_volume_set_all_clients.sh ├── Makefile ├── pa_volume.1.md ├── README.md ├── pa_volume.c └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | pa_volume 2 | pa_volume.1 3 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Roland Haas (rhaas80) 2 | 3 | Adam McKee (amckee) 4 | Leo Pham (ForgottenUmbrella) 5 | N.N. (coxtor) 6 | N.N. (milahu) 7 | -------------------------------------------------------------------------------- /contrib/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains scripts and utilities contributed by others. 2 | 3 | Please see the individual files for their copyright status. 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -O2 -std=c99 -Wall 2 | 3 | HAVE_PANDOC := $(shell pandoc --version 2>/dev/null) 4 | 5 | .PHONY: all clean 6 | 7 | all: pa_volume $(if $(HAVE_PANDOC),pa_volume.1) 8 | echo "All done" 9 | 10 | %: %.c 11 | $(CC) $(CFLAGS) -o $@ $< $(shell pkg-config pkg-config --libs libpulse) 12 | 13 | %.1: %.1.md 14 | pandoc --standalone --to man $< -o $@ 15 | 16 | clean: 17 | rm -f pa_volume pa_volume.1 18 | -------------------------------------------------------------------------------- /contrib/pa_volume_set_all_clients.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # pa_volume_set_all_clients.sh 3 | # set all known pulseaudio clients to one volume 4 | # license CC0-1.0, warranty none 5 | 6 | pa_volume_exe='./pa_volume' 7 | 8 | volume="$1" # first argument passed to this script 9 | if [[ -z "$volume" ]] 10 | then 11 | echo "usage: $0 volume_in_percent" 12 | exit 1 13 | fi 14 | 15 | echo "setting all known pulseaudio clients to volume $volume" 16 | while read line 17 | do 18 | client="$(echo "$line" | sed -E 's/client: (.*[^ ]) +[0-9]+%/\1/')" 19 | echo "$volume $client" 20 | "$pa_volume_exe" "$client" "$volume" 21 | done < <("$pa_volume_exe") # bash process substitution 22 | -------------------------------------------------------------------------------- /pa_volume.1.md: -------------------------------------------------------------------------------- 1 | % PA_VOLUME(1) 0.1.3 | Set remembered PulseAudio volume 2 | 3 | ## NAME 4 | pa_volume - set remembered PulseAudio volume 5 | 6 | ## SYNOPSIS 7 | pa_volume [OPTIONS] [CLIENT] [VOLUME | toggle | mute | unmute] [SINK-NAME] 8 | 9 | ## DESCRIPTION 10 | Get or set the remembered volume of CLIENT to VOLUME % and setting its target 11 | sink to SINK-NAME. If one of toggle, mute or unmute is used instead of a VOLUME 12 | toggle, set or unset the mute state of the sink. 13 | 14 | SINK-NAME is a valid PulseAudio sink name as reported by `pacmd list-sinks`. 15 | 16 | If SINK-NAME is not given then the target sink is left unchanged. 17 | 18 | If VOLUME or one of toggle, mute or unmute is not given, then the current 19 | volume is reported. 20 | 21 | If CLIENT is not given, volumes for all clients are reported. 22 | 23 | Mandatory arguments to long options are mandatory for short options too. 24 | 25 | **`-d`, `--show-device`** 26 | 27 | : Show name of sink client outputs to 28 | 29 | **`-s`, `--server=SERVER`** 30 | 31 | : Use server SERVER instead of default daemon 32 | 33 | **`-h`, `--help`** 34 | 35 | : Show this help 36 | 37 | **`--version`** 38 | 39 | : Show copyright notice and version information 40 | 41 | ### Exit status: 42 | 0 43 | : if OK, 44 | 45 | 1 46 | : if the specified client could not be found, 47 | 48 | 2 49 | : if anything failed. 50 | 51 | ## EXAMPLES 52 | Set volume of paplay to 66% on a PCI sound device 53 | 54 | pa_volume paplay 66 alsa_output.pci-0000_00_1f.3.analog-stereo 55 | 56 | Set volume of paplay to 50.1% 57 | 58 | pa_volume paplay 50.1 59 | 60 | Toggle mute of paplay 61 | 62 | pa_volume paplay toggle 63 | 64 | Show current volume of paplay 65 | 66 | pa_volume paplay 67 | 68 | Show all client volumes 69 | 70 | pa_volume 71 | 72 | ## REPORTING BUGS 73 | Please report any bugs found on 74 | [GitHub](https://github.com/rhaas80/pa_volume). 75 | 76 | ## AUTHOR 77 | Roland Haas, reachable at rhaas@ncsa.illinois.edu. 78 | 79 | ## COPYRIGHT 80 | Copyright (C) 2017 - 2020 The Board of Trustees of the University of Illinois 81 | 82 | ## SEE ALSO 83 | 84 | pacmd(1), pavucontrol(1) 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Pulseaudio volume setter 2 | ======================== 3 | 4 | pa_volume is a simple tool to set the remembered volume level of pulseaudio 5 | clients. It requires module-stream-restore to be loaded (which is usually the 6 | case) to function. When called without arguments it shows all the known clients 7 | (running and non-running) and their remembered volume level. To set the volume 8 | level pass it the name of the client followed by the volume in percent. 9 | 10 | ## Compiling 11 | No configure script is provided right now, but there is a simple Makefile. You 12 | will need to have pkg-config and the development packages for libpulse 13 | installed. To create a man page, pandoc is required. On Debian/Ubuntu based 14 | distributions these are the pkg-config, libpulse-dev, pandoc packages. 15 | 16 | ```bash 17 | sudo apt-get install pkg-config libpulse-dev pandoc 18 | git clone https://github.com/rhaas80/pa_volume.git 19 | cd pa_volume/ 20 | make 21 | ``` 22 | 23 | You can then test the executable using `./pa_volume`. 24 | 25 | Copy the executable (`pa_volume`) and man page (`pa_volume.1`) to 26 | a directory in your `$PATH` and `$MANPATH`, respectively. 27 | 28 | ### AUR 29 | This program is available on the AUR for Arch Linux-based distributions as 30 | `pa_volume-git`. 31 | 32 | ### Alpine Linux 33 | 34 | To compile and install on alpine Linux or other for Docker images these 35 | commands, suggested by @anvda may be used: 36 | 37 | ```bash 38 | RUN set -ex && apk --no-cache add build-base libpulse pulseaudio-dev make git 39 | RUN cd /tmp && \ 40 | git clone https://github.com/rhaas80/pa_volume.git && \ 41 | cd pa_volume && \ 42 | PKG_CONFIG_PATH=/usr/lib make && \ 43 | cp pa_volume /usr/local/bin 44 | ``` 45 | 46 | ## Examples 47 | 48 | ```bash 49 | pa_volume paplay 50.1 50 | ``` 51 | will set the volume of paplay to 50.1%. 52 | 53 | ```bash 54 | pa_volume 55 | ``` 56 | will list all known clients and their rememebered volume level for each 57 | channel. 58 | 59 | ```bash 60 | pa_volume paplay 66 alsa_output.pci-0000_00_1f.3.analog-stereo 61 | ``` 62 | will set the volume of paplay to 66% on a PCI sound device 63 | 64 | ```bash 65 | pa_volume paplay toggle 66 | ``` 67 | will toggle mute for paplay 68 | -------------------------------------------------------------------------------- /pa_volume.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | gcc -g3 -Wall pa_volume.c -lpulse 3 | exit 4 | #endif 5 | /* 6 | pa_volume sets the client volume in PA's client database 7 | Copyright (C) 2017 - 2020 The Board of Trustees of the University of 8 | Illinois 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | Authors: 25 | Roland Haas 26 | */ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | static const char *client; 39 | static char *server = NULL; 40 | static double volume = -1.; 41 | static bool toggle_mute = false; 42 | static bool set_mute = false; 43 | static bool set_nomute = false; 44 | static const char *device = NULL; 45 | static int show_device = 0; 46 | 47 | static int client_found = 0; 48 | 49 | // version string to match man page 50 | #define VERSION "0.1.3" 51 | 52 | // PA_CLAMP_VOLUME fails for me since PA_CLAMP_UNLIKELY is not defined 53 | #define CLAMP_VOLUME(v) \ 54 | ((v) < PA_VOLUME_MUTED ? PA_VOLUME_MUTED : \ 55 | (v) > PA_VOLUME_MAX ? PA_VOLUME_MAX : (v)) 56 | 57 | // exit codes used by us 58 | #define PAVO_EXIT_SUCCESS 0 59 | #define PAVO_EXIT_CLIENT_NO_FOUND 1 60 | #define PAVO_EXIT_FAILURE 2 61 | 62 | // the actual worker that checks if we have found the client we are looking for 63 | // then updates its volume 64 | static void read_callback(pa_context *context, 65 | const pa_ext_stream_restore_info *info, 66 | int eol, 67 | void *userdata) 68 | { 69 | assert(info || eol); 70 | 71 | if(info) { 72 | if(strstr(info->name, "sink-input-by-application-name:") || 73 | strstr(info->name, "sink-input-by-media-role:")) { 74 | const int take_action = (volume >= 0. || toggle_mute || set_mute || 75 | set_nomute) && 76 | (client && 77 | strcmp(strchr(info->name, ':')+1, client) == 0); 78 | const int show_volume = !(volume >= 0. || toggle_mute || set_mute || 79 | set_nomute) && ( 80 | !client || 81 | strcmp(strchr(info->name, ':')+1, client) == 0); 82 | if(client && strcmp(strchr(info->name, ':')+1, client) == 0) 83 | client_found = 1; 84 | 85 | if(take_action) { 86 | // we found the client we are looking for, now make a new info struct 87 | // replacing just the volume 88 | pa_ext_stream_restore_info new_info = *info; 89 | // it seems that as if the volume was never set then the database 90 | // contains invalid entries so I have to make a (hopefully sane) 91 | // default. Ideally I would like to query PulseAudio for "default" 92 | // values. 93 | if(new_info.channel_map.channels == 0) { 94 | if(!pa_channel_map_init_stereo(&new_info.channel_map)) { 95 | fprintf(stderr, "pa_channel_map_init_stereo() faiiled\n"); 96 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_FAILURE); 97 | } 98 | } 99 | if(new_info.volume.channels == 0) { 100 | new_info.volume.channels = 2; 101 | } 102 | if(volume >= 0.) { 103 | pa_volume_t channel_volume = 104 | CLAMP_VOLUME((pa_volume_t)(volume*PA_VOLUME_NORM)); 105 | pa_cvolume_set(&new_info.volume, new_info.volume.channels, 106 | channel_volume); 107 | } else if(toggle_mute) { 108 | new_info.mute = !new_info.mute; 109 | } else if(set_mute) { 110 | new_info.mute = 1; 111 | } else if(set_nomute) { 112 | new_info.mute = 0; 113 | } else { 114 | assert(0 && "Internal error: unexpected action"); 115 | } 116 | if(device) { 117 | new_info.device = device; 118 | } 119 | // use REPLACE rather than SET to keep the other client's information 120 | // intact 121 | pa_operation *write_op = pa_ext_stream_restore_write( 122 | context, PA_UPDATE_REPLACE, &new_info, 1, 1, NULL, NULL); 123 | if(write_op) { 124 | pa_operation_unref(write_op); 125 | } else { 126 | fprintf(stderr, "pa_ext_stream_restore_write() failed: %s\n", 127 | pa_strerror(pa_context_errno(context))); 128 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_FAILURE); 129 | } 130 | } 131 | if(show_volume) { 132 | char buf[PA_VOLUME_SNPRINT_MAX]; 133 | if(info->channel_map.channels != 0) { 134 | pa_volume_snprint(buf, sizeof(buf), pa_cvolume_avg(&info->volume)); 135 | } else { 136 | pa_volume_snprint(buf, sizeof(buf), PA_VOLUME_NORM); 137 | } 138 | if(show_device) { 139 | printf("client: %s %s [%s]%s\n", strchr(info->name, ':')+1, buf, 140 | info->device ? info->device : "default", 141 | info->mute ? " (muted)" : ""); 142 | } else { 143 | printf("client: %s %s%s\n", strchr(info->name, ':')+1, buf, 144 | info->mute ? " (muted)" : ""); 145 | } 146 | } 147 | } 148 | } 149 | if(eol) 150 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_SUCCESS); 151 | } 152 | 153 | // wait for module-stream-restore 154 | static void test_callback( 155 | pa_context *context, 156 | uint32_t version, 157 | void *userdata) 158 | { 159 | if(version > 0) { // is version 0 "not present"? 160 | // loops over all safed states 161 | pa_operation *operation = 162 | pa_ext_stream_restore_read(context, read_callback, 163 | (pa_mainloop*)userdata); 164 | if(operation) { 165 | pa_operation_unref(operation); 166 | } else { 167 | fprintf(stderr, "pa_ext_stream_restore_read() failed: %s\n", 168 | pa_strerror(pa_context_errno(context))); 169 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_FAILURE); 170 | } 171 | } 172 | } 173 | 174 | // just wait for pulseaudio to become available 175 | static void state_callback(pa_context *context, void *userdata) { 176 | pa_context_state_t state = pa_context_get_state(context); 177 | switch (state) { 178 | case PA_CONTEXT_UNCONNECTED: 179 | case PA_CONTEXT_CONNECTING: 180 | case PA_CONTEXT_AUTHORIZING: 181 | case PA_CONTEXT_SETTING_NAME: 182 | case PA_CONTEXT_TERMINATED: 183 | default: 184 | break; 185 | case PA_CONTEXT_FAILED: 186 | fprintf(stderr, "failed to connect: %s\n", 187 | pa_strerror(pa_context_errno(context))); 188 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_FAILURE); 189 | break; 190 | case PA_CONTEXT_READY: 191 | { 192 | // we need module-stream-restore so check (and wait) for it 193 | pa_operation *test_op = pa_ext_stream_restore_test(context, test_callback, 194 | (pa_mainloop*)userdata); 195 | if(test_op) { 196 | pa_operation_unref(test_op); 197 | } else { 198 | fprintf(stderr, "pa_ext_stream_restore_test() failed: %s\n", 199 | pa_strerror(pa_context_errno(context))); 200 | pa_mainloop_quit((pa_mainloop*)userdata, PAVO_EXIT_FAILURE); 201 | } 202 | } 203 | break; 204 | } 205 | } 206 | 207 | static void usage(const char *argv0, const struct option *longopts, 208 | const char *opthelp[], FILE *log) 209 | { 210 | fprintf(log, "usage: %s [OPTIONS] [client] [volume|mute|unmute|toggle] [sink-name]\n", argv0); 211 | fprintf(log, "Get / set stored volume for a pulseaudio client.\n\n"); 212 | fprintf(log, "sink-name is the name as output by: pacmd list-sinks\n\n"); 213 | fprintf(log, "Examples:\n"); 214 | fprintf(log, " # set volume of paplay to 66%% on a PCI sound device\n"); 215 | fprintf(log, " %s paplay 66 alsa_output.pci-0000_00_1f.3.analog-stereo\n", argv0); 216 | fprintf(log, " %s paplay 50.1 # set volume of paplay to 50.1%%\n", argv0); 217 | fprintf(log, " %s paplay toggle # toggle mute status of paplay\n", argv0); 218 | fprintf(log, " %s paplay # show curernt volume of paplay\n", argv0); 219 | fprintf(log, " %s # show all client volumes\n\n", argv0); 220 | fprintf(log, "Options:\n\n"); 221 | // computes maximum length of all option names to align output 222 | int maxlen = 0; 223 | for(const struct option *opt = longopts ; opt->name ; opt++) { 224 | int len = strlen(longopts->name); 225 | if(len > maxlen) 226 | maxlen = len; 227 | } 228 | 229 | // output table of options 230 | int buflen = 2*maxlen+4; // space for "--foo=FOO\0" 231 | char buf[buflen]; 232 | for(const struct option *opt = longopts ; opt->name ; opt++) { 233 | // make a string "--foo=FOO" or "--foo" for a description 234 | const int starti = snprintf(buf, buflen, "--%s", opt->name); 235 | assert(starti < buflen); 236 | if(opt->has_arg) { 237 | assert(starti < buflen); 238 | buf[starti] = '='; 239 | const int len = strlen(opt->name); 240 | for(int i = 0 ; i < len ; i++) { 241 | assert(starti + 1 + i < buflen); 242 | buf[starti + 1 + i] = toupper(opt->name[i]); 243 | } 244 | assert(starti + 1 + len < buflen); 245 | buf[starti + 1 + len] = '\0'; 246 | } 247 | int ind = opt - longopts; 248 | if(opt->val != 0) { 249 | fprintf(log, "-%c %-*s %s\n", opt->val, buflen-1, buf, opthelp[ind]); 250 | } else { 251 | fprintf(log, " %-*s %s\n", buflen-1, buf, opthelp[ind]); 252 | } 253 | } 254 | } 255 | 256 | void version(void) 257 | { 258 | printf("pa_volume %s\n", VERSION); 259 | printf("Copyright (C) 2017 - 2020 The Board of Trustees of the University of Illinois\n"); 260 | printf("License GPLv2+: GNU GPL version 2 or later .\n"); 261 | printf("This is free software: you are free to change and redistribute it.\n"); 262 | printf("There is NO WARRANTY, to the extent permitted by law.\n"); 263 | printf("\n"); 264 | printf("Written by Roland Haas.\n"); 265 | } 266 | 267 | static void parse_args(int argc, char **argv) 268 | { 269 | static const struct option longopts[] = { 270 | {"show-device", no_argument, NULL, 'd'}, 271 | {"server", required_argument, NULL, 's'}, 272 | {"help", no_argument, NULL, 'h'}, 273 | {"version", no_argument, NULL, 0}, 274 | {0, 0, 0, 0 }, 275 | }; 276 | static const char *opthelp[] = { 277 | "Show name of sink client outputs to", 278 | "The name of the server to connect to", 279 | "Show this help", 280 | "Output version information and exit" 281 | }; 282 | char optstring[2*sizeof(longopts)/sizeof(longopts[0])]; 283 | for(int i = 0, j = 0 ; i < sizeof(longopts)/sizeof(longopts[0]) - 1 ; i++) { 284 | assert(j < sizeof(optstring)); 285 | optstring[j++] = (char)longopts[i].val; 286 | if(longopts[i].has_arg) { 287 | assert(j < sizeof(optstring)); 288 | optstring[j++] = ':'; 289 | } 290 | // optstring always has space for the terminating NUL b/c of the empty 291 | // entry at the end 292 | assert(j < sizeof(optstring)); 293 | optstring[j] = '\0'; 294 | } 295 | 296 | int opt, longidx; 297 | while((opt = getopt_long(argc, argv, optstring, longopts, &longidx)) != -1) { 298 | switch(opt) 299 | { 300 | case 'd': 301 | show_device = 1; 302 | break; 303 | case 's': 304 | server = optarg; 305 | break; 306 | case 'h': 307 | usage(argv[0], longopts, opthelp, stdout); 308 | exit(PAVO_EXIT_SUCCESS); 309 | break; 310 | case 0: // long option only 311 | if(strcmp(longopts[longidx].name, "version") == 0) { 312 | version(); 313 | exit(PAVO_EXIT_SUCCESS); 314 | } else { 315 | fprintf(stderr, "unexpected long-only option '%s'\n", 316 | longopts[longidx].name); 317 | exit(PAVO_EXIT_FAILURE); 318 | } 319 | break; 320 | case '?': 321 | usage(argv[0], longopts, opthelp, stderr); // TODO: pass in argv[optind]? 322 | exit(PAVO_EXIT_FAILURE); 323 | break; 324 | default: 325 | fprintf(stderr, "getopt returned character cod 0x%x??\n", opt); 326 | exit(PAVO_EXIT_FAILURE); 327 | break; 328 | } 329 | } 330 | if(optind < argc) 331 | client = argv[optind++]; 332 | if(optind < argc) { 333 | char *endptr = NULL; 334 | if(strcmp(argv[optind], "toggle") == 0) { 335 | toggle_mute = true; 336 | } else if(strcmp(argv[optind], "mute") == 0) { 337 | set_mute = true; 338 | } else if(strcmp(argv[optind], "unmute") == 0) { 339 | set_nomute = true; 340 | } else { 341 | volume = strtod(argv[optind], &endptr); 342 | if(*endptr != '\0') { 343 | if(endptr == argv[optind]) { 344 | fprintf(stderr, "Invalid argument '%s' could not be read a number\n", 345 | endptr); 346 | } else { 347 | fprintf(stderr, "Extra characters '%s' after number '%.*s'\n", endptr, 348 | (int)(endptr - argv[optind]), argv[optind]); 349 | } 350 | exit(PAVO_EXIT_FAILURE); 351 | } 352 | if(volume < 0. || volume > 100.) { 353 | fprintf(stderr, "Invalid volume %g. Must be between 0 and 100.\n", 354 | volume); 355 | exit(PAVO_EXIT_FAILURE); 356 | } 357 | volume /= 100.; 358 | } 359 | assert(toggle_mute + set_mute + set_nomute + (volume >= 0.) == 1); 360 | optind += 1; 361 | } 362 | if(optind < argc) 363 | device = argv[optind++]; 364 | if(optind < argc) { 365 | while(optind < argc) 366 | fprintf(stderr, "extra argument '%s'\n", argv[optind++]); 367 | usage(argv[0], longopts, opthelp, stderr); 368 | exit(PAVO_EXIT_FAILURE); 369 | } 370 | } 371 | 372 | int main(int argc, char **argv) 373 | { 374 | parse_args(argc, argv); 375 | 376 | // set up callbacks to first wait for pulseaudio to become ready, then check 377 | // for the presence of module-stream-restore then loop over all safed states, 378 | // then set new states with the new volume 379 | int retval; 380 | pa_mainloop *mainloop = pa_mainloop_new(); 381 | if(mainloop) { 382 | pa_mainloop_api *mainloopapi = pa_mainloop_get_api(mainloop); 383 | if(mainloopapi) { 384 | pa_context *context = pa_context_new(mainloopapi, "Volume setter toy"); 385 | if(context) { 386 | if(pa_context_connect(context, server, 0, NULL) >= 0) { 387 | // set up callback for pulseaudio to become ready and fire off the chain of 388 | // callbacks 389 | pa_context_set_state_callback(context, state_callback, mainloop); 390 | if(pa_mainloop_run(mainloop, &retval) < 0) { 391 | fprintf(stderr, "pa_mainloop_run() failed\n"); 392 | retval = PAVO_EXIT_FAILURE; 393 | } 394 | 395 | // tear everything donw in reverse order 396 | pa_context_disconnect(context); 397 | } else { 398 | fprintf(stderr, "pa_context_connect() failed: %s\n", 399 | pa_strerror(pa_context_errno(context))); 400 | retval = PAVO_EXIT_FAILURE; 401 | } 402 | pa_context_unref(context); 403 | } else { 404 | fprintf(stderr, "pa_context_new() failed\n"); 405 | retval = PAVO_EXIT_FAILURE; 406 | } 407 | } else { 408 | fprintf(stderr, "pa_mainloop_get_api() failed\n"); 409 | retval = PAVO_EXIT_FAILURE; 410 | } 411 | pa_mainloop_free(mainloop); 412 | } else { 413 | fprintf(stderr, "pa_mainloop_new() failed"); 414 | retval = PAVO_EXIT_FAILURE; 415 | } 416 | 417 | if(retval != PAVO_EXIT_FAILURE) { 418 | if(client && !client_found) { 419 | fprintf(stderr, "Client '%s' not found.\n", client); 420 | retval = PAVO_EXIT_CLIENT_NO_FOUND; 421 | } 422 | } 423 | 424 | return retval; 425 | } 426 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | --------------------------------------------------------------------------------