61
63
.realtime_scheduling = FALSE,
62
64
.realtime_priority = 5, /* Half of JACK's default rtprio */
63
65
.disallow_module_loading = FALSE,
66
.disallow_exit = FALSE,
65
68
.module_idle_time = 20,
66
69
.scache_idle_time = 20,
67
70
.auto_log_target = 1,
68
71
.script_commands = NULL,
69
72
.dl_search_path = NULL,
73
.load_default_script_file = TRUE,
70
74
.default_script_file = NULL,
71
75
.log_target = PA_LOG_SYSLOG,
72
76
.log_level = PA_LOG_NOTICE,
73
77
.resample_method = PA_RESAMPLER_AUTO,
74
78
.disable_remixing = FALSE,
79
.disable_lfe_remixing = TRUE,
75
80
.config_file = NULL,
76
81
.use_pid_file = TRUE,
77
82
.system_instance = FALSE,
79
84
.disable_shm = FALSE,
80
85
.default_n_fragments = 4,
81
86
.default_fragment_size_msec = 25,
82
.default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 }
87
.default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 },
83
89
#ifdef HAVE_SYS_RESOURCE_H
84
, .rlimit_as = { .value = 0, .is_set = FALSE },
90
,.rlimit_fsize = { .value = 0, .is_set = FALSE },
91
.rlimit_data = { .value = 0, .is_set = FALSE },
92
.rlimit_stack = { .value = 0, .is_set = FALSE },
85
93
.rlimit_core = { .value = 0, .is_set = FALSE },
86
.rlimit_data = { .value = 0, .is_set = FALSE },
87
.rlimit_fsize = { .value = 0, .is_set = FALSE },
88
.rlimit_nofile = { .value = 256, .is_set = TRUE },
89
.rlimit_stack = { .value = 0, .is_set = FALSE }
94
.rlimit_rss = { .value = 0, .is_set = FALSE }
90
95
#ifdef RLIMIT_NPROC
91
, .rlimit_nproc = { .value = 0, .is_set = FALSE }
96
,.rlimit_nproc = { .value = 0, .is_set = FALSE }
98
,.rlimit_nofile = { .value = 256, .is_set = TRUE }
93
99
#ifdef RLIMIT_MEMLOCK
94
, .rlimit_memlock = { .value = 0, .is_set = FALSE }
100
,.rlimit_memlock = { .value = 0, .is_set = FALSE }
102
,.rlimit_as = { .value = 0, .is_set = FALSE }
104
,.rlimit_locks = { .value = 0, .is_set = FALSE }
106
#ifdef RLIMIT_SIGPENDING
107
,.rlimit_sigpending = { .value = 0, .is_set = FALSE }
109
#ifdef RLIMIT_MSGQUEUE
110
,.rlimit_msgqueue = { .value = 0, .is_set = FALSE }
96
112
#ifdef RLIMIT_NICE
97
, .rlimit_nice = { .value = 31, .is_set = TRUE } /* nice level of -11 */
113
,.rlimit_nice = { .value = 31, .is_set = TRUE } /* nice level of -11 */
99
115
#ifdef RLIMIT_RTPRIO
100
, .rlimit_rtprio = { .value = 9, .is_set = TRUE } /* One below JACK's default for the server */
116
,.rlimit_rtprio = { .value = 9, .is_set = TRUE } /* One below JACK's default for the server */
119
,.rlimit_rttime = { .value = PA_USEC_PER_SEC, .is_set = TRUE }
105
124
pa_daemon_conf* pa_daemon_conf_new(void) {
107
125
pa_daemon_conf *c = pa_xnewdup(pa_daemon_conf, &default_conf, 1);
109
if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file, "r")))
112
127
c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
189
204
if (pa_daemon_conf_set_log_target(c, rvalue) < 0) {
190
pa_log("[%s:%u] Invalid log target '%s'.", filename, line, rvalue);
205
pa_log(_("[%s:%u] Invalid log target '%s'."), filename, line, rvalue);
197
static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
212
static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
198
213
pa_daemon_conf *c = data;
200
215
pa_assert(filename);
205
220
if (pa_daemon_conf_set_log_level(c, rvalue) < 0) {
206
pa_log("[%s:%u] Invalid log level '%s'.", filename, line, rvalue);
221
pa_log(_("[%s:%u] Invalid log level '%s'."), filename, line, rvalue);
213
static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
228
static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
214
229
pa_daemon_conf *c = data;
216
231
pa_assert(filename);
221
236
if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) {
222
pa_log("[%s:%u] Invalid resample method '%s'.", filename, line, rvalue);
237
pa_log(_("[%s:%u] Invalid resample method '%s'."), filename, line, rvalue);
229
static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
244
static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
230
245
#ifdef HAVE_SYS_RESOURCE_H
231
246
struct pa_rlimit *r = data;
244
259
if (pa_atoi(rvalue, &k) < 0) {
245
pa_log("[%s:%u] Invalid rlimit '%s'.", filename, line, rvalue);
260
pa_log(_("[%s:%u] Invalid rlimit '%s'."), filename, line, rvalue);
248
263
r->is_set = k >= 0;
249
264
r->value = k >= 0 ? (rlim_t) k : 0;
252
pa_log_warn("[%s:%u] rlimit not supported on this platform.", filename, line);
267
pa_log_warn(_("[%s:%u] rlimit not supported on this platform."), filename, line);
258
static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
273
static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
259
274
pa_daemon_conf *c = data;
260
275
pa_sample_format_t f;
276
static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
291
static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
277
292
pa_daemon_conf *c = data;
280
295
pa_assert(filename);
281
296
pa_assert(lvalue);
282
297
pa_assert(rvalue);
285
if (pa_atoi(rvalue, &r) < 0 || r > PA_RATE_MAX || r <= 0) {
286
pa_log("[%s:%u] Invalid sample rate '%s'.", filename, line, rvalue);
300
if (pa_atou(rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0) {
301
pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue);
391
406
{ "high-priority", pa_config_parse_bool, NULL },
392
407
{ "realtime-scheduling", pa_config_parse_bool, NULL },
393
408
{ "disallow-module-loading", pa_config_parse_bool, NULL },
409
{ "disallow-exit", pa_config_parse_bool, NULL },
394
410
{ "use-pid-file", pa_config_parse_bool, NULL },
395
411
{ "system-instance", pa_config_parse_bool, NULL },
396
412
{ "no-cpu-limit", pa_config_parse_bool, NULL },
412
428
{ "default-fragment-size-msec", parse_fragment_size_msec, NULL },
413
429
{ "nice-level", parse_nice_level, NULL },
414
430
{ "disable-remixing", pa_config_parse_bool, NULL },
431
{ "disable-lfe-remixing", pa_config_parse_bool, NULL },
432
{ "load-default-script-file", pa_config_parse_bool, NULL },
433
{ "shm-size-bytes", pa_config_parse_size, NULL },
415
434
#ifdef HAVE_SYS_RESOURCE_H
416
{ "rlimit-as", parse_rlimit, NULL },
435
{ "rlimit-fsize", parse_rlimit, NULL },
436
{ "rlimit-data", parse_rlimit, NULL },
437
{ "rlimit-stack", parse_rlimit, NULL },
417
438
{ "rlimit-core", parse_rlimit, NULL },
418
{ "rlimit-data", parse_rlimit, NULL },
419
{ "rlimit-fsize", parse_rlimit, NULL },
439
{ "rlimit-rss", parse_rlimit, NULL },
420
440
{ "rlimit-nofile", parse_rlimit, NULL },
421
{ "rlimit-stack", parse_rlimit, NULL },
441
{ "rlimit-as", parse_rlimit, NULL },
422
442
#ifdef RLIMIT_NPROC
423
443
{ "rlimit-nproc", parse_rlimit, NULL },
425
445
#ifdef RLIMIT_MEMLOCK
426
446
{ "rlimit-memlock", parse_rlimit, NULL },
449
{ "rlimit-locks", parse_rlimit, NULL },
451
#ifdef RLIMIT_SIGPENDING
452
{ "rlimit-sigpending", parse_rlimit, NULL },
454
#ifdef RLIMIT_MSGQUEUE
455
{ "rlimit-msgqueue", parse_rlimit, NULL },
428
457
#ifdef RLIMIT_NICE
429
458
{ "rlimit-nice", parse_rlimit, NULL },
431
460
#ifdef RLIMIT_RTPRIO
432
461
{ "rlimit-rtprio", parse_rlimit, NULL },
464
{ "rlimit-rttime", parse_rlimit, NULL },
435
467
{ NULL, NULL, NULL },
440
472
table[2].data = &c->high_priority;
441
473
table[3].data = &c->realtime_scheduling;
442
474
table[4].data = &c->disallow_module_loading;
443
table[5].data = &c->use_pid_file;
444
table[6].data = &c->system_instance;
445
table[7].data = &c->no_cpu_limit;
446
table[8].data = &c->disable_shm;
447
table[9].data = &c->exit_idle_time;
448
table[10].data = &c->module_idle_time;
449
table[11].data = &c->scache_idle_time;
451
table[13].data = &c->dl_search_path;
452
table[14].data = &c->default_script_file;
475
table[5].data = &c->disallow_exit;
476
table[6].data = &c->use_pid_file;
477
table[7].data = &c->system_instance;
478
table[8].data = &c->no_cpu_limit;
479
table[9].data = &c->disable_shm;
480
table[10].data = &c->exit_idle_time;
481
table[11].data = &c->module_idle_time;
482
table[12].data = &c->scache_idle_time;
484
table[14].data = &c->dl_search_path;
485
table[15].data = &c->default_script_file;
454
486
table[16].data = c;
455
487
table[17].data = c;
456
488
table[18].data = c;
460
492
table[22].data = c;
461
493
table[23].data = c;
462
494
table[24].data = c;
463
table[25].data = &c->disable_remixing;
496
table[26].data = &c->disable_remixing;
497
table[27].data = &c->disable_lfe_remixing;
498
table[28].data = &c->load_default_script_file;
499
table[29].data = &c->shm_size;
464
500
#ifdef HAVE_SYS_RESOURCE_H
465
table[26].data = &c->rlimit_as;
466
table[27].data = &c->rlimit_core;
467
table[28].data = &c->rlimit_data;
468
table[29].data = &c->rlimit_fsize;
469
table[30].data = &c->rlimit_nofile;
470
table[31].data = &c->rlimit_stack;
501
table[30].data = &c->rlimit_fsize;
502
table[31].data = &c->rlimit_data;
503
table[32].data = &c->rlimit_stack;
504
table[33].data = &c->rlimit_as;
505
table[34].data = &c->rlimit_core;
506
table[35].data = &c->rlimit_nofile;
507
table[36].data = &c->rlimit_as;
471
508
#ifdef RLIMIT_NPROC
472
table[32].data = &c->rlimit_nproc;
509
table[37].data = &c->rlimit_nproc;
474
512
#ifdef RLIMIT_MEMLOCK
475
513
#ifndef RLIMIT_NPROC
476
514
#error "Houston, we have a numbering problem!"
478
table[33].data = &c->rlimit_memlock;
516
table[38].data = &c->rlimit_memlock;
481
520
#ifndef RLIMIT_MEMLOCK
482
521
#error "Houston, we have a numbering problem!"
484
table[34].data = &c->rlimit_nice;
523
table[39].data = &c->rlimit_locks;
526
#ifdef RLIMIT_SIGPENDING
528
#error "Houston, we have a numbering problem!"
530
table[40].data = &c->rlimit_sigpending;
533
#ifdef RLIMIT_MSGQUEUE
534
#ifndef RLIMIT_SIGPENDING
535
#error "Houston, we have a numbering problem!"
537
table[41].data = &c->rlimit_msgqueue;
541
#ifndef RLIMIT_MSGQUEUE
542
#error "Houston, we have a numbering problem!"
544
table[42].data = &c->rlimit_nice;
486
547
#ifdef RLIMIT_RTPRIO
487
548
#ifndef RLIMIT_NICE
488
549
#error "Houston, we have a numbering problem!"
490
table[35].data = &c->rlimit_rtprio;
551
table[43].data = &c->rlimit_rtprio;
555
#ifndef RLIMIT_RTTIME
556
#error "Houston, we have a numbering problem!"
558
table[44].data = &c->rlimit_rttime;
599
const char *pa_daemon_conf_get_default_script_file(pa_daemon_conf *c) {
602
if (!c->default_script_file) {
603
if (c->system_instance)
604
c->default_script_file = pa_find_config_file(DEFAULT_SYSTEM_SCRIPT_FILE, NULL, ENV_SCRIPT_FILE);
606
c->default_script_file = pa_find_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE);
609
return c->default_script_file;
612
FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c) {
616
if (!c->default_script_file) {
617
if (c->system_instance)
618
f = pa_open_config_file(DEFAULT_SYSTEM_SCRIPT_FILE, NULL, ENV_SCRIPT_FILE, &c->default_script_file);
620
f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file);
622
f = fopen(c->default_script_file, "r");
530
628
static const char* const log_level_to_string[] = {
531
629
[PA_LOG_DEBUG] = "debug",
532
630
[PA_LOG_INFO] = "info",
554
652
pa_strbuf_printf(s, "realtime-scheduling = %s\n", pa_yes_no(c->realtime_scheduling));
555
653
pa_strbuf_printf(s, "realtime-priority = %i\n", c->realtime_priority);
556
654
pa_strbuf_printf(s, "disallow-module-loading = %s\n", pa_yes_no(c->disallow_module_loading));
655
pa_strbuf_printf(s, "disallow-exit = %s\n", pa_yes_no(c->disallow_exit));
557
656
pa_strbuf_printf(s, "use-pid-file = %s\n", pa_yes_no(c->use_pid_file));
558
657
pa_strbuf_printf(s, "system-instance = %s\n", pa_yes_no(c->system_instance));
559
658
pa_strbuf_printf(s, "no-cpu-limit = %s\n", pa_yes_no(c->no_cpu_limit));
561
660
pa_strbuf_printf(s, "exit-idle-time = %i\n", c->exit_idle_time);
562
661
pa_strbuf_printf(s, "module-idle-time = %i\n", c->module_idle_time);
563
662
pa_strbuf_printf(s, "scache-idle-time = %i\n", c->scache_idle_time);
564
pa_strbuf_printf(s, "dl-search-path = %s\n", c->dl_search_path ? c->dl_search_path : "");
565
pa_strbuf_printf(s, "default-script-file = %s\n", c->default_script_file);
663
pa_strbuf_printf(s, "dl-search-path = %s\n", pa_strempty(c->dl_search_path));
664
pa_strbuf_printf(s, "default-script-file = %s\n", pa_strempty(pa_daemon_conf_get_default_script_file(c)));
665
pa_strbuf_printf(s, "load-default-script-file = %s\n", pa_yes_no(c->load_default_script_file));
566
666
pa_strbuf_printf(s, "log-target = %s\n", c->auto_log_target ? "auto" : (c->log_target == PA_LOG_SYSLOG ? "syslog" : "stderr"));
567
667
pa_strbuf_printf(s, "log-level = %s\n", log_level_to_string[c->log_level]);
568
668
pa_strbuf_printf(s, "resample-method = %s\n", pa_resample_method_to_string(c->resample_method));
569
669
pa_strbuf_printf(s, "disable-remixing = %s\n", pa_yes_no(c->disable_remixing));
670
pa_strbuf_printf(s, "disable-lfe-remixing = %s\n", pa_yes_no(c->disable_lfe_remixing));
570
671
pa_strbuf_printf(s, "default-sample-format = %s\n", pa_sample_format_to_string(c->default_sample_spec.format));
571
672
pa_strbuf_printf(s, "default-sample-rate = %u\n", c->default_sample_spec.rate);
572
673
pa_strbuf_printf(s, "default-sample-channels = %u\n", c->default_sample_spec.channels);
573
674
pa_strbuf_printf(s, "default-fragments = %u\n", c->default_n_fragments);
574
675
pa_strbuf_printf(s, "default-fragment-size-msec = %u\n", c->default_fragment_size_msec);
676
pa_strbuf_printf(s, "shm-size-bytes = %lu\n", (unsigned long) c->shm_size);
575
677
#ifdef HAVE_SYS_RESOURCE_H
576
pa_strbuf_printf(s, "rlimit-as = %li\n", c->rlimit_as.is_set ? (long int) c->rlimit_as.value : -1);
577
pa_strbuf_printf(s, "rlimit-core = %li\n", c->rlimit_core.is_set ? (long int) c->rlimit_core.value : -1);
678
pa_strbuf_printf(s, "rlimit-fsize = %li\n", c->rlimit_fsize.is_set ? (long int) c->rlimit_fsize.value : -1);
578
679
pa_strbuf_printf(s, "rlimit-data = %li\n", c->rlimit_data.is_set ? (long int) c->rlimit_data.value : -1);
579
pa_strbuf_printf(s, "rlimit-fsize = %li\n", c->rlimit_fsize.is_set ? (long int) c->rlimit_fsize.value : -1);
580
pa_strbuf_printf(s, "rlimit-nofile = %li\n", c->rlimit_nofile.is_set ? (long int) c->rlimit_nofile.value : -1);
581
680
pa_strbuf_printf(s, "rlimit-stack = %li\n", c->rlimit_stack.is_set ? (long int) c->rlimit_stack.value : -1);
681
pa_strbuf_printf(s, "rlimit-core = %li\n", c->rlimit_core.is_set ? (long int) c->rlimit_core.value : -1);
682
pa_strbuf_printf(s, "rlimit-as = %li\n", c->rlimit_as.is_set ? (long int) c->rlimit_as.value : -1);
683
pa_strbuf_printf(s, "rlimit-rss = %li\n", c->rlimit_rss.is_set ? (long int) c->rlimit_rss.value : -1);
582
684
#ifdef RLIMIT_NPROC
583
685
pa_strbuf_printf(s, "rlimit-nproc = %li\n", c->rlimit_nproc.is_set ? (long int) c->rlimit_nproc.value : -1);
687
pa_strbuf_printf(s, "rlimit-nofile = %li\n", c->rlimit_nofile.is_set ? (long int) c->rlimit_nofile.value : -1);
585
688
#ifdef RLIMIT_MEMLOCK
586
689
pa_strbuf_printf(s, "rlimit-memlock = %li\n", c->rlimit_memlock.is_set ? (long int) c->rlimit_memlock.value : -1);
692
pa_strbuf_printf(s, "rlimit-locks = %li\n", c->rlimit_locks.is_set ? (long int) c->rlimit_locks.value : -1);
694
#ifdef RLIMIT_SIGPENDING
695
pa_strbuf_printf(s, "rlimit-sigpending = %li\n", c->rlimit_sigpending.is_set ? (long int) c->rlimit_sigpending.value : -1);
697
#ifdef RLIMIT_MSGQUEUE
698
pa_strbuf_printf(s, "rlimit-msgqueue = %li\n", c->rlimit_msgqueue.is_set ? (long int) c->rlimit_msgqueue.value : -1);
588
700
#ifdef RLIMIT_NICE
589
pa_strbuf_printf(s, "rlimit-nice = %li\n", c->rlimit_memlock.is_set ? (long int) c->rlimit_nice.value : -1);
701
pa_strbuf_printf(s, "rlimit-nice = %li\n", c->rlimit_nice.is_set ? (long int) c->rlimit_nice.value : -1);
591
703
#ifdef RLIMIT_RTPRIO
592
pa_strbuf_printf(s, "rlimit-rtprio = %li\n", c->rlimit_memlock.is_set ? (long int) c->rlimit_rtprio.value : -1);
704
pa_strbuf_printf(s, "rlimit-rtprio = %li\n", c->rlimit_rtprio.is_set ? (long int) c->rlimit_rtprio.value : -1);
707
pa_strbuf_printf(s, "rlimit-rttime = %li\n", c->rlimit_rttime.is_set ? (long int) c->rlimit_rttime.value : -1);