mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
daemon: optionally call mlockall() on startup
This commit is contained in:
parent
71ce195d3b
commit
a9b38b3530
5 changed files with 37 additions and 12 deletions
|
|
@ -163,6 +163,14 @@ USA.
|
||||||
memory overcommit.</p>
|
memory overcommit.</p>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<p><opt>lock-memory=</opt> Locks the entire PulseAudio process
|
||||||
|
into memory. While this might increase drop-out safety when used
|
||||||
|
in conjunction with real-time scheduling this takes away a lot
|
||||||
|
of memory from other processes and might hence considerably slow
|
||||||
|
down your system. Defaults to <opt>no</opt>.</p>
|
||||||
|
</option>
|
||||||
|
|
||||||
<option>
|
<option>
|
||||||
<p><opt>flat-volumes=</opt> Enable 'flat' volumes, i.e. where
|
<p><opt>flat-volumes=</opt> Enable 'flat' volumes, i.e. where
|
||||||
possible let the sink volume equal the maximum of the volumes of
|
possible let the sink volume equal the maximum of the volumes of
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ static const pa_daemon_conf default_conf = {
|
||||||
.system_instance = FALSE,
|
.system_instance = FALSE,
|
||||||
.no_cpu_limit = FALSE,
|
.no_cpu_limit = FALSE,
|
||||||
.disable_shm = FALSE,
|
.disable_shm = FALSE,
|
||||||
|
.lock_memory = FALSE,
|
||||||
.default_n_fragments = 4,
|
.default_n_fragments = 4,
|
||||||
.default_fragment_size_msec = 25,
|
.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 },
|
||||||
|
|
@ -446,6 +447,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
|
||||||
{ "no-cpu-limit", pa_config_parse_bool, &c->no_cpu_limit, NULL },
|
{ "no-cpu-limit", pa_config_parse_bool, &c->no_cpu_limit, NULL },
|
||||||
{ "disable-shm", pa_config_parse_bool, &c->disable_shm, NULL },
|
{ "disable-shm", pa_config_parse_bool, &c->disable_shm, NULL },
|
||||||
{ "flat-volumes", pa_config_parse_bool, &c->flat_volumes, NULL },
|
{ "flat-volumes", pa_config_parse_bool, &c->flat_volumes, NULL },
|
||||||
|
{ "lock-memory", pa_config_parse_bool, &c->lock_memory, NULL },
|
||||||
{ "exit-idle-time", pa_config_parse_int, &c->exit_idle_time, NULL },
|
{ "exit-idle-time", pa_config_parse_int, &c->exit_idle_time, NULL },
|
||||||
{ "scache-idle-time", pa_config_parse_int, &c->scache_idle_time, NULL },
|
{ "scache-idle-time", pa_config_parse_int, &c->scache_idle_time, NULL },
|
||||||
{ "realtime-priority", parse_rtprio, c, NULL },
|
{ "realtime-priority", parse_rtprio, c, NULL },
|
||||||
|
|
@ -595,16 +597,14 @@ FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char* const log_level_to_string[] = {
|
|
||||||
[PA_LOG_DEBUG] = "debug",
|
|
||||||
[PA_LOG_INFO] = "info",
|
|
||||||
[PA_LOG_NOTICE] = "notice",
|
|
||||||
[PA_LOG_WARN] = "warning",
|
|
||||||
[PA_LOG_ERROR] = "error"
|
|
||||||
};
|
|
||||||
|
|
||||||
char *pa_daemon_conf_dump(pa_daemon_conf *c) {
|
char *pa_daemon_conf_dump(pa_daemon_conf *c) {
|
||||||
|
static const char* const log_level_to_string[] = {
|
||||||
|
[PA_LOG_DEBUG] = "debug",
|
||||||
|
[PA_LOG_INFO] = "info",
|
||||||
|
[PA_LOG_NOTICE] = "notice",
|
||||||
|
[PA_LOG_WARN] = "warning",
|
||||||
|
[PA_LOG_ERROR] = "error"
|
||||||
|
};
|
||||||
pa_strbuf *s;
|
pa_strbuf *s;
|
||||||
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||||
|
|
||||||
|
|
@ -630,6 +630,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
|
||||||
pa_strbuf_printf(s, "no-cpu-limit = %s\n", pa_yes_no(c->no_cpu_limit));
|
pa_strbuf_printf(s, "no-cpu-limit = %s\n", pa_yes_no(c->no_cpu_limit));
|
||||||
pa_strbuf_printf(s, "disable-shm = %s\n", pa_yes_no(c->disable_shm));
|
pa_strbuf_printf(s, "disable-shm = %s\n", pa_yes_no(c->disable_shm));
|
||||||
pa_strbuf_printf(s, "flat-volumes = %s\n", pa_yes_no(c->flat_volumes));
|
pa_strbuf_printf(s, "flat-volumes = %s\n", pa_yes_no(c->flat_volumes));
|
||||||
|
pa_strbuf_printf(s, "lock-memory = %s\n", pa_yes_no(c->lock_memory));
|
||||||
pa_strbuf_printf(s, "exit-idle-time = %i\n", c->exit_idle_time);
|
pa_strbuf_printf(s, "exit-idle-time = %i\n", c->exit_idle_time);
|
||||||
pa_strbuf_printf(s, "scache-idle-time = %i\n", c->scache_idle_time);
|
pa_strbuf_printf(s, "scache-idle-time = %i\n", c->scache_idle_time);
|
||||||
pa_strbuf_printf(s, "dl-search-path = %s\n", pa_strempty(c->dl_search_path));
|
pa_strbuf_printf(s, "dl-search-path = %s\n", pa_strempty(c->dl_search_path));
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,8 @@ typedef struct pa_daemon_conf {
|
||||||
disallow_exit,
|
disallow_exit,
|
||||||
log_meta,
|
log_meta,
|
||||||
log_time,
|
log_time,
|
||||||
flat_volumes;
|
flat_volumes,
|
||||||
|
lock_memory;
|
||||||
int exit_idle_time,
|
int exit_idle_time,
|
||||||
scache_idle_time,
|
scache_idle_time,
|
||||||
auto_log_target,
|
auto_log_target,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
; system-instance = no
|
; system-instance = no
|
||||||
; disable-shm = no
|
; disable-shm = no
|
||||||
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
|
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
|
||||||
|
; lock-memory = no
|
||||||
|
; no-cpu-limit = no
|
||||||
|
|
||||||
; high-priority = yes
|
; high-priority = yes
|
||||||
; nice-level = -11
|
; nice-level = -11
|
||||||
|
|
@ -55,8 +57,6 @@
|
||||||
|
|
||||||
; flat-volumes = yes
|
; flat-volumes = yes
|
||||||
|
|
||||||
; no-cpu-limit = no
|
|
||||||
|
|
||||||
; rlimit-fsize = -1
|
; rlimit-fsize = -1
|
||||||
; rlimit-data = -1
|
; rlimit-data = -1
|
||||||
; rlimit-stack = -1
|
; rlimit-stack = -1
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@
|
||||||
|
|
||||||
#include <liboil/liboil.h>
|
#include <liboil/liboil.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -960,6 +964,17 @@ int main(int argc, char *argv[]) {
|
||||||
pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
|
pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (conf->lock_memory) {
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
|
if (mlockall(MCL_FUTURE) < 0)
|
||||||
|
pa_log_warn("mlockall() failed: %s", pa_cstrerror(errno));
|
||||||
|
else
|
||||||
|
pa_log_info("Sucessfully locked process into memory.");
|
||||||
|
#else
|
||||||
|
pa_log_warn("Memory locking requested but not supported on platform.");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
pa_memtrap_install();
|
pa_memtrap_install();
|
||||||
|
|
||||||
pa_assert_se(mainloop = pa_mainloop_new());
|
pa_assert_se(mainloop = pa_mainloop_new());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue