]> code.delx.au - pulseaudio/blobdiff - src/daemon/daemon-conf.c
daemon: optionally call mlockall() on startup
[pulseaudio] / src / daemon / daemon-conf.c
index 10144ea45b302718ef84548a161f5204818017e0..664e4fdea2d885731f51f16f65d74491b866c6d2 100644 (file)
@@ -6,7 +6,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -85,6 +85,7 @@ static const pa_daemon_conf default_conf = {
     .system_instance = FALSE,
     .no_cpu_limit = FALSE,
     .disable_shm = FALSE,
+    .lock_memory = FALSE,
     .default_n_fragments = 4,
     .default_fragment_size_msec = 25,
     .default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 },
@@ -94,8 +95,10 @@ static const pa_daemon_conf default_conf = {
    ,.rlimit_fsize = { .value = 0, .is_set = FALSE },
     .rlimit_data = { .value = 0, .is_set = FALSE },
     .rlimit_stack = { .value = 0, .is_set = FALSE },
-    .rlimit_core = { .value = 0, .is_set = FALSE },
-    .rlimit_rss = { .value = 0, .is_set = FALSE }
+    .rlimit_core = { .value = 0, .is_set = FALSE }
+#ifdef RLIMIT_RSS
+   ,.rlimit_rss = { .value = 0, .is_set = FALSE }
+#endif
 #ifdef RLIMIT_NPROC
    ,.rlimit_nproc = { .value = 0, .is_set = FALSE }
 #endif
@@ -444,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 },
         { "disable-shm",                pa_config_parse_bool,     &c->disable_shm, 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 },
         { "scache-idle-time",           pa_config_parse_int,      &c->scache_idle_time, NULL },
         { "realtime-priority",          parse_rtprio,             c, NULL },
@@ -472,7 +476,9 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
         { "rlimit-data",                parse_rlimit,             &c->rlimit_data, NULL },
         { "rlimit-stack",               parse_rlimit,             &c->rlimit_stack, NULL },
         { "rlimit-core",                parse_rlimit,             &c->rlimit_core, NULL },
+#ifdef RLIMIT_RSS
         { "rlimit-rss",                 parse_rlimit,             &c->rlimit_rss, NULL },
+#endif
 #ifdef RLIMIT_NOFILE
         { "rlimit-nofile",              parse_rlimit,             &c->rlimit_nofile, NULL },
 #endif
@@ -591,16 +597,14 @@ FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c) {
     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) {
+    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;
     char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
 
@@ -626,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, "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, "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, "scache-idle-time = %i\n", c->scache_idle_time);
     pa_strbuf_printf(s, "dl-search-path = %s\n", pa_strempty(c->dl_search_path));
@@ -651,7 +656,9 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
     pa_strbuf_printf(s, "rlimit-data = %li\n", c->rlimit_data.is_set ? (long int) c->rlimit_data.value : -1);
     pa_strbuf_printf(s, "rlimit-stack = %li\n", c->rlimit_stack.is_set ? (long int) c->rlimit_stack.value : -1);
     pa_strbuf_printf(s, "rlimit-core = %li\n", c->rlimit_core.is_set ? (long int) c->rlimit_core.value : -1);
+#ifdef RLIMIT_RSS
     pa_strbuf_printf(s, "rlimit-rss = %li\n", c->rlimit_rss.is_set ? (long int) c->rlimit_rss.value : -1);
+#endif
 #ifdef RLIMIT_AS
     pa_strbuf_printf(s, "rlimit-as = %li\n", c->rlimit_as.is_set ? (long int) c->rlimit_as.value : -1);
 #endif