~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/daemon/daemon-conf.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: daemon-conf.c 2067 2007-11-21 01:30:40Z lennart $ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
33
31
#include <sched.h>
34
32
 
35
33
#include <pulse/xmalloc.h>
 
34
#include <pulse/timeval.h>
 
35
#include <pulse/i18n.h>
36
36
 
37
37
#include <pulsecore/core-error.h>
38
38
#include <pulsecore/core-util.h>
45
45
 
46
46
#define DEFAULT_SCRIPT_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "default.pa"
47
47
#define DEFAULT_SCRIPT_FILE_USER PA_PATH_SEP "default.pa"
 
48
#define DEFAULT_SYSTEM_SCRIPT_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "system.pa"
 
49
 
48
50
#define DEFAULT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "daemon.conf"
49
51
#define DEFAULT_CONFIG_FILE_USER PA_PATH_SEP "daemon.conf"
50
52
 
61
63
    .realtime_scheduling = FALSE,
62
64
    .realtime_priority = 5,  /* Half of JACK's default rtprio */
63
65
    .disallow_module_loading = FALSE,
64
 
    .exit_idle_time = -1,
 
66
    .disallow_exit = FALSE,
 
67
    .exit_idle_time = 20,
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 },
 
88
    .shm_size = 0
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 }
92
97
#endif
 
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 }
 
101
#endif
 
102
   ,.rlimit_as = { .value = 0, .is_set = FALSE }
 
103
#ifdef RLIMIT_LOCKS
 
104
   ,.rlimit_locks = { .value = 0, .is_set = FALSE }
 
105
#endif
 
106
#ifdef RLIMIT_SIGPENDING
 
107
   ,.rlimit_sigpending = { .value = 0, .is_set = FALSE }
 
108
#endif
 
109
#ifdef RLIMIT_MSGQUEUE
 
110
   ,.rlimit_msgqueue = { .value = 0, .is_set = FALSE }
95
111
#endif
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 */
98
114
#endif
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 */
 
117
#endif
 
118
#ifdef RLIMIT_RTTIME
 
119
   ,.rlimit_rttime = { .value = PA_USEC_PER_SEC, .is_set = TRUE }
101
120
#endif
102
121
#endif
103
122
};
104
123
 
105
124
pa_daemon_conf* pa_daemon_conf_new(void) {
106
 
    FILE *f;
107
125
    pa_daemon_conf *c = pa_xnewdup(pa_daemon_conf, &default_conf, 1);
108
126
 
109
 
    if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file, "r")))
110
 
        fclose(f);
111
 
 
112
127
    c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
113
128
    return c;
114
129
}
178
193
    return 0;
179
194
}
180
195
 
181
 
static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
196
static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
182
197
    pa_daemon_conf *c = data;
183
198
 
184
199
    pa_assert(filename);
187
202
    pa_assert(data);
188
203
 
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);
191
206
        return -1;
192
207
    }
193
208
 
194
209
    return 0;
195
210
}
196
211
 
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;
199
214
 
200
215
    pa_assert(filename);
203
218
    pa_assert(data);
204
219
 
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);
207
222
        return -1;
208
223
    }
209
224
 
210
225
    return 0;
211
226
}
212
227
 
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;
215
230
 
216
231
    pa_assert(filename);
219
234
    pa_assert(data);
220
235
 
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);
223
238
        return -1;
224
239
    }
225
240
 
226
241
    return 0;
227
242
}
228
243
 
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;
232
247
 
242
257
    } else {
243
258
        int32_t k;
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);
246
261
            return -1;
247
262
        }
248
263
        r->is_set = k >= 0;
249
264
        r->value = k >= 0 ? (rlim_t) k : 0;
250
265
    }
251
266
#else
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);
253
268
#endif
254
269
 
255
270
    return 0;
256
271
}
257
272
 
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;
261
276
 
265
280
    pa_assert(data);
266
281
 
267
282
    if ((f = pa_parse_sample_format(rvalue)) < 0) {
268
 
        pa_log("[%s:%u] Invalid sample format '%s'.", filename, line, rvalue);
 
283
        pa_log(_("[%s:%u] Invalid sample format '%s'."), filename, line, rvalue);
269
284
        return -1;
270
285
    }
271
286
 
273
288
    return 0;
274
289
}
275
290
 
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;
278
 
    int32_t r;
 
293
    uint32_t r;
279
294
 
280
295
    pa_assert(filename);
281
296
    pa_assert(lvalue);
282
297
    pa_assert(rvalue);
283
298
    pa_assert(data);
284
299
 
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);
287
302
        return -1;
288
303
    }
289
304
 
291
306
    return 0;
292
307
}
293
308
 
294
 
