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 = {
# Properties to configure the session and some # Properties to configure the session and some
# modules # modules
#mem.mlock-all = false
} }

View file

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

View file

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

View file

@ -27,6 +27,7 @@
#include <stdio.h> #include <stdio.h>
#include <regex.h> #include <regex.h>
#include <limits.h> #include <limits.h>
#include <sys/mman.h>
#include <pipewire/log.h> #include <pipewire/log.h>
@ -220,6 +221,13 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
goto error_free; 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; this->properties = properties;
fill_defaults(this); fill_defaults(this);