merge glitch-free branch back into trunk
[profile/ivi/pulseaudio.git] / src / daemon / daemon-conf.h
1 #ifndef foodaemonconfhfoo
2 #define foodaemonconfhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of PulseAudio.
8
9   Copyright 2004-2006 Lennart Poettering
10   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
11
12   PulseAudio is free software; you can redistribute it and/or modify
13   it under the terms of the GNU Lesser General Public License as published
14   by the Free Software Foundation; either version 2 of the License,
15   or (at your option) any later version.
16
17   PulseAudio is distributed in the hope that it will be useful, but
18   WITHOUT ANY WARRANTY; without even the implied warranty of
19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20   General Public License for more details.
21
22   You should have received a copy of the GNU Lesser General Public License
23   along with PulseAudio; if not, write to the Free Software
24   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25   USA.
26 ***/
27
28 #include <pulsecore/log.h>
29 #include <pulsecore/macro.h>
30 #include <pulsecore/core-util.h>
31 #include <pulse/sample.h>
32
33 #ifdef HAVE_SYS_RESOURCE_H
34 #include <sys/resource.h>
35 #endif
36
37 /* The actual command to execute */
38 typedef enum pa_daemon_conf_cmd {
39     PA_CMD_DAEMON,  /* the default */
40     PA_CMD_HELP,
41     PA_CMD_VERSION,
42     PA_CMD_DUMP_CONF,
43     PA_CMD_DUMP_MODULES,
44     PA_CMD_KILL,
45     PA_CMD_CHECK,
46     PA_CMD_DUMP_RESAMPLE_METHODS,
47     PA_CMD_CLEANUP_SHM
48 } pa_daemon_conf_cmd_t;
49
50 #ifdef HAVE_SYS_RESOURCE_H
51 typedef struct pa_rlimit {
52     rlim_t value;
53     pa_bool_t is_set;
54 } pa_rlimit;
55 #endif
56
57 /* A structure containing configuration data for the PulseAudio server . */
58 typedef struct pa_daemon_conf {
59     pa_daemon_conf_cmd_t cmd;
60     pa_bool_t daemonize,
61         fail,
62         high_priority,
63         realtime_scheduling,
64         disallow_module_loading,
65         use_pid_file,
66         system_instance,
67         no_cpu_limit,
68         disable_shm,
69         disable_remixing,
70         load_default_script_file;
71     int exit_idle_time,
72         module_idle_time,
73         scache_idle_time,
74         auto_log_target,
75         realtime_priority,
76         nice_level,
77         resample_method;
78     char *script_commands, *dl_search_path, *default_script_file;
79     pa_log_target_t log_target;
80     pa_log_level_t log_level;
81     char *config_file;
82
83 #ifdef HAVE_SYS_RESOURCE_H
84     pa_rlimit rlimit_fsize, rlimit_data, rlimit_stack, rlimit_core, rlimit_rss, rlimit_nofile, rlimit_as;
85 #ifdef RLIMIT_NPROC
86     pa_rlimit rlimit_nproc;
87 #endif
88 #ifdef RLIMIT_MEMLOCK
89     pa_rlimit rlimit_memlock;
90 #endif
91 #ifdef RLIMIT_LOCKS
92     pa_rlimit rlimit_locks;
93 #endif
94 #ifdef RLIMIT_SIGPENDING
95     pa_rlimit rlimit_sigpending;
96 #endif
97 #ifdef RLIMIT_MSGQUEUE
98     pa_rlimit rlimit_msgqueue;
99 #endif
100 #ifdef RLIMIT_NICE
101     pa_rlimit rlimit_nice;
102 #endif
103 #ifdef RLIMIT_RTPRIO
104     pa_rlimit rlimit_rtprio;
105 #endif
106 #ifdef RLIMIT_RTTIME
107     pa_rlimit rlimit_rttime;
108 #endif
109 #endif
110
111     unsigned default_n_fragments, default_fragment_size_msec;
112     pa_sample_spec default_sample_spec;
113 } pa_daemon_conf;
114
115 /* Allocate a new structure and fill it with sane defaults */
116 pa_daemon_conf* pa_daemon_conf_new(void);
117 void pa_daemon_conf_free(pa_daemon_conf*c);
118
119 /* Load configuration data from the specified file overwriting the
120  * current settings in *c. If filename is NULL load the default daemon
121  * configuration file */
122 int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename);
123
124 /* Pretty print the current configuration data of the daemon. The
125  * returned string has to be freed manually. The output of this
126  * function may be parsed with pa_daemon_conf_load(). */
127 char *pa_daemon_conf_dump(pa_daemon_conf *c);
128
129 /* Load the configuration data from the process' environment
130  * overwriting the current settings in *c. */
131 int pa_daemon_conf_env(pa_daemon_conf *c);
132
133 /* Set these configuration variables in the structure by passing a string */
134 int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string);
135 int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const char *string);
136 int pa_daemon_conf_set_resample_method(pa_daemon_conf *c, const char *string);
137
138 const char *pa_daemon_conf_get_default_script_file(pa_daemon_conf *c);
139 FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c);
140
141 #endif