static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
309
static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
295
310
    pa_daemon_conf *c = data;
296
311
    int32_t n;
297
312
 
300
315
    pa_assert(rvalue);
301
316
    pa_assert(data);
302
317
 
303
 
    if (pa_atoi(rvalue, &n) < 0 || n > PA_CHANNELS_MAX || n <= 0) {
304
 
        pa_log("[%s:%u] Invalid sample channels '%s'.", filename, line, rvalue);
 
318
    if (pa_atoi(rvalue, &n) < 0 || n > (int32_t) PA_CHANNELS_MAX || n <= 0) {
 
319
        pa_log(_("[%s:%u] Invalid sample channels '%s'."), filename, line, rvalue);
305
320
        return -1;
306
321
    }
307
322
 
309
324
    return 0;
310
325
}
311
326
 
312
 
static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
327
static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
313
328
    pa_daemon_conf *c = data;
314
329
    int32_t n;
315
330
 
319
334
    pa_assert(data);
320
335
 
321
336
    if (pa_atoi(rvalue, &n) < 0 || n < 2) {
322
 
        pa_log("[%s:%u] Invalid number of fragments '%s'.", filename, line, rvalue);
 
337
        pa_log(_("[%s:%u] Invalid number of fragments '%s'."), filename, line, rvalue);
323
338
        return -1;
324
339
    }
325
340
 
327
342
    return 0;
328
343
}
329
344
 
330
 
static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
345
static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
331
346
    pa_daemon_conf *c = data;
332
347
    int32_t n;
333
348
 
337
352
    pa_assert(data);
338
353
 
339
354
    if (pa_atoi(rvalue, &n) < 0 || n < 1) {
340
 
        pa_log("[%s:%u] Invalid fragment size '%s'.", filename, line, rvalue);
 
355
        pa_log(_("[%s:%u] Invalid fragment size '%s'."), filename, line, rvalue);
341
356
        return -1;
342
357
    }
343
358
 
345
360
    return 0;
346
361
}
347
362
 
348
 
static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
363
static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
349
364
    pa_daemon_conf *c = data;
350
365
    int32_t level;
351
366
 
355
370
    pa_assert(data);
356
371
 
357
372
    if (pa_atoi(rvalue, &level) < 0 || level < -20 || level > 19) {
358
 
        pa_log("[%s:%u] Invalid nice level '%s'.", filename, line, rvalue);
 
373
        pa_log(_("[%s:%u] Invalid nice level '%s'."), filename, line, rvalue);
359
374
        return -1;
360
375
    }
361
376
 
363
378
    return 0;
364
379
}
365
380
 
366
 
static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
 
381
static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
367
382
    pa_daemon_conf *c = data;
368
383
    int32_t rtprio;
369
384
 
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 },
424
444
#endif
425
445
#ifdef RLIMIT_MEMLOCK
426
446
        { "rlimit-memlock",             parse_rlimit,             NULL },
427
447
#endif
 
448
#ifdef RLIMIT_LOCKS
 
449
        { "rlimit-locks",               parse_rlimit,             NULL },
 
450
#endif
 
451
#ifdef RLIMIT_SIGPENDING
 
452
        { "rlimit-sigpending",          parse_rlimit,             NULL },
 
453
#endif
 
454
#ifdef RLIMIT_MSGQUEUE
 
455
        { "rlimit-msgqueue",            parse_rlimit,             NULL },
 
456
#endif
428
457
#ifdef RLIMIT_NICE
429
458
        { "rlimit-nice",                parse_rlimit,             NULL },
430
459
#endif
431
460
#ifdef RLIMIT_RTPRIO
432
461
        { "rlimit-rtprio",              parse_rlimit,             NULL },
433
462
#endif
 
463
#ifdef RLIMIT_RTTIME
 
464
        { "rlimit-rttime",              parse_rlimit,             NULL },
 
465
#endif
434
466
#endif
435
467
        { NULL,                         NULL,                     NULL },
436
468
    };
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;
450
 
    table[12].data = c;
451
 
    table[13].data = &c->dl_search_path;
452
 
    table[14].data = &c->default_script_file;
453
 
    table[15].data = c;
 
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;
 
483
    table[13].data = c;
 
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;
 
495
    table[25].data = c;
 
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;
473
510
#endif
 
511
 
474
512
#ifdef RLIMIT_MEMLOCK
475
513
#ifndef RLIMIT_NPROC
476
514
#error "Houston, we have a numbering problem!"
477
515
#endif
478
 
    table[33].data = &c->rlimit_memlock;
 
516
    table[38].data = &c->rlimit_memlock;
479
517
#endif
480
 
#ifdef RLIMIT_NICE
 
518
 
 
519
#ifdef RLIMIT_LOCKS
481
520
#ifndef RLIMIT_MEMLOCK
482
521
#error "Houston, we have a numbering problem!"
483
522
#endif
484
 
    table[34].data = &c->rlimit_nice;
485
 
#endif
 
523
    table[39].data = &c->rlimit_locks;
 
524
#endif
 
525
 
 
526
#ifdef RLIMIT_SIGPENDING
 
527
#ifndef RLIMIT_LOCKS
 
528
#error "Houston, we have a numbering problem!"
 
529
#endif
 
530
    table[40].data = &c->rlimit_sigpending;
 
531
#endif
 
532
 
 
533
#ifdef RLIMIT_MSGQUEUE
 
534
#ifndef RLIMIT_SIGPENDING
 
535
#error "Houston, we have a numbering problem!"
 
536
#endif
 
537
    table[41].data = &c->rlimit_msgqueue;
 
538
#endif
 
539
 
 
540
#ifdef RLIMIT_NICE
 
541
#ifndef RLIMIT_MSGQUEUE
 
542
#error "Houston, we have a numbering problem!"
 
543
#endif
 
544
    table[42].data = &c->rlimit_nice;
 
545
#endif
 
546
 
486
547
#ifdef RLIMIT_RTPRIO
487
548
#ifndef RLIMIT_NICE
488
549
#error "Houston, we have a numbering problem!"
489
550
#endif
490
 
    table[35].data = &c->rlimit_rtprio;
 
551
    table[43].data = &c->rlimit_rtprio;
 
552
#endif
 
553
 
 
554
#ifdef RLIMIT_RTTIME
 
555
#ifndef RLIMIT_RTTIME
 
556
#error "Houston, we have a numbering problem!"
 
557
#endif
 
558
    table[44].data = &c->rlimit_rttime;
491
559
#endif
492
560
#endif
493
561
 
496
564
 
497
565
    f = filename ?
498
566
        fopen(c->config_file = pa_xstrdup(filename), "r") :
499
 
        pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file, "r");
 
567
        pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file);
500
568
 
501
569
    if (!f && errno != ENOENT) {
502
 
        pa_log_warn("Failed to open configuration file '%s': %s", c->config_file, pa_cstrerror(errno));
 
570
        pa_log_warn(_("Failed to open configuration file: %s"), pa_cstrerror(errno));
503
571
        goto finish;
504
572
    }
505
573
 
514
582
 
515
583
int pa_daemon_conf_env(pa_daemon_conf *c) {
516
584
    char *e;
 
585
    pa_assert(c);
517
586
 
518
587
    if ((e = getenv(ENV_DL_SEARCH_PATH))) {
519
588
        pa_xfree(c->dl_search_path);
527
596
    return 0;
528
597
}
529
598
 
 
599
const char *pa_daemon_conf_get_default_script_file(pa_daemon_conf *c) {
 
600
    pa_assert(c);
 
601
 
 
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);
 
605
        else
 
606
            c->default_script_file = pa_find_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE);
 
607
    }
 
608
 
 
609
    return c->default_script_file;
 
610
}
 
611
 
 
612
FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c) {
 
613
    FILE *f;
 
614
    pa_assert(c);
 
615
 
 
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);
 
619
        else
 
620
            f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file);
 
621
    } else
 
622
        f = fopen(c->default_script_file, "r");
 
623
 
 
624
    return f;
 
625
}
 
626
 
 
627
 
530
628
static const char* const log_level_to_string[] = {
531
629
    [PA_LOG_DEBUG] = "debug",
532
630
    [PA_LOG_INFO] = "info",
543
641
    s = pa_strbuf_new();
544
642
 
545
643
    if (c->config_file)
546
 
        pa_strbuf_printf(s, "### Read from configuration file: %s ###\n", c->config_file);
 
644
        pa_strbuf_printf(s, _("### Read from configuration file: %s ###\n"), c->config_file);
547
645
 
548
646
    pa_assert(c->log_level <= PA_LOG_LEVEL_MAX);
549
647
 
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);
584
686
#endif
 
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);
587
690
#endif
 
691
#ifdef RLIMIT_LOCKS
 
692
    pa_strbuf_printf(s, "rlimit-locks = %li\n", c->rlimit_locks.is_set ? (long int) c->rlimit_locks.value : -1);
 
693
#endif
 
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);
 
696
#endif
 
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);
 
699
#endif
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);
590
702
#endif
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);
 
705
#endif
 
706
#ifdef RLIMIT_RTTIME
 
707
    pa_strbuf_printf(s, "rlimit-rttime = %li\n", c->rlimit_rttime.is_set ? (long int) c->rlimit_rttime.value : -1);
593
708
#endif
594
709
#endif
595
710