daemon: add support for mlockall

This commit is contained in:
Wim Taymans 2021-01-19 12:17:29 +01:00
parent ab91e94b59
commit 8c84c96fe1
4 changed files with 14 additions and 4 deletions

View file

@ -2,6 +2,7 @@
properties = {
# Properties to configure the session and some
# modules
#mem.mlock-all = false
}

View file

@ -6,6 +6,7 @@ properties = {
#link.max-buffers = 64
link.max-buffers = 16 # version < 3 clients can't handle more
#mem.allow-mlock = true
#mem.mlock-all = false
#log.level = 2
## Properties for the DSP configuration

View file

@ -2281,7 +2281,9 @@ int main(int argc, char *argv[])
pw_init(&argc, &argv);
impl.state_dir_fd = -1;
impl.this.props = pw_properties_new(NULL, NULL);
impl.this.props = pw_properties_new(
PW_KEY_CONTEXT_PROFILE_MODULES, "default,rtkit",
NULL);
if (impl.this.props == NULL)
return -1;
@ -2326,9 +2328,7 @@ int main(int argc, char *argv[])
pw_loop_add_signal(impl.this.loop, SIGTERM, do_quit, &impl);
impl.this.context = pw_context_new(impl.this.loop,
pw_properties_new(
PW_KEY_CONTEXT_PROFILE_MODULES, "default,rtkit",
NULL),
pw_properties_copy(impl.this.props),
0);
if (impl.this.context == NULL)

View file

@ -27,6 +27,7 @@
#include <stdio.h>
#include <regex.h>
#include <limits.h>
#include <sys/mman.h>
#include <pipewire/log.h>
@ -220,6 +221,13 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
goto error_free;
}
if ((str = pw_properties_get(properties, "mem.mlock-all")) != NULL &&
pw_properties_parse_bool(str)) {
if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0)
pw_log_warn(NAME" %p: could not mlockall; %m", impl);
else
pw_log_info(NAME" %p: mlockall succeeded", impl);
}
this->properties = properties;
fill_defaults(this);