Huge trailing whitespace cleanup. Let's keep the tree pure from here on,

mmmkay?


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Pierre Ossman 2007-01-04 13:43:45 +00:00
parent 1a460ee40a
commit 521daf6f0a
283 changed files with 3742 additions and 3742 deletions

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -50,7 +50,7 @@ int setresuid(uid_t r, uid_t e, uid_t s);
/* Drop root rights when called SUID root */
void pa_drop_root(void) {
uid_t uid = getuid();
if (uid == 0 || geteuid() != 0)
return;
@ -96,13 +96,13 @@ int pa_limit_caps(void) {
if (cap_set_proc(caps) < 0)
goto fail;
pa_log_info("dropped capabilities successfully.");
pa_log_info("dropped capabilities successfully.");
r = 0;
fail:
cap_free (caps);
return r;
}
@ -124,12 +124,12 @@ int pa_drop_caps(void) {
pa_log("failed to drop capabilities: %s", pa_cstrerror(errno));
goto fail;
}
r = 0;
fail:
cap_free (caps);
return r;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -100,7 +100,7 @@ void pa_cmdline_help(const char *argv0) {
e++;
else
e = argv0;
printf("%s [options]\n\n"
"COMMANDS:\n"
" -h, --help Show this help\n"
@ -124,7 +124,7 @@ void pa_cmdline_help(const char *argv0) {
" --scache-idle-time=SECS Unload autoloaded samples when idle and\n"
" this time passed\n"
" --log-level[=LEVEL] Increase or set verbosity level\n"
" -v Increase the verbosity level\n"
" -v Increase the verbosity level\n"
" --log-target={auto,syslog,stderr} Specify the log target\n"
" -p, --dl-search-path=PATH Set the search path for dynamic shared\n"
" objects (plugins)\n"
@ -143,7 +143,7 @@ void pa_cmdline_help(const char *argv0) {
" -F, --file=FILENAME Run the specified script\n"
" -C Open a command line on the running TTY\n"
" after startup\n\n"
" -n Don't load default script file\n", e);
}
@ -156,7 +156,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
if (conf->script_commands)
pa_strbuf_puts(buf, conf->script_commands);
while ((c = getopt_long(argc, argv, "L:F:ChDnp:kv", long_options, NULL)) != -1) {
switch (c) {
case ARG_HELP:
@ -184,21 +184,21 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
case ARG_CHECK:
conf->cmd = PA_CMD_CHECK;
break;
case ARG_LOAD:
case 'L':
pa_strbuf_printf(buf, "load-module %s\n", optarg);
break;
case ARG_FILE:
case 'F':
pa_strbuf_printf(buf, ".include %s\n", optarg);
break;
case 'C':
pa_strbuf_puts(buf, "load-module module-cli exit_on_eof=1\n");
break;
case ARG_DAEMONIZE:
case 'D':
if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
@ -226,7 +226,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
if (conf->log_level < PA_LOG_LEVEL_MAX-1)
conf->log_level++;
}
break;
case ARG_HIGH_PRIORITY:
@ -249,13 +249,13 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
goto fail;
}
break;
case 'p':
case ARG_DL_SEARCH_PATH:
pa_xfree(conf->dl_search_path);
conf->dl_search_path = *optarg ? pa_xstrdup(optarg) : NULL;
break;
case 'n':
pa_xfree(conf->default_script_file);
conf->default_script_file = NULL;
@ -307,7 +307,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
goto fail;
}
break;
default:
goto fail;
}
@ -322,12 +322,12 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
}
*d = optind;
return 0;
fail:
if (buf)
pa_strbuf_free(buf);
return -1;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -80,7 +80,7 @@ static pa_io_event *io_event = NULL;
static struct sigaction sigaction_prev;
/* Nonzero after pa_cpu_limit_init() */
static int installed = 0;
static int installed = 0;
/* The current state of operation */
static enum {
@ -131,24 +131,24 @@ static void signal_handler(int sig) {
snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
write_err(t);
#endif
if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
static const char c = 'X';
write_err("Soft CPU time limit exhausted, terminating.\n");
/* Try a soft cleanup */
write(the_pipe[1], &c, sizeof(c));
phase = PHASE_SOFT;
reset_cpu_time(CPUTIME_INTERVAL_HARD);
} else {
/* Everything's fine */
reset_cpu_time(CPUTIME_INTERVAL_SOFT);
last_time = now;
}
} else if (phase == PHASE_SOFT) {
write_err("Hard CPU time limit exhausted, terminating forcibly.\n");
_exit(1); /* Forced exit */
@ -167,7 +167,7 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
int pa_cpu_limit_init(pa_mainloop_api *m) {
struct sigaction sa;
assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1 && !installed);
time(&last_time);
/* Prepare the main loop pipe */
@ -191,7 +191,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) {
sa.sa_handler = signal_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(SIGXCPU, &sa, &sigaction_prev) < 0) {
pa_cpu_limit_done();
return -1;
@ -200,7 +200,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) {
installed = 1;
reset_cpu_time(CPUTIME_INTERVAL_SOFT);
return 0;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -231,7 +231,7 @@ static int parse_rlimit(const char *filename, unsigned line, const char *lvalue,
int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
int r = -1;
FILE *f = NULL;
pa_config_item table[] = {
{ "daemonize", pa_config_parse_bool, NULL },
{ "fail", pa_config_parse_bool, NULL },
@ -266,7 +266,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
#endif
{ NULL, NULL, NULL },
};
table[0].data = &c->daemonize;
table[1].data = &c->fail;
table[2].data = &c->high_priority;
@ -301,8 +301,8 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
table[24].data = &c->rlimit_memlock;
#endif
#endif
pa_xfree(c->config_file);
c->config_file = NULL;
@ -316,11 +316,11 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
}
r = f ? pa_config_parse(c->config_file, f, table, NULL) : 0;
finish:
if (f)
fclose(f);
return r;
}
@ -354,7 +354,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
pa_strbuf_printf(s, "### Read from configuration file: %s ###\n", c->config_file);
assert(c->log_level <= PA_LOG_LEVEL_MAX);
pa_strbuf_printf(s, "daemonize = %i\n", !!c->daemonize);
pa_strbuf_printf(s, "fail = %i\n", !!c->fail);
pa_strbuf_printf(s, "high-priority = %i\n", !!c->high_priority);
@ -385,6 +385,6 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
pa_strbuf_printf(s, "rlimit-memlock = %li\n", c->rlimit_memlock.is_set ? (long int) c->rlimit_memlock.value : -1);
#endif
#endif
return pa_strbuf_tostring_free(s);
}

View file

