mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
Apply #ifdefs around functionality not available on win32
And also the reverse: around some win32 specific functionality
This commit is contained in:
parent
0ac0479534
commit
bb12ff8356
20 changed files with 120 additions and 13 deletions
|
|
@ -390,6 +390,7 @@ AC_CHECK_HEADERS_ONCE([byteswap.h])
|
||||||
AC_CHECK_HEADERS_ONCE([sys/syscall.h])
|
AC_CHECK_HEADERS_ONCE([sys/syscall.h])
|
||||||
AC_CHECK_HEADERS_ONCE([sys/eventfd.h])
|
AC_CHECK_HEADERS_ONCE([sys/eventfd.h])
|
||||||
AC_CHECK_HEADERS_ONCE([execinfo.h])
|
AC_CHECK_HEADERS_ONCE([execinfo.h])
|
||||||
|
AC_CHECK_HEADERS_ONCE([langinfo.h])
|
||||||
|
|
||||||
#### Typdefs, structures, etc. ####
|
#### Typdefs, structures, etc. ####
|
||||||
|
|
||||||
|
|
@ -470,7 +471,7 @@ AC_FUNC_SELECT_ARGTYPES
|
||||||
AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
|
AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
|
||||||
getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
|
getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
|
||||||
pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
|
pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
|
||||||
sigaction sleep sysconf pthread_setaffinity_np])
|
sigaction sleep symlink sysconf uname pthread_setaffinity_np])
|
||||||
AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
|
AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_MKFIFO, test "x$HAVE_MKFIFO" = "x1")
|
AM_CONDITIONAL(HAVE_MKFIFO, test "x$HAVE_MKFIFO" = "x1")
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
@ -460,10 +463,12 @@ static int parse_rtprio(const char *filename, unsigned line, const char *section
|
||||||
pa_assert(rvalue);
|
pa_assert(rvalue);
|
||||||
pa_assert(data);
|
pa_assert(data);
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
if (pa_atoi(rvalue, &rtprio) < 0 || rtprio < sched_get_priority_min(SCHED_FIFO) || rtprio > sched_get_priority_max(SCHED_FIFO)) {
|
if (pa_atoi(rvalue, &rtprio) < 0 || rtprio < sched_get_priority_min(SCHED_FIFO) || rtprio > sched_get_priority_max(SCHED_FIFO)) {
|
||||||
pa_log("[%s:%u] Invalid realtime priority '%s'.", filename, line, rvalue);
|
pa_log("[%s:%u] Invalid realtime priority '%s'.", filename, line, rvalue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
c->realtime_priority = (int) rtprio;
|
c->realtime_priority = (int) rtprio;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,9 @@ static void show_info(const char *name, const char *path, void (*info)(const cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
extern const lt_dlsymlist lt_preloaded_symbols[];
|
extern const lt_dlsymlist lt_preloaded_symbols[];
|
||||||
|
#endif
|
||||||
|
|
||||||
static int is_preloaded(const char *name) {
|
static int is_preloaded(const char *name) {
|
||||||
const lt_dlsymlist *l;
|
const lt_dlsymlist *l;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@
|
||||||
#undef PA_BIND_NOW
|
#undef PA_BIND_NOW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
#undef PA_BIND_NOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PA_BIND_NOW
|
#ifdef PA_BIND_NOW
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -654,6 +654,7 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (getuid() == 0 && !conf->system_instance)
|
if (getuid() == 0 && !conf->system_instance)
|
||||||
pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
|
pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
|
||||||
#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
|
#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
|
||||||
|
|
@ -662,6 +663,7 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* HAVE_GETUID */
|
||||||
|
|
||||||
if (conf->cmd == PA_CMD_START && conf->system_instance) {
|
if (conf->cmd == PA_CMD_START && conf->system_instance) {
|
||||||
pa_log(_("--start not supported for system instances."));
|
pa_log(_("--start not supported for system instances."));
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ static void update_rule(struct rule *r) {
|
||||||
DIR *desktopfiles_dir;
|
DIR *desktopfiles_dir;
|
||||||
struct dirent *dir;
|
struct dirent *dir;
|
||||||
|
|
||||||
|
#ifdef DT_DIR
|
||||||
/* Let's try a more aggressive search, but only one level */
|
/* Let's try a more aggressive search, but only one level */
|
||||||
if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
|
if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
|
||||||
while ((dir = readdir(desktopfiles_dir))) {
|
while ((dir = readdir(desktopfiles_dir))) {
|
||||||
|
|
@ -200,6 +201,7 @@ static void update_rule(struct rule *r) {
|
||||||
}
|
}
|
||||||
closedir(desktopfiles_dir);
|
closedir(desktopfiles_dir);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
r->good = FALSE;
|
r->good = FALSE;
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,14 @@ int pa__init(pa_module*m) {
|
||||||
* of log messages, particularly because if stdout and stderr are
|
* of log messages, particularly because if stdout and stderr are
|
||||||
* dup'ed they share the same O_NDELAY, too. */
|
* dup'ed they share the same O_NDELAY, too. */
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
|
if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
|
||||||
io = pa_iochannel_new(m->core->mainloop, fd, fd);
|
io = pa_iochannel_new(m->core->mainloop, fd, fd);
|
||||||
pa_log_debug("Managed to open /dev/tty.");
|
pa_log_debug("Managed to open /dev/tty.");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
||||||
pa_iochannel_set_noclose(io, TRUE);
|
pa_iochannel_set_noclose(io, TRUE);
|
||||||
pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
|
pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,18 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NETINET_TCP_H
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_SOCKIOS_H
|
#ifdef HAVE_LINUX_SOCKIOS_H
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
|
|
|
||||||
|
|
@ -585,10 +585,12 @@ static char *get_old_legacy_runtime_dir(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -607,10 +609,12 @@ static char *get_very_old_legacy_runtime_dir(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -997,6 +1001,7 @@ int pa_context_connect(
|
||||||
/* Set up autospawning */
|
/* Set up autospawning */
|
||||||
if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) {
|
if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) {
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (getuid() == 0)
|
if (getuid() == 0)
|
||||||
pa_log_debug("Not doing autospawn since we are root.");
|
pa_log_debug("Not doing autospawn since we are root.");
|
||||||
else {
|
else {
|
||||||
|
|
@ -1005,6 +1010,7 @@ int pa_context_connect(
|
||||||
if (api)
|
if (api)
|
||||||
c->spawn_api = *api;
|
c->spawn_api = *api;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_context_set_state(c, PA_CONTEXT_CONNECTING);
|
pa_context_set_state(c, PA_CONTEXT_CONNECTING);
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,15 @@ char *pa_get_user_name(char *s, size_t l) {
|
||||||
pa_assert(s);
|
pa_assert(s);
|
||||||
pa_assert(l > 0);
|
pa_assert(l > 0);
|
||||||
|
|
||||||
if ((p = (getuid() == 0 ? "root" : NULL)) ||
|
p = NULL;
|
||||||
(p = getenv("USER")) ||
|
#ifdef HAVE_GETUID
|
||||||
(p = getenv("LOGNAME")) ||
|
p = getuid() == 0 ? "root" : NULL;
|
||||||
(p = getenv("USERNAME")))
|
#endif
|
||||||
{
|
if (!p) p = getenv("USER");
|
||||||
|
if (!p) p = getenv("LOGNAME");
|
||||||
|
if (!p) p = getenv("USERNAME");
|
||||||
|
|
||||||
|
if (p) {
|
||||||
name = pa_strlcpy(s, p, l);
|
name = pa_strlcpy(s, p, l);
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,7 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
|
||||||
return tv;
|
return tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
pa_usec_t pa_timespec_load(const struct timespec *ts) {
|
pa_usec_t pa_timespec_load(const struct timespec *ts) {
|
||||||
|
|
||||||
if (PA_UNLIKELY(!ts))
|
if (PA_UNLIKELY(!ts))
|
||||||
|
|
@ -198,6 +199,7 @@ struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v) {
|
||||||
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,10 @@ void pa_rtclock_hrtimer_enable(void);
|
||||||
|
|
||||||
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
||||||
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
|
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,14 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LANGINFO_H
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNAME
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRTOF_L
|
#ifdef HAVE_STRTOF_L
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
@ -216,7 +222,7 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
|
||||||
if (r < 0 && errno != EEXIST)
|
if (r < 0 && errno != EEXIST)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#ifdef HAVE_FSTAT
|
#if defined(HAVE_FSTAT) && !defined(OS_IS_WIN32)
|
||||||
if ((fd = open(dir,
|
if ((fd = open(dir,
|
||||||
#ifdef O_CLOEXEC
|
#ifdef O_CLOEXEC
|
||||||
O_CLOEXEC|
|
O_CLOEXEC|
|
||||||
|
|
@ -254,7 +260,6 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_assert_se(pa_close(fd) >= 0);
|
pa_assert_se(pa_close(fd) >= 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LSTAT
|
#ifdef HAVE_LSTAT
|
||||||
|
|
@ -610,6 +615,7 @@ char *pa_strlcpy(char *b, const char *s, size_t l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_scheduler(int rtprio) {
|
static int set_scheduler(int rtprio) {
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
struct sched_param sp;
|
struct sched_param sp;
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -633,6 +639,7 @@ static int set_scheduler(int rtprio) {
|
||||||
pa_log_debug("SCHED_RR worked.");
|
pa_log_debug("SCHED_RR worked.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SCHED_H */
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* Try to talk to RealtimeKit */
|
/* Try to talk to RealtimeKit */
|
||||||
|
|
@ -702,10 +709,12 @@ static int set_nice(int nice_level) {
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) {
|
if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) {
|
||||||
pa_log_debug("setpriority() worked.");
|
pa_log_debug("setpriority() worked.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* Try to talk to RealtimeKit */
|
/* Try to talk to RealtimeKit */
|
||||||
|
|
@ -826,6 +835,7 @@ int pa_parse_boolean(const char *v) {
|
||||||
else if (!strcmp(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
|
else if (!strcmp(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_LANGINFO_H
|
||||||
/* And then we check language dependant */
|
/* And then we check language dependant */
|
||||||
if ((expr = nl_langinfo(YESEXPR)))
|
if ((expr = nl_langinfo(YESEXPR)))
|
||||||
if (expr[0])
|
if (expr[0])
|
||||||
|
|
@ -836,6 +846,7 @@ int pa_parse_boolean(const char *v) {
|
||||||
if (expr[0])
|
if (expr[0])
|
||||||
if (pa_match(expr, v) > 0)
|
if (pa_match(expr, v) > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1338,11 +1349,13 @@ static char *get_pulse_home(void) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_log_error("Home directory %s not ours.", h);
|
pa_log_error("Home directory %s not ours.", h);
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
||||||
|
|
||||||
|
|
@ -1440,7 +1453,11 @@ static char* make_random_dir(mode_t m) {
|
||||||
fn[i] = table[rand() % (sizeof(table)-1)];
|
fn[i] = table[rand() % (sizeof(table)-1)];
|
||||||
|
|
||||||
u = umask((~m) & 0777);
|
u = umask((~m) & 0777);
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
r = mkdir(fn, m);
|
r = mkdir(fn, m);
|
||||||
|
#else
|
||||||
|
r = mkdir(fn);
|
||||||
|
#endif
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
umask(u);
|
umask(u);
|
||||||
|
|
@ -1463,6 +1480,7 @@ static int make_random_dir_and_link(mode_t m, const char *k) {
|
||||||
if (!(p = make_random_dir(m)))
|
if (!(p = make_random_dir(m)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#ifdef HAVE_SYMLINK
|
||||||
if (symlink(p, k) < 0) {
|
if (symlink(p, k) < 0) {
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
|
|
||||||
|
|
@ -1475,6 +1493,7 @@ static int make_random_dir_and_link(mode_t m, const char *k) {
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1559,6 +1578,7 @@ char *pa_get_runtime_dir(void) {
|
||||||
/* Hmm, so this symlink is still around, make sure nobody fools
|
/* Hmm, so this symlink is still around, make sure nobody fools
|
||||||
* us */
|
* us */
|
||||||
|
|
||||||
|
#ifdef HAVE_LSTAT
|
||||||
if (lstat(p, &st) < 0) {
|
if (lstat(p, &st) < 0) {
|
||||||
|
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
|
|
@ -1578,6 +1598,7 @@ char *pa_get_runtime_dir(void) {
|
||||||
|
|
||||||
pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory.");
|
pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory.");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
|
@ -2217,6 +2238,7 @@ void pa_close_pipe(int fds[2]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_readlink(const char *p) {
|
char *pa_readlink(const char *p) {
|
||||||
|
#ifdef HAVE_READLINK
|
||||||
size_t l = 100;
|
size_t l = 100;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
@ -2238,6 +2260,9 @@ char *pa_readlink(const char *p) {
|
||||||
pa_xfree(c);
|
pa_xfree(c);
|
||||||
l *= 2;
|
l *= 2;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_close_all(int except_fd, ...) {
|
int pa_close_all(int except_fd, ...) {
|
||||||
|
|
@ -2276,6 +2301,7 @@ int pa_close_all(int except_fd, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_close_allv(const int except_fds[]) {
|
int pa_close_allv(const int except_fds[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
int maxfd, fd;
|
int maxfd, fd;
|
||||||
|
|
||||||
|
|
@ -2365,6 +2391,7 @@ int pa_close_allv(const int except_fds[]) {
|
||||||
if (pa_close(fd) < 0 && errno != EBADF)
|
if (pa_close(fd) < 0 && errno != EBADF)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif /* !OS_IS_WIN32 */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2405,6 +2432,7 @@ int pa_unblock_sigs(int except, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_unblock_sigsv(const int except[]) {
|
int pa_unblock_sigsv(const int except[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
int i;
|
int i;
|
||||||
sigset_t ss;
|
sigset_t ss;
|
||||||
|
|
||||||
|
|
@ -2416,6 +2444,9 @@ int pa_unblock_sigsv(const int except[]) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return sigprocmask(SIG_SETMASK, &ss, NULL);
|
return sigprocmask(SIG_SETMASK, &ss, NULL);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_reset_sigs(int except, ...) {
|
int pa_reset_sigs(int except, ...) {
|
||||||
|
|
@ -2454,6 +2485,7 @@ int pa_reset_sigs(int except, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_reset_sigsv(const int except[]) {
|
int pa_reset_sigsv(const int except[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
for (sig = 1; sig < NSIG; sig++) {
|
for (sig = 1; sig < NSIG; sig++) {
|
||||||
|
|
@ -2490,6 +2522,7 @@ int pa_reset_sigsv(const int except[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2624,9 +2657,13 @@ char *pa_machine_id(void) {
|
||||||
if ((h = pa_get_host_name_malloc()))
|
if ((h = pa_get_host_name_malloc()))
|
||||||
return h;
|
return h;
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
/* If no hostname was set we use the POSIX hostid. It's usually
|
/* If no hostname was set we use the POSIX hostid. It's usually
|
||||||
* the IPv4 address. Might not be that stable. */
|
* the IPv4 address. Might not be that stable. */
|
||||||
return pa_sprintf_malloc("%08lx", (unsigned long) gethostid);
|
return pa_sprintf_malloc("%08lx", (unsigned long) gethostid);
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_session_id(void) {
|
char *pa_session_id(void) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
#ifndef fooinet_ntophfoo
|
#ifndef fooinet_ntophfoo
|
||||||
#define fooinet_ntophfoo
|
#define fooinet_ntophfoo
|
||||||
|
|
||||||
|
#ifndef HAVE_INET_NTOP
|
||||||
|
|
||||||
#include <pulsecore/socket.h>
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
#ifndef fooinet_ptonhfoo
|
#ifndef fooinet_ptonhfoo
|
||||||
#define fooinet_ptonhfoo
|
#define fooinet_ptonhfoo
|
||||||
|
|
||||||
|
#ifndef HAVE_INET_PTON
|
||||||
|
|
||||||
#include <pulsecore/socket.h>
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
int inet_pton(int af, const char *src, void *dst);
|
int inet_pton(int af, const char *src, void *dst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/i18n.h>
|
#include <pulse/i18n.h>
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
@ -206,11 +209,14 @@ static void empty_pipe(void) {
|
||||||
static void thread_func(void *u) {
|
static void thread_func(void *u) {
|
||||||
int fd;
|
int fd;
|
||||||
char *lf;
|
char *lf;
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
sigset_t fullset;
|
sigset_t fullset;
|
||||||
|
|
||||||
/* No signals in this thread please */
|
/* No signals in this thread please */
|
||||||
sigfillset(&fullset);
|
sigfillset(&fullset);
|
||||||
pthread_sigmask(SIG_BLOCK, &fullset, NULL);
|
pthread_sigmask(SIG_BLOCK, &fullset, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) {
|
if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) {
|
||||||
pa_log_warn(_("Cannot access autospawn lock."));
|
pa_log_warn(_("Cannot access autospawn lock."));
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is deprecated on glibc but is still used by FreeBSD */
|
/* This is deprecated on glibc but is still used by FreeBSD */
|
||||||
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
||||||
|
|
@ -68,6 +71,7 @@ static void sigsafe_error(const char *s) {
|
||||||
(void) write(STDERR_FILENO, s, strlen(s));
|
(void) write(STDERR_FILENO, s, strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
static void signal_handler(int sig, siginfo_t* si, void *data) {
|
static void signal_handler(int sig, siginfo_t* si, void *data) {
|
||||||
unsigned j;
|
unsigned j;
|
||||||
pa_memtrap *m;
|
pa_memtrap *m;
|
||||||
|
|
@ -102,6 +106,7 @@ fail:
|
||||||
sigsafe_error("Failed to handle SIGBUS.\n");
|
sigsafe_error("Failed to handle SIGBUS.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void memtrap_link(pa_memtrap *m, unsigned j) {
|
static void memtrap_link(pa_memtrap *m, unsigned j) {
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
@ -221,6 +226,7 @@ unlock:
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_memtrap_install(void) {
|
void pa_memtrap_install(void) {
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
allocate_aupdate();
|
allocate_aupdate();
|
||||||
|
|
@ -230,4 +236,5 @@ void pa_memtrap_install(void) {
|
||||||
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
||||||
|
|
||||||
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
|
||||||
pid_t child;
|
pid_t child;
|
||||||
int pipe_fds[2] = { -1, -1 };
|
int pipe_fds[2] = { -1, -1 };
|
||||||
|
|
||||||
|
#ifdef HAVE_FORK
|
||||||
if (pipe(pipe_fds) < 0) {
|
if (pipe(pipe_fds) < 0) {
|
||||||
pa_log("pipe() failed: %s", pa_cstrerror(errno));
|
pa_log("pipe() failed: %s", pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -104,6 +105,7 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
|
||||||
execl(name, name, argv1, NULL);
|
execl(name, name, argv1, NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
pa_close_pipe(pipe_fds);
|
pa_close_pipe(pipe_fds);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ void *pa_tls_set(pa_tls *t, void *userdata);
|
||||||
} \
|
} \
|
||||||
struct __stupid_useless_struct_to_allow_trailing_semicolon
|
struct __stupid_useless_struct_to_allow_trailing_semicolon
|
||||||
|
|
||||||
#ifdef SUPPORT_TLS___THREAD
|
#if defined(SUPPORT_TLS___THREAD) && !defined(OS_IS_WIN32)
|
||||||
/* An optimized version of the above that requires no dynamic
|
/* An optimized version of the above that requires no dynamic
|
||||||
* allocation if the compiler supports __thread */
|
* allocation if the compiler supports __thread */
|
||||||
#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \
|
#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,10 @@
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulse/gccmacro.h>
|
#include <pulse/gccmacro.h>
|
||||||
|
|
@ -43,9 +46,6 @@ static int msec_lower, msec_upper;
|
||||||
static void* work(void *p) PA_GCC_NORETURN;
|
static void* work(void *p) PA_GCC_NORETURN;
|
||||||
|
|
||||||
static void* work(void *p) {
|
static void* work(void *p) {
|
||||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
|
||||||
cpu_set_t mask;
|
|
||||||
#endif
|
|
||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
||||||
|
|
@ -55,9 +55,13 @@ static void* work(void *p) {
|
||||||
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0);
|
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0);
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
||||||
|
{
|
||||||
|
cpu_set_t mask;
|
||||||
|
|
||||||
CPU_ZERO(&mask);
|
CPU_ZERO(&mask);
|
||||||
CPU_SET((size_t) PA_PTR_TO_UINT(p), &mask);
|
CPU_SET((size_t) PA_PTR_TO_UINT(p), &mask);
|
||||||
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
|
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue