summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/caps.c7
-rw-r--r--src/daemon/cmdline.c27
-rw-r--r--src/daemon/cpulimit.c21
-rw-r--r--src/daemon/daemon-conf.c165
-rw-r--r--src/daemon/daemon-conf.h7
-rw-r--r--src/daemon/daemon.conf.in7
-rwxr-xr-xsrc/daemon/default.pa.in12
-rw-r--r--src/daemon/dumpmodules.c2
-rw-r--r--src/daemon/ltdl-bind-now.c10
-rw-r--r--src/daemon/main.c93
-rwxr-xr-xsrc/daemon/system.pa.in5
11 files changed, 225 insertions, 131 deletions
diff --git a/src/daemon/caps.c b/src/daemon/caps.c
index f7b6658b..b5cbbc63 100644
--- a/src/daemon/caps.c
+++ b/src/daemon/caps.c
@@ -34,6 +34,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
+#include <pulsecore/core-util.h>
#ifdef HAVE_SYS_CAPABILITY_H
#include <sys/capability.h>
@@ -59,7 +60,7 @@ void pa_drop_root(void) {
if (uid == 0 || geteuid() != 0)
return;
- pa_log_info(_("Dropping root priviliges."));
+ pa_log_info(_("Dropping root privileges."));
#if defined(HAVE_SETRESUID)
pa_assert_se(setresuid(uid, uid, uid) >= 0);
@@ -112,9 +113,9 @@ void pa_drop_caps(void) {
#ifndef __OPTIMIZE__
/* Valgrind doesn't not know set_caps, so we bypass it here -- but
- * only in development builts.*/
+ * only in development builds.*/
- if (getenv("VALGRIND") && !pa_have_caps())
+ if (pa_in_valgrind() && !pa_have_caps())
return;
#endif
diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index fbd6dc32..0bfc8a92 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -55,6 +55,9 @@ enum {
ARG_MODULE_IDLE_TIME,
ARG_SCACHE_IDLE_TIME,
ARG_LOG_TARGET,
+ ARG_LOG_META,
+ ARG_LOG_TIME,
+ ARG_LOG_BACKTRACE,
ARG_LOAD,
ARG_FILE,
ARG_DL_SEARCH_PATH,
@@ -88,6 +91,9 @@ static const struct option long_options[] = {
{"module-idle-time", 2, 0, ARG_MODULE_IDLE_TIME},
{"scache-idle-time", 2, 0, ARG_SCACHE_IDLE_TIME},
{"log-target", 1, 0, ARG_LOG_TARGET},
+ {"log-meta", 2, 0, ARG_LOG_META},
+ {"log-time", 2, 0, ARG_LOG_TIME},
+ {"log-backtrace", 1, 0, ARG_LOG_BACKTRACE},
{"load", 1, 0, ARG_LOAD},
{"file", 1, 0, ARG_FILE},
{"dl-search-path", 1, 0, ARG_DL_SEARCH_PATH},
@@ -148,6 +154,9 @@ void pa_cmdline_help(const char *argv0) {
" --log-level[=LEVEL] Increase or set verbosity level\n"
" -v Increase the verbosity level\n"
" --log-target={auto,syslog,stderr} Specify the log target\n"
+ " --log-meta[=BOOL] Include code location in log messages\n"
+ " --log-time[=BOOL] Include timestamps in log messages\n"
+ " --log-backtrace=FRAMES Include a backtrace in log messages\n"
" -p, --dl-search-path=PATH Set the search path for dynamic shared\n"
" objects (plugins)\n"
" --resample-method=METHOD Use the specified resampling method\n"
@@ -321,6 +330,24 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
}
break;
+ case ARG_LOG_TIME:
+ if ((conf->log_time = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+ pa_log(_("--log-time boolean argument"));
+ goto fail;
+ }
+ break;
+
+ case ARG_LOG_META:
+ if ((conf->log_meta = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+ pa_log(_("--log-meta boolean argument"));
+ goto fail;
+ }
+ break;
+
+ case ARG_LOG_BACKTRACE:
+ conf->log_backtrace = (unsigned) atoi(optarg);
+ break;
+
case ARG_EXIT_IDLE_TIME:
conf->exit_idle_time = atoi(optarg);
break;
diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c
index 42a71f7e..a909600e 100644
--- a/src/daemon/cpulimit.c
+++ b/src/daemon/cpulimit.c
@@ -24,11 +24,13 @@
#endif
#include <pulse/error.h>
+#include <pulse/timeval.h>
#include <pulsecore/core-util.h>
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
+#include <pulsecore/rtclock.h>
#include "cpulimit.h"
@@ -67,7 +69,7 @@
#define CPUTIME_INTERVAL_HARD (5)
/* Time of the last CPU load check */
-static time_t last_time = 0;
+static pa_usec_t last_time = 0;
/* Pipe for communicating with the main loop */
static int the_pipe[2] = {-1, -1};
@@ -100,7 +102,7 @@ static void reset_cpu_time(int t) {
n = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec + t;
pa_assert_se(getrlimit(RLIMIT_CPU, &rl) >= 0);
- rl.rlim_cur = n;
+ rl.rlim_cur = (rlim_t) n;
pa_assert_se(setrlimit(RLIMIT_CPU, &rl) >= 0);
}
@@ -117,20 +119,21 @@ static void signal_handler(int sig) {
pa_assert(sig == SIGXCPU);
if (phase == PHASE_IDLE) {
- time_t now;
+ pa_usec_t now, elapsed;
#ifdef PRINT_CPU_LOAD
char t[256];
#endif
- time(&now);
+ now = pa_rtclock_usec();
+ elapsed = now - last_time;
#ifdef PRINT_CPU_LOAD
- pa_snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
+ pa_snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", ((double) CPUTIME_INTERVAL_SOFT * (double) PA_USEC_PER_SEC) / (double) elapsed * 100.0);
write_err(t);
#endif
- if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
+ if (((double) CPUTIME_INTERVAL_SOFT * (double) PA_USEC_PER_SEC) >= ((double) elapsed * (double) CPUTIME_PERCENT / 100.0)) {
static const char c = 'X';
write_err("Soft CPU time limit exhausted, terminating.\n");
@@ -164,6 +167,8 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
pa_assert(e == io_event);
pa_assert(fd == the_pipe[0]);
+ pa_log("Recevied request to terminate due to CPU overload.");
+
pa_read(the_pipe[0], &c, sizeof(c), NULL);
m->quit(m, 1); /* Quit the main loop */
}
@@ -179,7 +184,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) {
pa_assert(the_pipe[1] == -1);
pa_assert(!installed);
- time(&last_time);
+ last_time = pa_rtclock_usec();
/* Prepare the main loop pipe */
if (pipe(the_pipe) < 0) {
@@ -235,7 +240,7 @@ void pa_cpu_limit_done(void) {
#else /* HAVE_SIGXCPU */
-int pa_cpu_limit_init(PA_GCC_UNUSED pa_mainloop_api *m) {
+int pa_cpu_limit_init(pa_mainloop_api *m) {
return 0;
}
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 05c86c87..d7ffc105 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -74,8 +74,12 @@ static const pa_daemon_conf default_conf = {
.default_script_file = NULL,
.log_target = PA_LOG_SYSLOG,
.log_level = PA_LOG_NOTICE,
+ .log_backtrace = 0,
+ .log_meta = FALSE,
+ .log_time = FALSE,
.resample_method = PA_RESAMPLER_AUTO,
.disable_remixing = FALSE,
+ .disable_lfe_remixing = TRUE,
.config_file = NULL,
.use_pid_file = TRUE,
.system_instance = FALSE,
@@ -83,7 +87,8 @@ static const pa_daemon_conf default_conf = {
.disable_shm = FALSE,
.default_n_fragments = 4,
.default_fragment_size_msec = 25,
- .default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 }
+ .default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 },
+ .shm_size = 0
#ifdef HAVE_SYS_RESOURCE_H
,.rlimit_fsize = { .value = 0, .is_set = FALSE },
.rlimit_data = { .value = 0, .is_set = FALSE },
@@ -191,7 +196,7 @@ int pa_daemon_conf_set_resample_method(pa_daemon_conf *c, const char *string) {
return 0;
}
-static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
pa_assert(filename);
@@ -207,7 +212,7 @@ static int parse_log_target(const char *filename, unsigned line, const char *lva
return 0;
}
-static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
pa_assert(filename);
@@ -223,7 +228,7 @@ static int parse_log_level(const char *filename, unsigned line, const char *lval
return 0;
}
-static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
pa_assert(filename);
@@ -239,7 +244,7 @@ static int parse_resample_method(const char *filename, unsigned line, const char
return 0;
}
-static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
#ifdef HAVE_SYS_RESOURCE_H
struct pa_rlimit *r = data;
@@ -268,7 +273,7 @@ static int parse_rlimit(const char *filename, unsigned line, const char *lvalue,
return 0;
}
-static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
pa_sample_format_t f;
@@ -286,16 +291,16 @@ static int parse_sample_format(const char *filename, unsigned line, const char *
return 0;
}
-static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
- int32_t r;
+ uint32_t r;
pa_assert(filename);
pa_assert(lvalue);
pa_assert(rvalue);
pa_assert(data);
- if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) {
+ if (pa_atou(rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0) {
pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue);
return -1;
}
@@ -304,7 +309,7 @@ static int parse_sample_rate(const char *filename, unsigned line, const char *lv
return 0;
}
-static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
int32_t n;
@@ -322,7 +327,7 @@ static int parse_sample_channels(const char *filename, unsigned line, const char
return 0;
}
-static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
int32_t n;
@@ -340,7 +345,7 @@ static int parse_fragments(const char *filename, unsigned line, const char *lval
return 0;
}
-static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
int32_t n;
@@ -358,7 +363,7 @@ static int parse_fragment_size_msec(const char *filename, unsigned line, const c
return 0;
}
-static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
int32_t level;
@@ -376,7 +381,7 @@ static int parse_nice_level(const char *filename, unsigned line, const char *lva
return 0;
}
-static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
+static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
int32_t rtprio;
@@ -397,6 +402,7 @@ static int parse_rtprio(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;
+ unsigned i = 0;
pa_config_item table[] = {
{ "daemonize", pa_config_parse_bool, NULL },
@@ -426,7 +432,12 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
{ "default-fragment-size-msec", parse_fragment_size_msec, NULL },
{ "nice-level", parse_nice_level, NULL },
{ "disable-remixing", pa_config_parse_bool, NULL },
+ { "disable-lfe-remixing", pa_config_parse_bool, NULL },
{ "load-default-script-file", pa_config_parse_bool, NULL },
+ { "shm-size-bytes", pa_config_parse_size, NULL },
+ { "log-meta", pa_config_parse_bool, NULL },
+ { "log-time", pa_config_parse_bool, NULL },
+ { "log-backtrace", pa_config_parse_unsigned, NULL },
#ifdef HAVE_SYS_RESOURCE_H
{ "rlimit-fsize", parse_rlimit, NULL },
{ "rlimit-data", parse_rlimit, NULL },
@@ -463,96 +474,75 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
{ NULL, NULL, NULL },
};
- table[0].data = &c->daemonize;
- table[1].data = &c->fail;
- table[2].data = &c->high_priority;
- table[3].data = &c->realtime_scheduling;
- table[4].data = &c->disallow_module_loading;
- table[5].data = &c->disallow_exit;
- table[6].data = &c->use_pid_file;
- table[7].data = &c->system_instance;
- table[8].data = &c->no_cpu_limit;
- table[9].data = &c->disable_shm;
- table[10].data = &c->exit_idle_time;
- table[11].data = &c->module_idle_time;
- table[12].data = &c->scache_idle_time;
- table[13].data = c;
- table[14].data = &c->dl_search_path;
- table[15].data = &c->default_script_file;
- table[16].data = c;
- table[17].data = c;
- table[18].data = c;
- table[19].data = c;
- table[20].data = c;
- table[21].data = c;
- table[22].data = c;
- table[23].data = c;
- table[24].data = c;
- table[25].data = c;
- table[26].data = &c->disable_remixing;
- table[27].data = &c->load_default_script_file;
+ table[i++].data = &c->daemonize;
+ table[i++].data = &c->fail;
+ table[i++].data = &c->high_priority;
+ table[i++].data = &c->realtime_scheduling;
+ table[i++].data = &c->disallow_module_loading;
+ table[i++].data = &c->disallow_exit;
+ table[i++].data = &c->use_pid_file;
+ table[i++].data = &c->system_instance;
+ table[i++].data = &c->no_cpu_limit;
+ table[i++].data = &c->disable_shm;
+ table[i++].data = &c->exit_idle_time;
+ table[i++].data = &c->module_idle_time;
+ table[i++].data = &c->scache_idle_time;
+ table[i++].data = c;
+ table[i++].data = &c->dl_search_path;
+ table[i++].data = &c->default_script_file;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = c;
+ table[i++].data = &c->disable_remixing;
+ table[i++].data = &c->disable_lfe_remixing;
+ table[i++].data = &c->load_default_script_file;
+ table[i++].data = &c->shm_size;
+ table[i++].data = &c->log_meta;
+ table[i++].data = &c->log_time;
+ table[i++].data = &c->log_backtrace;
#ifdef HAVE_SYS_RESOURCE_H
- table[28].data = &c->rlimit_fsize;
- table[29].data = &c->rlimit_data;
- table[30].data = &c->rlimit_stack;
- table[31].data = &c->rlimit_as;
- table[32].data = &c->rlimit_core;
- table[33].data = &c->rlimit_nofile;
- table[34].data = &c->rlimit_as;
+ table[i++].data = &c->rlimit_fsize;
+ table[i++].data = &c->rlimit_data;
+ table[i++].data = &c->rlimit_stack;
+ table[i++].data = &c->rlimit_as;
+ table[i++].data = &c->rlimit_core;
+ table[i++].data = &c->rlimit_nofile;
+ table[i++].data = &c->rlimit_as;
#ifdef RLIMIT_NPROC
- table[35].data = &c->rlimit_nproc;
+ table[i++].data = &c->rlimit_nproc;
#endif
-
#ifdef RLIMIT_MEMLOCK
-#ifndef RLIMIT_NPROC
-#error "Houston, we have a numbering problem!"
-#endif
- table[36].data = &c->rlimit_memlock;
+ table[i++].data = &c->rlimit_memlock;
#endif
-
#ifdef RLIMIT_LOCKS
-#ifndef RLIMIT_MEMLOCK
-#error "Houston, we have a numbering problem!"
-#endif
- table[37].data = &c->rlimit_locks;
+ table[i++].data = &c->rlimit_locks;
#endif
-
#ifdef RLIMIT_SIGPENDING
-#ifndef RLIMIT_LOCKS
-#error "Houston, we have a numbering problem!"
-#endif
- table[38].data = &c->rlimit_sigpending;
+ table[i++].data = &c->rlimit_sigpending;
#endif
-
#ifdef RLIMIT_MSGQUEUE
-#ifndef RLIMIT_SIGPENDING
-#error "Houston, we have a numbering problem!"
-#endif
- table[39].data = &c->rlimit_msgqueue;
+ table[i++].data = &c->rlimit_msgqueue;
#endif
-
#ifdef RLIMIT_NICE
-#ifndef RLIMIT_MSGQUEUE
-#error "Houston, we have a numbering problem!"
-#endif
- table[40].data = &c->rlimit_nice;
+ table[i++].data = &c->rlimit_nice;
#endif
-
#ifdef RLIMIT_RTPRIO
-#ifndef RLIMIT_NICE
-#error "Houston, we have a numbering problem!"
-#endif
- table[41].data = &c->rlimit_rtprio;
+ table[i++].data = &c->rlimit_rtprio;
#endif
-
#ifdef RLIMIT_RTTIME
-#ifndef RLIMIT_RTTIME
-#error "Houston, we have a numbering problem!"
-#endif
- table[42].data = &c->rlimit_rttime;
+ table[i++].data = &c->rlimit_rttime;
#endif
#endif
+ pa_assert(i == PA_ELEMENTSOF(table)-1);
+
pa_xfree(c->config_file);
c->config_file = NULL;
@@ -661,11 +651,16 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
pa_strbuf_printf(s, "log-level = %s\n", log_level_to_string[c->log_level]);
pa_strbuf_printf(s, "resample-method = %s\n", pa_resample_method_to_string(c->resample_method));
pa_strbuf_printf(s, "disable-remixing = %s\n", pa_yes_no(c->disable_remixing));
+ pa_strbuf_printf(s, "disable-lfe-remixing = %s\n", pa_yes_no(c->disable_lfe_remixing));
pa_strbuf_printf(s, "default-sample-format = %s\n", pa_sample_format_to_string(c->default_sample_spec.format));
pa_strbuf_printf(s, "default-sample-rate = %u\n", c->default_sample_spec.rate);
pa_strbuf_printf(s, "default-sample-channels = %u\n", c->default_sample_spec.channels);
pa_strbuf_printf(s, "default-fragments = %u\n", c->default_n_fragments);
pa_strbuf_printf(s, "default-fragment-size-msec = %u\n", c->default_fragment_size_msec);
+ pa_strbuf_printf(s, "shm-size-bytes = %lu\n", (unsigned long) c->shm_size);
+ pa_strbuf_printf(s, "log-meta = %s\n", pa_yes_no(c->log_meta));
+ pa_strbuf_printf(s, "log-time = %s\n", pa_yes_no(c->log_time));
+ pa_strbuf_printf(s, "log-backtrace = %u\n", c->log_backtrace);
#ifdef HAVE_SYS_RESOURCE_H
pa_strbuf_printf(s, "rlimit-fsize = %li\n", c->rlimit_fsize.is_set ? (long int) c->rlimit_fsize.value : -1);
pa_strbuf_printf(s, "rlimit-data = %li\n", c->rlimit_data.is_set ? (long int) c->rlimit_data.value : -1);
diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h
index c42984f9..04a4ebe7 100644
--- a/src/daemon/daemon-conf.h
+++ b/src/daemon/daemon-conf.h
@@ -66,8 +66,11 @@ typedef struct pa_daemon_conf {
no_cpu_limit,
disable_shm,
disable_remixing,
+ disable_lfe_remixing,
load_default_script_file,
- disallow_exit;
+ disallow_exit,
+ log_meta,
+ log_time;
int exit_idle_time,
module_idle_time,
scache_idle_time,
@@ -78,6 +81,7 @@ typedef struct pa_daemon_conf {
char *script_commands, *dl_search_path, *default_script_file;
pa_log_target_t log_target;
pa_log_level_t log_level;
+ unsigned log_backtrace;
char *config_file;
#ifdef HAVE_SYS_RESOURCE_H
@@ -110,6 +114,7 @@ typedef struct pa_daemon_conf {
unsigned default_n_fragments, default_fragment_size_msec;
pa_sample_spec default_sample_spec;
+ size_t shm_size;
} pa_daemon_conf;
/* Allocate a new structure and fill it with sane defaults */
diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in
index 33b1d61d..00a95932 100644
--- a/src/daemon/daemon.conf.in
+++ b/src/daemon/daemon.conf.in
@@ -26,6 +26,7 @@
; use-pid-file = yes
; system-instance = no
; disable-shm = no
+; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; high-priority = yes
; nice-level = -11
@@ -39,14 +40,18 @@
; dl-search-path = (depends on architecture)
-; load-defaul-script-file = yes
+; load-default-script-file = yes
; default-script-file = @PA_DEFAULT_CONFIG_FILE@
; log-target = auto
; log-level = notice
+; log-meta = no
+; log-time = no
+; log-backtrace = 0
; resample-method = speex-float-3
; disable-remixing = no
+; disable-lfe-remixing = yes
; no-cpu-limit = no
diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index cdaa8bbd..a8318766 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -23,7 +23,7 @@
### Load something into the sample cache
#load-sample-lazy x11-bell /usr/share/sounds/gtk-events/activate.wav
-load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav
+#load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav
#load-sample-lazy pulse-coldplug /usr/share/sounds/startup3.wav
#load-sample-lazy pulse-access /usr/share/sounds/generic.wav
@@ -48,6 +48,11 @@ load-module module-hal-detect
load-module module-detect
.endif
+### Automatically load driver modules for Bluetooth hardware
+#.ifexists module-bluetooth-discover@PA_SOEXT@
+#load-module module-bluetooth-discover
+#.endif
+
### Load several protocols
.ifexists module-esound-protocol-unix@PA_SOEXT@
load-module module-esound-protocol-unix
@@ -67,9 +72,12 @@ load-module module-native-protocol-unix
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="RTP Multicast Sink"
#load-module module-rtp-send source=rtp.monitor
+### Enable flat volumes where possible
+load-module module-flat-volume
+
### Automatically restore the volume of streams and devices
-load-module module-stream-restore
load-module module-device-restore
+load-module module-stream-restore
### Automatically restore the default sink/source when changed by the user during runtime
load-module module-default-device-restore
diff --git a/src/daemon/dumpmodules.c b/src/daemon/dumpmodules.c
index 26fb8eef..9c9f1c81 100644
--- a/src/daemon/dumpmodules.c
+++ b/src/daemon/dumpmodules.c
@@ -40,7 +40,7 @@
#define PREFIX "module-"
-static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) {
+static void short_info(const char *name, const char *path, pa_modinfo *i) {
pa_assert(name);
pa_assert(i);
diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c
index 6821aac4..2d80fc7a 100644
--- a/src/daemon/ltdl-bind-now.c
+++ b/src/daemon/ltdl-bind-now.c
@@ -24,11 +24,11 @@
#include <config.h>
#endif
-#if HAVE_DLFCN_H
+#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
-#if HAVE_SYS_DL_H
+#ifdef HAVE_SYS_DL_H
#include <sys/dl.h>
#endif
@@ -74,7 +74,9 @@ static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise ad
pa_assert(fname);
if (!(m = dlopen(fname, PA_BIND_NOW))) {
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return NULL;
}
@@ -86,7 +88,9 @@ static int bind_now_close(lt_user_data d, lt_module m) {
pa_assert(m);
if (dlclose(m) != 0){
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return 1;
}
@@ -100,7 +104,9 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
pa_assert(symbol);
if (!(ptr = dlsym(m, symbol))) {
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return NULL;
}
diff --git a/src/daemon/main.c b/src/daemon/main.c
index ab438320..f6d2512c 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -66,6 +66,7 @@
#include <pulse/xmalloc.h>
#include <pulse/i18n.h>
+#include <pulsecore/lock-autospawn.h>
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core.h>
@@ -95,8 +96,6 @@
#include "ltdl-bind-now.h"
#include "polkit.h"
-#define AUTOSPAWN_LOCK "autospawn.lock"
-
#ifdef HAVE_LIBWRAP
/* Only one instance of these variables */
int allow_severity = LOG_INFO;
@@ -112,7 +111,7 @@ int __padsp_disabled__ = 7;
#ifdef OS_IS_WIN32
-static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
+static void message_cb(pa_mainloop_api*a, pa_time_event*e, const struct timeval *tv, void *userdata) {
MSG msg;
struct timeval tvnext;
@@ -131,7 +130,7 @@ static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const s
#endif
-static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) {
+static void signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
pa_log_info(_("Got signal %s."), pa_sig2str(sig));
switch (sig) {
@@ -223,7 +222,7 @@ static int change_user(void) {
#elif defined(HAVE_SETREGID)
r = setregid(gr->gr_gid, gr->gr_gid);
#else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
#endif
if (r < 0) {
@@ -239,7 +238,7 @@ static int change_user(void) {
#elif defined(HAVE_SETREUID)
r = setreuid(pw->pw_uid, pw->pw_uid);
#else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
#endif
if (r < 0) {
@@ -346,7 +345,11 @@ int main(int argc, char *argv[]) {
struct timeval win32_tv;
#endif
char *lf = NULL;
- int autospawn_lock_fd = -1;
+ int autospawn_fd = -1;
+ pa_bool_t autospawn_locked = FALSE;
+
+ pa_log_set_maximal_level(PA_LOG_INFO);
+ pa_log_set_ident("pulseaudio");
#if defined(__linux__) && defined(__OPTIMIZE__)
/*
@@ -379,7 +382,7 @@ int main(int argc, char *argv[]) {
/* Drop all capabilities except CAP_SYS_NICE */
pa_limit_caps();
- /* Drop priviliges, but keep CAP_SYS_NICE */
+ /* Drop privileges, but keep CAP_SYS_NICE */
pa_drop_root();
/* After dropping root, the effective set is reset, hence,
@@ -410,9 +413,6 @@ int main(int argc, char *argv[]) {
setlocale(LC_ALL, "");
pa_init_i18n();
- pa_log_set_maximal_level(PA_LOG_INFO);
- pa_log_set_ident("pulseaudio");
-
conf = pa_daemon_conf_new();
if (pa_daemon_conf_load(conf, NULL) < 0)
@@ -428,6 +428,9 @@ int main(int argc, char *argv[]) {
pa_log_set_maximal_level(conf->log_level);
pa_log_set_target(conf->auto_log_target ? PA_LOG_STDERR : conf->log_target, NULL);
+ pa_log_set_show_meta(conf->log_meta);
+ pa_log_set_show_backtrace(conf->log_backtrace);
+ pa_log_set_show_time(conf->log_time);
pa_log_debug("Started as real root: %s, suid root: %s", pa_yes_no(real_root), pa_yes_no(suid_root));
@@ -476,9 +479,9 @@ int main(int argc, char *argv[]) {
pa_drop_caps();
if (conf->high_priority || conf->realtime_scheduling)
- pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
- "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
- "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
+ pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
+ "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us privileges. Dropping SUID again.\n"
+ "For enabling real-time scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
}
}
@@ -606,7 +609,7 @@ int main(int argc, char *argv[]) {
case PA_CMD_KILL:
if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0)
- pa_log(_("Failed to kill daemon."));
+ pa_log(_("Failed to kill daemon: %s"), pa_cstrerror(errno));
else
retval = 0;
@@ -626,7 +629,7 @@ int main(int argc, char *argv[]) {
if (real_root && !conf->system_instance)
pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
else if (!real_root && conf->system_instance) {
- pa_log(_("Root priviliges required."));
+ pa_log(_("Root privileges required."));
goto finish;
}
@@ -646,9 +649,9 @@ int main(int argc, char *argv[]) {
conf->disable_shm = TRUE;
}
- if (conf->system_instance && conf->exit_idle_time > 0) {
+ if (conf->system_instance && conf->exit_idle_time >= 0) {
pa_log_notice(_("Running in system mode, forcibly disabling exit idle time!"));
- conf->exit_idle_time = 0;
+ conf->exit_idle_time = -1;
}
if (conf->cmd == PA_CMD_START) {
@@ -656,8 +659,17 @@ int main(int argc, char *argv[]) {
* first take the autospawn lock to make things
* synchronous. */
- lf = pa_runtime_path(AUTOSPAWN_LOCK);
- autospawn_lock_fd = pa_lock_lockfile(lf);
+ if ((autospawn_fd = pa_autospawn_lock_init()) < 0) {
+ pa_log("Failed to initialize autospawn lock");
+ goto finish;
+ }
+
+ if ((pa_autospawn_lock_acquire(TRUE) < 0)) {
+ pa_log("Failed to acquire autospawn lock");
+ goto finish;
+ }
+
+ autospawn_locked = TRUE;
}
if (conf->daemonize) {
@@ -703,12 +715,15 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (autospawn_lock_fd >= 0) {
+ if (autospawn_fd >= 0) {
/* The lock file is unlocked from the parent, so we need
* to close it in the child */
- pa_close(autospawn_lock_fd);
- autospawn_lock_fd = -1;
+ pa_autospawn_lock_release();
+ pa_autospawn_lock_done(TRUE);
+
+ autospawn_locked = FALSE;
+ autospawn_fd = -1;
}
pa_assert_se(pa_close(daemon_pipe[0]) == 0);
@@ -766,8 +781,29 @@ int main(int argc, char *argv[]) {
pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0");
pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION);
+ pa_log_debug(_("Compilation host: %s"), CANONICAL_HOST);
+ pa_log_debug(_("Compilation CFLAGS: %s"), PA_CFLAGS);
+
+ s = pa_uname_string();
+ pa_log_debug(_("Running on host: %s"), s);
+ pa_xfree(s);
+
pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ pa_log_debug(_("Compiled with Valgrind support: yes"));
+#else
+ pa_log_debug(_("Compiled with Valgrind support: no"));
+#endif
+
+ pa_log_debug(_("Running in valgrind mode: %s"), pa_yes_no(pa_in_valgrind()));
+
+#ifdef __OPTIMIZE__
+ pa_log_debug(_("Optimized build: yes"));
+#else
+ pa_log_debug(_("Optimized build: no"));
+#endif
+
if (!(s = pa_machine_id())) {
pa_log(_("Failed to get machine ID"));
goto finish;
@@ -823,7 +859,7 @@ int main(int argc, char *argv[]) {
pa_assert_se(mainloop = pa_mainloop_new());
- if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) {
+ if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm, conf->shm_size))) {
pa_log(_("pa_core_new() failed."));
goto finish;
}
@@ -838,6 +874,7 @@ int main(int argc, char *argv[]) {
c->realtime_priority = conf->realtime_priority;
c->realtime_scheduling = !!conf->realtime_scheduling;
c->disable_remixing = !!conf->disable_remixing;
+ c->disable_lfe_remixing = !!conf->disable_lfe_remixing;
c->running_as_daemon = !!conf->daemonize;
c->disallow_exit = conf->disallow_exit;
@@ -917,8 +954,12 @@ int main(int argc, char *argv[]) {
finish:
- if (autospawn_lock_fd >= 0)
- pa_unlock_lockfile(lf, autospawn_lock_fd);
+ if (autospawn_fd >= 0) {
+ if (autospawn_locked)
+ pa_autospawn_lock_release();
+
+ pa_autospawn_lock_done(FALSE);
+ }
if (lf)
pa_xfree(lf);
diff --git a/src/daemon/system.pa.in b/src/daemon/system.pa.in
index f6052c4b..27e42815 100755
--- a/src/daemon/system.pa.in
+++ b/src/daemon/system.pa.in
@@ -34,8 +34,9 @@ load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
-### Automatically restore the volume of playback streams
-load-module module-volume-restore
+### Automatically restore the volume of streams and devices
+load-module module-stream-restore
+load-module module-device-restore
### Automatically restore the default sink/source when changed by the user during runtime
load-module module-default-device-restore