@ -66,7 +66,7 @@ typedef struct pa_daemon_conf {
pa_log_level_t log_level;
int resample_method;
char *config_file;
#ifdef HAVE_SYS_RESOURCE_H
pa_rlimit rlimit_as, rlimit_core, rlimit_data, rlimit_fsize, rlimit_nofile, rlimit_stack;
#ifdef RLIMIT_NPROC
@ -76,7 +76,7 @@ typedef struct pa_daemon_conf {
pa_rlimit rlimit_memlock;
#endif
#endif
} pa_daemon_conf;
/* Allocate a new structure and fill it with sane defaults */

View file

@ -45,14 +45,14 @@ static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modi
static void long_info(const char *name, const char *path, pa_modinfo *i) {
static int nl = 0;
assert(name && i);
if (nl)
printf("\n");
nl = 1;
printf("Name: %s\n", name);
if (!i->description && !i->version && !i->author && !i->usage)
printf("No module information available\n");
else {
@ -65,14 +65,14 @@ static void long_info(const char *name, const char *path, pa_modinfo *i) {
if (i->usage)
printf("Usage: %s\n", i->usage);
}
if (path)
printf("Path: %s\n", path);
}
static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {
pa_modinfo *i;
if ((i = pa_modinfo_get_by_name(path ? path : name))) {
info(name, path, i);
pa_modinfo_free(i);
@ -86,10 +86,10 @@ static int is_preloaded(const char *name) {
for (l = lt_preloaded_symbols; l->name; l++) {
char buf[64], *e;
if (l->address)
continue;
snprintf(buf, sizeof(buf), "%s", l->name);
if ((e = strrchr(buf, '.')))
*e = 0;
@ -112,7 +112,7 @@ static int callback(const char *path, lt_ptr data) {
if (is_preloaded(e))
return 0;
show_info(e, path, c->log_level >= PA_LOG_INFO ? long_info : short_info);
return 0;
}
@ -127,20 +127,20 @@ void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
for (l = lt_preloaded_symbols; l->name; l++) {
char buf[64], *e;
if (l->address)
continue;
if (strlen(l->name) <= sizeof(PREFIX)-1 || strncmp(l->name, PREFIX, sizeof(PREFIX)-1))
continue;
snprintf(buf, sizeof(buf), "%s", l->name);
if ((e = strrchr(buf, '.')))
*e = 0;
show_info(buf, NULL, c->log_level >= PA_LOG_INFO ? long_info : short_info);
}
lt_dlforeachfile(NULL, callback, c);
}
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -125,7 +125,7 @@ static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e,
pa_module_load(userdata, "module-cli", NULL);
break;
#endif
#ifdef SIGUSR2
case SIGUSR2:
pa_module_load(userdata, "module-cli-protocol-unix", NULL);
@ -170,7 +170,7 @@ static int change_user(void) {
/* This function is called only in system-wide mode. It creates a
* runtime dir in /var/run/ with proper UID/GID and drops privs
* afterwards. */
if (!(pw = getpwnam(PA_SYSTEM_USER))) {
pa_log("Failed to find user '%s'.", PA_SYSTEM_USER);
return -1;
@ -197,7 +197,7 @@ static int change_user(void) {
pa_log("Failed to create '%s': %s", PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno));
return -1;
}
if (initgroups(PA_SYSTEM_USER, gr->gr_gid) != 0) {
pa_log("Failed to change group list: %s", pa_cstrerror(errno));
return -1;
@ -265,7 +265,7 @@ static int create_runtime_dir(void) {
/* This function is called only when the daemon is started in
* per-user mode. We create the runtime directory somewhere in
* /tmp/ with the current UID/GID */
if (pa_make_secure_dir(fn, 0700, (uid_t)-1, (gid_t)-1) < 0) {
pa_log("Failed to create '%s': %s", fn, pa_cstrerror(errno));
return -1;
@ -311,7 +311,7 @@ int main(int argc, char *argv[]) {
pa_daemon_conf *conf = NULL;
pa_mainloop *mainloop = NULL;
char *s;
char *s;
int r, retval = 1, d = 0;
int daemon_pipe[2] = { -1, -1 };
int suid_root, real_root;
@ -333,7 +333,7 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_GETUID
real_root = getuid() == 0;
suid_root = !real_root && geteuid() == 0;
if (suid_root && (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) <= 0 || gid >= 1000)) {
pa_log_warn("WARNING: called SUID root, but not in group '"PA_REALTIME_GROUP"'.");
pa_drop_root();
@ -342,9 +342,9 @@ int main(int argc, char *argv[]) {
real_root = 0;
suid_root = 0;
#endif
LTDL_SET_PRELOADED_SYMBOLS();
r = lt_dlinit();
assert(r == 0);
@ -356,11 +356,11 @@ int main(int argc, char *argv[]) {
#endif
pa_random_seed();
pa_log_set_ident("pulseaudio");
conf = pa_daemon_conf_new();
if (pa_daemon_conf_load(conf, NULL) < 0)
goto finish;
@ -429,9 +429,9 @@ int main(int argc, char *argv[]) {
pa_log("failed to kill daemon.");
else
retval = 0;
goto finish;
default:
assert(conf->cmd == PA_CMD_DAEMON);
}
@ -457,7 +457,7 @@ int main(int argc, char *argv[]) {
pa_log("failed to create pipe.");
goto finish;
}
if ((child = fork()) < 0) {
pa_log("fork() failed: %s", pa_cstrerror(errno));
goto finish;
@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
pa_log("daemon startup failed.");
else
pa_log_info("daemon startup successful.");
goto finish;
}
@ -517,7 +517,7 @@ int main(int argc, char *argv[]) {
#ifdef SIGTSTP
signal(SIGTSTP, SIG_IGN);
#endif
#ifdef TIOCNOTTY
if ((tty_fd = open("/dev/tty", O_RDWR)) >= 0) {
ioctl(tty_fd, TIOCNOTTY, (char*) 0);
@ -528,13 +528,13 @@ int main(int argc, char *argv[]) {
chdir("/");
umask(0022);
if (conf->system_instance) {
if (change_user() < 0)
goto finish;
} else if (create_runtime_dir() < 0)
goto finish;
if (conf->use_pid_file) {
if (pa_pid_file_create() < 0) {
pa_log("pa_pid_file_create() failed.");
@ -551,7 +551,7 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_SYS_RESOURCE_H
set_all_rlimits(conf);
#endif
#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN);
#endif
@ -580,7 +580,7 @@ int main(int argc, char *argv[]) {
#ifdef SIGHUP
pa_signal_new(SIGHUP, signal_callback, c);
#endif
#ifdef OS_IS_WIN32
timer = pa_mainloop_get_api(mainloop)->time_new(
pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
@ -596,7 +596,7 @@ int main(int argc, char *argv[]) {
r = pa_cpu_limit_init(pa_mainloop_get_api(mainloop));
assert(r == 0);
}
buf = pa_strbuf_new();
if (conf->default_script_file)
r = pa_cli_command_execute_file(c, conf->default_script_file, buf, &conf->fail);
@ -605,7 +605,7 @@ int main(int argc, char *argv[]) {
r = pa_cli_command_execute(c, conf->script_commands, buf, &conf->fail);
pa_log_error("%s", s = pa_strbuf_tostring_free(buf));
pa_xfree(s);
if (r < 0 && conf->fail) {
pa_log("failed to initialize daemon.");
#ifdef HAVE_FORK
@ -652,11 +652,11 @@ int main(int argc, char *argv[]) {
if (!conf->no_cpu_limit)
pa_cpu_limit_done();
pa_signal_done();
pa_log_info("Daemon terminated.");
finish:
if (mainloop)
@ -667,7 +667,7 @@ finish:
if (valid_pid_file)
pa_pid_file_remove();
close_pipe(daemon_pipe);
#ifdef OS_IS_WIN32
@ -675,6 +675,6 @@ finish:
#endif
lt_dlexit();
return retval;
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -270,7 +270,7 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s
};
int i, ret;
assert(pcm_handle);
assert(f);
@ -290,12 +290,12 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s
if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0)
return ret;
try_auto:
for (i = 0; try_order[i] != PA_SAMPLE_INVALID; i++) {
*f = try_order[i];
if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0)
return ret;
}
@ -312,14 +312,14 @@ int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, pa_sample_spec *ss, uint32_t *p
unsigned int c = ss->channels;
pa_sample_format_t f = ss->format;
snd_pcm_hw_params_t *hwparams;
assert(pcm_handle);
assert(ss);
assert(periods);
assert(period_size);
buffer_size = *periods * *period_size;
if ((ret = snd_pcm_hw_params_malloc(&hwparams)) < 0 ||
(ret = snd_pcm_hw_params_any(pcm_handle, hwparams)) < 0 ||
(ret = snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 0)) < 0 ||
@ -359,25 +359,25 @@ int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, pa_sample_spec *ss, uint32_t *p
pa_log_warn("device doesn't support sample format %s, changed to %s.", pa_sample_format_to_string(ss->format), pa_sample_format_to_string(f));
ss->format = f;
}
if ((ret = snd_pcm_prepare(pcm_handle)) < 0)
goto finish;
if ((ret = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size)) < 0 ||
(ret = snd_pcm_hw_params_get_period_size(hwparams, period_size, NULL)) < 0)
goto finish;
assert(buffer_size > 0);
assert(*period_size > 0);
*periods = buffer_size / *period_size;
assert(*periods > 0);
ret = 0;
finish:
if (hwparams)
snd_pcm_hw_params_free(hwparams);
return ret;
}
@ -419,7 +419,7 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const
if (fallback) {
snd_mixer_selem_id_set_name(sid, fallback);
if (!(elem = snd_mixer_find_selem(mixer, sid)))
pa_log_warn("Cannot find fallback mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -95,13 +95,13 @@ static void update_usage(struct userdata *u) {
static void clear_up(struct userdata *u) {
assert(u);
if (u->sink) {
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
u->sink = NULL;
}
if (u->pcm_fdl)
pa_alsa_fdlist_free(u->pcm_fdl);
if (u->mixer_fdl)
@ -113,7 +113,7 @@ static void clear_up(struct userdata *u) {
snd_mixer_close(u->mixer_handle);
u->mixer_handle = NULL;
}
if (u->pcm_handle) {
snd_pcm_drop(u->pcm_handle);
snd_pcm_close(u->pcm_handle);
@ -126,7 +126,7 @@ static int xrun_recovery(struct userdata *u) {
assert(u);
pa_log_info("*** ALSA-XRUN (playback) ***");
if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) {
pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret));
@ -142,11 +142,11 @@ static void do_write(struct userdata *u) {
assert(u);
update_usage(u);
for (;;) {
pa_memchunk *memchunk = NULL;
snd_pcm_sframes_t frames;
if (u->memchunk.memblock)
memchunk = &u->memchunk;
else {
@ -155,7 +155,7 @@ static void do_write(struct userdata *u) {
else
memchunk = &u->memchunk;
}
assert(memchunk->memblock && memchunk->memblock->data && memchunk->length && memchunk->memblock->length && (memchunk->length % u->frame_size) == 0);
if ((frames = snd_pcm_writei(u->pcm_handle, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length / u->frame_size)) < 0) {
@ -165,7 +165,7 @@ static void do_write(struct userdata *u) {
if (frames == -EPIPE) {
if (xrun_recovery(u) < 0)
return;
continue;
}
@ -187,7 +187,7 @@ static void do_write(struct userdata *u) {
memchunk->index = memchunk->length = 0;
}
}
break;
}
}
@ -229,7 +229,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
snd_pcm_sframes_t frames;
int err;
assert(s && u && u->sink);
if ((err = snd_pcm_delay(u->pcm_handle, &frames)) < 0) {
@ -292,14 +292,14 @@ static int sink_set_hw_volume_cb(pa_sink *s) {
for (i = 0; i < s->hw_volume.channels; i++) {
long alsa_vol;
assert(snd_mixer_selem_has_playback_channel(u->mixer_elem, i));
vol = s->hw_volume.values[i];
if (vol > PA_VOLUME_NORM)
vol = PA_VOLUME_NORM;
alsa_vol = (long) roundf(((float) vol * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
if ((err = snd_mixer_selem_set_playback_volume(u->mixer_elem, i, alsa_vol)) < 0)
@ -367,7 +367,7 @@ int pa__init(pa_core *c, pa_module*m) {
const char *name;
char *name_buf = NULL;
int namereg_fail;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
@ -380,7 +380,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
frame_size = pa_frame_size(&ss);
/* Fix latency to 100ms */
periods = 8;
fragsize = pa_bytes_per_second(&ss)/128;
@ -390,11 +390,11 @@ int pa__init(pa_core *c, pa_module*m) {
goto fail;
}
period_size = fragsize/frame_size;
u = pa_xnew0(struct userdata, 1);
m->userdata = u;
u->module = m;
snd_config_update_free_global();
if ((err = snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err));
@ -415,7 +415,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (ss.channels != map.channels)
/* Seems ALSA didn't like the channel number, so let's fix the channel map */
pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA);
if ((err = snd_mixer_open(&u->mixer_handle, 0)) < 0) {
pa_log("Error opening mixer: %s", snd_strerror(err));
goto fail;
@ -486,7 +486,7 @@ int pa__init(pa_core *c, pa_module*m) {
snd_mixer_elem_set_callback_private(u->mixer_elem, u);
} else
u->mixer_fdl = NULL;
u->frame_size = frame_size;
u->fragment_size = period_size * frame_size;
@ -499,7 +499,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->memchunk.memblock = NULL;
u->memchunk.index = u->memchunk.length = 0;
ret = 0;
/* Get initial mixer settings */
@ -507,21 +507,21 @@ int pa__init(pa_core *c, pa_module*m) {
u->sink->get_hw_volume(u->sink);
if (u->sink->get_hw_mute)
u->sink->get_hw_mute(u->sink);
finish:
pa_xfree(name_buf);
if (ma)
pa_modargs_free(ma);
if (pcm_info)
snd_pcm_info_free(pcm_info);
return ret;
fail:
if (u)
pa__done(c, m);
@ -541,7 +541,7 @@ void pa__done(pa_core *c, pa_module*m) {
pa_memblock_unref(u->memchunk.memblock);
if (u->silence.memblock)
pa_memblock_unref(u->silence.memblock);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -96,13 +96,13 @@ static void update_usage(struct userdata *u) {
static void clear_up(struct userdata *u) {
assert(u);
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
u->source = NULL;
}
if (u->pcm_fdl)
pa_alsa_fdlist_free(u->pcm_fdl);
if (u->mixer_fdl)
@ -114,7 +114,7 @@ static void clear_up(struct userdata *u) {
snd_mixer_close(u->mixer_handle);
u->mixer_handle = NULL;
}
if (u->pcm_handle) {
snd_pcm_drop(u->pcm_handle);
snd_pcm_close(u->pcm_handle);
@ -127,7 +127,7 @@ static int xrun_recovery(struct userdata *u) {
assert(u);
pa_log_info("*** ALSA-XRUN (capture) ***");
if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) {
pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret));
@ -144,17 +144,17 @@ static void do_read(struct userdata *u) {
assert(u);
update_usage(u);
for (;;) {
pa_memchunk post_memchunk;
snd_pcm_sframes_t frames;
size_t l;
if (!u->memchunk.memblock) {
u->memchunk.memblock = pa_memblock_new(u->source->core->mempool, u->memchunk.length = u->fragment_size);
u->memchunk.index = 0;
}
assert(u->memchunk.memblock);
assert(u->memchunk.length);
assert(u->memchunk.memblock->data);
@ -164,11 +164,11 @@ static void do_read(struct userdata *u) {
if ((frames = snd_pcm_readi(u->pcm_handle, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length / u->frame_size)) < 0) {
if (frames == -EAGAIN)
return;
if (frames == -EPIPE) {
if (xrun_recovery(u) < 0)
return;
continue;
}
@ -180,7 +180,7 @@ static void do_read(struct userdata *u) {
}
l = frames * u->frame_size;
post_memchunk = u->memchunk;
post_memchunk.length = l;
@ -188,13 +188,13 @@ static void do_read(struct userdata *u) {
u->memchunk.index += l;
u->memchunk.length -= l;
if (u->memchunk.length == 0) {
pa_memblock_unref(u->memchunk.memblock);
u->memchunk.memblock = NULL;
u->memchunk.index = u->memchunk.length = 0;
}
break;
}
}
@ -223,7 +223,7 @@ static int mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) {
u->source->get_hw_volume(u->source);
if (u->source->get_hw_mute)
u->source->get_hw_mute(u->source);
pa_subscription_post(u->source->core,
PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE,
u->source->index);
@ -256,14 +256,14 @@ static int source_get_hw_volume_cb(pa_source *s) {
for (i = 0;i < s->hw_volume.channels;i++) {
long set_vol;
assert(snd_mixer_selem_has_capture_channel(u->mixer_elem, i));
if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, i, &vol)) < 0)
goto fail;
set_vol = (long) roundf(((float) s->hw_volume.values[i] * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
/* Try to avoid superfluous volume changes */
if (set_vol != vol)
s->hw_volume.values[i] = (pa_volume_t) roundf(((float) (vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min));
@ -361,7 +361,7 @@ int pa__init(pa_core *c, pa_module*m) {
const char *name;
char *name_buf = NULL;
int namereg_fail;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
@ -378,17 +378,17 @@ int pa__init(pa_core *c, pa_module*m) {
/* Fix latency to 100ms */
periods = 12;
fragsize = pa_bytes_per_second(&ss)/128;
if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) {
pa_log("failed to parse buffer metrics");
goto fail;
}
period_size = fragsize/frame_size;
u = pa_xnew0(struct userdata, 1);
m->userdata = u;
u->module = m;
snd_config_update_free_global();
if ((err = snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)) < 0) {
pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err));
@ -427,7 +427,7 @@ int pa__init(pa_core *c, pa_module*m) {
name = name_buf = pa_sprintf_malloc("alsa_input.%s", dev);
namereg_fail = 0;
}
if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map))) {
pa_log("Failed to create source object");
goto fail;
@ -490,7 +490,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->memchunk.index = u->memchunk.length = 0;
snd_pcm_start(u->pcm_handle);
ret = 0;
/* Get initial mixer settings */
@ -507,11 +507,11 @@ finish:
if (pcm_info)
snd_pcm_info_free(pcm_info);
return ret;
fail:
if (u)
pa__done(c, m);
@ -526,10 +526,10 @@ void pa__done(pa_core *c, pa_module*m) {
return;
clear_up(u);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -48,7 +48,7 @@ static const char* const valid_modargs[] = {
static void eof_and_unload_cb(pa_cli*c, void *userdata) {
pa_module *m = userdata;
assert(c);
assert(m);
@ -68,7 +68,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_iochannel *io;
pa_modargs *ma;
int exit_on_eof = 0;
assert(c);
assert(m);
@ -81,7 +81,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments.");
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "exit_on_eof", &exit_on_eof) < 0) {
pa_log("exit_on_eof= expects boolean argument.");
goto fail;
@ -102,7 +102,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m);
pa_modargs_free(ma);
return 0;
fail:

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -91,7 +91,7 @@ struct userdata {
struct output *master;
pa_time_event *time_event;
uint32_t adjust_time;
PA_LLIST_HEAD(struct output, outputs);
};
@ -110,9 +110,9 @@ static void adjust_rates(struct userdata *u) {
for (o = u->outputs; o; o = o->next) {
uint32_t sink_latency = o->sink_input->sink ? pa_sink_get_latency(o->sink_input->sink) : 0;
o->total_latency = sink_latency + pa_sink_input_get_latency(o->sink_input);
if (sink_latency > max_sink_latency)
max_sink_latency = sink_latency;
@ -123,14 +123,14 @@ static void adjust_rates(struct userdata *u) {
assert(min_total_latency != (pa_usec_t) -1);
target_latency = max_sink_latency > min_total_latency ? max_sink_latency : min_total_latency;
pa_log_info("[%s] target latency is %0.0f usec.", u->sink->name, (float) target_latency);
base_rate = u->sink->sample_spec.rate;
for (o = u->outputs; o; o = o->next) {
uint32_t r = base_rate;
uint32_t r = base_rate;
if (o->total_latency < target_latency)
r -= (uint32_t) (((((double) target_latency - o->total_latency))/u->adjust_time)*r/ 1000000);
else if (o->total_latency > target_latency)
@ -151,7 +151,7 @@ static void request_memblock(struct userdata *u) {
assert(u && u->sink);
update_usage(u);
if (pa_sink_render(u->sink, RENDER_SIZE, &chunk) < 0)
return;
@ -179,10 +179,10 @@ static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk) {
if (pa_memblockq_peek(o->memblockq, chunk) >= 0)
return 0;
/* Try harder */
request_memblock(o->userdata);
return pa_memblockq_peek(o->memblockq, chunk);
}
@ -204,7 +204,7 @@ static void sink_input_kill_cb(pa_sink_input *i) {
static pa_usec_t sink_input_get_latency_cb(pa_sink_input *i) {
struct output *o = i->userdata;
assert(i && o && o->sink_input);
return pa_bytes_to_usec(pa_memblockq_get_length(o->memblockq), &i->sample_spec);
}
@ -220,11 +220,11 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) {
static void sink_notify(pa_sink *s) {
struct userdata *u;
struct output *o;
assert(s);
u = s->userdata;
assert(u);
for (o = u->outputs; o; o = o->next)
pa_sink_notify(o->sink_input->sink);
}
@ -233,12 +233,12 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample
struct output *o = NULL;
char t[256];
pa_sink_input_new_data data;
assert(u && sink && u->sink);
o = pa_xmalloc(sizeof(struct output));
o->userdata = u;
o->counter = 0;
o->memblockq = pa_memblockq_new(
0,
@ -258,7 +258,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample
pa_sink_input_new_data_set_sample_spec(&data, &u->sink->sample_spec);
pa_sink_input_new_data_set_channel_map(&data, &u->sink->channel_map);
data.module = u->module;
if (!(o->sink_input = pa_sink_input_new(u->core, &data, PA_SINK_INPUT_VARIABLE_RATE)))
goto fail;
@ -267,7 +267,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample
o->sink_input->drop = sink_input_drop_cb;
o->sink_input->kill = sink_input_kill_cb;
o->sink_input->userdata = o;
PA_LLIST_PREPEND(struct output, u->outputs, o);
u->n_outputs++;
return o;
@ -282,7 +282,7 @@ fail:
if (o->memblockq)
pa_memblockq_free(o->memblockq);
pa_xfree(o);
}
@ -302,17 +302,17 @@ static void output_free(struct output *o) {
static void clear_up(struct userdata *u) {
struct output *o;
assert(u);
if (u->time_event) {
u->core->mainloop->time_free(u->time_event);
u->time_event = NULL;
}
while ((o = u->outputs))
output_free(o);
u->master = NULL;
if (u->sink) {
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
@ -331,7 +331,7 @@ int pa__init(pa_core *c, pa_module*m) {
int resample_method = -1;
pa_sample_spec ss;
pa_channel_map map;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -345,7 +345,7 @@ int pa__init(pa_core *c, pa_module*m) {
goto fail;
}
}
u = pa_xnew(struct userdata, 1);
m->userdata = u;
u->sink = NULL;
@ -361,7 +361,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse adjust_time value");
goto fail;
}
if (!(master_name = pa_modargs_get_value(ma, "master", NULL)) || !(slaves = pa_modargs_get_value(ma, "slaves", NULL))) {
pa_log("no master or slave sinks specified");
goto fail;
@ -392,7 +392,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("channel map and sample specification don't match.");
goto fail;
}
if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log("failed to create sink");
goto fail;
@ -403,16 +403,16 @@ int pa__init(pa_core *c, pa_module*m) {
u->sink->get_latency = sink_get_latency_cb;
u->sink->notify = sink_notify;
u->sink->userdata = u;
if (!(u->master = output_new(u, master_sink, resample_method))) {
pa_log("failed to create master sink input on sink '%s'.", u->sink->name);
goto fail;
}
split_state = NULL;
while ((n = pa_split(slaves, ",", &split_state))) {
pa_sink *slave_sink;
if (!(slave_sink = pa_namereg_get(c, n, PA_NAMEREG_SINK, 1))) {
pa_log("invalid slave sink '%s'", n);
goto fail;
@ -425,7 +425,7 @@ int pa__init(pa_core *c, pa_module*m) {
goto fail;
}
}
if (u->n_outputs <= 1)
pa_log_warn("WARNING: no slave sinks specified.");
@ -434,13 +434,13 @@ int pa__init(pa_core *c, pa_module*m) {
tv.tv_sec += u->adjust_time;
u->time_event = c->mainloop->time_new(c->mainloop, &tv, time_callback, u);
}
pa_modargs_free(ma);
return 0;
return 0;
fail:
pa_xfree(n);
if (ma)
pa_modargs_free(ma);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -58,7 +58,7 @@ static int detect_alsa(pa_core *c, int just_one) {
if (errno != ENOENT)
pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno));
return -1;
}
@ -66,7 +66,7 @@ static int detect_alsa(pa_core *c, int just_one) {
char line[64], args[64];
unsigned device, subdevice;
int is_sink;
if (!fgets(line, sizeof(line), f))
break;
@ -81,7 +81,7 @@ static int detect_alsa(pa_core *c, int just_one) {
if (just_one && is_sink && n_sink >= 1)
continue;
if (just_one && !is_sink && n_source >= 1)
continue;
@ -105,7 +105,7 @@ static int detect_alsa(pa_core *c, int just_one) {
}
fclose(f);
return n;
}
#endif
@ -114,7 +114,7 @@ static int detect_alsa(pa_core *c, int just_one) {
static int detect_oss(pa_core *c, int just_one) {
FILE *f;
int n = 0, b = 0;
if (!(f = fopen("/dev/sndstat", "r")) &&
!(f = fopen("/proc/sndstat", "r")) &&
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
@ -128,7 +128,7 @@ static int detect_oss(pa_core *c, int just_one) {
while (!feof(f)) {
char line[64], args[64];
unsigned device;
if (!fgets(line, sizeof(line), f))
break;
@ -141,20 +141,20 @@ static int detect_oss(pa_core *c, int just_one) {
if (line[0] == 0)
break;
if (sscanf(line, "%u: ", &device) == 1) {
if (device == 0)
snprintf(args, sizeof(args), "device=/dev/dsp");
else
snprintf(args, sizeof(args), "device=/dev/dsp%u", device);
if (!pa_module_load(c, "module-oss", args))
continue;
} else if (sscanf(line, "pcm%u: ", &device) == 1) {
/* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */
snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device);
if (!pa_module_load(c, "module-oss", args))
continue;
}
@ -219,7 +219,7 @@ int pa__init(pa_core *c, pa_module*m) {
"just-one",
NULL
};
assert(c);
assert(m);
@ -227,14 +227,14 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("Failed to parse module arguments");
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) {
pa_log("just_one= expects a boolean argument.");
goto fail;
}
#if HAVE_ALSA
if ((n = detect_alsa(c, just_one)) <= 0)
if ((n = detect_alsa(c, just_one)) <= 0)
#endif
#if HAVE_OSS
if ((n = detect_oss(c, just_one)) <= 0)
@ -251,7 +251,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_log_info("loaded %i modules.", n);
/* We were successful and can unload ourselves now. */
pa_module_unload_request(m);
@ -262,7 +262,7 @@ int pa__init(pa_core *c, pa_module*m) {
fail:
if (ma)
pa_modargs_free(ma);
return -1;
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -1,17 +1,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -69,7 +69,7 @@ struct userdata {
void *write_data;
size_t write_length, write_index;
void *read_data;
size_t read_length, read_index;
@ -135,7 +135,7 @@ static int do_write(struct userdata *u) {
u->write_index += r;
assert(u->write_index <= u->write_length);
if (u->write_index == u->write_length) {
free(u->write_data);
u->write_data = NULL;
@ -143,13 +143,13 @@ static int do_write(struct userdata *u) {
}
} else if (u->state == STATE_RUNNING) {
pa_module_set_used(u->module, pa_sink_used_by(u->sink));
if (!u->memchunk.length)
if (pa_sink_render(u->sink, 8192, &u->memchunk) < 0)
return 0;
assert(u->memchunk.memblock && u->memchunk.length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) {
pa_log("write() failed: %s", pa_cstrerror(errno));
return -1;
@ -157,13 +157,13 @@ static int do_write(struct userdata *u) {
u->memchunk.index += r;
u->memchunk.length -= r;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
u->memchunk.memblock = NULL;
}
}
return 0;
}
@ -191,7 +191,7 @@ static int handle_response(struct userdata *u) {
assert(u->read_length >= sizeof(int32_t));
u->read_index = 0;
u->read_length = sizeof(int32_t);
break;
case STATE_LATENCY: {
@ -220,10 +220,10 @@ static int handle_response(struct userdata *u) {
pa_xfree(u->read_data);
u->read_data = NULL;
u->read_index = u->read_length = 0;
break;
}
default:
abort();
}
@ -233,18 +233,18 @@ static int handle_response(struct userdata *u) {
static int do_read(struct userdata *u) {
assert(u);
if (!pa_iochannel_is_readable(u->io))
return 0;
if (u->state == STATE_AUTH || u->state == STATE_LATENCY) {
ssize_t r;
if (!u->read_data)
return 0;
assert(u->read_index < u->read_length);
if ((r = pa_iochannel_read(u->io, (uint8_t*) u->read_data + u->read_index, u->read_length - u->read_index)) <= 0) {
pa_log("read() failed: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
cancel(u);
@ -265,7 +265,7 @@ static void do_work(struct userdata *u) {
assert(u);
u->core->mainloop->defer_enable(u->defer_event, 0);
if (do_read(u) < 0 || do_write(u) < 0)
cancel(u);
}
@ -304,13 +304,13 @@ static void on_connection(PA_GCC_UNUSED pa_socket_client *c, pa_iochannel*io, vo
pa_socket_client_unref(u->client);
u->client = NULL;
if (!io) {
pa_log("connection failed: %s", pa_cstrerror(errno));
cancel(u);
return;
}
u->io = io;
pa_iochannel_set_callback(u->io, io_callback, u);
}
@ -321,9 +321,9 @@ int pa__init(pa_core *c, pa_module*m) {
pa_sample_spec ss;
pa_modargs *ma = NULL;
char *t;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
@ -340,7 +340,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("esound sample type support is limited to mono/stereo and U8 or S16NE sample data");
goto fail;
}
u = pa_xmalloc0(sizeof(struct userdata));
u->core = c;
u->module = m;
@ -378,7 +378,7 @@ int pa__init(pa_core *c, pa_module*m) {
/* Reserve space for the response */
u->read_data = pa_xmalloc(u->read_length = sizeof(int32_t));
u->sink->notify = notify_cb;
u->sink->get_latency = get_latency_cb;
u->sink->userdata = u;
@ -392,15 +392,15 @@ int pa__init(pa_core *c, pa_module*m) {
u->defer_event = c->mainloop->defer_new(c->mainloop, defer_callback, u);
c->mainloop->defer_enable(u->defer_event, 0);
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
pa__done(c, m);
return -1;
@ -415,13 +415,13 @@ void pa__done(pa_core *c, pa_module*m) {
u->module = NULL;
cancel(u);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
if (u->client)
pa_socket_client_unref(u->client);
pa_xfree(u->read_data);
pa_xfree(u->write_data);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -58,7 +58,7 @@ typedef enum {
#endif
#ifdef HAVE_OSS
CAP_OSS,
#endif
#endif
CAP_MAX
} capability_t;
@ -181,7 +181,7 @@ static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi,
module_name = "module-alsa-source";
snprintf(args, sizeof(args), "device=hw:%u source_name=alsa_input.%s", card, strip_udi(udi));
}
return pa_module_load(u->core, module_name, args);
}
@ -198,7 +198,7 @@ static dbus_bool_t hal_device_is_oss_pcm(LibHalContext *ctx, const char *udi,
type = libhal_device_get_property_string(ctx, udi, "oss.type", error);
if (!type || dbus_error_is_set(error))
return FALSE;
if (!strcmp(type, "pcm")) {
char *e;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -75,7 +75,7 @@ struct userdata {
pthread_mutex_t mutex;
pthread_cond_t cond;
void * buffer[PA_CHANNELS_MAX];
jack_nframes_t frames_requested;
int quit_requested;
@ -100,7 +100,7 @@ static const char* const valid_modargs[] = {
static void stop_sink(struct userdata *u) {
assert (u);
jack_client_close(u->client);
u->client = NULL;
u->core->mainloop->io_free(u->io_event);
@ -114,7 +114,7 @@ static void stop_sink(struct userdata *u) {
static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_flags_t flags, void *userdata) {
struct userdata *u = userdata;
char x;
assert(m);
assert(e);
assert(flags == PA_IO_EVENT_INPUT);
@ -122,39 +122,39 @@ static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_
assert(u->pipe_fds[0] == fd);
pa_read(fd, &x, 1, &u->pipe_fd_type);
if (u->quit_requested) {
stop_sink(u);
u->quit_requested = 0;
return;
}
pthread_mutex_lock(&u->mutex);
if (u->frames_requested > 0) {
unsigned fs;
jack_nframes_t frame_idx;
pa_memchunk chunk;
fs = pa_frame_size(&u->sink->sample_spec);
pa_sink_render_full(u->sink, u->frames_requested * fs, &chunk);
for (frame_idx = 0; frame_idx < u->frames_requested; frame_idx ++) {
unsigned c;
for (c = 0; c < u->channels; c++) {
float *s = ((float*) ((uint8_t*) chunk.memblock->data + chunk.index)) + (frame_idx * u->channels) + c;
float *d = ((float*) u->buffer[c]) + frame_idx;
*d = *s;
}
}
pa_memblock_unref(chunk.memblock);
u->frames_requested = 0;
pthread_cond_signal(&u->cond);
}
@ -183,36 +183,36 @@ static int jack_process(jack_nframes_t nframes, void *arg) {
if (jack_transport_query(u->client, NULL) == JackTransportRolling) {
unsigned c;
pthread_mutex_lock(&u->mutex);
u->frames_requested = nframes;
for (c = 0; c < u->channels; c++) {
u->buffer[c] = jack_port_get_buffer(u->port[c], nframes);
assert(u->buffer[c]);
}
request_render(u);
pthread_cond_wait(&u->cond, &u->mutex);
u->frames_in_buffer = nframes;
u->timestamp = jack_get_current_transport_frame(u->client);
pthread_mutex_unlock(&u->mutex);
}
return 0;
}
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
struct userdata *u;
jack_nframes_t n, l, d;
assert(s);
u = s->userdata;
if (jack_transport_query(u->client, NULL) != JackTransportRolling)
return 0;
@ -226,7 +226,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) {
if (d >= l)
return 0;
return pa_bytes_to_usec((l - d) * pa_frame_size(&s->sample_spec), &s->sample_spec);
}
@ -246,12 +246,12 @@ int pa__init(pa_core *c, pa_module*m) {
unsigned i;
const char **ports = NULL, **p;
char *t;
assert(c);
assert(m);
jack_set_error_function(jack_error_func);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments.");
goto fail;
@ -261,7 +261,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse connect= argument.");
goto fail;
}
server_name = pa_modargs_get_value(ma, "server_name", NULL);
client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio");
@ -274,28 +274,28 @@ int pa__init(pa_core *c, pa_module*m) {
pthread_mutex_init(&u->mutex, NULL);
pthread_cond_init(&u->cond, NULL);
if (pipe(u->pipe_fds) < 0) {
pa_log("pipe() failed: %s", pa_cstrerror(errno));
goto fail;
}
pa_make_nonblock_fd(u->pipe_fds[1]);
if (!(u->client = jack_client_open(client_name, server_name ? JackServerName : JackNullOption, &status, server_name))) {
pa_log("jack_client_open() failed.");
goto fail;
}
ports = jack_get_ports(u->client, NULL, NULL, JackPortIsPhysical|JackPortIsInput);
channels = 0;
for (p = ports; *p; p++)
channels++;
if (!channels)
channels = c->default_sample_spec.channels;
if (pa_modargs_get_value_u32(ma, "channels", &channels) < 0 || channels <= 0 || channels >= PA_CHANNELS_MAX) {
pa_log("failed to parse channels= argument.");
goto fail;
@ -306,7 +306,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse channel_map= argument.");
goto fail;
}
pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client));
ss.channels = u->channels = channels;
@ -350,7 +350,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_log_info("connecting %s to %s", jack_port_name(u->port[i]), *p);
if (jack_connect(u->client, jack_port_name(u->port[i]), *p)) {
pa_log("failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p);
break;
@ -360,10 +360,10 @@ int pa__init(pa_core *c, pa_module*m) {
}
u->io_event = c->mainloop->io_new(c->mainloop, u->pipe_fds[0], PA_IO_EVENT_INPUT, io_event_cb, u);
free(ports);
pa_modargs_free(ma);
return 0;
fail:
@ -371,7 +371,7 @@ fail:
pa_modargs_free(ma);
free(ports);
pa__done(c, m);
return -1;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -75,7 +75,7 @@ struct userdata {
pthread_mutex_t mutex;
pthread_cond_t cond;
void * buffer[PA_CHANNELS_MAX];
jack_nframes_t frames_posted;
int quit_requested;
@ -100,7 +100,7 @@ static const char* const valid_modargs[] = {
static void stop_source(struct userdata *u) {
assert (u);
jack_client_close(u->client);
u->client = NULL;
u->core->mainloop->io_free(u->io_event);
@ -114,39 +114,39 @@ static void stop_source(struct userdata *u) {
static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_flags_t flags, void *userdata) {
struct userdata *u = userdata;
char x;
assert(m);
assert(flags == PA_IO_EVENT_INPUT);
assert(u);
assert(u->pipe_fds[0] == fd);
pa_read(fd, &x, 1, &u->pipe_fd_type);
if (u->quit_requested) {
stop_source(u);
u->quit_requested = 0;
return;
}
pthread_mutex_lock(&u->mutex);
if (u->frames_posted > 0) {
unsigned fs;
jack_nframes_t frame_idx;
pa_memchunk chunk;
fs = pa_frame_size(&u->source->sample_spec);
chunk.memblock = pa_memblock_new(u->core->mempool, chunk.length = u->frames_posted * fs);
chunk.index = 0;
for (frame_idx = 0; frame_idx < u->frames_posted; frame_idx ++) {
unsigned c;
for (c = 0; c < u->channels; c++) {
float *s = ((float*) u->buffer[c]) + frame_idx;
float *d = ((float*) ((uint8_t*) chunk.memblock->data + chunk.index)) + (frame_idx * u->channels) + c;
*d = *s;
}
}
@ -155,7 +155,7 @@ static void io_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event_
pa_memblock_unref(chunk.memblock);
u->frames_posted = 0;
pthread_cond_signal(&u->cond);
}
@ -184,36 +184,36 @@ static int jack_process(jack_nframes_t nframes, void *arg) {
if (jack_transport_query(u->client, NULL) == JackTransportRolling) {
unsigned c;
pthread_mutex_lock(&u->mutex);
u->frames_posted = nframes;
for (c = 0; c < u->channels; c++) {
u->buffer[c] = jack_port_get_buffer(u->port[c], nframes);
assert(u->buffer[c]);
}
request_post(u);
pthread_cond_wait(&u->cond, &u->mutex);
u->frames_in_buffer = nframes;
u->timestamp = jack_get_current_transport_frame(u->client);
pthread_mutex_unlock(&u->mutex);
}
return 0;
}
static pa_usec_t source_get_latency_cb(pa_source *s) {
struct userdata *u;
jack_nframes_t n, l, d;
assert(s);
u = s->userdata;
if (jack_transport_query(u->client, NULL) != JackTransportRolling)
return 0;
@ -224,7 +224,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) {
d = n - u->timestamp;
l = jack_port_get_total_latency(u->client, u->port[0]);
return pa_bytes_to_usec((l + d) * pa_frame_size(&s->sample_spec), &s->sample_spec);
}
@ -244,12 +244,12 @@ int pa__init(pa_core *c, pa_module*m) {
unsigned i;
const char **ports = NULL, **p;
char *t;
assert(c);
assert(m);
jack_set_error_function(jack_error_func);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments.");
goto fail;
@ -259,7 +259,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse connect= argument.");
goto fail;
}
server_name = pa_modargs_get_value(ma, "server_name", NULL);
client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio");
@ -272,28 +272,28 @@ int pa__init(pa_core *c, pa_module*m) {
pthread_mutex_init(&u->mutex, NULL);
pthread_cond_init(&u->cond, NULL);
if (pipe(u->pipe_fds) < 0) {
pa_log("pipe() failed: %s", pa_cstrerror(errno));
goto fail;
}
pa_make_nonblock_fd(u->pipe_fds[1]);
if (!(u->client = jack_client_open(client_name, server_name ? JackServerName : JackNullOption, &status, server_name))) {
pa_log("jack_client_open() failed.");
goto fail;
}
ports = jack_get_ports(u->client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput);
channels = 0;
for (p = ports; *p; p++)
channels++;
if (!channels)
channels = c->default_sample_spec.channels;
if (pa_modargs_get_value_u32(ma, "channels", &channels) < 0 || channels <= 0 || channels >= PA_CHANNELS_MAX) {
pa_log("failed to parse channels= argument.");
goto fail;
@ -304,7 +304,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse channel_map= argument.");
goto fail;
}
pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client));
ss.channels = u->channels = channels;
@ -348,7 +348,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_log_info("connecting %s to %s", jack_port_name(u->port[i]), *p);
if (jack_connect(u->client, *p, jack_port_name(u->port[i]))) {
pa_log("failed to connect %s to %s, leaving unconnected.", jack_port_name(u->port[i]), *p);
break;
@ -358,10 +358,10 @@ int pa__init(pa_core *c, pa_module*m) {
}
u->io_event = c->mainloop->io_new(c->mainloop, u->pipe_fds[0], PA_IO_EVENT_INPUT, io_event_cb, u);
free(ports);
pa_modargs_free(ma);
return 0;
fail:
@ -369,7 +369,7 @@ fail:
pa_modargs_free(ma);
free(ports);
pa__done(c, m);
return -1;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -73,20 +73,20 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_log("lost connection to LIRC daemon.");
goto fail;
}
if (events & PA_IO_EVENT_INPUT) {
char *c;
if (lirc_nextcode(&code) != 0 || !code) {
pa_log("lirc_nextcode() failed.");
goto fail;
}
c = pa_xstrdup(code);
c[strcspn(c, "\n\r")] = 0;
pa_log_debug("raw IR code '%s'", c);
pa_xfree(c);
while (lirc_code2char(u->config, code, &name) == 0 && name) {
enum {
INVALID,
@ -96,9 +96,9 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
RESET,
MUTE_TOGGLE
} volchange = INVALID;
pa_log_info("translated IR code '%s'", name);
if (strcasecmp(name, "volume-up") == 0)
volchange = UP;
else if (strcasecmp(name, "volume-down") == 0)
@ -109,12 +109,12 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
volchange = MUTE_TOGGLE;
else if (strcasecmp(name, "reset") == 0)
volchange = RESET;
if (volchange == INVALID)
pa_log_warn("recieved unknown IR code '%s'", name);
else {
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
pa_log("failed to get sink '%s'", u->sink_name);
else {
@ -134,7 +134,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
break;
case DOWN:
for (i = 0; i < cv.channels; i++) {
if (cv.values[i] >= DELTA)
@ -142,18 +142,18 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
else
cv.values[i] = PA_VOLUME_MUTED;
}
pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
break;
case MUTE:
pa_sink_set_mute(s, PA_MIXER_HARDWARE, 0);
break;
case RESET:
pa_sink_set_mute(s, PA_MIXER_HARDWARE, 1);
break;
case MUTE_TOGGLE:
pa_sink_set_mute(s, PA_MIXER_HARDWARE, !pa_sink_get_mute(s, PA_MIXER_HARDWARE));
@ -170,7 +170,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_xfree(code);
return;
fail:
u->module->core->mainloop->io_free(u->io);
u->io = NULL;
@ -179,7 +179,7 @@ fail:
free(code);
}
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
@ -189,7 +189,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("module-lirc may no be loaded twice.");
return -1;
}
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
@ -212,13 +212,13 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("lirc_readconfig() failed.");
goto fail;
}
u->io = c->mainloop->io_new(c->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
lirc_in_use = 1;
pa_modargs_free(ma);
return 0;
fail:

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -88,7 +88,7 @@ static int load_rules(struct userdata *u, const char *filename) {
}
pa_lock_fd(fileno(f), 1);
while (!feof(f)) {
char *d, *v;
pa_volume_t volume;
@ -96,12 +96,12 @@ static int load_rules(struct userdata *u, const char *filename) {
regex_t regex;
char ln[256];
struct rule *rule;
if (!fgets(ln, sizeof(ln), f))
break;
n++;
pa_strip_nl(ln);
if (ln[0] == '#' || !*ln )
@ -110,7 +110,7 @@ static int load_rules(struct userdata *u, const char *filename) {
d = ln+strcspn(ln, WHITESPACE);
v = d+strspn(d, WHITESPACE);
if (!*v) {
pa_log(__FILE__ ": [%s:%u] failed to parse line - too few words", filename, n);
goto finish;
@ -124,7 +124,7 @@ static int load_rules(struct userdata *u, const char *filename) {
volume = (pa_volume_t) k;
if (regcomp(&regex, ln, REG_EXTENDED|REG_NOSUB) != 0) {
pa_log("[%s:%u] invalid regular expression", filename, n);
goto finish;
@ -140,12 +140,12 @@ static int load_rules(struct userdata *u, const char *filename) {
else
u->rules = rule;
end = rule;
*d = 0;
}
ret = 0;
finish:
if (f) {
pa_lock_fd(fileno(f), 0);
@ -172,7 +172,7 @@ static void callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, v
if (!si->name)
return;
for (r = u->rules; r; r = r->next) {
if (!regexec(&r->regex, si->name, 0, NULL, 0)) {
pa_cvolume cv;
@ -197,7 +197,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->rules = NULL;
u->subscription = NULL;
m->userdata = u;
if (load_rules(u, pa_modargs_get_value(ma, "table", NULL)) < 0)
goto fail;
@ -224,7 +224,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (u->subscription)
pa_subscription_free(u->subscription);
for (r = u->rules; r; r = n) {
n = r->next;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -85,7 +85,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_log("lost connection to evdev device.");
goto fail;
}
if (events & PA_IO_EVENT_INPUT) {
struct input_event ev;
@ -107,15 +107,15 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
if (volchange != INVALID) {
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
pa_log("failed to get sink '%s'", u->sink_name);
else {
int i;
pa_cvolume cv = *pa_sink_get_volume(s, PA_MIXER_HARDWARE);
#define DELTA (PA_VOLUME_NORM/20)
switch (volchange) {
case UP:
for (i = 0; i < cv.channels; i++) {
@ -127,7 +127,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
break;
case DOWN:
for (i = 0; i < cv.channels; i++) {
if (cv.values[i] >= DELTA)
@ -135,10 +135,10 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
else
cv.values[i] = PA_VOLUME_MUTED;
}
pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
break;
case MUTE_TOGGLE:
pa_sink_set_mute(s, PA_MIXER_HARDWARE, !pa_sink_get_mute(s, PA_MIXER_HARDWARE));
@ -153,7 +153,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
}
return;
fail:
u->module->core->mainloop->io_free(u->io);
u->io = NULL;
@ -162,7 +162,7 @@ fail:
}
#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
@ -226,7 +226,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->io = c->mainloop->io_new(c->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
pa_modargs_free(ma);
return 0;
fail:

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -61,7 +61,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("invalid file descriptor.");
goto finish;
}
io = pa_iochannel_new(c->mainloop, fd, fd);
if (!(m->userdata = pa_protocol_native_new_iochannel(c, io, m, ma))) {
@ -74,7 +74,7 @@ int pa__init(pa_core *c, pa_module*m) {
finish:
if (ma)
pa_modargs_free(ma);
return r;
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -115,10 +115,10 @@ int pa__init(pa_core *c, pa_module*m) {
pa_sample_spec ss;
pa_channel_map map;
pa_modargs *ma = NULL;
assert(c);
assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments.");
goto fail;
@ -129,12 +129,12 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("invalid sample format specification or channel map.");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
u->core = c;
u->module = m;
m->userdata = u;
if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log("failed to create sink.");
goto fail;
@ -147,19 +147,19 @@ int pa__init(pa_core *c, pa_module*m) {
u->n_bytes = 0;
pa_gettimeofday(&u->start_time);
u->time_event = c->mainloop->time_new(c->mainloop, &u->start_time, time_callback, u);
u->block_size = pa_bytes_per_second(&ss) / 10;
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
pa__done(c, m);
return -1;
@ -171,7 +171,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (!(u = m->userdata))
return;
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -113,7 +113,7 @@ static const char* const valid_modargs[] = {
#define DEFAULT_FRAGSIZE 1024
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
pa_module_set_used(u->module,
(u->sink ? pa_sink_used_by(u->sink) : 0) +
(u->source ? pa_source_used_by(u->source) : 0));
}
@ -126,7 +126,7 @@ static void clear_up(struct userdata *u) {
pa_sink_unref(u->sink);
u->sink = NULL;
}
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
@ -137,12 +137,12 @@ static void clear_up(struct userdata *u) {
munmap(u->in_mmap, u->in_mmap_length);
u->in_mmap = NULL;
}
if (u->out_mmap && u->out_mmap != MAP_FAILED) {
munmap(u->out_mmap, u->out_mmap_length);
u->out_mmap = NULL;
}
if (u->io_event) {
u->core->mainloop->io_free(u->io_event);
u->io_event = NULL;
@ -156,13 +156,13 @@ static void clear_up(struct userdata *u) {
static void out_fill_memblocks(struct userdata *u, unsigned n) {
assert(u && u->out_memblocks);
while (n > 0) {
pa_memchunk chunk;
if (u->out_memblocks[u->out_current])
pa_memblock_unref_fixed(u->out_memblocks[u->out_current]);
chunk.memblock = u->out_memblocks[u->out_current] =
pa_memblock_new_fixed(
u->core->mempool,
@ -172,13 +172,13 @@ static void out_fill_memblocks(struct userdata *u, unsigned n) {
assert(chunk.memblock);
chunk.length = chunk.memblock->length;
chunk.index = 0;
pa_sink_render_into_full(u->sink, &chunk);
u->out_current++;
while (u->out_current >= u->out_fragments)
u->out_current -= u->out_fragments;
n--;
}
}
@ -188,7 +188,7 @@ static void do_write(struct userdata *u) {
assert(u && u->sink);
update_usage(u);
if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) {
pa_log("SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno));
@ -199,31 +199,31 @@ static void do_write(struct userdata *u) {
info.blocks += u->out_blocks_saved;
u->out_blocks_saved = 0;
if (!info.blocks)
return;
out_fill_memblocks(u, info.blocks);
}
static void in_post_memblocks(struct userdata *u, unsigned n) {
assert(u && u->in_memblocks);
while (n > 0) {
pa_memchunk chunk;
if (!u->in_memblocks[u->in_current]) {
chunk.memblock = u->in_memblocks[u->in_current] = pa_memblock_new_fixed(u->core->mempool, (uint8_t*) u->in_mmap+u->in_fragment_size*u->in_current, u->in_fragment_size, 1);
chunk.length = chunk.memblock->length;
chunk.index = 0;
pa_source_post(u->source, &chunk);
}
u->in_current++;
while (u->in_current >= u->in_fragments)
u->in_current -= u->in_fragments;
n--;
}
}
@ -234,7 +234,7 @@ static void in_clear_memblocks(struct userdata*u, unsigned n) {
if (n > u->in_fragments)
n = u->in_fragments;
while (n > 0) {
if (u->in_memblocks[i]) {
pa_memblock_unref_fixed(u->in_memblocks[i]);
@ -254,7 +254,7 @@ static void do_read(struct userdata *u) {
assert(u && u->source);
update_usage(u);
if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) {
pa_log("SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno));
@ -265,10 +265,10 @@ static void do_read(struct userdata *u) {
info.blocks += u->in_blocks_saved;
u->in_blocks_saved = 0;
if (!info.blocks)
return;
in_post_memblocks(u, info.blocks);
in_clear_memblocks(u, u->in_fragments/2);
}
@ -311,7 +311,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) {
n = bpos - info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->out_fragment_size, u->out_fragments); */
return pa_bytes_to_usec(n, &s->sample_spec);
}
@ -337,7 +337,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) {
n = (u->in_fragments * u->in_fragment_size) - bpos + info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->in_fragment_size, u->in_fragments); */
return pa_bytes_to_usec(n, &s->sample_spec);
}
@ -416,7 +416,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments.");
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) {
pa_log("record= and playback= expect numeric arguments.");
goto fail;
@ -460,7 +460,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (nfrags >= 2 && frag_size >= 1)
if (pa_oss_set_fragments(u->fd, nfrags, frag_size) < 0)
goto fail;
if (pa_oss_auto_format(u->fd, &u->sample_spec) < 0)
goto fail;
@ -491,7 +491,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map)))
goto fail;
u->source->userdata = u;
u->source->get_latency = source_get_latency_cb;
u->source->get_hw_volume = source_get_hw_volume;
@ -504,22 +504,22 @@ int pa__init(pa_core *c, pa_module*m) {
hwdesc[0] ? ")" : ""));
pa_xfree(t);
u->source->is_hardware = 1;
u->in_memblocks = pa_xnew0(pa_memblock*, u->in_fragments);
enable_bits |= PCM_ENABLE_INPUT;
}
}
pa_xfree(name_buf);
name_buf = NULL;
if (mode != O_RDONLY) {
if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
pa_log("SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno));
goto fail;
}
pa_log_info("output -- %u fragments of size %u.", info.fragstotal, info.fragsize);
u->out_mmap_length = (u->out_fragment_size = info.fragsize) * (u->out_fragments = info.fragstotal);
@ -540,7 +540,7 @@ int pa__init(pa_core *c, pa_module*m) {
name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p));
namereg_fail = 0;
}
if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map)))
goto fail;
@ -555,28 +555,28 @@ int pa__init(pa_core *c, pa_module*m) {
hwdesc[0] ? hwdesc : "",
hwdesc[0] ? ")" : ""));
pa_xfree(t);
u->sink->is_hardware = 1;
u->out_memblocks = pa_xmalloc0(sizeof(struct memblock *)*u->out_fragments);
enable_bits |= PCM_ENABLE_OUTPUT;
}
}
pa_xfree(name_buf);
name_buf = NULL;
zero = 0;
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &zero) < 0) {
pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) < 0) {
pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
assert(u->source || u->sink);
u->io_event = c->mainloop->io_new(c->mainloop, u->fd, (u->source ? PA_IO_EVENT_INPUT : 0) | (u->sink ? PA_IO_EVENT_OUTPUT : 0), io_callback, u);
@ -589,7 +589,7 @@ int pa__init(pa_core *c, pa_module*m) {
source_get_hw_volume(u->source);
if (u->sink)
sink_get_hw_volume(u->sink);
return 0;
fail:
@ -599,13 +599,13 @@ fail:
pa_modargs_free(ma);
pa_xfree(name_buf);
return -1;
}
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);
@ -629,6 +629,6 @@ void pa__done(pa_core *c, pa_module*m) {
pa_memblock_unref_fixed(u->in_memblocks[i]);
pa_xfree(u->in_memblocks);
}
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -100,20 +100,20 @@ static const char* const valid_modargs[] = {
#define DEFAULT_DEVICE "/dev/dsp"
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
pa_module_set_used(u->module,
(u->sink ? pa_sink_used_by(u->sink) : 0) +
(u->source ? pa_source_used_by(u->source) : 0));
}
static void clear_up(struct userdata *u) {
assert(u);
if (u->sink) {
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
u->sink = NULL;
}
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
@ -131,7 +131,7 @@ static void do_write(struct userdata *u) {
ssize_t r;
size_t l;
int loop = 0;
assert(u);
if (!u->sink || !pa_iochannel_is_writable(u->io))
@ -140,10 +140,10 @@ static void do_write(struct userdata *u) {
update_usage(u);
l = u->out_fragment_size;
if (u->use_getospace) {
audio_buf_info info;
if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
u->use_getospace = 0;
else {
@ -156,15 +156,15 @@ static void do_write(struct userdata *u) {
do {
memchunk = &u->memchunk;
if (!memchunk->length)
if (pa_sink_render(u->sink, l, memchunk) < 0)
memchunk = &u->silence;
assert(memchunk->memblock);
assert(memchunk->memblock->data);
assert(memchunk->length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) memchunk->memblock->data + memchunk->index, memchunk->length)) < 0) {
pa_log("write() failed: %s", pa_cstrerror(errno));
@ -172,13 +172,13 @@ static void do_write(struct userdata *u) {
pa_module_unload_request(u->module);
break;
}
if (memchunk == &u->silence)
assert(r % u->sample_size == 0);
else {
u->memchunk.index += r;
u->memchunk.length -= r;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
u->memchunk.memblock = NULL;
@ -195,7 +195,7 @@ static void do_read(struct userdata *u) {
size_t l;
int loop = 0;
assert(u);
if (!u->source || !pa_iochannel_is_readable(u->io) || !pa_idxset_size(u->source->outputs))
return;
@ -205,7 +205,7 @@ static void do_read(struct userdata *u) {
if (u->use_getispace) {
audio_buf_info info;
if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0)
u->use_getispace = 0;
else {
@ -215,7 +215,7 @@ static void do_read(struct userdata *u) {
}
}
}
do {
memchunk.memblock = pa_memblock_new(u->core->mempool, l);
assert(memchunk.memblock);
@ -228,11 +228,11 @@ static void do_read(struct userdata *u) {
}
break;
}
assert(r <= (ssize_t) memchunk.memblock->length);
memchunk.length = memchunk.memblock->length = r;
memchunk.index = 0;
pa_source_post(u->source, &memchunk);
pa_memblock_unref(memchunk.memblock);
@ -280,12 +280,12 @@ static pa_usec_t source_get_latency_cb(pa_source *s) {
if (!u->use_getispace)
return 0;
if (ioctl(u->fd, SNDCTL_DSP_GETISPACE, &info) < 0) {
u->use_getispace = 0;
return 0;
}
if (info.bytes <= 0)
return 0;
@ -355,7 +355,7 @@ int pa__init(pa_core *c, pa_module*m) {
const char *name;
char *name_buf = NULL;
int namereg_fail;
assert(c);
assert(m);
@ -363,7 +363,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments.");
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) {
pa_log("record= and playback= expect numeric argument.");
goto fail;
@ -381,11 +381,11 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse sample specification or channel map");
goto fail;
}
/* Fix latency to 100ms */
nfrags = 12;
frag_size = pa_bytes_per_second(&ss)/128;
if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) {
pa_log("failed to parse fragments arguments");
goto fail;
@ -398,12 +398,12 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log_info("hardware name is '%s'.", hwdesc);
else
hwdesc[0] = 0;
pa_log_info("device opened in %s mode.", mode == O_WRONLY ? "O_WRONLY" : (mode == O_RDONLY ? "O_RDONLY" : "O_RDWR"));
if (nfrags >= 2 && frag_size >= 1)
if (pa_oss_set_fragments(fd, nfrags, frag_size) < 0)
goto fail;
if (pa_oss_set_fragments(fd, nfrags, frag_size) < 0)
goto fail;
if (pa_oss_auto_format(fd, &ss) < 0)
goto fail;
@ -418,7 +418,7 @@ int pa__init(pa_core *c, pa_module*m) {
u = pa_xmalloc(sizeof(struct userdata));
u->core = c;
u->use_getospace = u->use_getispace = 0;
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) >= 0) {
pa_log_info("input -- %u fragments of size %u.", info.fragstotal, info.fragsize);
in_frag_size = info.fragsize;
@ -438,7 +438,7 @@ int pa__init(pa_core *c, pa_module*m) {
name = name_buf = pa_sprintf_malloc("oss_input.%s", pa_path_get_filename(p));
namereg_fail = 0;
}
if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map)))
goto fail;
@ -468,7 +468,7 @@ int pa__init(pa_core *c, pa_module*m) {
name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p));
namereg_fail = 0;
}
if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map)))
goto fail;
@ -489,7 +489,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_xfree(name_buf);
name_buf = NULL;
assert(u->source || u->sink);
u->io = pa_iochannel_new(c->mainloop, u->source ? fd : -1, u->sink ? fd : -1);
@ -539,13 +539,13 @@ fail:
pa_modargs_free(ma);
pa_xfree(name_buf);
return -1;
}
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);
@ -553,7 +553,7 @@ void pa__done(pa_core *c, pa_module*m) {
return;
clear_up(u);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
if (u->silence.memblock)

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -63,7 +63,7 @@ struct userdata {
pa_core *core;
char *filename;
pa_sink *sink;
pa_iochannel *io;
pa_defer_event *defer_event;
@ -87,18 +87,18 @@ static void do_write(struct userdata *u) {
assert(u);
u->core->mainloop->defer_enable(u->defer_event, 0);
if (!pa_iochannel_is_writable(u->io))
return;
pa_module_set_used(u->module, pa_sink_used_by(u->sink));
if (!u->memchunk.length)
if (pa_sink_render(u->sink, PIPE_BUF, &u->memchunk) < 0)
return;
assert(u->memchunk.memblock && u->memchunk.length);
if ((r = pa_iochannel_write(u->io, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length)) < 0) {
pa_log("write(): %s", pa_cstrerror(errno));
return;
@ -106,7 +106,7 @@ static void do_write(struct userdata *u) {
u->memchunk.index += r;
u->memchunk.length -= r;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
u->memchunk.memblock = NULL;
@ -149,9 +149,9 @@ int pa__init(pa_core *c, pa_module*m) {
pa_channel_map map;
pa_modargs *ma = NULL;
char *t;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
@ -162,7 +162,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("invalid sample format specification");
goto fail;
}
mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777);
if ((fd = open(p, O_RDWR)) < 0) {
@ -171,7 +171,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_fd_set_cloexec(fd, 1);
if (fstat(fd, &st) < 0) {
pa_log("fstat('%s'): %s", p, pa_cstrerror(errno));
goto fail;
@ -187,7 +187,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->core = c;
u->module = m;
m->userdata = u;
if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log("failed to create sink.");
goto fail;
@ -211,13 +211,13 @@ int pa__init(pa_core *c, pa_module*m) {
c->mainloop->defer_enable(u->defer_event, 0);
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
if (fd >= 0)
close(fd);
@ -232,10 +232,10 @@ void pa__done(pa_core *c, pa_module*m) {
if (!(u = m->userdata))
return;
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
pa_iochannel_free(u->io);
@ -244,6 +244,6 @@ void pa__done(pa_core *c, pa_module*m) {
assert(u->filename);
unlink(u->filename);
pa_xfree(u->filename);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -63,7 +63,7 @@ struct userdata {
pa_core *core;
char *filename;
pa_source *source;
pa_iochannel *io;
pa_module *module;
@ -127,9 +127,9 @@ int pa__init(pa_core *c, pa_module*m) {
pa_channel_map map;
pa_modargs *ma = NULL;
char *t;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
@ -140,7 +140,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("invalid sample format specification or channel map");
goto fail;
}
mkfifo(p = pa_modargs_get_value(ma, "file", DEFAULT_FIFO_NAME), 0777);
if ((fd = open(p, O_RDWR)) < 0) {
@ -149,7 +149,7 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_fd_set_cloexec(fd, 1);
if (fstat(fd, &st) < 0) {
pa_log("fstat('%s'): %s", p, pa_cstrerror(errno));
goto fail;
@ -164,7 +164,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->filename = pa_xstrdup(p);
u->core = c;
if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
pa_log("failed to create source.");
goto fail;
@ -180,18 +180,18 @@ int pa__init(pa_core *c, pa_module*m) {
u->chunk.memblock = NULL;
u->chunk.index = u->chunk.length = 0;
u->module = m;
m->userdata = u;
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
if (fd >= 0)
close(fd);
@ -206,10 +206,10 @@ void pa__done(pa_core *c, pa_module*m) {
if (!(u = m->userdata))
return;
if (u->chunk.memblock)
pa_memblock_unref(u->chunk.memblock);
pa_source_disconnect(u->source);
pa_source_unref(u->source);
pa_iochannel_free(u->io);
@ -217,6 +217,6 @@ void pa__done(pa_core *c, pa_module*m) {
assert(u->filename);
unlink(u->filename);
pa_xfree(u->filename);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -85,13 +85,13 @@
"record=<enable record?> "
SOCKET_USAGE)
#elif defined(USE_PROTOCOL_CLI)
#include <pulsecore/protocol-cli.h>
#include <pulsecore/protocol-cli.h>
#define protocol_new pa_protocol_cli_new
#define protocol_free pa_protocol_cli_free
#define TCPWRAP_SERVICE "pulseaudio-cli"
#define IPV4_PORT 4712
#define UNIX_SOCKET "cli"
#define MODULE_ARGUMENTS
#define MODULE_ARGUMENTS
#ifdef USE_TCP_SOCKETS
#include "module-cli-protocol-tcp-symdef.h"
#else
@ -106,7 +106,7 @@
#define TCPWRAP_SERVICE "pulseaudio-http"
#define IPV4_PORT 4714
#define UNIX_SOCKET "http"
#define MODULE_ARGUMENTS
#define MODULE_ARGUMENTS
#ifdef USE_TCP_SOCKETS
#include "module-http-protocol-tcp-symdef.h"
#else
@ -129,16 +129,16 @@
#endif
#if defined(HAVE_CREDS) && !defined(USE_TCP_SOCKETS)
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-group", "auth-group-enable",
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-group", "auth-group-enable",
#define AUTH_USAGE "auth-group=<system group to allow access> auth-group-enable=<enable auth by UNIX group?> "
#elif defined(USE_TCP_SOCKETS)
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl",
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl",
#define AUTH_USAGE "auth-ip-acl=<IP address ACL to allow access> "
#else
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON
#define AUTH_USAGE
#endif
PA_MODULE_DESCRIPTION("Native protocol "SOCKET_DESCRIPTION)
PA_MODULE_USAGE("auth-anonymous=<don't check for cookies?> "
"cookie=<path to cookie file> "
@ -160,7 +160,7 @@
#endif
#if defined(USE_TCP_SOCKETS)
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl",
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON "auth-ip-acl",
#define AUTH_USAGE "auth-ip-acl=<IP address ACL to allow access> "
#else
#define MODULE_ARGUMENTS MODULE_ARGUMENTS_COMMON
@ -175,7 +175,7 @@
AUTH_USAGE
SOCKET_USAGE)
#else
#error "Broken build system"
#error "Broken build system"
#endif
PA_MODULE_AUTHOR("Lennart Poettering")
@ -266,21 +266,21 @@ int pa__init(pa_core *c, pa_module*m) {
/* This socket doesn't reside in our own runtime dir but in
* /tmp/.esd/, hence we have to create the dir first */
if (pa_make_secure_parent_dir(u->socket_path, c->is_system_instance ? 0755 : 0700, (uid_t)-1, (gid_t)-1) < 0) {
pa_log("Failed to create socket directory: %s\n", pa_cstrerror(errno));
goto fail;
}
#endif
if ((r = pa_unix_socket_remove_stale(tmp)) < 0) {
pa_log("Failed to remove stale UNIX socket '%s': %s", tmp, pa_cstrerror(errno));
goto fail;
}
if (r)
pa_log("Removed stale UNIX socket '%s'.", tmp);
if (!(s = pa_socket_server_new_unix(c->mainloop, tmp)))
goto fail;
@ -332,7 +332,7 @@ fail:
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);
@ -354,8 +354,8 @@ void pa__done(pa_core *c, pa_module*m) {
pa_xfree(p);
}
#endif
pa_xfree(u->socket_path);
#endif

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -49,7 +49,7 @@ struct userdata {
static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* userdata) {
pa_sink_input *i;
pa_sink *target;
assert(c);
assert(sink);
@ -57,7 +57,7 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
pa_log_debug("No sink inputs to move away.");
return PA_HOOK_OK;
}
if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SINK, 0))) {
pa_log_info("No evacuation sink found.");
return PA_HOOK_OK;
@ -74,14 +74,14 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index, i->name, target->name);
}
return PA_HOOK_OK;
}
static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void* userdata) {
pa_source_output *o;
pa_source *target;
assert(c);
assert(source);
@ -89,7 +89,7 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
pa_log_debug("No source outputs to move away.");
return PA_HOOK_OK;
}
if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE, 0))) {
pa_log_info("No evacuation source found.");
return PA_HOOK_OK;
@ -106,14 +106,14 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index, o->name, target->name);
}
return PA_HOOK_OK;
}
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
assert(c);
assert(m);
@ -132,7 +132,7 @@ int pa__init(pa_core *c, pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -96,7 +96,7 @@ static void calc_sine(float *f, size_t l, float freq) {
size_t i;
l /= sizeof(float);
for (i = 0; i < l; i++)
f[i] = (float) sin((double) i/l*M_PI*2*freq)/2;
}
@ -115,7 +115,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("Failed to parse module arguments");
goto fail;
}
m->userdata = u = pa_xmalloc(sizeof(struct userdata));
u->core = c;
u->module = m;
@ -138,7 +138,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("Invalid frequency specification");
goto fail;
}
u->memblock = pa_memblock_new(c->mempool, pa_bytes_per_second(&ss));
calc_sine(u->memblock->data, u->memblock->length, frequency);
@ -160,10 +160,10 @@ int pa__init(pa_core *c, pa_module*m) {
u->sink_input->userdata = u;
u->peek_index = 0;
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
@ -183,7 +183,7 @@ void pa__done(pa_core *c, pa_module*m) {
pa_sink_input_disconnect(u->sink_input);
pa_sink_input_unref(u->sink_input);
}
if (u->memblock)
pa_memblock_unref(u->memblock);
pa_xfree(u);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -124,7 +124,7 @@ static void do_write(struct userdata *u) {
int err;
size_t len;
ssize_t r;
assert(u);
/* We cannot check pa_iochannel_is_writable() because of our buffer hack */
@ -163,7 +163,7 @@ static void do_write(struct userdata *u) {
}
u->sink_underflow = 0;
assert(u->memchunk.memblock);
assert(u->memchunk.memblock->data);
assert(u->memchunk.length);
@ -181,10 +181,10 @@ static void do_write(struct userdata *u) {
}
assert(r % u->frame_size == 0);
u->memchunk.index += r;
u->memchunk.length -= r;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
u->memchunk.memblock = NULL;
@ -199,7 +199,7 @@ static void do_read(struct userdata *u) {
size_t l;
ssize_t r;
assert(u);
if (!u->source || !pa_iochannel_is_readable(u->io))
return;
@ -221,11 +221,11 @@ static void do_read(struct userdata *u) {
pa_log("read() failed: %s", pa_cstrerror(errno));
return;
}
assert(r <= (ssize_t) memchunk.memblock->length);
memchunk.length = memchunk.memblock->length = r;
memchunk.index = 0;
pa_source_post(u->source, &memchunk);
pa_memblock_unref(memchunk.memblock);
@ -256,7 +256,7 @@ static void timer_cb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *
static void sig_callback(pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata) {
struct userdata *u = userdata;
pa_cvolume old_vol;
assert(u);
if (u->sink) {
@ -518,7 +518,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments.");
goto fail;
}
if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) {
pa_log("record= and playback= expect numeric argument.");
goto fail;
@ -531,7 +531,7 @@ int pa__init(pa_core *c, pa_module*m) {
mode = (playback&&record) ? O_RDWR : (playback ? O_WRONLY : (record ? O_RDONLY : 0));
buffer_size = 16384;
buffer_size = 16384;
if (pa_modargs_get_value_s32(ma, "buffer_size", &buffer_size) < 0) {
pa_log("failed to parse buffer size argument");
goto fail;
@ -542,7 +542,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse sample specification");
goto fail;
}
if ((fd = open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), mode | O_NONBLOCK)) < 0)
goto fail;
@ -642,7 +642,7 @@ fail:
if (ma)
pa_modargs_free(ma);
return -1;
}
@ -657,7 +657,7 @@ void pa__done(pa_core *c, pa_module*m) {
c->mainloop->time_free(u->timer);
ioctl(u->fd, I_SETSIG, 0);
pa_signal_free(u->sig);
if (u->memchunk.memblock)
pa_memblock_unref(u->memchunk.memblock);
@ -665,12 +665,12 @@ void pa__done(pa_core *c, pa_module*m) {
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
}
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
}
pa_iochannel_free(u->io);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -116,10 +116,10 @@ static void command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
#ifdef TUNNEL_SINK
[PA_COMMAND_REQUEST] = command_request,
#endif
#endif
[PA_COMMAND_PLAYBACK_STREAM_KILLED] = command_stream_killed,
[PA_COMMAND_RECORD_STREAM_KILLED] = command_stream_killed,
[PA_COMMAND_SUBSCRIBE_EVENT] = command_subscribe_event,
[PA_COMMAND_SUBSCRIBE_EVENT] = command_subscribe_event,
};
struct userdata {
@ -136,7 +136,7 @@ struct userdata {
char *source_name;
pa_source *source;
#endif
pa_module *module;
pa_core *core;
@ -146,7 +146,7 @@ struct userdata {
uint32_t ctag;
uint32_t device_index;
uint32_t channel;
pa_usec_t host_latency;
pa_time_event *time_event;
@ -156,7 +156,7 @@ struct userdata {
static void close_stuff(struct userdata *u) {
assert(u);
if (u->pstream) {
pa_pstream_close(u->pstream);
pa_pstream_unref(u->pstream);
@ -256,10 +256,10 @@ static void send_bytes(struct userdata *u) {
while (u->requested_bytes > 0) {
pa_memchunk chunk;
if (pa_sink_render(u->sink, u->requested_bytes, &chunk) < 0) {
if (u->requested_bytes >= DEFAULT_TLENGTH-DEFAULT_PREBUF)
if (u->requested_bytes >= DEFAULT_TLENGTH-DEFAULT_PREBUF)
send_prebuf_request(u);
return;
}
@ -293,7 +293,7 @@ static void command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED ui
die(u);
return;
}
u->requested_bytes += bytes;
send_bytes(u);
}
@ -316,7 +316,7 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, PA_G
die(u);
return;
}
if (pa_tagstruct_get_usec(t, &sink_usec) < 0 ||
pa_tagstruct_get_usec(t, &source_usec) < 0 ||
pa_tagstruct_get_boolean(t, &playing) < 0 ||
@ -333,14 +333,14 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, PA_G
pa_gettimeofday(&now);
/* FIXME! This could use some serious love. */
if (pa_timeval_cmp(&local, &remote) < 0 && pa_timeval_cmp(&remote, &now)) {
/* local and remote seem to have synchronized clocks */
#ifdef TUNNEL_SINK
transport_usec = pa_timeval_diff(&remote, &local);
#else
transport_usec = pa_timeval_diff(&now, &remote);
#endif
#endif
} else
transport_usec = pa_timeval_diff(&now, &local)/2;
@ -364,7 +364,7 @@ static void request_latency(struct userdata *u) {
assert(u);
t = pa_tagstruct_new(NULL, 0);
#ifdef TUNNEL_SINK
#ifdef TUNNEL_SINK
pa_tagstruct_putu32(t, PA_COMMAND_GET_PLAYBACK_LATENCY);
#else
pa_tagstruct_putu32(t, PA_COMMAND_GET_RECORD_LATENCY);
@ -374,7 +374,7 @@ static void request_latency(struct userdata *u) {
pa_gettimeofday(&now);
pa_tagstruct_put_timeval(t, &now);
pa_pstream_send_tagstruct(u->pstream, t);
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_latency_callback, u, NULL);
}
@ -496,7 +496,7 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED
assert(m && e && u);
request_latency(u);
pa_gettimeofday(&ntv);
ntv.tv_sec += LATENCY_INTERVAL;
m->time_restart(e, &ntv);
@ -518,16 +518,16 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
if (pa_tagstruct_getu32(t, &u->channel) < 0 ||
pa_tagstruct_getu32(t, &u->device_index) < 0
#ifdef TUNNEL_SINK
#ifdef TUNNEL_SINK
|| pa_tagstruct_getu32(t, &u->requested_bytes) < 0
#endif
#endif
)
goto parse_error;
if (u->version >= 9) {
#ifdef TUNNEL_SINK
uint32_t maxlength, tlength, prebuf, minreq;
if (pa_tagstruct_getu32(t, &maxlength) < 0 ||
pa_tagstruct_getu32(t, &tlength) < 0 ||
pa_tagstruct_getu32(t, &prebuf) < 0 ||
@ -535,13 +535,13 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
goto parse_error;
#else
uint32_t maxlength, fragsize;
if (pa_tagstruct_getu32(t, &maxlength) < 0 ||
pa_tagstruct_getu32(t, &fragsize) < 0)
pa_tagstruct_getu32(t, &fragsize) < 0)
goto parse_error;
#endif
}
if (!pa_tagstruct_eof(t))
goto parse_error;
@ -559,7 +559,7 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
#endif
return;
parse_error:
pa_log("invalid reply. (create stream)");
die(u);
@ -603,7 +603,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_get_user_name(un, sizeof(un)),
u->source->name);
#endif
reply = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME);
pa_tagstruct_putu32(reply, tag = u->ctag++);
@ -612,7 +612,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
/* We ignore the server's reply here */
reply = pa_tagstruct_new(NULL, 0);
#ifdef TUNNEL_SINK
#ifdef TUNNEL_SINK
pa_tagstruct_putu32(reply, PA_COMMAND_CREATE_PLAYBACK_STREAM);
pa_tagstruct_putu32(reply, tag = u->ctag++);
pa_tagstruct_puts(reply, name);
@ -640,7 +640,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_tagstruct_put_boolean(reply, 0);
pa_tagstruct_putu32(reply, DEFAULT_FRAGSIZE);
#endif
pa_pstream_send_tagstruct(u->pstream, reply);
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, create_stream_callback, u, NULL);
}
@ -673,7 +673,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, PA_GCC_UN
die(u);
return;
}
pa_source_post(u->source, chunk);
}
#endif
@ -686,7 +686,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
pa_socket_client_unref(u->client);
u->client = NULL;
if (!io) {
pa_log("connection failed.");
pa_module_unload_request(u->module);
@ -701,7 +701,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
#ifndef TUNNEL_SINK
pa_pstream_set_recieve_memblock_callback(u->pstream, pstream_memblock_callback, u);
#endif
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_AUTH);
pa_tagstruct_putu32(t, tag = u->ctag++);
@ -709,7 +709,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
pa_tagstruct_put_arbitrary(t, u->auth_cookie, sizeof(u->auth_cookie));
pa_pstream_send_tagstruct(u->pstream, t);
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, u, NULL);
}
#ifdef TUNNEL_SINK
@ -862,14 +862,14 @@ static int load_key(struct userdata *u, const char*fn) {
assert(u);
u->auth_cookie_in_property = 0;
if (!fn && pa_authkey_prop_get(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) {
pa_log_debug("using already loaded auth cookie.");
pa_authkey_prop_ref(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME);
u->auth_cookie_in_property = 1;
return 0;
}
if (!fn)
fn = PA_NATIVE_COOKIE_FILE;
@ -877,7 +877,7 @@ static int load_key(struct userdata *u, const char*fn) {
return -1;
pa_log_debug("loading cookie from disk.");
if (pa_authkey_prop_put(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0)
u->auth_cookie_in_property = 1;
@ -890,7 +890,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_sample_spec ss;
pa_channel_map map;
char *t, *dn = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -919,10 +919,10 @@ int pa__init(pa_core *c, pa_module*m) {
u->host_latency = 0;
u->auth_cookie_in_property = 0;
u->time_event = NULL;
if (load_key(u, pa_modargs_get_value(ma, "cookie", NULL)) < 0)
goto fail;
if (!(u->server_name = pa_xstrdup(pa_modargs_get_value(ma, "server", NULL)))) {
pa_log("no server specified.");
goto fail;
@ -938,7 +938,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to connect to server '%s'", u->server_name);
goto fail;
}
if (!u->client)
goto fail;
@ -987,7 +987,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_source_set_owner(u->source, m);
#endif
pa_xfree(dn);
u->time_event = NULL;
@ -995,7 +995,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_modargs_free(ma);
return 0;
fail:
pa__done(c, m);
@ -1003,7 +1003,7 @@ fail:
pa_modargs_free(ma);
pa_xfree(dn);
return -1;
}
@ -1018,7 +1018,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (u->auth_cookie_in_property)
pa_authkey_prop_unref(c, PA_NATIVE_COOKIE_PROPERTY_NAME);
#ifdef TUNNEL_SINK
pa_xfree(u->sink_name);
#else

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -82,7 +82,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) {
char *p;
long k;
unsigned i;
assert(s);
assert(v);
@ -92,7 +92,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) {
k = strtol(s, &p, 0);
if (k <= 0 || k > PA_CHANNELS_MAX)
return NULL;
v->channels = (unsigned) k;
for (i = 0; i < v->channels; i++) {
@ -105,7 +105,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) {
if (k < PA_VOLUME_MUTED)
return NULL;
v->values[i] = (pa_volume_t) k;
}
@ -132,22 +132,22 @@ static int load_rules(struct userdata *u) {
ret = 0;
} else
pa_log("failed to open file '%s': %s", u->table_file, pa_cstrerror(errno));
goto finish;
}
pa_lock_fd(fileno(f), 1);
while (!feof(f)) {
struct rule *rule;
pa_cvolume v;
int v_is_set;
if (!fgets(ln, sizeof(buf_name), f))
break;
n++;
pa_strip_nl(ln);
if (ln[0] == '#')
@ -181,12 +181,12 @@ static int load_rules(struct userdata *u) {
v_is_set = 0;
ln = buf_name;
if (pa_hashmap_get(u->hashmap, buf_name)) {
pa_log("double entry in %s:%u, ignoring", u->table_file, n);
continue;
}
rule = pa_xnew(struct rule, 1);
rule->name = pa_xstrdup(buf_name);
if ((rule->volume_is_set = v_is_set))
@ -203,7 +203,7 @@ static int load_rules(struct userdata *u) {
}
ret = 0;
finish:
if (f) {
pa_lock_fd(fileno(f), 0);
@ -218,7 +218,7 @@ static int save_rules(struct userdata *u) {
int ret = -1;
void *state = NULL;
struct rule *rule;
f = u->table_file ?
fopen(u->table_file, "w") :
pa_open_config_file(NULL, DEFAULT_VOLUME_TABLE_FILE, NULL, &u->table_file, "w");
@ -232,7 +232,7 @@ static int save_rules(struct userdata *u) {
while ((rule = pa_hashmap_iterate(u->hashmap, &state, NULL))) {
unsigned i;
fprintf(f, "%s\n", rule->name);
if (rule->volume_is_set) {
@ -241,14 +241,14 @@ static int save_rules(struct userdata *u) {
for (i = 0; i < rule->volume.channels; i++)
fprintf(f, " %u", rule->volume.values[i]);
}
fprintf(f, "\n%s\n%s\n",
rule->sink ? rule->sink : "",
rule->source ? rule->source : "");
}
ret = 0;
finish:
if (f) {
pa_lock_fd(fileno(f), 0);
@ -260,7 +260,7 @@ finish:
static char* client_name(pa_client *c) {
char *t, *e;
if (!c->name || !c->driver)
return NULL;
@ -280,11 +280,11 @@ static char* client_name(pa_client *c) {
* sessions of the same application, which is something we
* explicitly don't want. Besides other stuff this makes xmms
* with esound work properly for us. */
if (*k == ')' && *(k+1) == 0)
*e = 0;
}
return t;
}
@ -294,7 +294,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
pa_source_output *so = NULL;
struct rule *r;
char *name;
assert(c);
assert(u);
@ -307,7 +307,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK_INPUT) {
if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx)))
return;
if (!si->client || !(name = client_name(si->client)))
return;
} else {
@ -315,7 +315,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (!(so = pa_idxset_get_by_index(c->source_outputs, idx)))
return;
if (!so->client || !(name = client_name(so->client)))
return;
}
@ -348,7 +348,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
u->modified = 1;
}
}
} else {
pa_log_info("Creating new entry for <%s>", name);
@ -366,7 +366,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
r->sink = NULL;
r->source = pa_xstrdup(so->source->name);
}
pa_hashmap_put(u->hashmap, r->name, r);
u->modified = 1;
}
@ -419,7 +419,7 @@ static pa_hook_result_t source_output_hook_callback(pa_core *c, pa_source_output
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
assert(c);
assert(m);
@ -433,9 +433,9 @@ int pa__init(pa_core *c, pa_module*m) {
u->subscription = NULL;
u->table_file = pa_xstrdup(pa_modargs_get_value(ma, "table", NULL));
u->modified = 0;
m->userdata = u;
if (load_rules(u) < 0)
goto fail;
@ -451,7 +451,7 @@ fail:
if (ma)
pa_modargs_free(ma);
return -1;
}
@ -467,7 +467,7 @@ static void free_func(void *p, void *userdata) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata* u;
assert(c);
assert(m);
@ -486,7 +486,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (u->modified)
save_rules(u);
pa_hashmap_free(u->hashmap, free_func, NULL);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -172,7 +172,7 @@ static void do_write(struct userdata *u)
pa_log_error(__FILE__ ": ERROR: Unable to write waveOut block: %d",
res);
}
u->written_bytes += hdr->dwBufferLength;
EnterCriticalSection(&u->crit);
@ -233,7 +233,7 @@ static void do_read(struct userdata *u)
pa_log_error(__FILE__ ": ERROR: Unable to add waveIn block: %d",
res);
}
free_frags--;
u->cur_ihdr++;
u->cur_ihdr %= u->fragments;
@ -561,7 +561,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->ohdrs[i].lpData = pa_xmalloc(u->fragment_size);
assert(u->ohdrs);
}
u->module = m;
m->userdata = u;
@ -585,7 +585,7 @@ fail:
if (ma)
pa_modargs_free(ma);
return -1;
}
@ -597,7 +597,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (!(u = m->userdata))
return;
if (u->event)
c->mainloop->time_free(u->event);
@ -608,12 +608,12 @@ void pa__done(pa_core *c, pa_module*m) {
pa_sink_disconnect(u->sink);
pa_sink_unref(u->sink);
}
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
}
if (u->hwi != INVALID_HANDLE_VALUE) {
waveInReset(u->hwi);
waveInClose(u->hwi);
@ -633,6 +633,6 @@ void pa__done(pa_core *c, pa_module*m) {
pa_xfree(u->ohdrs);
DeleteCriticalSection(&u->crit);
pa_xfree(u);
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -107,19 +107,19 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments");
goto fail;
}
m->userdata = u = pa_xmalloc(sizeof(struct userdata));
u->core = c;
u->scache_item = pa_xstrdup(pa_modargs_get_value(ma, "sample", "x11-bell"));
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
u->x11_client = NULL;
if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
goto fail;
major = XkbMajorVersion;
minor = XkbMinorVersion;
if (!XkbLibraryVersion(&major, &minor)) {
pa_log("XkbLibraryVersion() failed");
goto fail;
@ -140,11 +140,11 @@ int pa__init(pa_core *c, pa_module*m) {
XkbChangeEnabledControls(pa_x11_wrapper_get_display(u->x11_wrapper), XkbUseCoreKbd, XkbAudibleBellMask, 0);
u->x11_client = pa_x11_client_new(u->x11_wrapper, x11_event_callback, u);
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -77,14 +77,14 @@ static int load_key(struct userdata *u, const char*fn) {
assert(u);
u->auth_cookie_in_property = 0;
if (!fn && pa_authkey_prop_get(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0) {
pa_log_debug("using already loaded auth cookie.");
pa_authkey_prop_ref(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME);
u->auth_cookie_in_property = 1;
return 0;
}
if (!fn)
fn = PA_NATIVE_COOKIE_FILE;
@ -92,7 +92,7 @@ static int load_key(struct userdata *u, const char*fn) {
return -1;
pa_log_debug("loading cookie from disk.");
if (pa_authkey_prop_put(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0)
u->auth_cookie_in_property = 1;
@ -121,7 +121,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (load_key(u, pa_modargs_get_value(ma, "cookie", NULL)) < 0)
goto fail;
if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
goto fail;
if (!(l = pa_property_get(c, PA_NATIVE_SERVER_PROPERTY_NAME)))
@ -130,10 +130,10 @@ int pa__init(pa_core *c, pa_module*m) {
s = pa_strlist_tostring(l);
pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER", s);
pa_xfree(s);
if (!pa_get_fqdn(hn, sizeof(hn)) || !pa_get_user_name(un, sizeof(un)))
goto fail;
u->id = pa_sprintf_malloc("%s@%s/%u", un, hn, (unsigned) getpid());
pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id);
@ -144,10 +144,10 @@ int pa__init(pa_core *c, pa_module*m) {
pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK", t);
pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE", pa_hexstr(u->auth_cookie, sizeof(u->auth_cookie), hx, sizeof(hx)));
pa_modargs_free(ma);
return 0;
fail:
if (ma)
pa_modargs_free(ma);
@ -162,7 +162,7 @@ void pa__done(pa_core *c, pa_module*m) {
if (!(u = m->userdata))
return;
if (u->x11_wrapper) {
char t[256];
@ -178,7 +178,7 @@ void pa__done(pa_core *c, pa_module*m) {
XSync(pa_x11_wrapper_get_display(u->x11_wrapper), False);
}
}
if (u->x11_wrapper)
pa_x11_wrapper_unref(u->x11_wrapper);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -153,7 +153,7 @@ static int publish_service(struct userdata *u, struct service *s) {
if (!u->client || avahi_client_get_state(u->client) != AVAHI_CLIENT_S_RUNNING)
return 0;
if ((s->published == PUBLISHED_REAL && s->loaded.valid) ||
(s->published == PUBLISHED_AUTOLOAD && s->autoload.valid && !s->loaded.valid))
return 0;
@ -161,8 +161,8 @@ static int publish_service(struct userdata *u, struct service *s) {
if (s->published != UNPUBLISHED) {
avahi_entry_group_reset(s->entry_group);
s->published = UNPUBLISHED;
}
}
if (s->loaded.valid || s->autoload.valid) {
pa_namereg_type_t type;
@ -172,26 +172,26 @@ static int publish_service(struct userdata *u, struct service *s) {
goto finish;
}
}
txt = avahi_string_list_add_pair(txt, "device", s->name);
txt = txt_record_server_data(u->core, txt);
if (s->loaded.valid) {
char *description;
pa_sample_spec ss;
get_service_data(u, s, &ss, &description);
txt = avahi_string_list_add_printf(txt, "rate=%u", ss.rate);
txt = avahi_string_list_add_printf(txt, "channels=%u", ss.channels);
txt = avahi_string_list_add_pair(txt, "format", pa_sample_format_to_string(ss.format));
if (description)
txt = avahi_string_list_add_pair(txt, "description", description);
type = s->loaded.type;
} else if (s->autoload.valid)
type = s->autoload.type;
if (avahi_entry_group_add_service_strlst(
s->entry_group,
AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
@ -202,24 +202,24 @@ static int publish_service(struct userdata *u, struct service *s) {
NULL,
u->port,
txt) < 0) {
pa_log("avahi_entry_group_add_service_strlst(): %s", avahi_strerror(avahi_client_errno(u->client)));
goto finish;
}
if (avahi_entry_group_commit(s->entry_group) < 0) {
pa_log("avahi_entry_group_commit(): %s", avahi_strerror(avahi_client_errno(u->client)));
goto finish;
}
if (s->loaded.valid)
s->published = PUBLISHED_REAL;
else if (s->autoload.valid)
s->published = PUBLISHED_AUTOLOAD;
}
r = 0;
finish:
if (s->published == UNPUBLISHED) {
@ -227,7 +227,7 @@ finish:
if (s->entry_group)
avahi_entry_group_free(s->entry_group);
pa_hashmap_remove(u->services, s->name);
pa_xfree(s->name);
pa_xfree(s->service_name);
@ -236,17 +236,17 @@ finish:
if (txt)
avahi_string_list_free(txt);
return r;
}
static struct service *get_service(struct userdata *u, const char *name, const char *description) {
struct service *s;
char hn[64];
if ((s = pa_hashmap_get(u->services, name)))
return s;
s = pa_xnew(struct service, 1);
s->userdata = u;
s->entry_group = NULL;
@ -283,7 +283,7 @@ static int publish_sink(struct userdata *u, pa_sink *s) {
static int publish_source(struct userdata *u, pa_source *s) {
struct service *svc;
int ret;
assert(u && s);
svc = get_service(u, s->name, s->description);
@ -295,7 +295,7 @@ static int publish_source(struct userdata *u, pa_source *s) {
svc->loaded.index = s->index;
pa_dynarray_put(u->source_dynarray, s->index, svc);
if ((ret = publish_service(u, svc)) < 0)
return ret;
@ -306,7 +306,7 @@ static int publish_source(struct userdata *u, pa_source *s) {
static int publish_autoload(struct userdata *u, pa_autoload_entry *s) {
struct service *svc;
int ret;
assert(u && s);
svc = get_service(u, s->name, NULL);
@ -319,7 +319,7 @@ static int publish_autoload(struct userdata *u, pa_autoload_entry *s) {
if ((ret = publish_service(u, svc)) < 0)
return ret;
pa_dynarray_put(u->autoload_dynarray, s->index, svc);
return ret;
}
@ -336,14 +336,14 @@ static int remove_sink(struct userdata *u, uint32_t idx) {
svc->loaded.valid = 0;
pa_dynarray_put(u->sink_dynarray, idx, NULL);
return publish_service(u, svc);
}
static int remove_source(struct userdata *u, uint32_t idx) {
struct service *svc;
assert(u && idx != PA_INVALID_INDEX);
if (!(svc = pa_dynarray_get(u->source_dynarray, idx)))
return 0;
@ -359,7 +359,7 @@ static int remove_source(struct userdata *u, uint32_t idx) {
static int remove_autoload(struct userdata *u, uint32_t idx) {
struct service *svc;
assert(u && idx != PA_INVALID_INDEX);
if (!(svc = pa_dynarray_get(u->autoload_dynarray, idx)))
return 0;
@ -389,14 +389,14 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (remove_sink(u, idx) < 0)
goto fail;
}
break;
case PA_SUBSCRIPTION_EVENT_SOURCE:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
pa_source *source;
if ((source = pa_idxset_get_by_index(c->sources, idx))) {
if (publish_source(u, source) < 0)
goto fail;
@ -405,13 +405,13 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (remove_source(u, idx) < 0)
goto fail;
}
break;
case PA_SUBSCRIPTION_EVENT_AUTOLOAD:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
pa_autoload_entry *autoload;
if ((autoload = pa_idxset_get_by_index(c->autoload_idxset, idx))) {
if (publish_autoload(u, autoload) < 0)
goto fail;
@ -420,7 +420,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (remove_autoload(u, idx) < 0)
goto fail;
}
break;
}
@ -453,7 +453,7 @@ static void main_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState s
static int publish_main_service(struct userdata *u) {
AvahiStringList *txt = NULL;
int r = -1;
if (!u->main_entry_group) {
if (!(u->main_entry_group = avahi_entry_group_new(u->client, main_entry_group_callback, u))) {
pa_log("avahi_entry_group_new() failed: %s", avahi_strerror(avahi_client_errno(u->client)));
@ -461,7 +461,7 @@ static int publish_main_service(struct userdata *u) {
}
} else
avahi_entry_group_reset(u->main_entry_group);
txt = txt_record_server_data(u->core, NULL);
if (avahi_entry_group_add_service_strlst(
@ -474,18 +474,18 @@ static int publish_main_service(struct userdata *u) {
NULL,
u->port,
txt) < 0) {
pa_log("avahi_entry_group_add_service_strlst() failed: %s", avahi_strerror(avahi_client_errno(u->client)));
goto fail;
}
if (avahi_entry_group_commit(u->main_entry_group) < 0) {
pa_log("avahi_entry_group_commit() failed: %s", avahi_strerror(avahi_client_errno(u->client)));
goto fail;
}
r = 0;
fail:
avahi_string_list_free(txt);
@ -498,7 +498,7 @@ static int publish_all_services(struct userdata *u) {
pa_autoload_entry *autoload;
int r = -1;
uint32_t idx;
assert(u);
pa_log_debug("Publishing services in Zeroconf");
@ -518,9 +518,9 @@ static int publish_all_services(struct userdata *u) {
if (publish_main_service(u) < 0)
goto fail;
r = 0;
fail:
return r;
}
@ -528,7 +528,7 @@ fail:
static void unpublish_all_services(struct userdata *u, int rem) {
void *state = NULL;
struct service *s;
assert(u);
pa_log_debug("Unpublishing services in Zeroconf");
@ -538,7 +538,7 @@ static void unpublish_all_services(struct userdata *u, int rem) {
if (rem) {
avahi_entry_group_free(s->entry_group);
s->entry_group = NULL;
} else
} else
avahi_entry_group_reset(s->entry_group);
}
@ -559,12 +559,12 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
assert(c);
u->client = c;
switch (state) {
case AVAHI_CLIENT_S_RUNNING:
publish_all_services(u);
break;
case AVAHI_CLIENT_S_COLLISION:
unpublish_all_services(u, 0);
break;
@ -578,7 +578,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error)))
pa_log("pa_avahi_client_new() failed: %s", avahi_strerror(error));
}
break;
default: ;
@ -607,7 +607,7 @@ int pa__init(pa_core *c, pa_module*m) {
u->port = (uint16_t) port;
u->avahi_poll = pa_avahi_poll_new(c->mainloop);
u->services = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
u->sink_dynarray = pa_dynarray_new();
u->source_dynarray = pa_dynarray_new();
@ -628,15 +628,15 @@ int pa__init(pa_core *c, pa_module*m) {
}
pa_modargs_free(ma);
return 0;
fail:
pa__done(c, m);
if (ma)
pa_modargs_free(ma);
return -1;
}
@ -649,7 +649,7 @@ static void service_free(void *p, void *userdata) {
if (s->entry_group)
avahi_entry_group_free(s->entry_group);
pa_xfree(s->service_name);
pa_xfree(s->name);
pa_xfree(s);
@ -674,14 +674,14 @@ void pa__done(pa_core *c, pa_module*m) {
pa_dynarray_free(u->source_dynarray, NULL, NULL);
if (u->autoload_dynarray)
pa_dynarray_free(u->autoload_dynarray, NULL, NULL);
if (u->main_entry_group)
avahi_entry_group_free(u->main_entry_group);
if (u->client)
avahi_client_free(u->client);
if (u->avahi_poll)
pa_avahi_poll_free(u->avahi_poll);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -48,14 +48,14 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) {
if(!pcaps)
pcaps = &caps;
if (*mode == O_RDWR) {
if ((fd = open(device, O_RDWR|O_NDELAY)) >= 0) {
int dcaps, *tcaps;
ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
tcaps = pcaps ? pcaps : &dcaps;
if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) {
pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
goto fail;
@ -68,7 +68,7 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) {
close(fd);
}
if ((fd = open(device, (*mode = O_WRONLY)|O_NDELAY)) < 0) {
if ((fd = open(device, (*mode = O_RDONLY)|O_NDELAY)) < 0) {
pa_log("open('%s'): %s", device, pa_cstrerror(errno));
@ -80,17 +80,17 @@ int pa_oss_open(const char *device, int *mode, int* pcaps) {
pa_log("open('%s'): %s", device, pa_cstrerror(errno));
goto fail;
}
}
}
success:
*pcaps = 0;
if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) {
pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
goto fail;
}
pa_log_debug("capabilities:%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
*pcaps & DSP_CAP_BATCH ? " BATCH" : "",
#ifdef DSP_CAP_BIND
@ -100,7 +100,7 @@ success:
#endif
*pcaps & DSP_CAP_COPROC ? " COPROC" : "",
*pcaps & DSP_CAP_DUPLEX ? " DUPLEX" : "",
#ifdef DSP_CAP_FREERATE
#ifdef DSP_CAP_FREERATE
*pcaps & DSP_CAP_FREERATE ? " FREERATE" : "",
#else
"",
@ -140,7 +140,7 @@ success:
*pcaps & DSP_CAP_TRIGGER ? " TRIGGER" : "");
pa_fd_set_cloexec(fd, 1);
return fd;
fail:
@ -152,7 +152,7 @@ fail:
int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
int format, channels, speed, reqformat;
pa_sample_format_t orig_format;
static const int format_trans[PA_SAMPLE_MAX] = {
[PA_SAMPLE_U8] = AFMT_U8,
[PA_SAMPLE_ALAW] = AFMT_A_LAW,
@ -166,7 +166,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
assert(fd >= 0 && ss);
orig_format = ss->format;
reqformat = format = format_trans[ss->format];
if (reqformat == AFMT_QUERY || ioctl(fd, SNDCTL_DSP_SETFMT, &format) < 0 || format != reqformat) {
format = AFMT_S16_NE;
@ -190,7 +190,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
pa_log_warn("device doesn't support sample format %s, changed to %s.",
pa_sample_format_to_string(orig_format),
pa_sample_format_to_string(ss->format));
channels = ss->channels;
if (ioctl(fd, SNDCTL_DSP_CHANNELS, &channels) < 0) {
pa_log("SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno));
@ -229,14 +229,14 @@ static int simple_log2(int v) {
if (!v) break;
k++;
}
return k;
}
int pa_oss_set_fragments(int fd, int nfrags, int frag_size) {
int arg;
arg = ((int) nfrags << 16) | simple_log2(frag_size);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) < 0) {
pa_log("SNDCTL_DSP_SETFRAGMENT: %s", pa_cstrerror(errno));
return -1;
@ -252,7 +252,7 @@ static int pa_oss_get_volume(int fd, int mixer, const pa_sample_spec *ss, pa_cvo
assert(fd >= 0);
assert(ss);
assert(volume);
if (ioctl(fd, mixer, &vol) < 0)
return -1;
@ -278,7 +278,7 @@ static int pa_oss_set_volume(int fd, int mixer, const pa_sample_spec *ss, const
r = volume->values[1] > PA_VOLUME_NORM ? PA_VOLUME_NORM : volume->values[1];
vol |= ((r*100)/PA_VOLUME_NORM) << 8;
}
if (ioctl(fd, mixer, &vol) < 0)
return -1;
@ -321,7 +321,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
n = *e - '0';
else
return -1;
if (!(f = fopen("/dev/sndstat", "r")) &&
!(f = fopen("/proc/sndstat", "r")) &&
!(f = fopen("/proc/asound/oss/sndstat", "r"))) {
@ -335,7 +335,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
while (!feof(f)) {
char line[64];
int device;
if (!fgets(line, sizeof(line), f))
break;
@ -348,7 +348,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
if (line[0] == 0)
break;
if (sscanf(line, "%i: ", &device) != 1)
continue;
@ -360,7 +360,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
if (pa_endswith(k, " (DUPLEX)"))
k[strlen(k)-9] = 0;
pa_strlcpy(name, k, l);
r = 0;
break;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,26 +2,26 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
@ -53,10 +53,10 @@ struct pa_browser {
pa_browser_error_cb_t error_callback;
void *error_userdata;
AvahiClient *client;
AvahiServiceBrowser *server_browser, *sink_browser, *source_browser;
};
static int map_to_opcode(const char *type, int new) {
@ -84,7 +84,7 @@ static void resolve_callback(
AvahiStringList *txt,
AvahiLookupResultFlags flags,
void *userdata) {
pa_browser *b = userdata;
pa_browse_info i;
char ip[256], a[256];
@ -94,7 +94,7 @@ static void resolve_callback(
pa_sample_spec ss;
int ss_valid = 0;
char *key = NULL, *value = NULL;
assert(b);
memset(&i, 0, sizeof(i));
@ -102,7 +102,7 @@ static void resolve_callback(
if (event != AVAHI_RESOLVER_FOUND)
goto fail;
if (!b->callback)
goto fail;
@ -119,10 +119,10 @@ static void resolve_callback(
while (txt) {
if (avahi_string_list_get_pair(txt, &key, &value, NULL) < 0)
break;
if (!strcmp(key, "device")) {
device_found = 1;
pa_xfree((char*) i.device);
@ -138,11 +138,11 @@ static void resolve_callback(
value = NULL;
} else if (!strcmp(key, "fqdn")) {
size_t l;
pa_xfree((char*) i.fqdn);
i.fqdn = value;
value = NULL;
l = strlen(a);
assert(l+1 <= sizeof(a));
strncat(a, " ", sizeof(a)-l-1);
@ -151,7 +151,7 @@ static void resolve_callback(
if (pa_atou(value, &cookie) < 0)
goto fail;
i.cookie = &cookie;
} else if (!strcmp(key, "description")) {
pa_xfree((char*) i.description);
@ -159,13 +159,13 @@ static void resolve_callback(
value = NULL;
} else if (!strcmp(key, "channels")) {
uint32_t ch;
if (pa_atou(value, &ch) < 0 || ch <= 0 || ch > 255)
goto fail;
ss.channels = (uint8_t) ch;
ss_valid |= 1;
} else if (!strcmp(key, "rate")) {
if (pa_atou(value, &ss.rate) < 0)
goto fail;
@ -174,7 +174,7 @@ static void resolve_callback(
if ((ss.format = pa_parse_sample_format(value)) == PA_SAMPLE_INVALID)
goto fail;
ss_valid |= 4;
}
@ -186,7 +186,7 @@ static void resolve_callback(
}
/* No device txt record was sent for a sink or source service */
if (opcode != PA_BROWSE_NEW_SERVER && !device_found)
if (opcode != PA_BROWSE_NEW_SERVER && !device_found)
goto fail;
if (ss_valid == 7)
@ -203,7 +203,7 @@ fail:
pa_xfree(key);
pa_xfree(value);
avahi_service_resolver_free(r);
}
@ -263,19 +263,19 @@ static void browse_callback(
break;
}
case AVAHI_BROWSER_REMOVE: {
if (b->callback) {
pa_browse_info i;
int opcode;
memset(&i, 0, sizeof(i));
i.name = name;
opcode = map_to_opcode(type, 0);
assert(opcode >= 0);
b->callback(b, opcode, &i, b->userdata);
}
break;
@ -285,7 +285,7 @@ static void browse_callback(
handle_failure(b);
break;
}
default:
;
}
@ -313,7 +313,7 @@ pa_browser *pa_browser_new_full(pa_mainloop_api *mainloop, pa_browse_flags_t fla
if (flags & ~(PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES) || flags == 0)
return NULL;
b = pa_xnew(pa_browser, 1);
b->mainloop = mainloop;
b->ref = 1;
@ -346,7 +346,7 @@ pa_browser *pa_browser_new_full(pa_mainloop_api *mainloop, pa_browse_flags_t fla
*error_string = avahi_strerror(avahi_client_errno(b->client));
goto fail;
}
if ((flags & PA_BROWSE_FOR_SINKS) &&
!(b->sink_browser = avahi_service_browser_new(
b->client,
@ -378,13 +378,13 @@ pa_browser *pa_browser_new_full(pa_mainloop_api *mainloop, pa_browse_flags_t fla
*error_string = avahi_strerror(avahi_client_errno(b->client));
goto fail;
}
return b;
fail:
if (b)
browser_free(b);
return NULL;
}
@ -403,7 +403,7 @@ static void browser_free(pa_browser *b) {
if (b->avahi_poll)
pa_avahi_poll_free(b->avahi_poll);
pa_xfree(b);
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -41,7 +41,7 @@ typedef enum pa_browse_opcode {
PA_BROWSE_NEW_SINK, /**< New sink found */
PA_BROWSE_NEW_SOURCE, /**< New source found */
PA_BROWSE_REMOVE_SERVER, /**< Server disappeared */
PA_BROWSE_REMOVE_SINK, /**< Sink disappeared */
PA_BROWSE_REMOVE_SINK, /**< Sink disappeared */
PA_BROWSE_REMOVE_SOURCE /**< Source disappeared */
} pa_browse_opcode_t;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -35,23 +35,23 @@
const char *const table[] = {
[PA_CHANNEL_POSITION_MONO] = "mono",
[PA_CHANNEL_POSITION_FRONT_CENTER] = "front-center",
[PA_CHANNEL_POSITION_FRONT_LEFT] = "front-left",
[PA_CHANNEL_POSITION_FRONT_RIGHT] = "front-right",
[PA_CHANNEL_POSITION_REAR_CENTER] = "rear-center",
[PA_CHANNEL_POSITION_REAR_LEFT] = "rear-left",
[PA_CHANNEL_POSITION_REAR_RIGHT] = "rear-right",
[PA_CHANNEL_POSITION_LFE] = "lfe",
[PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER] = "front-left-of-center",
[PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER] = "front-right-of-center",
[PA_CHANNEL_POSITION_SIDE_LEFT] = "side-left",
[PA_CHANNEL_POSITION_SIDE_RIGHT] = "side-right",
[PA_CHANNEL_POSITION_AUX0] = "aux0",
[PA_CHANNEL_POSITION_AUX1] = "aux1",
[PA_CHANNEL_POSITION_AUX2] = "aux2",
@ -86,7 +86,7 @@ const char *const table[] = {
[PA_CHANNEL_POSITION_AUX31] = "aux31",
[PA_CHANNEL_POSITION_TOP_CENTER] = "top-center",
[PA_CHANNEL_POSITION_TOP_FRONT_LEFT] = "top-front-left",
[PA_CHANNEL_POSITION_TOP_FRONT_RIGHT] = "top-front-right",
[PA_CHANNEL_POSITION_TOP_FRONT_CENTER] = "top-front-center",
@ -140,14 +140,14 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
switch (def) {
case PA_CHANNEL_MAP_AIFF:
/* This is somewhat compatible with RFC3551 */
switch (channels) {
case 1:
m->map[0] = PA_CHANNEL_POSITION_MONO;
return m;
case 6:
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
m->map[1] = PA_CHANNEL_POSITION_SIDE_LEFT;
@ -156,31 +156,31 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
m->map[4] = PA_CHANNEL_POSITION_SIDE_RIGHT;
m->map[5] = PA_CHANNEL_POSITION_LFE;
return m;
case 5:
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
m->map[3] = PA_CHANNEL_POSITION_REAR_LEFT;
m->map[4] = PA_CHANNEL_POSITION_REAR_RIGHT;
/* Fall through */
case 2:
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
return m;
case 3:
m->map[0] = PA_CHANNEL_POSITION_LEFT;
m->map[1] = PA_CHANNEL_POSITION_RIGHT;
m->map[2] = PA_CHANNEL_POSITION_CENTER;
return m;
case 4:
m->map[0] = PA_CHANNEL_POSITION_LEFT;
m->map[1] = PA_CHANNEL_POSITION_CENTER;
m->map[2] = PA_CHANNEL_POSITION_RIGHT;
m->map[3] = PA_CHANNEL_POSITION_LFE;
return m;
default:
return NULL;
}
@ -191,43 +191,43 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
case 1:
m->map[0] = PA_CHANNEL_POSITION_MONO;
return m;
case 8:
m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT;
m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT;
/* Fall through */
case 6:
m->map[5] = PA_CHANNEL_POSITION_LFE;
/* Fall through */
case 5:
m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER;
/* Fall through */
case 4:
m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT;
m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT;
/* Fall through */
case 2:
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
return m;
default:
return NULL;
}
case PA_CHANNEL_MAP_AUX: {
unsigned i;
if (channels >= PA_CHANNELS_MAX)
return NULL;
for (i = 0; i < channels; i++)
m->map[i] = PA_CHANNEL_POSITION_AUX0 + i;
return m;
}
@ -237,55 +237,55 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
case 1:
m->map[0] = PA_CHANNEL_POSITION_MONO;
return m;
case 18:
m->map[15] = PA_CHANNEL_POSITION_TOP_REAR_LEFT;
m->map[16] = PA_CHANNEL_POSITION_TOP_REAR_CENTER;
m->map[17] = PA_CHANNEL_POSITION_TOP_REAR_RIGHT;
/* Fall through */
case 15:
m->map[12] = PA_CHANNEL_POSITION_TOP_FRONT_LEFT;
m->map[13] = PA_CHANNEL_POSITION_TOP_FRONT_CENTER;
m->map[14] = PA_CHANNEL_POSITION_TOP_FRONT_RIGHT;
/* Fall through */
case 12:
m->map[11] = PA_CHANNEL_POSITION_TOP_CENTER;
/* Fall through */
case 11:
m->map[9] = PA_CHANNEL_POSITION_SIDE_LEFT;
m->map[10] = PA_CHANNEL_POSITION_SIDE_RIGHT;
/* Fall through */
case 9:
m->map[8] = PA_CHANNEL_POSITION_REAR_CENTER;
/* Fall through */
case 8:
m->map[6] = PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
m->map[7] = PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
/* Fall through */
case 6:
m->map[4] = PA_CHANNEL_POSITION_REAR_LEFT;
m->map[5] = PA_CHANNEL_POSITION_REAR_RIGHT;
/* Fall through */
case 4:
m->map[3] = PA_CHANNEL_POSITION_LFE;
/* Fall through */
case 3:
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
/* Fall through */
case 2:
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
return m;
default:
return NULL;
}
@ -296,12 +296,12 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
case 1:
m->map[0] = PA_CHANNEL_POSITION_MONO;
return m;
case 8:
m->map[6] = PA_CHANNEL_POSITION_REAR_LEFT;
m->map[7] = PA_CHANNEL_POSITION_REAR_RIGHT;
/* Fall through */
case 6:
m->map[4] = PA_CHANNEL_POSITION_SIDE_LEFT;
m->map[5] = PA_CHANNEL_POSITION_SIDE_RIGHT;
@ -310,20 +310,20 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
case 4:
m->map[3] = PA_CHANNEL_POSITION_LFE;
/* Fall through */
case 3:
m->map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
/* Fall through */
case 2:
m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
return m;
default:
return NULL;
}
default:
return NULL;
@ -341,13 +341,13 @@ const char* pa_channel_position_to_string(pa_channel_position_t pos) {
int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) {
unsigned c;
assert(a);
assert(b);
if (a->channels != b->channels)
return 0;
for (c = 0; c < a->channels; c++)
if (a->map[c] != b->map[c])
return 0;
@ -359,7 +359,7 @@ char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) {
unsigned channel;
int first = 1;
char *e;
assert(s);
assert(l > 0);
assert(map);
@ -382,7 +382,7 @@ pa_channel_map *pa_channel_map_parse(pa_channel_map *rmap, const char *s) {
const char *state;
pa_channel_map map;
char *p;
assert(rmap);
assert(s);
@ -397,14 +397,14 @@ pa_channel_map *pa_channel_map_parse(pa_channel_map *rmap, const char *s) {
state = NULL;
map.channels = 0;
while ((p = pa_split(s, ",", &state))) {
if (map.channels >= PA_CHANNELS_MAX) {
pa_xfree(p);
return NULL;
}
/* Some special aliases */
if (strcmp(p, "left") == 0)
map.map[map.channels++] = PA_CHANNEL_POSITION_LEFT;
@ -416,13 +416,13 @@ pa_channel_map *pa_channel_map_parse(pa_channel_map *rmap, const char *s) {
map.map[map.channels++] = PA_CHANNEL_POSITION_SUBWOOFER;
else {
pa_channel_position_t i;
for (i = 0; i < PA_CHANNEL_POSITION_MAX; i++)
if (strcmp(p, table[i]) == 0) {
map.map[map.channels++] = i;
break;
}
if (i >= PA_CHANNEL_POSITION_MAX) {
pa_xfree(p);
return NULL;
@ -433,24 +433,24 @@ pa_channel_map *pa_channel_map_parse(pa_channel_map *rmap, const char *s) {
}
finish:
if (!pa_channel_map_valid(&map))
return NULL;
*rmap = map;
return rmap;
}
int pa_channel_map_valid(const pa_channel_map *map) {
unsigned c;
assert(map);
if (map->channels <= 0 || map->channels > PA_CHANNELS_MAX)
return 0;
for (c = 0; c < map->channels; c++) {
if (map->map[c] < 0 ||map->map[c] >= PA_CHANNEL_POSITION_MAX)
return 0;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -72,7 +72,7 @@ typedef enum pa_channel_position {
PA_CHANNEL_POSITION_LEFT,
PA_CHANNEL_POSITION_RIGHT,
PA_CHANNEL_POSITION_CENTER,
PA_CHANNEL_POSITION_FRONT_LEFT = PA_CHANNEL_POSITION_LEFT,
PA_CHANNEL_POSITION_FRONT_RIGHT = PA_CHANNEL_POSITION_RIGHT,
PA_CHANNEL_POSITION_FRONT_CENTER = PA_CHANNEL_POSITION_CENTER,
@ -80,13 +80,13 @@ typedef enum pa_channel_position {
PA_CHANNEL_POSITION_REAR_CENTER,
PA_CHANNEL_POSITION_REAR_LEFT,
PA_CHANNEL_POSITION_REAR_RIGHT,
PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
PA_CHANNEL_POSITION_SIDE_LEFT,
PA_CHANNEL_POSITION_SIDE_RIGHT,
@ -124,7 +124,7 @@ typedef enum pa_channel_position {
PA_CHANNEL_POSITION_AUX31,
PA_CHANNEL_POSITION_TOP_CENTER,
PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
@ -132,7 +132,7 @@ typedef enum pa_channel_position {
PA_CHANNEL_POSITION_TOP_REAR_LEFT,
PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
PA_CHANNEL_POSITION_TOP_REAR_CENTER,
PA_CHANNEL_POSITION_MAX
} pa_channel_position_t;
@ -143,7 +143,7 @@ typedef enum pa_channel_map_def {
PA_CHANNEL_MAP_AUX, /**< Only aux channels */
PA_CHANNEL_MAP_WAVEEX, /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
PA_CHANNEL_MAP_OSS, /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF /**< The default channel map */
} pa_channel_map_def_t;

View file

@ -44,7 +44,7 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
if (!dname && !getenv("DISPLAY"))
goto finish;
if (!(d = XOpenDisplay(dname))) {
pa_log("XOpenDisplay() failed");
goto finish;
@ -89,5 +89,5 @@ finish:
XCloseDisplay(d);
return ret;
}

View file

@ -69,11 +69,11 @@ static const pa_client_conf default_conf = {
pa_client_conf *pa_client_conf_new(void) {
pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
c->daemon_binary = pa_xstrdup(PA_BINARY);
c->extra_arguments = pa_xstrdup("--log-target=syslog --exit-idle-time=5");
c->cookie_file = pa_xstrdup(PA_NATIVE_COOKIE_FILE);
return c;
}
@ -122,25 +122,25 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
pa_log("WARNING: failed to open configuration file '%s': %s", fn, pa_cstrerror(errno));
goto finish;
}
r = f ? pa_config_parse(fn, f, table, NULL) : 0;
if (!r)
r = pa_client_conf_load_cookie(c);
finish:
pa_xfree(fn);
if (f)
fclose(f);
return r;
}
int pa_client_conf_env(pa_client_conf *c) {
char *e;
if ((e = getenv(ENV_DEFAULT_SINK))) {
pa_xfree(c->default_sink);
c->default_sink = pa_xstrdup(e);
@ -155,7 +155,7 @@ int pa_client_conf_env(pa_client_conf *c) {
pa_xfree(c->default_server);
c->default_server = pa_xstrdup(e);
}
if ((e = getenv(ENV_DAEMON_BINARY))) {
pa_xfree(c->daemon_binary);
c->daemon_binary = pa_xstrdup(e);
@ -167,7 +167,7 @@ int pa_client_conf_env(pa_client_conf *c) {
return pa_client_conf_load_cookie(c);
}
return 0;
}

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -88,11 +88,11 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
static void unlock_autospawn_lock_file(pa_context *c) {
assert(c);
if (c->autospawn_lock_fd >= 0) {
char lf[PATH_MAX];
pa_runtime_path(AUTOSPAWN_LOCK, lf, sizeof(lf));
pa_unlock_lockfile(lf, c->autospawn_lock_fd);
c->autospawn_lock_fd = -1;
}
@ -102,10 +102,10 @@ static void context_free(pa_context *c);
pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
pa_context *c;
assert(mainloop);
assert(name);
c = pa_xnew(pa_context, 1);
c->ref = 1;
c->name = pa_xstrdup(name);
@ -118,7 +118,7 @@ pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
PA_LLIST_HEAD_INIT(pa_stream, c->streams);
PA_LLIST_HEAD_INIT(pa_operation, c->operations);
c->error = PA_OK;
c->state = PA_CONTEXT_UNCONNECTED;
c->ctag = 0;
@ -138,7 +138,7 @@ pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
c->do_autospawn = 0;
#ifndef MSG_NOSIGNAL
#ifdef SIGPIPE
#ifdef SIGPIPE
pa_check_signal_is_blocked(SIGPIPE);
#endif
#endif
@ -183,7 +183,7 @@ static void context_free(pa_context *c) {
pa_pstream_close(c->pstream);
pa_pstream_unref(c->pstream);
}
if (c->record_streams)
pa_dynarray_free(c->record_streams, NULL, NULL);
if (c->playback_streams)
@ -196,7 +196,7 @@ static void context_free(pa_context *c) {
pa_client_conf_free(c->conf);
pa_strlist_free(c->server_list);
pa_xfree(c->name);
pa_xfree(c->server);
pa_xfree(c);
@ -205,7 +205,7 @@ static void context_free(pa_context *c) {
pa_context* pa_context_ref(pa_context *c) {
assert(c);
assert(c->ref >= 1);
c->ref++;
return c;
}
@ -221,7 +221,7 @@ void pa_context_unref(pa_context *c) {
void pa_context_set_state(pa_context *c, pa_context_state_t st) {
assert(c);
assert(c->ref >= 1);
if (c->state == st)
return;
@ -233,7 +233,7 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
if (st == PA_CONTEXT_FAILED || st == PA_CONTEXT_TERMINATED) {
pa_stream *s;
s = c->streams ? pa_stream_ref(c->streams) : NULL;
while (s) {
pa_stream *n = s->next ? pa_stream_ref(s->next) : NULL;
@ -245,13 +245,13 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
if (c->pdispatch)
pa_pdispatch_unref(c->pdispatch);
c->pdispatch = NULL;
if (c->pstream) {
pa_pstream_close(c->pstream);
pa_pstream_unref(c->pstream);
}
c->pstream = NULL;
if (c->client)
pa_socket_client_unref(c->client);
c->client = NULL;
@ -263,7 +263,7 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
void pa_context_fail(pa_context *c, int error) {
assert(c);
assert(c->ref >= 1);
pa_context_set_error(c, error);
pa_context_set_state(c, PA_CONTEXT_FAILED);
}
@ -283,19 +283,19 @@ static void pstream_die_callback(pa_pstream *p, void *userdata) {
assert(p);
assert(c);
pa_context_fail(c, PA_ERR_CONNECTIONTERMINATED);
}
static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_creds *creds, void *userdata) {
pa_context *c = userdata;
assert(p);
assert(packet);
assert(c);
pa_context_ref(c);
if (pa_pdispatch_run(c->pdispatch, packet, creds, c) < 0)
pa_context_fail(c, PA_ERR_PROTOCOL);
@ -305,7 +305,7 @@ static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_c
static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk, void *userdata) {
pa_context *c = userdata;
pa_stream *s;
assert(p);
assert(chunk);
assert(chunk->memblock);
@ -321,7 +321,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
pa_memblockq_seek(s->record_memblockq, offset, seek);
pa_memblockq_push_align(s->record_memblockq, chunk);
if (s->read_callback) {
size_t l;
@ -339,11 +339,11 @@ int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t) {
if (command == PA_COMMAND_ERROR) {
assert(t);
if (pa_tagstruct_getu32(t, &c->error) < 0) {
pa_context_fail(c, PA_ERR_PROTOCOL);
return -1;
}
} else if (command == PA_COMMAND_TIMEOUT)
c->error = PA_ERR_TIMEOUT;
@ -357,15 +357,15 @@ int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t) {
static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_context *c = userdata;
assert(pd);
assert(c);
assert(c->state == PA_CONTEXT_AUTHORIZING || c->state == PA_CONTEXT_SETTING_NAME);
pa_context_ref(c);
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(c, command, t) < 0)
pa_context_fail(c, PA_ERR_PROTOCOL);
@ -398,7 +398,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
* user. This is a security measure because otherwise
* data private to the user might leak. */
#ifdef HAVE_CREDS
#ifdef HAVE_CREDS
const pa_creds *creds;
if ((creds = pa_pdispatch_creds(pd)))
if (getuid() == creds->uid)
@ -418,7 +418,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
case PA_CONTEXT_SETTING_NAME :
pa_context_set_state(c, PA_CONTEXT_READY);
break;
default:
assert(0);
}
@ -430,12 +430,12 @@ finish:
static void setup_context(pa_context *c, pa_iochannel *io) {
pa_tagstruct *t;
uint32_t tag;
assert(c);
assert(io);
pa_context_ref(c);
assert(!c->pstream);
c->pstream = pa_pstream_new(c->mainloop, io, c->mempool);
@ -462,13 +462,13 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
ucred.uid = getuid();
ucred.gid = getgid();
pa_pstream_send_tagstruct_with_creds(c->pstream, t, &ucred);
}
#else
pa_pstream_send_tagstruct(c->pstream, t);
#endif
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c, NULL);
pa_context_set_state(c, PA_CONTEXT_AUTHORIZING);
@ -487,7 +487,7 @@ static int context_connect_spawn(pa_context *c) {
pa_iochannel *io;
pa_context_ref(c);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
pa_log("socketpair(): %s", pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL);
@ -495,7 +495,7 @@ static int context_connect_spawn(pa_context *c) {
}
pa_fd_set_cloexec(fds[0], 1);
pa_socket_low_delay(fds[0]);
pa_socket_low_delay(fds[1]);
@ -508,7 +508,7 @@ static int context_connect_spawn(pa_context *c) {
if (c->spawn_api.postfork)
c->spawn_api.postfork();
goto fail;
} else if (!pid) {
/* Child */
@ -521,17 +521,17 @@ static int context_connect_spawn(pa_context *c) {
/* Not required, since fds[0] has CLOEXEC enabled anyway */
close(fds[0]);
if (c->spawn_api.atfork)
c->spawn_api.atfork();
/* Setup argv */
n = 0;
argv[n++] = c->conf->daemon_binary;
argv[n++] = "--daemonize=yes";
snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
argv[n++] = strdup(t);
@ -540,7 +540,7 @@ static int context_connect_spawn(pa_context *c) {
if (!(a = pa_split_spaces(c->conf->extra_arguments, &state)))
break;
argv[n++] = a;
}
@ -549,7 +549,7 @@ static int context_connect_spawn(pa_context *c) {
execv(argv[0], (char * const *) argv);
_exit(1);
#undef MAX_ARGS
}
}
/* Parent */
@ -557,7 +557,7 @@ static int context_connect_spawn(pa_context *c) {
if (c->spawn_api.postfork)
c->spawn_api.postfork();
if (r < 0) {
pa_log("waitpid(): %s", pa_cstrerror(errno));
pa_context_fail(c, PA_ERR_INTERNAL);
@ -570,7 +570,7 @@ static int context_connect_spawn(pa_context *c) {
close(fds[1]);
c->is_local = 1;
io = pa_iochannel_new(c->mainloop, fds[0], fds[0]);
setup_context(c, io);
@ -598,16 +598,16 @@ fail:
static int try_next_connection(pa_context *c) {
char *u = NULL;
int r = -1;
assert(c);
assert(!c->client);
for (;;) {
pa_xfree(u);
u = NULL;
c->server_list = pa_strlist_pop(c->server_list, &u);
if (!u) {
#ifndef OS_IS_WIN32
@ -616,19 +616,19 @@ static int try_next_connection(pa_context *c) {
goto finish;
}
#endif
pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
goto finish;
}
pa_log_debug("Trying to connect to %s...", u);
pa_log_debug("Trying to connect to %s...", u);
pa_xfree(c->server);
c->server = pa_xstrdup(u);
if (!(c->client = pa_socket_client_new_string(c->mainloop, u, PA_NATIVE_DEFAULT_PORT)))
continue;
c->is_local = pa_socket_client_is_local(c->client);
pa_socket_client_set_callback(c->client, on_connection, c);
break;
@ -638,13 +638,13 @@ static int try_next_connection(pa_context *c) {
finish:
pa_xfree(u);
return r;
}
static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata) {
pa_context *c = userdata;
assert(client);
assert(c);
assert(c->state == PA_CONTEXT_CONNECTING);
@ -677,9 +677,9 @@ int pa_context_connect(
const char *server,
pa_context_flags_t flags,
const pa_spawn_api *api) {
int r = -1;
assert(c);
assert(c->ref >= 1);
@ -693,7 +693,7 @@ int pa_context_connect(
pa_context_ref(c);
assert(!c->server_list);
if (server) {
if (!(c->server_list = pa_strlist_parse(server))) {
pa_context_fail(c, PA_ERR_INVALIDSERVER);
@ -704,7 +704,7 @@ int pa_context_connect(
char ufn[PATH_MAX];
/* Prepend in reverse order */
if ((d = getenv("DISPLAY"))) {
char *e;
d = pa_xstrdup(d);
@ -716,7 +716,7 @@ int pa_context_connect(
pa_xfree(d);
}
c->server_list = pa_strlist_prepend(c->server_list, "tcp6:localhost");
c->server_list = pa_strlist_prepend(c->server_list, "tcp4:localhost");
@ -744,38 +744,38 @@ int pa_context_connect(
pa_context_set_state(c, PA_CONTEXT_CONNECTING);
r = try_next_connection(c);
finish:
pa_context_unref(c);
return r;
}
void pa_context_disconnect(pa_context *c) {
assert(c);
assert(c->ref >= 1);
pa_context_set_state(c, PA_CONTEXT_TERMINATED);
}
pa_context_state_t pa_context_get_state(pa_context *c) {
assert(c);
assert(c->ref >= 1);
return c->state;
}
int pa_context_errno(pa_context *c) {
assert(c);
assert(c->ref >= 1);
return c->error;
}
void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
assert(c);
assert(c->ref >= 1);
c->state_callback = cb;
c->state_userdata = userdata;
}
@ -807,7 +807,7 @@ static void pstream_drain_callback(PA_GCC_UNUSED pa_pstream *s, void *userdata)
static void set_dispatch_callbacks(pa_operation *o) {
int done = 1;
assert(o);
assert(o->ref >= 1);
assert(o->context);
@ -816,7 +816,7 @@ static void set_dispatch_callbacks(pa_operation *o) {
pa_pstream_set_drain_callback(o->context->pstream, NULL, NULL);
pa_pdispatch_set_drain_callback(o->context->pdispatch, NULL, NULL);
if (pa_pdispatch_is_pending(o->context->pdispatch)) {
pa_pdispatch_set_drain_callback(o->context->pdispatch, pdispatch_drain_callback, o);
done = 0;
@ -832,7 +832,7 @@ static void set_dispatch_callbacks(pa_operation *o) {
pa_context_notify_cb_t cb = (pa_context_notify_cb_t) o->callback;
cb(o->context, o->userdata);
}
pa_operation_done(o);
pa_operation_unref(o);
}
@ -840,13 +840,13 @@ static void set_dispatch_callbacks(pa_operation *o) {
pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
pa_operation *o;
assert(c);
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_context_is_pending(c), PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
set_dispatch_callbacks(pa_operation_ref(o));
@ -856,7 +856,7 @@ pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *u
void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
int success = 1;
assert(pd);
assert(o);
assert(o->ref >= 1);
@ -907,12 +907,12 @@ pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, pa
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, cb, userdata);
t = pa_tagstruct_command(c, command, &tag);
@ -926,7 +926,7 @@ pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_co
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
@ -951,7 +951,7 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_DEFAULT_SOURCE, &tag);
@ -964,7 +964,7 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_
int pa_context_is_local(pa_context *c) {
assert(c);
return c->is_local;
}
@ -978,7 +978,7 @@ pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_su
assert(name);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag);
@ -999,12 +999,12 @@ const char* pa_context_get_server(pa_context *c) {
if (!c->server)
return NULL;
if (*c->server == '{') {
char *e = strchr(c->server+1, '}');
return e ? e+1 : c->server;
}
return c->server;
}
@ -1024,7 +1024,7 @@ pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *ta
assert(c);
assert(tag);
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, command);
pa_tagstruct_putu32(t, *tag = c->ctag++);

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -50,7 +50,7 @@
* The abstraction is represented as a number of function pointers in the
* pa_mainloop_api structure.
*
* To actually be able to use these functions, an implementation needs to
* To actually be able to use these functions, an implementation needs to
* be coupled to the abstraction. There are three of these shipped with
* PulseAudio, but any other can be used with a minimal ammount of work,
* provided it supports the three basic events listed above.
@ -76,7 +76,7 @@
* and decrease their reference counts. Whenever an object's reference
* count reaches zero, that object gets destroy and any resources it uses
* get freed.
*
*
* The benefit of this design is that an application need not worry about
* whether or not it needs to keep an object around in case the library is
* using it internally. If it is, then it has made sure it has its own

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -69,7 +69,7 @@ typedef enum pa_context_flags {
PA_CONTEXT_NOAUTOSPAWN = 1 /**< Disabled autospawning of the PulseAudio daemon if required */
} pa_context_flags_t;
/** The direction of a pa_stream object */
/** The direction of a pa_stream object */
typedef enum pa_stream_direction {
PA_STREAM_NODIRECTION, /**< Invalid direction */
PA_STREAM_PLAYBACK, /**< Playback stream */
@ -149,7 +149,7 @@ enum {
PA_ERR_EXIST, /**< Entity exists */
PA_ERR_NOENTITY, /**< No such entity */
PA_ERR_CONNECTIONREFUSED, /**< Connection refused */
PA_ERR_PROTOCOL, /**< Protocol error */
PA_ERR_PROTOCOL, /**< Protocol error */
PA_ERR_TIMEOUT, /**< Timeout */
PA_ERR_AUTHKEY, /**< No authorization key */
PA_ERR_INTERNAL, /**< Internal error */
@ -207,7 +207,7 @@ typedef enum pa_subscription_event_type {
* total output latency a sample that is written with
* pa_stream_write() takes to be played may be estimated by
* sink_usec+buffer_usec+transport_usec. (where buffer_usec is defined
* as pa_bytes_to_usec(write_index-read_index)) The output buffer
* as pa_bytes_to_usec(write_index-read_index)) The output buffer
* which buffer_usec relates to may be manipulated freely (with
* pa_stream_write()'s seek argument, pa_stream_flush() and friends),
* the buffers sink_usec and source_usec relate to are first-in
@ -256,7 +256,7 @@ typedef struct pa_timing_info {
* flush request that corrupted it has
* been issued in the time since this
* latency info was current. \since 0.8 */
int64_t read_index; /**< Current read index into the
* playback buffer in bytes. Think twice before
* using this for seeking purposes: it
@ -288,7 +288,7 @@ typedef struct pa_spawn_api {
/** Seek type for pa_stream_write(). \since 0.8*/
typedef enum pa_seek_mode {
PA_SEEK_RELATIVE = 0, /**< Seek relatively to the write index */
PA_SEEK_ABSOLUTE = 1, /**< Seek relatively to the start of the buffer queue */
PA_SEEK_ABSOLUTE = 1, /**< Seek relatively to the start of the buffer queue */
PA_SEEK_RELATIVE_ON_READ = 2, /**< Seek relatively to the read index. */
PA_SEEK_RELATIVE_END = 3 /**< Seek relatively to the current end of the buffer queue. */
} pa_seek_mode_t;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -69,7 +69,7 @@ struct pa_defer_event {
int dead;
int enabled;
pa_defer_event_cb_t callback;
void *userdata;
pa_defer_event_destroy_cb_t destroy_callback;
@ -79,7 +79,7 @@ struct pa_defer_event {
struct pa_glib_mainloop {
GSource source;
pa_mainloop_api api;
GMainContext *context;
@ -102,7 +102,7 @@ static void cleanup_io_events(pa_glib_mainloop *g, int force) {
if (!force && g->io_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_io_event, g->io_events, e);
@ -110,13 +110,13 @@ static void cleanup_io_events(pa_glib_mainloop *g, int force) {
g_assert(g->io_events_please_scan > 0);
g->io_events_please_scan--;
}
if (e->poll_fd_added)
g_source_remove_poll(&g->source, &e->poll_fd);
if (e->destroy_callback)
e->destroy_callback(&g->api, e, e->userdata);
pa_xfree(e);
}
@ -135,7 +135,7 @@ static void cleanup_time_events(pa_glib_mainloop *g, int force) {
if (!force && g->time_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_time_event, g->time_events, e);
@ -148,10 +148,10 @@ static void cleanup_time_events(pa_glib_mainloop *g, int force) {
g_assert(g->n_enabled_time_events > 0);
g->n_enabled_time_events--;
}
if (e->destroy_callback)
e->destroy_callback(&g->api, e, e->userdata);
pa_xfree(e);
}
@ -170,7 +170,7 @@ static void cleanup_defer_events(pa_glib_mainloop *g, int force) {
if (!force && g->defer_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_defer_event, g->defer_events, e);
@ -183,10 +183,10 @@ static void cleanup_defer_events(pa_glib_mainloop *g, int force) {
g_assert(g->n_enabled_defer_events > 0);
g->n_enabled_defer_events--;
}
if (e->destroy_callback)
e->destroy_callback(&g->api, e, e->userdata);
pa_xfree(e);
}
@ -218,7 +218,7 @@ static pa_io_event* glib_io_new(
pa_io_event_flags_t f,
pa_io_event_cb_t cb,
void *userdata) {
pa_io_event *e;
pa_glib_mainloop *g;
@ -226,7 +226,7 @@ static pa_io_event* glib_io_new(
g_assert(m->userdata);
g_assert(fd >= 0);
g_assert(cb);
g = m->userdata;
e = pa_xnew(pa_io_event, 1);
@ -236,7 +236,7 @@ static pa_io_event* glib_io_new(
e->poll_fd.fd = fd;
e->poll_fd.events = map_flags_to_glib(f);
e->poll_fd.revents = 0;
e->callback = cb;
e->userdata = userdata;
e->destroy_callback = NULL;
@ -245,7 +245,7 @@ static pa_io_event* glib_io_new(
g_source_add_poll(&g->source, &e->poll_fd);
e->poll_fd_added = 1;
return e;
}
@ -272,7 +272,7 @@ static void glib_io_free(pa_io_event*e) {
static void glib_io_set_destroy(pa_io_event*e, pa_io_event_destroy_cb_t cb) {
g_assert(e);
g_assert(!e->dead);
e->destroy_callback = cb;
}
@ -283,14 +283,14 @@ static pa_time_event* glib_time_new(
const struct timeval *tv,
pa_time_event_cb_t cb,
void *userdata) {
pa_glib_mainloop *g;
pa_time_event *e;
g_assert(m);
g_assert(m->userdata);
g_assert(cb);
g = m->userdata;
e = pa_xnew(pa_time_event, 1);
@ -308,13 +308,13 @@ static pa_time_event* glib_time_new(
g->cached_next_time_event = e;
}
}
e->callback = cb;
e->userdata = userdata;
e->destroy_callback = NULL;
PA_LLIST_PREPEND(pa_time_event, g->time_events, e);
return e;
}
@ -328,12 +328,12 @@ static void glib_time_restart(pa_time_event*e, const struct timeval *tv) {
} else if (!e->enabled && tv)
e->mainloop->n_enabled_time_events++;
if ((e->enabled = !!tv))
if ((e->enabled = !!tv))
e->timeval = *tv;
if (e->mainloop->cached_next_time_event && e->enabled) {
g_assert(e->mainloop->cached_next_time_event->enabled);
if (pa_timeval_cmp(tv, &e->mainloop->cached_next_time_event->timeval) < 0)
e->mainloop->cached_next_time_event = e;
} else if (e->mainloop->cached_next_time_event == e)
@ -357,7 +357,7 @@ static void glib_time_free(pa_time_event *e) {
static void glib_time_set_destroy(pa_time_event *e, pa_time_event_destroy_cb_t cb) {
g_assert(e);
g_assert(!e->dead);
e->destroy_callback = cb;
}
@ -367,27 +367,27 @@ static pa_defer_event* glib_defer_new(
pa_mainloop_api*m,
pa_defer_event_cb_t cb,
void *userdata) {
pa_defer_event *e;
pa_glib_mainloop *g;
g_assert(m);
g_assert(m->userdata);
g_assert(cb);
g = m->userdata;
e = pa_xnew(pa_defer_event, 1);
e->mainloop = g;
e->dead = 0;
e->enabled = 1;
g->n_enabled_defer_events++;
e->callback = cb;
e->userdata = userdata;
e->destroy_callback = NULL;
PA_LLIST_PREPEND(pa_defer_event, g->defer_events, e);
return e;
}
@ -430,7 +430,7 @@ static void glib_defer_set_destroy(pa_defer_event *e, pa_defer_event_destroy_cb_
static void glib_quit(pa_mainloop_api*a, PA_GCC_UNUSED int retval) {
g_warning("quit() ignored");
/* NOOP */
}
@ -440,7 +440,7 @@ static pa_time_event* find_next_time_event(pa_glib_mainloop *g) {
if (g->cached_next_time_event)
return g->cached_next_time_event;
for (t = g->time_events; t; t = t->next) {
if (t->dead || !t->enabled)
@ -461,7 +461,7 @@ static pa_time_event* find_next_time_event(pa_glib_mainloop *g) {
static void scan_dead(pa_glib_mainloop *g) {
g_assert(g);
if (g->io_events_please_scan)
cleanup_io_events(g, 0);
@ -499,7 +499,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) {
if (pa_timeval_cmp(&t->timeval, &tvnow) <= 0) {
*timeout = 0;
return TRUE;
}
}
usec = pa_timeval_diff(&t->timeval, &tvnow);
*timeout = (gint) (usec / 1000);
} else
@ -519,10 +519,10 @@ static gboolean check_func(GSource *source) {
pa_time_event *t;
GTimeVal now;
struct timeval tvnow;
t = find_next_time_event(g);
g_assert(t);
g_source_get_current_time(source, &now);
tvnow.tv_sec = now.tv_sec;
tvnow.tv_usec = now.tv_usec;
@ -555,7 +555,7 @@ static gboolean dispatch_func(GSource *source, PA_GCC_UNUSED GSourceFunc callbac
}
g_assert(d);
d->callback(&g->api, d, d->userdata);
return TRUE;
}
@ -567,7 +567,7 @@ static gboolean dispatch_func(GSource *source, PA_GCC_UNUSED GSourceFunc callbac
t = find_next_time_event(g);
g_assert(t);
g_source_get_current_time(source, &now);
tvnow.tv_sec = now.tv_sec;
tvnow.tv_usec = now.tv_usec;
@ -576,7 +576,7 @@ static gboolean dispatch_func(GSource *source, PA_GCC_UNUSED GSourceFunc callbac
/* Disable time event */
glib_time_restart(t, NULL);
t->callback(&g->api, t, &t->timeval, t->userdata);
return TRUE;
}
@ -604,12 +604,12 @@ static const pa_mainloop_api vtable = {
.time_restart = glib_time_restart,
.time_free = glib_time_free,
.time_set_destroy = glib_time_set_destroy,
.defer_new = glib_defer_new,
.defer_enable = glib_defer_enable,
.defer_free = glib_defer_free,
.defer_set_destroy = glib_defer_set_destroy,
.quit = glib_quit,
};
@ -624,10 +624,10 @@ pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) {
NULL,
NULL
};
g = (pa_glib_mainloop*) g_source_new(&source_funcs, sizeof(pa_glib_mainloop));
g_main_context_ref(g->context = c ? c : g_main_context_default());
g->api = vtable;
g->api.userdata = g;
@ -639,10 +639,10 @@ pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) {
g->io_events_please_scan = g->time_events_please_scan = g->defer_events_please_scan = 0;
g->cached_next_time_event = NULL;
g_source_attach(&g->source, g->context);
g_source_set_can_recurse(&g->source, FALSE);
return g;
}
@ -660,6 +660,6 @@ void pa_glib_mainloop_free(pa_glib_mainloop* g) {
pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g) {
g_assert(g);
return &g->api;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -45,7 +45,7 @@
struct pa_context {
int ref;
char *name;
pa_mainloop_api* mainloop;
@ -75,7 +75,7 @@ struct pa_context {
int do_autospawn;
int autospawn_lock_fd;
pa_spawn_api spawn_api;
pa_strlist *server_list;
char *server;
@ -109,7 +109,7 @@ struct pa_stream {
uint32_t device_index;
pa_stream_direction_t direction;
pa_stream_state_t state;
uint32_t requested_bytes;
pa_memchunk peek_memchunk;
@ -120,10 +120,10 @@ struct pa_stream {
/* Store latest latency info */
pa_timing_info timing_info;
int timing_info_valid;
/* Use to make sure that time advances monotonically */
pa_usec_t previous_time;
/* time updates with tags older than these are invalid */
uint32_t write_index_not_before;
uint32_t read_index_not_before;
@ -135,7 +135,7 @@ struct pa_stream {
/* Latency interpolation stuff */
pa_time_event *auto_timing_update_event;
int auto_timing_update_requested;
pa_usec_t cached_time;
int cached_time_valid;
@ -160,7 +160,7 @@ struct pa_operation {
int ref;
pa_context *context;
pa_stream *stream;
PA_LLIST_FIELDS(pa_operation);
pa_operation_state_t state;

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -39,7 +39,7 @@
static void context_stat_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
pa_stat_info i, *p = &i;
assert(pd);
assert(o);
assert(o->ref >= 1);
@ -81,11 +81,11 @@ pa_operation* pa_context_stat(pa_context *c, pa_stat_info_cb_t cb, void *userdat
static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
pa_server_info i, *p = &i;
assert(pd);
assert(o);
assert(o->ref >= 1);
if (!o->context)
goto finish;
@ -107,7 +107,7 @@ static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command,
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
if (o->callback) {
pa_server_info_cb_t cb = (pa_server_info_cb_t) o->callback;
cb(o->context, p, o->userdata);
@ -127,14 +127,14 @@ pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb,
static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
int eol = 1;
assert(pd);
assert(o);
assert(o->ref >= 1);
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
@ -142,10 +142,10 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, P
eol = -1;
} else {
uint32_t flags;
while (!pa_tagstruct_eof(t)) {
pa_sink_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_gets(t, &i.description) < 0 ||
@ -159,7 +159,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, P
pa_tagstruct_get_usec(t, &i.latency) < 0 ||
pa_tagstruct_gets(t, &i.driver) < 0 ||
pa_tagstruct_getu32(t, &flags) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -172,7 +172,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, P
}
}
}
if (o->callback) {
pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -191,7 +191,7 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
assert(cb);
@ -213,7 +213,7 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name,
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
assert(cb);
@ -251,11 +251,11 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_source_info i;
uint32_t flags;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_gets(t, &i.description) < 0 ||
@ -269,7 +269,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
pa_tagstruct_get_usec(t, &i.latency) < 0 ||
pa_tagstruct_gets(t, &i.driver) < 0 ||
pa_tagstruct_getu32(t, &flags) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -282,7 +282,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
}
if (o->callback) {
pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -309,7 +309,7 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag);
pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
@ -361,10 +361,10 @@ static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command,
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_client_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
@ -379,7 +379,7 @@ static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
}
if (o->callback) {
pa_client_info_cb_t cb = (pa_client_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -428,17 +428,17 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_module_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_gets(t, &i.argument) < 0 ||
@ -454,7 +454,7 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
}
if (o->callback) {
pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -476,7 +476,7 @@ pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_GET_MODULE_INFO, &tag);
@ -503,17 +503,17 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_sink_input_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
@ -526,7 +526,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
pa_tagstruct_get_usec(t, &i.sink_usec) < 0 ||
pa_tagstruct_gets(t, &i.resample_method) < 0 ||
pa_tagstruct_gets(t, &i.driver) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -537,7 +537,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm
}
}
}
if (o->callback) {
pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -559,7 +559,7 @@ pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sin
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INPUT_INFO, &tag);
@ -593,10 +593,10 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_source_output_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
@ -608,7 +608,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
pa_tagstruct_get_usec(t, &i.source_usec) < 0 ||
pa_tagstruct_gets(t, &i.resample_method) < 0 ||
pa_tagstruct_gets(t, &i.driver) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -619,7 +619,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
}
}
}
if (o->callback) {
pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -641,7 +641,7 @@ pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO, &tag);
@ -695,7 +695,7 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag);
@ -741,7 +741,7 @@ pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name,
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_MUTE, &tag);
@ -766,7 +766,7 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME, &tag);
@ -815,7 +815,7 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag);
@ -861,7 +861,7 @@ pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_MUTE, &tag);
@ -886,17 +886,17 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command,
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_sample_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
@ -906,7 +906,7 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command,
pa_tagstruct_getu32(t, &i.bytes) < 0 ||
pa_tagstruct_get_boolean(t, &i.lazy) < 0 ||
pa_tagstruct_gets(t, &i.filename) < 0) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -917,7 +917,7 @@ static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
}
if (o->callback) {
pa_sample_info_cb_t cb = (pa_sample_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -932,7 +932,7 @@ pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
assert(cb);
@ -1002,7 +1002,7 @@ static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx,
pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
return command_kill(c, PA_COMMAND_KILL_CLIENT, idx, cb, userdata);
}
pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata) {
return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, idx, cb, userdata);
}
@ -1021,7 +1021,7 @@ static void context_index_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
@ -1048,7 +1048,7 @@ pa_operation* pa_context_load_module(pa_context *c, const char*name, const char
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
@ -1089,10 +1089,10 @@ static void context_get_autoload_info_callback(pa_pdispatch *pd, uint32_t comman
eol = -1;
} else {
while (!pa_tagstruct_eof(t)) {
pa_autoload_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
pa_tagstruct_getu32(t, &i.type) < 0 ||
@ -1108,7 +1108,7 @@ static void context_get_autoload_info_callback(pa_pdispatch *pd, uint32_t comman
}
}
}
if (o->callback) {
pa_autoload_info_cb_t cb = (pa_autoload_info_cb_t) o->callback;
cb(o->context, NULL, eol, o->userdata);
@ -1147,7 +1147,7 @@ pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx,
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(c);
assert(c->ref >= 1);
assert(cb);
@ -1176,7 +1176,7 @@ pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autolo
assert(c);
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, type == PA_AUTOLOAD_SINK || type == PA_AUTOLOAD_SOURCE, PA_ERR_INVALID);
@ -1202,7 +1202,7 @@ pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name
assert(c);
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, type == PA_AUTOLOAD_SINK || type == PA_AUTOLOAD_SOURCE, PA_ERR_INVALID);

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -206,7 +206,7 @@ PA_C_DECL_BEGIN
/** Stores information about sinks */
typedef struct pa_sink_info {
const char *name; /**< Name of the sink */
uint32_t index; /**< Index of the sink */
uint32_t index; /**< Index of the sink */
const char *description; /**< Description of this sink */
pa_sample_spec sample_spec; /**< Sample spec of this sink */
pa_channel_map channel_map; /**< Channel map \since 0.8 */
@ -233,7 +233,7 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t id, pa_s
pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb, void *userdata);
/** Stores information about sources */
typedef struct pa_source_info {
typedef struct pa_source_info {
const char *name ; /**< Name of the source */
uint32_t index; /**< Index of the source */
const char *description; /**< Description of this source */
@ -316,7 +316,7 @@ pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t
/** Stores information about sink inputs */
typedef struct pa_sink_input_info {
uint32_t index; /**< Index of the sink input */
uint32_t index; /**< Index of the sink input */
const char *name; /**< Name of the sink input */
uint32_t owner_module; /**< Index of the module this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any module */
uint32_t client; /**< Index of the client this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any client */
@ -341,11 +341,11 @@ pa_operation* pa_context_get_sink_input_info_list(pa_context *c, pa_sink_input_i
/** Stores information about source outputs */
typedef struct pa_source_output_info {
uint32_t index; /**< Index of the sink input */
uint32_t index; /**< Index of the sink input */
const char *name; /**< Name of the sink input */
uint32_t owner_module; /**< Index of the module this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any module */
uint32_t client; /**< Index of the client this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any client */
uint32_t source; /**< Index of the connected source */
uint32_t owner_module; /**< Index of the module this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any module */
uint32_t client; /**< Index of the client this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any client */
uint32_t source; /**< Index of the connected source */
pa_sample_spec sample_spec; /**< The sample specification of the source output */
pa_channel_map channel_map; /**< Channel map */
pa_usec_t buffer_usec; /**< Latency due to buffering in the source output, see pa_latency_info for details. \since 0.5 */
@ -396,7 +396,7 @@ typedef struct pa_stat_info {
uint32_t memblock_total_size; /**< Currentl total size of allocated memory blocks */
uint32_t memblock_allocated; /**< Allocated memory blocks during the whole lifetime of the daemon */
uint32_t memblock_allocated_size; /**< Total size of all memory blocks allocated during the whole lifetime of the daemon */
uint32_t scache_size; /**< Total size of all sample cache entries. \since 0.4 */
uint32_t scache_size; /**< Total size of all sample cache entries. \since 0.4 */
} pa_stat_info;
/** Callback prototype for pa_context_stat() */
@ -432,7 +432,7 @@ pa_operation* pa_context_get_sample_info_list(pa_context *c, pa_sample_info_cb_t
/** Kill a client. \since 0.5 */
pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);
/** Kill a sink input. \since 0.5 */
pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context_success_cb_t cb, void *userdata);

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -28,7 +28,7 @@
#include <pulse/cdecl.h>
/** \file
*
*
* Main loop abstraction layer. Both the PulseAudio core and the
* PulseAudio client library use a main loop abstraction layer. Due to
* this it is possible to embed PulseAudio into other

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -73,7 +73,7 @@ static void signal_handler(int sig) {
static void dispatch(pa_mainloop_api*a, int sig) {
pa_signal_event*s;
for (s = signals; s; s = s->next)
for (s = signals; s; s = s->next)
if (s->sig == sig) {
assert(s->callback);
s->callback(a, s, sig, s->userdata);
@ -93,7 +93,7 @@ static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags
pa_log("read(): %s", pa_cstrerror(errno));
return;
}
if (r != sizeof(sig)) {
pa_log("short read()");
return;
@ -129,7 +129,7 @@ void pa_signal_done(void) {
while (signals)
pa_signal_free(signals);
api->io_free(io_event);
io_event = NULL;
@ -148,11 +148,11 @@ pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api,
#endif
assert(sig > 0 && _callback);
for (e = signals; e; e = e->next)
if (e->sig == sig)
goto fail;
e = pa_xmalloc(sizeof(pa_signal_event));
e->sig = sig;
e->callback = _callback;
@ -164,7 +164,7 @@ pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api,
sa.sa_handler = signal_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(sig, &sa, &e->saved_sigaction) < 0)
#else
if ((e->saved_handler = signal(sig, signal_handler)) == SIG_ERR)
@ -200,7 +200,7 @@ void pa_signal_free(pa_signal_event *e) {
if (e->destroy_callback)
e->destroy_callback(api, e, e->userdata);
pa_xfree(e);
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -57,11 +57,11 @@
struct pa_io_event {
pa_mainloop *mainloop;
int dead;
int fd;
pa_io_event_flags_t events;
struct pollfd *pollfd;
pa_io_event_cb_t callback;
void *userdata;
pa_io_event_destroy_cb_t destroy_callback;
@ -154,7 +154,7 @@ static pa_io_event* mainloop_io_new(
pa_io_event_flags_t events,
pa_io_event_cb_t callback,
void *userdata) {
pa_mainloop *m;
pa_io_event *e;
@ -162,7 +162,7 @@ static pa_io_event* mainloop_io_new(
assert(a->userdata);
assert(fd >= 0);
assert(callback);
m = a->userdata;
assert(a == &m->api);
@ -173,7 +173,7 @@ static pa_io_event* mainloop_io_new(
e->fd = fd;
e->events = events;
e->pollfd = NULL;
e->callback = callback;
e->userdata = userdata;
e->destroy_callback = NULL;
@ -213,7 +213,7 @@ static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
if (e->events == events)
return;
e->events = events;
if (e->pollfd)
@ -239,7 +239,7 @@ static void mainloop_io_free(pa_io_event *e) {
static void mainloop_io_set_destroy(pa_io_event *e, pa_io_event_destroy_cb_t callback) {
assert(e);
e->destroy_callback = callback;
}
@ -255,7 +255,7 @@ static pa_defer_event* mainloop_defer_new(
assert(a);
assert(a->userdata);
assert(callback);
m = a->userdata;
assert(a == &m->api);
@ -265,7 +265,7 @@ static pa_defer_event* mainloop_defer_new(
e->enabled = 1;
m->n_enabled_defer_events++;
e->callback = callback;
e->userdata = userdata;
e->destroy_callback = NULL;
@ -288,7 +288,7 @@ static void mainloop_defer_enable(pa_defer_event *e, int b) {
e->mainloop->n_enabled_defer_events++;
pa_mainloop_wakeup(e->mainloop);
}
e->enabled = b;
}
@ -318,14 +318,14 @@ static pa_time_event* mainloop_time_new(
const struct timeval *tv,
pa_time_event_cb_t callback,
void *userdata) {
pa_mainloop *m;
pa_time_event *e;
assert(a);
assert(a->userdata);
assert(callback);
m = a->userdata;
assert(a == &m->api);
@ -354,7 +354,7 @@ static pa_time_event* mainloop_time_new(
if (e->enabled)
pa_mainloop_wakeup(m);
return e;
}
@ -375,7 +375,7 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
if (e->mainloop->cached_next_time_event && e->enabled) {
assert(e->mainloop->cached_next_time_event->enabled);
if (pa_timeval_cmp(tv, &e->mainloop->cached_next_time_event->timeval) < 0)
e->mainloop->cached_next_time_event = e;
} else if (e->mainloop->cached_next_time_event == e)
@ -396,7 +396,7 @@ static void mainloop_time_free(pa_time_event *e) {
if (e->mainloop->cached_next_time_event == e)
e->mainloop->cached_next_time_event = NULL;
/* no wakeup needed here. Think about it! */
}
@ -411,7 +411,7 @@ static void mainloop_time_set_destroy(pa_time_event *e, pa_time_event_destroy_cb
static void mainloop_quit(pa_mainloop_api*a, int retval) {
pa_mainloop *m;
assert(a);
assert(a->userdata);
m = a->userdata;
@ -419,7 +419,7 @@ static void mainloop_quit(pa_mainloop_api*a, int retval) {
pa_mainloop_quit(m, retval);
}
static const pa_mainloop_api vtable = {
.userdata = NULL,
@ -432,12 +432,12 @@ static const pa_mainloop_api vtable = {
.time_restart = mainloop_time_restart,
.time_free = mainloop_time_free,
.time_set_destroy = mainloop_time_set_destroy,
.defer_new = mainloop_defer_new,
.defer_enable = mainloop_defer_enable,
.defer_free = mainloop_defer_free,
.defer_set_destroy = mainloop_defer_set_destroy,
.quit = mainloop_quit,
};
@ -466,7 +466,7 @@ pa_mainloop *pa_mainloop_new(void) {
m->cached_next_time_event = NULL;
m->prepared_timeout = 0;
m->pollfds = NULL;
m->max_pollfds = m->n_pollfds = 0;
m->rebuild_pollfds = 1;
@ -481,7 +481,7 @@ pa_mainloop *pa_mainloop_new(void) {
m->poll_func = NULL;
m->poll_func_userdata = NULL;
m->poll_func_ret = -1;
return m;
}
@ -494,7 +494,7 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
if (!force && m->io_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_io_event, m->io_events, e);
@ -502,10 +502,10 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
assert(m->io_events_please_scan > 0);
m->io_events_please_scan--;
}
if (e->destroy_callback)
e->destroy_callback(&m->api, e, e->userdata);
pa_xfree(e);
m->rebuild_pollfds = 1;
@ -526,7 +526,7 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
if (!force && m->time_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_time_event, m->time_events, e);
@ -539,10 +539,10 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
assert(m->n_enabled_time_events > 0);
m->n_enabled_time_events--;
}
if (e->destroy_callback)
e->destroy_callback(&m->api, e, e->userdata);
pa_xfree(e);
}
@ -561,7 +561,7 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
if (!force && m->defer_events_please_scan <= 0)
break;
if (force || e->dead) {
PA_LLIST_REMOVE(pa_defer_event, m->defer_events, e);
@ -574,10 +574,10 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
assert(m->n_enabled_defer_events > 0);
m->n_enabled_defer_events--;
}
if (e->destroy_callback)
e->destroy_callback(&m->api, e, e->userdata);
pa_xfree(e);
}
@ -664,11 +664,11 @@ static int dispatch_pollfds(pa_mainloop *m) {
int r = 0, k;
assert(m->poll_func_ret > 0);
for (e = m->io_events, k = m->poll_func_ret; e && !m->quit && k > 0; e = e->next) {
if (e->dead || !e->pollfd || !e->pollfd->revents)
continue;
assert(e->pollfd->fd == e->fd && e->callback);
e->callback(&m->api, e, e->fd, map_flags_from_libc(e->pollfd->revents), e->userdata);
e->pollfd->revents = 0;
@ -690,7 +690,7 @@ static int dispatch_defer(pa_mainloop *m) {
for (e = m->defer_events; e && !m->quit; e = e->next) {
if (e->dead || !e->enabled)
continue;
assert(e->callback);
e->callback(&m->api, e, e->userdata);
r++;
@ -705,7 +705,7 @@ static pa_time_event* find_next_time_event(pa_mainloop *m) {
if (m->cached_next_time_event)
return m->cached_next_time_event;
for (t = m->time_events; t; t = t->next) {
if (t->dead || !t->enabled)
@ -737,7 +737,7 @@ static int calc_next_timeout(pa_mainloop *m) {
if (t->timeval.tv_sec <= 0)
return 0;
pa_gettimeofday(&now);
if (pa_timeval_cmp(&t->timeval, &now) <= 0)
@ -759,7 +759,7 @@ static int dispatch_timeout(pa_mainloop *m) {
pa_gettimeofday(&now);
for (e = m->time_events; e && !m->quit; e = e->next) {
if (e->dead || !e->enabled)
continue;
@ -815,7 +815,7 @@ int pa_mainloop_prepare(pa_mainloop *m, int timeout) {
if (m->n_enabled_defer_events <= 0) {
if (m->rebuild_pollfds)
rebuild_pollfds(m);
m->prepared_timeout = calc_next_timeout(m);
if (timeout >= 0 && (timeout < m->prepared_timeout || m->prepared_timeout < 0))
m->prepared_timeout = timeout;
@ -842,7 +842,7 @@ int pa_mainloop_poll(pa_mainloop *m) {
m->poll_func_ret = 0;
else {
assert(!m->rebuild_pollfds);
if (m->poll_func)
m->poll_func_ret = m->poll_func(m->pollfds, m->n_pollfds, m->prepared_timeout, m->poll_func_userdata);
else
@ -872,23 +872,23 @@ int pa_mainloop_dispatch(pa_mainloop *m) {
if (m->quit)
goto quit;
if (m->n_enabled_defer_events)
dispatched += dispatch_defer(m);
else {
if (m->n_enabled_time_events)
if (m->n_enabled_time_events)
dispatched += dispatch_timeout(m);
if (m->quit)
goto quit;
if (m->poll_func_ret > 0)
dispatched += dispatch_pollfds(m);
}
if (m->quit)
goto quit;
m->state = STATE_PASSIVE;
return dispatched;
@ -919,7 +919,7 @@ int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval) {
return r;
quit:
if ((r == -2) && retval)
*retval = pa_mainloop_get_retval(m);
return r;
@ -927,7 +927,7 @@ quit:
int pa_mainloop_run(pa_mainloop *m, int *retval) {
int r;
while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0);
if (r == -2)

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -65,7 +65,7 @@ struct pollfd;
*/
/** \file
*
*
* A minimal main loop implementation based on the C library's poll()
* function. Using the routines defined herein you may create a simple
* main loop supporting the generic main loop abstraction layer as

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -46,14 +46,14 @@ pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t cb
/* Refcounting is strictly one-way: from the "bigger" to the "smaller" object. */
PA_LLIST_PREPEND(pa_operation, c->operations, o);
pa_operation_ref(o);
return o;
}
pa_operation *pa_operation_ref(pa_operation *o) {
assert(o);
assert(o->ref >= 1);
o->ref++;
return o;
}
@ -81,14 +81,14 @@ static void operation_set_state(pa_operation *o, pa_operation_state_t st) {
o->state = st;
if ((o->state == PA_OPERATION_DONE) || (o->state == PA_OPERATION_CANCELED)) {
if (o->context) {
assert(o->ref >= 2);
PA_LLIST_REMOVE(pa_operation, o->context->operations, o);
pa_operation_unref(o);
}
o->context = NULL;
o->stream = NULL;
o->callback = NULL;
@ -101,14 +101,14 @@ static void operation_set_state(pa_operation *o, pa_operation_state_t st) {
void pa_operation_cancel(pa_operation *o) {
assert(o);
assert(o->ref >= 1);
operation_set_state(o, PA_OPERATION_CANCELED);
}
void pa_operation_done(pa_operation *o) {
assert(o);
assert(o->ref >= 1);
operation_set_state(o, PA_OPERATION_DONE);
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -55,11 +55,11 @@
/** \mainpage
*
* \section intro_sec Introduction
*
*
* This document describes the client API for the PulseAudio sound
* server. The API comes in two flavours to accomodate different styles
* of applications and different needs in complexity:
*
*
* \li The complete but somewhat complicated to use asynchronous API
* \li The simplified, easy to use, but limited synchronous API
*
@ -67,7 +67,7 @@
* locale. Some functions will filter invalid sequences from the string, some
* will simply fail. To ensure reliable behaviour, make sure everything you
* pass to the API is already in UTF-8.
* \section simple_sec Simple API
*
* Use this if you develop your program in synchronous style and just

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -70,7 +70,7 @@ pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) {
assert(spec);
return (size_t) (((double) t * spec->rate / 1000000))*pa_frame_size(spec);
return (size_t) (((double) t * spec->rate / 1000000))*pa_frame_size(spec);
}
int pa_sample_spec_valid(const pa_sample_spec *spec) {
@ -111,7 +111,7 @@ const char *pa_sample_format_to_string(pa_sample_format_t f) {
char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
assert(s && l && spec);
if (!pa_sample_spec_valid(spec))
snprintf(s, l, "Invalid");
else
@ -134,7 +134,7 @@ char* pa_bytes_snprint(char *s, size_t l, unsigned v) {
}
pa_sample_format_t pa_parse_sample_format(const char *format) {
if (strcasecmp(format, "s16le") == 0)
return PA_SAMPLE_S16LE;
else if (strcasecmp(format, "s16be") == 0)

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -37,14 +37,14 @@
int pa_stream_connect_upload(pa_stream *s, size_t length) {
pa_tagstruct *t;
uint32_t tag;
assert(s);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, length > 0, PA_ERR_INVALID);
pa_stream_ref(s);
s->direction = PA_STREAM_UPLOAD;
t = pa_tagstruct_command(s->context, PA_COMMAND_CREATE_UPLOAD_STREAM, &tag);
@ -56,7 +56,7 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) {
pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
pa_stream_set_state(s, PA_STREAM_CREATING);
pa_stream_unref(s);
return 0;
}
@ -87,16 +87,16 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char
assert(c);
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, !dev || *dev, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
if (!dev)
dev = c->conf->default_sink;
t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag);
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
pa_tagstruct_puts(t, dev);
@ -118,9 +118,9 @@ pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_conte
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_SAMPLE, &tag);
pa_tagstruct_puts(t, name);
pa_pstream_send_tagstruct(c->pstream, t);

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -64,7 +64,7 @@ if (!(expression)) { \
goto label; \
} \
} while(0);
#define CHECK_DEAD_GOTO(p, rerror, label) do { \
if (!(p)->context || pa_context_get_state((p)->context) != PA_CONTEXT_READY || \
!(p)->stream || pa_stream_get_state((p)->stream) != PA_STREAM_READY) { \
@ -143,7 +143,7 @@ pa_simple* pa_simple_new(
const pa_channel_map *map,
const pa_buffer_attr *attr,
int *rerror) {
pa_simple *p;
int error = PA_ERR_INTERNAL, r;
@ -162,12 +162,12 @@ pa_simple* pa_simple_new(
if (!(p->mainloop = pa_threaded_mainloop_new()))
goto fail;
if (!(p->context = pa_context_new(pa_threaded_mainloop_get_api(p->mainloop), name)))
goto fail;
pa_context_set_state_callback(p->context, context_state_cb, p);
if (pa_context_connect(p->context, server, 0, NULL) < 0) {
error = pa_context_errno(p->context);
goto fail;
@ -180,7 +180,7 @@ pa_simple* pa_simple_new(
/* Wait until the context is ready */
pa_threaded_mainloop_wait(p->mainloop);
if (pa_context_get_state(p->context) != PA_CONTEXT_READY) {
error = pa_context_errno(p->context);
goto unlock_and_fail;
@ -216,12 +216,12 @@ pa_simple* pa_simple_new(
}
pa_threaded_mainloop_unlock(p->mainloop);
return p;
unlock_and_fail:
pa_threaded_mainloop_unlock(p->mainloop);
fail:
if (rerror)
*rerror = error;
@ -234,10 +234,10 @@ void pa_simple_free(pa_simple *s) {
if (s->mainloop)
pa_threaded_mainloop_stop(s->mainloop);
if (s->stream)
pa_stream_unref(s->stream);
if (s->context)
pa_context_unref(s->context);
@ -249,38 +249,38 @@ void pa_simple_free(pa_simple *s) {
int pa_simple_write(pa_simple *p, const void*data, size_t length, int *rerror) {
assert(p);
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
CHECK_VALIDITY_RETURN_ANY(rerror, data && length, PA_ERR_INVALID, -1);
pa_threaded_mainloop_lock(p->mainloop);
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
while (length > 0) {
size_t l;
int r;
while (!(l = pa_stream_writable_size(p->stream))) {
pa_threaded_mainloop_wait(p->mainloop);
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
}
CHECK_SUCCESS_GOTO(p, rerror, l != (size_t) -1, unlock_and_fail);
if (l > length)
l = length;
r = pa_stream_write(p->stream, data, l, NULL, 0, PA_SEEK_RELATIVE);
CHECK_SUCCESS_GOTO(p, rerror, r >= 0, unlock_and_fail);
data = (const uint8_t*) data + l;
length -= l;
}
pa_threaded_mainloop_unlock(p->mainloop);
return 0;
unlock_and_fail:
pa_threaded_mainloop_unlock(p->mainloop);
return -1;
@ -293,15 +293,15 @@ int pa_simple_read(pa_simple *p, void*data, size_t length, int *rerror) {
CHECK_VALIDITY_RETURN_ANY(rerror, data && length, PA_ERR_INVALID, -1);
pa_threaded_mainloop_lock(p->mainloop);
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
while (length > 0) {
size_t l;
while (!p->read_data) {
int r;
r = pa_stream_peek(p->stream, &p->read_data, &p->read_length);
CHECK_SUCCESS_GOTO(p, rerror, r == 0, unlock_and_fail);
@ -311,31 +311,31 @@ int pa_simple_read(pa_simple *p, void*data, size_t length, int *rerror) {
} else
p->read_index = 0;
}
l = p->read_length < length ? p->read_length : length;
memcpy(data, (const uint8_t*) p->read_data+p->read_index, l);
data = (uint8_t*) data + l;
length -= l;
p->read_index += l;
p->read_length -= l;
if (!p->read_length) {
int r;
r = pa_stream_drop(p->stream);
p->read_data = NULL;
p->read_length = 0;
p->read_index = 0;
CHECK_SUCCESS_GOTO(p, rerror, r == 0, unlock_and_fail);
}
}
pa_threaded_mainloop_unlock(p->mainloop);
return 0;
unlock_and_fail:
pa_threaded_mainloop_unlock(p->mainloop);
return -1;
@ -353,7 +353,7 @@ static void success_cb(pa_stream *s, int success, void *userdata) {
int pa_simple_drain(pa_simple *p, int *rerror) {
pa_operation *o = NULL;
assert(p);
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
@ -370,7 +370,7 @@ int pa_simple_drain(pa_simple *p, int *rerror) {
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
}
CHECK_SUCCESS_GOTO(p, rerror, p->operation_success, unlock_and_fail);
pa_operation_unref(o);
pa_threaded_mainloop_unlock(p->mainloop);
@ -389,7 +389,7 @@ unlock_and_fail:
int pa_simple_flush(pa_simple *p, int *rerror) {
pa_operation *o = NULL;
assert(p);
CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
@ -399,7 +399,7 @@ int pa_simple_flush(pa_simple *p, int *rerror) {
o = pa_stream_flush(p->stream, success_cb, p);
CHECK_SUCCESS_GOTO(p, rerror, o, unlock_and_fail);
p->operation_success = 0;
while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
pa_threaded_mainloop_wait(p->mainloop);
@ -426,14 +426,14 @@ unlock_and_fail:
pa_usec_t pa_simple_get_latency(pa_simple *p, int *rerror) {
pa_usec_t t;
int negative;
assert(p);
pa_threaded_mainloop_lock(p->mainloop);
for (;;) {
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
if (pa_stream_get_latency(p->stream, &t, &negative) >= 0)
break;
@ -442,7 +442,7 @@ pa_usec_t pa_simple_get_latency(pa_simple *p, int *rerror) {
/* Wait until latency data is available again */
pa_threaded_mainloop_wait(p->mainloop);
}
pa_threaded_mainloop_unlock(p->mainloop);
return negative ? 0 : t;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -43,7 +43,7 @@
pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map) {
pa_stream *s;
int i;
assert(c);
PA_CHECK_VALIDITY_RETURN_NULL(c, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID);
@ -76,7 +76,7 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
s->channel_map = *map;
else
pa_channel_map_init_auto(&s->channel_map, ss->channels, PA_CHANNEL_MAP_DEFAULT);
s->channel = 0;
s->channel_valid = 0;
s->syncid = c->csyncid++;
@ -99,11 +99,11 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
for (i = 0; i < PA_MAX_WRITE_INDEX_CORRECTIONS; i++)
s->write_index_corrections[i].valid = 0;
s->current_write_index_correction = 0;
s->corked = 0;
s->cached_time_valid = 0;
s->auto_timing_update_event = NULL;
s->auto_timing_update_requested = 0;
@ -143,7 +143,7 @@ void pa_stream_unref(pa_stream *s) {
pa_stream* pa_stream_ref(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
s->ref++;
return s;
}
@ -151,14 +151,14 @@ pa_stream* pa_stream_ref(pa_stream *s) {
pa_stream_state_t pa_stream_get_state(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
return s->state;
}
pa_context* pa_stream_get_context(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
return s->context;
}
@ -167,17 +167,17 @@ uint32_t pa_stream_get_index(pa_stream *s) {
assert(s->ref >= 1);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX);
return s->device_index;
}
void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
assert(s);
assert(s->ref >= 1);
if (s->state == st)
return;
pa_stream_ref(s);
s->state = st;
@ -192,24 +192,24 @@ void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
/* Unref all operatio object that point to us */
for (o = s->context->operations; o; o = n) {
n = o->next;
if (o->stream == s)
pa_operation_cancel(o);
}
/* Drop all outstanding replies for this stream */
if (s->context->pdispatch)
pa_pdispatch_unregister_reply(s->context->pdispatch, s);
if (s->channel_valid)
pa_dynarray_put((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, s->channel, NULL);
PA_LLIST_REMOVE(pa_stream, s->context->streams, s);
pa_stream_unref(s);
s->channel = 0;
s->channel_valid = 0;
s->context = NULL;
}
@ -220,20 +220,20 @@ void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
pa_context *c = userdata;
pa_stream *s;
uint32_t channel;
assert(pd);
assert(command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED);
assert(t);
assert(c);
pa_context_ref(c);
if (pa_tagstruct_getu32(t, &channel) < 0 ||
!pa_tagstruct_eof(t)) {
pa_context_fail(c, PA_ERR_PROTOCOL);
goto finish;
}
if (!(s = pa_dynarray_get(command == PA_COMMAND_PLAYBACK_STREAM_KILLED ? c->playback_streams : c->record_streams, channel)))
goto finish;
@ -248,27 +248,27 @@ void pa_command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32
pa_stream *s;
pa_context *c = userdata;
uint32_t bytes, channel;
assert(pd);
assert(command == PA_COMMAND_REQUEST);
assert(t);
assert(c);
pa_context_ref(c);
if (pa_tagstruct_getu32(t, &channel) < 0 ||
pa_tagstruct_getu32(t, &bytes) < 0 ||
!pa_tagstruct_eof(t)) {
pa_context_fail(c, PA_ERR_PROTOCOL);
goto finish;
}
if (!(s = pa_dynarray_get(c->playback_streams, channel)))
goto finish;
if (s->state == PA_STREAM_READY) {
s->requested_bytes += bytes;
if (s->requested_bytes > 0 && s->write_callback)
s->write_callback(s, s->requested_bytes, s->write_userdata);
}
@ -288,13 +288,13 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, PA_GCC
assert(c);
pa_context_ref(c);
if (pa_tagstruct_getu32(t, &channel) < 0 ||
!pa_tagstruct_eof(t)) {
pa_context_fail(c, PA_ERR_PROTOCOL);
goto finish;
}
if (!(s = pa_dynarray_get(c->playback_streams, channel)))
goto finish;
@ -319,11 +319,11 @@ static void request_auto_timing_update(pa_stream *s, int force) {
if (!(s->flags & PA_STREAM_AUTO_TIMING_UPDATE))
return;
if (s->state == PA_STREAM_READY &&
(force || !s->auto_timing_update_requested)) {
pa_operation *o;
/* pa_log("automatically requesting new timing data"); */
if ((o = pa_stream_update_timing_info(s, NULL, NULL))) {
@ -341,32 +341,32 @@ static void invalidate_indexes(pa_stream *s, int r, int w) {
assert(s);
/* pa_log("invalidate r:%u w:%u tag:%u", r, w, s->context->ctag); */
if (s->state != PA_STREAM_READY)
return;
if (w) {
s->write_index_not_before = s->context->ctag;
if (s->timing_info_valid)
s->timing_info.write_index_corrupt = 1;
/* pa_log("write_index invalidated"); */
}
if (r) {
s->read_index_not_before = s->context->ctag;
if (s->timing_info_valid)
s->timing_info.read_index_corrupt = 1;
/* pa_log("read_index invalidated"); */
}
if ((s->direction == PA_STREAM_PLAYBACK && r) ||
(s->direction == PA_STREAM_RECORD && w))
s->cached_time_valid = 0;
request_auto_timing_update(s, 1);
}
@ -382,17 +382,17 @@ static void auto_timing_update_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC
void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_stream *s = userdata;
assert(pd);
assert(s);
assert(s->state == PA_STREAM_CREATING);
pa_stream_ref(s);
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(s->context, command, t) < 0)
goto finish;
pa_stream_set_state(s, PA_STREAM_FAILED);
goto finish;
}
@ -429,9 +429,9 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
if (s->direction == PA_STREAM_RECORD) {
assert(!s->record_memblockq);
s->record_memblockq = pa_memblockq_new(
0,
0,
s->buffer_attr.maxlength,
0,
pa_frame_size(&s->sample_spec),
@ -444,7 +444,7 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
pa_dynarray_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, s->channel, s);
pa_stream_set_state(s, PA_STREAM_READY);
if (s->direction != PA_STREAM_UPLOAD &&
s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
struct timeval tv;
@ -473,13 +473,13 @@ static int create_stream(
pa_stream_flags_t flags,
const pa_cvolume *volume,
pa_stream *sync_stream) {
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, !(flags & ~((direction != PA_STREAM_UPLOAD ?
PA_STREAM_START_CORKED|
@ -493,10 +493,10 @@ static int create_stream(
s->direction = direction;
s->flags = flags;
if (sync_stream)
s->syncid = sync_stream->syncid;
if (attr)
s->buffer_attr = *attr;
else {
@ -515,7 +515,7 @@ static int create_stream(
s->context,
s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CREATE_PLAYBACK_STREAM : PA_COMMAND_CREATE_RECORD_STREAM,
&tag);
pa_tagstruct_put(
t,
PA_TAG_STRING, s->name,
@ -526,7 +526,7 @@ static int create_stream(
PA_TAG_U32, s->buffer_attr.maxlength,
PA_TAG_BOOLEAN, !!(flags & PA_STREAM_START_CORKED),
PA_TAG_INVALID);
if (s->direction == PA_STREAM_PLAYBACK) {
pa_cvolume cv;
@ -540,7 +540,7 @@ static int create_stream(
if (!volume)
volume = pa_cvolume_reset(&cv, s->sample_spec.channels);
pa_tagstruct_put_cvolume(t, volume);
} else
pa_tagstruct_putu32(t, s->buffer_attr.fragsize);
@ -549,7 +549,7 @@ static int create_stream(
pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
pa_stream_set_state(s, PA_STREAM_CREATING);
pa_stream_unref(s);
return 0;
}
@ -561,10 +561,10 @@ int pa_stream_connect_playback(
pa_stream_flags_t flags,
pa_cvolume *volume,
pa_stream *sync_stream) {
assert(s);
assert(s->ref >= 1);
return create_stream(PA_STREAM_PLAYBACK, s, dev, attr, flags, volume, sync_stream);
}
@ -573,7 +573,7 @@ int pa_stream_connect_record(
const char *dev,
const pa_buffer_attr *attr,
pa_stream_flags_t flags) {
assert(s);
assert(s->ref >= 1);
@ -587,9 +587,9 @@ int pa_stream_write(
void (*free_cb)(void *p),
int64_t offset,
pa_seek_mode_t seek) {
pa_memchunk chunk;
assert(s);
assert(s->ref >= 1);
assert(data);
@ -602,29 +602,29 @@ int pa_stream_write(
if (length <= 0)
return 0;
if (free_cb)
if (free_cb)
chunk.memblock = pa_memblock_new_user(s->context->mempool, (void*) data, length, free_cb, 1);
else {
chunk.memblock = pa_memblock_new(s->context->mempool, length);
memcpy(chunk.memblock->data, data, length);
}
chunk.index = 0;
chunk.length = length;
pa_pstream_send_memblock(s->context->pstream, s->channel, offset, seek, &chunk);
pa_memblock_unref(chunk.memblock);
if (length < s->requested_bytes)
s->requested_bytes -= length;
else
s->requested_bytes = 0;
if (s->direction == PA_STREAM_PLAYBACK) {
/* Update latency request correction */
if (s->write_index_corrections[s->current_write_index_correction].valid) {
if (seek == PA_SEEK_ABSOLUTE) {
s->write_index_corrections[s->current_write_index_correction].corrupt = 0;
s->write_index_corrections[s->current_write_index_correction].absolute = 1;
@ -635,10 +635,10 @@ int pa_stream_write(
} else
s->write_index_corrections[s->current_write_index_correction].corrupt = 1;
}
/* Update the write index in the already available latency data */
if (s->timing_info_valid) {
if (seek == PA_SEEK_ABSOLUTE) {
s->timing_info.write_index_corrupt = 0;
s->timing_info.write_index = offset + length;
@ -652,7 +652,7 @@ int pa_stream_write(
if (!s->timing_info_valid || s->timing_info.write_index_corrupt)
request_auto_timing_update(s, 1);
}
return 0;
}
@ -664,7 +664,7 @@ int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
if (!s->peek_memchunk.memblock) {
if (pa_memblockq_peek(s->record_memblockq, &s->peek_memchunk) < 0) {
@ -686,13 +686,13 @@ int pa_stream_drop(pa_stream *s) {
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->peek_memchunk.memblock, PA_ERR_BADSTATE);
pa_memblockq_drop(s->record_memblockq, &s->peek_memchunk, s->peek_memchunk.length);
/* Fix the simulated local read index */
if (s->timing_info_valid && !s->timing_info.read_index_corrupt)
s->timing_info.read_index += s->peek_memchunk.length;
pa_memblock_unref(s->peek_memchunk.memblock);
s->peek_memchunk.length = 0;
s->peek_memchunk.index = 0;
@ -707,7 +707,7 @@ size_t pa_stream_writable_size(pa_stream *s) {
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1);
return s->requested_bytes;
}
@ -725,7 +725,7 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
@ -746,7 +746,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
pa_operation *o = userdata;
struct timeval local, remote, now;
pa_timing_info *i;
assert(pd);
assert(o);
@ -756,7 +756,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
i = &o->stream->timing_info;
/* pa_log("pre corrupt w:%u r:%u\n", !o->stream->timing_info_valid || i->write_index_corrupt,!o->stream->timing_info_valid || i->read_index_corrupt); */
o->stream->timing_info_valid = 0;
i->write_index_corrupt = 0;
i->read_index_corrupt = 0;
@ -777,21 +777,21 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
!pa_tagstruct_eof(t)) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
goto finish;
} else {
o->stream->timing_info_valid = 1;
pa_gettimeofday(&now);
/* Calculcate timestamps */
if (pa_timeval_cmp(&local, &remote) <= 0 && pa_timeval_cmp(&remote, &now) <= 0) {
/* local and remote seem to have synchronized clocks */
if (o->stream->direction == PA_STREAM_PLAYBACK)
i->transport_usec = pa_timeval_diff(&remote, &local);
else
i->transport_usec = pa_timeval_diff(&now, &remote);
i->synchronized_clocks = 1;
i->timestamp = remote;
} else {
@ -816,7 +816,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
uint32_t ctag = tag;
/* Go through the saved correction values and add up the total correction.*/
for (n = 0, j = o->stream->current_write_index_correction+1;
n < PA_MAX_WRITE_INDEX_CORRECTIONS;
n++, j = (j + 1) % PA_MAX_WRITE_INDEX_CORRECTIONS) {
@ -851,21 +851,21 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
if (!i->read_index_corrupt)
i->read_index -= pa_memblockq_get_length(o->stream->record_memblockq);
}
o->stream->cached_time_valid = 0;
}
o->stream->auto_timing_update_requested = 0;
/* pa_log("post corrupt w:%u r:%u\n", i->write_index_corrupt || !o->stream->timing_info_valid, i->read_index_corrupt || !o->stream->timing_info_valid); */
/* Clear old correction entries */
if (o->stream->direction == PA_STREAM_PLAYBACK) {
int n;
for (n = 0; n < PA_MAX_WRITE_INDEX_CORRECTIONS; n++) {
if (!o->stream->write_index_corrections[n].valid)
continue;
if (o->stream->write_index_corrections[n].tag <= tag)
o->stream->write_index_corrections[n].valid = 0;
}
@ -873,12 +873,12 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
if (o->stream->latency_update_callback)
o->stream->latency_update_callback(o->stream, o->stream->latency_update_userdata);
if (o->callback && o->stream && o->stream->state == PA_STREAM_READY) {
pa_stream_success_cb_t cb = (pa_stream_success_cb_t) o->callback;
cb(o->stream, o->stream->timing_info_valid, o->userdata);
}
finish:
pa_operation_done(o);
@ -891,29 +891,29 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
pa_tagstruct *t;
struct timeval now;
int cidx = 0;
assert(s);
assert(s->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
if (s->direction == PA_STREAM_PLAYBACK) {
/* Find a place to store the write_index correction data for this entry */
cidx = (s->current_write_index_correction + 1) % PA_MAX_WRITE_INDEX_CORRECTIONS;
/* Check if we could allocate a correction slot. If not, there are too many outstanding queries */
PA_CHECK_VALIDITY_RETURN_NULL(s->context, !s->write_index_corrections[cidx].valid, PA_ERR_INTERNAL);
}
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(
s->context,
s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_GET_PLAYBACK_LATENCY : PA_COMMAND_GET_RECORD_LATENCY,
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_put_timeval(t, pa_gettimeofday(&now));
pa_pstream_send_tagstruct(s->context->pstream, t);
pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_timing_info_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
@ -926,15 +926,15 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
o->stream->write_index_corrections[cidx].value = 0;
o->stream->write_index_corrections[cidx].corrupt = 0;
}
/* pa_log("requesting update %u\n", tag); */
return o;
}
void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_stream *s = userdata;
assert(pd);
assert(s);
assert(s->ref >= 1);
@ -961,7 +961,7 @@ finish:
int pa_stream_disconnect(pa_stream *s) {
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
@ -1010,7 +1010,7 @@ void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *
void pa_stream_set_overflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
s->overflow_callback = cb;
s->overflow_userdata = userdata;
}
@ -1018,7 +1018,7 @@ void pa_stream_set_overflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, voi
void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
s->underflow_callback = cb;
s->underflow_userdata = userdata;
}
@ -1026,7 +1026,7 @@ void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, vo
void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
s->latency_update_callback = cb;
s->latency_update_userdata = userdata;
}
@ -1034,14 +1034,14 @@ void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t c
void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_operation *o = userdata;
int success = 1;
assert(pd);
assert(o);
assert(o->ref >= 1);
if (!o->context)
goto finish;
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
@ -1066,15 +1066,15 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
s->corked = b;
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(
@ -1096,12 +1096,12 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
pa_tagstruct *t;
pa_operation *o;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(s->context, command, &tag);
@ -1114,26 +1114,26 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
pa_operation *o;
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
if ((o = stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata))) {
if (s->direction == PA_STREAM_PLAYBACK) {
if (s->write_index_corrections[s->current_write_index_correction].valid)
s->write_index_corrections[s->current_write_index_correction].corrupt = 1;
if (s->timing_info_valid)
s->timing_info.write_index_corrupt = 1;
if (s->buffer_attr.prebuf > 0)
if (s->buffer_attr.prebuf > 0)
invalidate_indexes(s, 1, 0);
else
request_auto_timing_update(s, 1);
} else
invalidate_indexes(s, 0, 1);
}
return o;
}
@ -1151,13 +1151,13 @@ pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *us
pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
pa_operation *o;
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
if ((o = stream_send_simple_command(s, PA_COMMAND_TRIGGER_PLAYBACK_STREAM, cb, userdata)))
invalidate_indexes(s, 1, 0);
return o;
}
@ -1165,7 +1165,7 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
assert(name);
@ -1213,7 +1213,7 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
* to us, we assume that the real output time is actually
* a little ahead */
usec += s->timing_info.transport_usec;
/* However, the output device usually maintains a buffer
too, hence the real sample currently played is a little
back */
@ -1222,7 +1222,7 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
else
usec -= s->timing_info.sink_usec;
}
} else if (s->direction == PA_STREAM_RECORD) {
/* The last byte written into the server side queue had
* this time value associated */
@ -1231,10 +1231,10 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
if (!s->corked) {
/* Add transport latency */
usec += s->timing_info.transport_usec;
/* Add latency of data in device buffer */
usec += s->timing_info.source_usec;
/* If this is a monitor source, we need to correct the
* time by the playback device buffer */
if (s->timing_info.sink_usec >= usec)
@ -1269,18 +1269,18 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
if (r_usec)
*r_usec = usec;
return 0;
}
static pa_usec_t time_counter_diff(pa_stream *s, pa_usec_t a, pa_usec_t b, int *negative) {
assert(s);
assert(s->ref >= 1);
if (negative)
*negative = 0;
if (a >= b)
if (a >= b)
return a-b;
else {
if (negative && s->direction == PA_STREAM_RECORD) {
@ -1305,7 +1305,7 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
PA_CHECK_VALIDITY(s->context, s->timing_info_valid, PA_ERR_NODATA);
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_PLAYBACK || !s->timing_info.write_index_corrupt, PA_ERR_NODATA);
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_RECORD || !s->timing_info.read_index_corrupt, PA_ERR_NODATA);
if ((r = pa_stream_get_time(s, &t)) < 0)
return r;
@ -1316,7 +1316,7 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
if (cindex < 0)
cindex = 0;
c = pa_bytes_to_usec(cindex, &s->sample_spec);
if (s->direction == PA_STREAM_PLAYBACK)

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -113,7 +113,7 @@
* read index may be larger than the write index, in which case
* silence is played. If the application writes data to indexes lower
* than the read index, the data is immediately lost.
*
*
* \section transfer_sec Transferring Data
*
* Once the stream is up, data can start flowing between the client and the
@ -159,13 +159,13 @@
* \li PA_SEEK_ABSOLUTE - seek relative to the beginning of the playback buffer, (i.e. the first that was ever played in the stream)
* \li PA_SEEK_RELATIVE_ON_READ - seek relative to the current read index. Use this to write data to the output buffer that should be played as soon as possible
* \li PA_SEEK_RELATIVE_END - seek relative to the last byte ever written.
*
*
* If an application just wants to append some data to the output
* buffer, PA_SEEK_RELATIVE and an offset of 0 should be used.
*
* After a call to pa_stream_write() the write index will be left at
* the position right after the last byte of the written data.
*
*
* \section latency_sec Latency
*
* A major problem with networked audio is the increased latency caused by
@ -217,7 +217,7 @@
* this option with PA_STREAM_AUTO_TIMING_UPDATE, which will enable
* you to monitor the current playback time/latency very precisely and
* very frequently without requiring a network round trip every time.
*
*
* \section flow_sec Overflow and underflow
*
* Even with the best precautions, buffers will sometime over - or
@ -275,7 +275,7 @@ typedef void (*pa_stream_notify_cb_t)(pa_stream *p, void *userdata);
/** Create a new, unconnected stream with the specified name and sample type */
pa_stream* pa_stream_new(
pa_context *c /**< The context to create this stream in */,
pa_context *c /**< The context to create this stream in */,
const char *name /**< A name for this stream */,
const pa_sample_spec *ss /**< The desired sample format */,
const pa_channel_map *map /**< The desired channel map, or NULL for default */);
@ -320,7 +320,7 @@ int pa_stream_disconnect(pa_stream *s);
* is not copied. If NULL, the data is copied into an internal
* buffer. The client my freely seek around in the output buffer. For
* most applications passing 0 and PA_SEEK_RELATIVE as arguments for
* offset and seek should be useful.*/
* offset and seek should be useful.*/
int pa_stream_write(
pa_stream *p /**< The stream to use */,
const void *data /**< The data to write */,
@ -333,7 +333,7 @@ int pa_stream_write(
* data will point to the actual data and length will contain the size
* of the data in bytes (which can be less than a complete framgnet).
* Use pa_stream_drop() to actually remove the data from the
* buffer. If no data is available will return a NULL pointer \since 0.8 */
* buffer. If no data is available will return a NULL pointer \since 0.8 */
int pa_stream_peek(
pa_stream *p /**< The stream to use */,
const void **data /**< Pointer to pointer that will point to data */,

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -69,7 +69,7 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
assert(c->ref >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(c, PA_COMMAND_SUBSCRIBE, &tag);
@ -83,7 +83,7 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
void pa_context_set_subscribe_callback(pa_context *c, pa_context_subscribe_cb_t cb, void *userdata) {
assert(c);
assert(c->ref >= 1);
c->subscribe_callback = cb;
c->subscribe_userdata = userdata;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -128,7 +128,7 @@ void pa_threaded_mainloop_free(pa_threaded_mainloop* m) {
pa_mutex_free(m->mutex);
pa_cond_free(m->cond);
pa_cond_free(m->accept_cond);
pa_xfree(m);
}
@ -161,7 +161,7 @@ void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) {
void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) {
assert(m);
/* Make sure that this function is not called from the helper thread */
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
@ -170,7 +170,7 @@ void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) {
void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) {
assert(m);
/* Make sure that this function is not called from the helper thread */
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
@ -188,7 +188,7 @@ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
assert(m);
/* Make sure that this function is not called from the helper thread */
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
@ -202,7 +202,7 @@ void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
assert(m);
/* Make sure that this function is not called from the helper thread */
assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -149,7 +149,7 @@ PA_C_DECL_BEGIN
* deal with that.
*
* The functions will not dead lock because the wait function will release
* the lock before waiting and then regrab it once it has been signaled.
* the lock before waiting and then regrab it once it has been signaled.
* For those of you familiar with threads, the behaviour is that of a
* condition variable.
*
@ -229,7 +229,7 @@ PA_C_DECL_BEGIN
*/
/** \file
*
*
* A thread based event loop implementation based on pa_mainloop. The
* event loop is run in a helper thread in the background. A few
* synchronization primitives are available to access the objects

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -38,7 +38,7 @@
struct timeval *pa_gettimeofday(struct timeval *tv) {
#ifdef HAVE_GETTIMEOFDAY
assert(tv);
return gettimeofday(tv, NULL) < 0 ? NULL : tv;
#elif defined(OS_IS_WIN32)
/*
@ -118,14 +118,14 @@ int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) {
pa_usec_t pa_timeval_age(const struct timeval *tv) {
struct timeval now;
assert(tv);
return pa_timeval_diff(pa_gettimeofday(&now), tv);
}
struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
unsigned long secs;
assert(tv);
secs = (v/1000000);
tv->tv_sec += (unsigned long) secs;
v -= secs*1000000;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -130,7 +130,7 @@ ONE_REMAINING:
if (o)
o++;
continue;
error:

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -79,7 +79,7 @@ char *pa_get_user_name(char *s, size_t l) {
if (!(p = getenv("USER")) && !(p = getenv("LOGNAME")) && !(p = getenv("USERNAME"))) {
#ifdef HAVE_PWD_H
#ifdef HAVE_GETPWUID_R
if (getpwuid_r(getuid(), &pw, buf, sizeof(buf), &r) != 0 || !r) {
#else
@ -90,7 +90,7 @@ char *pa_get_user_name(char *s, size_t l) {
snprintf(s, l, "%lu", (unsigned long) getuid());
return s;
}
p = r->pw_name;
#elif defined(OS_IS_WIN32) /* HAVE_PWD_H */
@ -162,26 +162,26 @@ char *pa_get_binary_name(char *s, size_t l) {
#if defined(OS_IS_WIN32)
{
char path[PATH_MAX];
if (GetModuleFileName(NULL, path, PATH_MAX))
return pa_strlcpy(s, pa_path_get_filename(path), l);
}
#endif
#ifdef HAVE_READLINK
{
int i;
char path[PATH_MAX];
/* This works on Linux only */
if ((i = readlink("/proc/self/exe", path, sizeof(path)-1)) >= 0) {
path[i] = 0;
return pa_strlcpy(s, pa_path_get_filename(path), l);
}
}
#endif
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_GET_NAME)
{
@ -192,14 +192,14 @@ char *pa_get_binary_name(char *s, size_t l) {
char tcomm[TASK_COMM_LEN+1];
memset(tcomm, 0, sizeof(tcomm));
/* This works on Linux only */
if (prctl(PR_GET_NAME, (unsigned long) tcomm, 0, 0, 0) == 0)
return pa_strlcpy(s, tcomm, l);
}
#endif
return NULL;
}
@ -214,7 +214,7 @@ const char *pa_path_get_filename(const char *p) {
char *pa_get_fqdn(char *s, size_t l) {
char hn[256];
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO
struct addrinfo *a, hints;
#endif
@ -225,7 +225,7 @@ char *pa_get_fqdn(char *s, size_t l) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_CANONNAME;
if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a->ai_canonname || !*a->ai_canonname)
return pa_strlcpy(s, hn, l);

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -36,7 +36,7 @@ int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
if (a->channels != b->channels)
return 0;
for (i = 0; i < a->channels; i++)
if (a->values[i] != b->values[i])
return 0;
@ -46,7 +46,7 @@ int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
int i;
assert(a);
assert(channels > 0);
assert(channels <= PA_CHANNELS_MAX);
@ -115,7 +115,7 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
unsigned channel;
int first = 1;
char *e;
assert(s);
assert(l > 0);
assert(c);
@ -149,7 +149,7 @@ int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) {
pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) {
unsigned i;
assert(dest);
assert(a);
assert(b);

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -60,10 +60,10 @@ void* pa_xmalloc(size_t size) {
void *p;
assert(size > 0);
assert(size < MAX_ALLOC_SIZE);
if (!(p = malloc(size)))
oom();
return p;
}
@ -71,18 +71,18 @@ void* pa_xmalloc0(size_t size) {
void *p;
assert(size > 0);
assert(size < MAX_ALLOC_SIZE);
if (!(p = calloc(1, size)))
oom();
return p;
}
void *pa_xrealloc(void *ptr, size_t size) {
void *p;
assert(size > 0);
assert(size < MAX_ALLOC_SIZE);
if (!(p = realloc(ptr, size)))
oom();
return p;
@ -107,7 +107,7 @@ char *pa_xstrdup(const char *s) {
char *pa_xstrndup(const char *s, size_t l) {
char *e, *r;
if (!s)
return NULL;

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -48,7 +48,7 @@ struct pa_anotify {
static void dispatch_event(pa_anotify *a) {
assert(a);
assert(a->queue_index < a->n_queued_events);
a->callback(a->queued_events[a->queue_index++], a->userdata);
if (a->queue_index >= a->n_queued_events) {
@ -69,14 +69,14 @@ static void io_callback(
int fd,
pa_io_event_flags_t events,
void *userdata) {
pa_anotify *a = userdata;
ssize_t r;
assert(a);
assert(events == PA_IO_EVENT_INPUT);
assert(a->n_queued_events == 0);
r = read(fd, a->queued_events, sizeof(a->queued_events));
assert(r > 0);
@ -96,7 +96,7 @@ static void defer_callback(pa_mainloop_api *api, pa_defer_event *e, void *userda
pa_anotify *pa_anotify_new(pa_mainloop_api*api, pa_anotify_cb_t cb, void *userdata) {
pa_anotify *a;
assert(api);
assert(cb);
@ -106,7 +106,7 @@ pa_anotify *pa_anotify_new(pa_mainloop_api*api, pa_anotify_cb_t cb, void *userda
pa_xfree(a);
return NULL;
}
a->api = api;
a->callback = cb;
a->userdata = userdata;
@ -130,7 +130,7 @@ void pa_anotify_free(pa_anotify *a) {
close(a->fds[0]);
if (a->fds[1] >= 0)
close(a->fds[1]);
pa_xfree(a);
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -37,7 +37,7 @@ struct authkey_data {
int pa_authkey_prop_get(pa_core *c, const char *name, void *data, size_t len) {
struct authkey_data *a;
assert(c && name && data && len > 0);
if (!(a = pa_property_get(c, name)))
return -1;
@ -59,7 +59,7 @@ int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t l
memcpy(a+1, data, len);
pa_property_set(c, name, a);
return 0;
}

View file

@ -5,17 +5,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307

View file

@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@ -91,25 +91,25 @@ static int load(const char *fn, void *data, size_t length) {
if ((size_t) r != length) {
pa_log_debug("got %d bytes from cookie file '%s', expected %d", (int)r, fn, (int)length);
if (!writable) {
pa_log("unable to write cookie to read only file");
goto finish;
}
if (generate(fd, data, length) < 0)
goto finish;
}
ret = 0;
finish:
if (fd >= 0) {
if (unlock)
pa_lock_fd(fd, 0);
close(fd);
}
@ -144,7 +144,7 @@ static const char *normalize_path(const char *fn, char *s, size_t l) {
char homedir[PATH_MAX];
if (!pa_get_home_dir(homedir, sizeof(homedir)))
return NULL;
#ifndef OS_IS_WIN32
snprintf(s, l, "%s/%s", homedir, fn);
#else
@ -165,7 +165,7 @@ int pa_authkey_load_auto(const char *fn, void *data, size_t length) {
if (!(p = normalize_path(fn, path, sizeof(path))))
return -2;
return pa_authkey_load(p, data, length);
}
@ -194,14 +194,14 @@ int pa_authkey_save(const char *fn, const void *data, size_t length) {
}
ret = 0;
finish:
if (fd >= 0) {
if (unlock)
pa_lock_fd(fd, 0);
close(fd);
}

Some files were not shown because too many files have changed in this diff Show more