1 | //config.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARCONFIG_H_ |
---|
37 | #define _LIBROARCONFIG_H_ |
---|
38 | |
---|
39 | #include "libroar.h" |
---|
40 | |
---|
41 | struct roar_connection; |
---|
42 | |
---|
43 | // WorkAroundS: |
---|
44 | #define ROAR_LIBROAR_CONFIG_WAS_NONE 0x00 |
---|
45 | #define ROAR_LIBROAR_CONFIG_WAS_USE_EXECED 0x01 |
---|
46 | #define ROAR_LIBROAR_CONFIG_WAS_NO_SLP 0x02 |
---|
47 | |
---|
48 | #define ROAR_LIBROAR_CONFIG_PSET_Q 0x0001 |
---|
49 | #define ROAR_LIBROAR_CONFIG_PSET_COMPLEXITY 0x0002 |
---|
50 | #define ROAR_LIBROAR_CONFIG_PSET_DTX 0x0004 |
---|
51 | #define ROAR_LIBROAR_CONFIG_PSET_MAX_CC 0x0008 |
---|
52 | #define ROAR_LIBROAR_CONFIG_PSET_ABR 0x0010 /* need to implement */ |
---|
53 | #define ROAR_LIBROAR_CONFIG_PSET_VAD 0x0020 /* need to implement */ |
---|
54 | #define ROAR_LIBROAR_CONFIG_PSET_AGC 0x0040 /* need to implement */ |
---|
55 | #define ROAR_LIBROAR_CONFIG_PSET_DENOISE 0x0080 /* need to implement */ |
---|
56 | #define ROAR_LIBROAR_CONFIG_PSET_VBR 0x0100 |
---|
57 | #define ROAR_LIBROAR_CONFIG_PSET_MODE 0x0200 |
---|
58 | |
---|
59 | #define ROAR_LIBROAR_CONFIG_MODE_NB ROAR_SPEEX_MODE_NB |
---|
60 | #define ROAR_LIBROAR_CONFIG_MODE_WB ROAR_SPEEX_MODE_WB |
---|
61 | #define ROAR_LIBROAR_CONFIG_MODE_UWB ROAR_SPEEX_MODE_UWB |
---|
62 | |
---|
63 | // mode of operation: |
---|
64 | enum roar_libroar_config_opmode { |
---|
65 | ROAR_LIBROAR_CONFIG_OPMODE_NORMAL = 0, |
---|
66 | #define ROAR_LIBROAR_CONFIG_OPMODE_NORMAL ROAR_LIBROAR_CONFIG_OPMODE_NORMAL |
---|
67 | ROAR_LIBROAR_CONFIG_OPMODE_FUNNY = 1, |
---|
68 | #define ROAR_LIBROAR_CONFIG_OPMODE_FUNNY ROAR_LIBROAR_CONFIG_OPMODE_FUNNY |
---|
69 | ROAR_LIBROAR_CONFIG_OPMODE_MS = 2, |
---|
70 | #define ROAR_LIBROAR_CONFIG_OPMODE_MS ROAR_LIBROAR_CONFIG_OPMODE_MS |
---|
71 | }; |
---|
72 | |
---|
73 | struct roar_libroar_forkapi { |
---|
74 | int (*prefork)(void ** context, void * userdata); |
---|
75 | pid_t (*fork )(void ** context, void * userdata); |
---|
76 | int (*failed )(void ** context, void * userdata); |
---|
77 | int (*parent )(void ** context, void * userdata, pid_t child); |
---|
78 | int (*child )(void ** context, void * userdata); |
---|
79 | void * userdata; |
---|
80 | }; |
---|
81 | |
---|
82 | struct roar_libroar_memmgrapi { |
---|
83 | void * (*calloc) (void * userdata, size_t nmemb, size_t size); |
---|
84 | void * (*malloc) (void * userdata, size_t size); |
---|
85 | int (*free) (void * userdata, void * ptr); |
---|
86 | void * (*realloc) (void * userdata, void * ptr, size_t size); |
---|
87 | int (*reset) (void * userdata); |
---|
88 | ssize_t (*sizeofbuf)(void * userdata, void * ptr); |
---|
89 | |
---|
90 | // TODO: Memmory locking is not yet supported this way. |
---|
91 | int (*mlock) (void * userdata, const void * addr, size_t len); |
---|
92 | int (*munlock) (void * userdata, const void * addr, size_t len); |
---|
93 | int (*mlockall) (void * userdata, int flags); |
---|
94 | int (*munlockall) (void * userdata); |
---|
95 | |
---|
96 | void * userdata; |
---|
97 | }; |
---|
98 | |
---|
99 | struct roar_libroar_config_codec { |
---|
100 | uint32_t codec; // Codec ID |
---|
101 | |
---|
102 | // parameters which are set: |
---|
103 | unsigned int para_set; |
---|
104 | |
---|
105 | // the folloing ints are 256 times there correct value |
---|
106 | // to emulate a .8 bit fixed point float. |
---|
107 | int q; |
---|
108 | int complexity; |
---|
109 | |
---|
110 | // currectly bools: |
---|
111 | int dtx; |
---|
112 | int vbr; |
---|
113 | |
---|
114 | // sizes: |
---|
115 | size_t max_cc; |
---|
116 | |
---|
117 | // enums: |
---|
118 | int mode; |
---|
119 | }; |
---|
120 | |
---|
121 | struct roar_libroar_config { |
---|
122 | struct { |
---|
123 | int workarounds; |
---|
124 | } workaround; |
---|
125 | const char * server; |
---|
126 | struct { |
---|
127 | int sysio; |
---|
128 | int obsolete; |
---|
129 | } warnings; |
---|
130 | struct { |
---|
131 | size_t num; |
---|
132 | struct roar_libroar_config_codec * codec; |
---|
133 | } codecs; |
---|
134 | struct roar_audio_info info; |
---|
135 | char * authfile; |
---|
136 | char * serversfile; |
---|
137 | struct { |
---|
138 | char * display; |
---|
139 | } x11; |
---|
140 | size_t nowarncounter; |
---|
141 | #ifdef ROAR_SUPPORT_TRAP |
---|
142 | enum roar_trap_policy trap_policy; |
---|
143 | #endif |
---|
144 | enum roar_libroar_config_opmode opmode; |
---|
145 | const struct roar_libroar_forkapi * forkapi; |
---|
146 | struct roar_vio_calls * (*connect_internal)(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout); |
---|
147 | char * daemonimage; |
---|
148 | int serverflags; |
---|
149 | int protocolversion; |
---|
150 | }; |
---|
151 | |
---|
152 | struct roar_libroar_config * roar_libroar_get_config_ptr(void) _LIBROAR_ATTR_USE_RESULT; |
---|
153 | struct roar_libroar_config * roar_libroar_get_config(void) _LIBROAR_ATTR_USE_RESULT; |
---|
154 | |
---|
155 | int roar_libroar_reset_config(void); |
---|
156 | |
---|
157 | int roar_libroar_config_parse(char * txt, char * delm) _LIBROAR_ATTR_NONNULL(1); |
---|
158 | |
---|
159 | struct roar_libroar_config_codec * roar_libroar_config_codec_get(int32_t codec, int create); |
---|
160 | |
---|
161 | int roar_libroar_set_server(const char * server); |
---|
162 | const char * roar_libroar_get_server(void) _LIBROAR_ATTR_USE_RESULT; |
---|
163 | |
---|
164 | int roar_libroar_set_forkapi(const struct roar_libroar_forkapi * api); |
---|
165 | int roar_libroar_set_memmgrapi(const struct roar_libroar_memmgrapi * api); // implemented in memmgr.c. |
---|
166 | |
---|
167 | int roar_libroar_set_connect_internal(struct roar_vio_calls * (*func)(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout)); |
---|
168 | |
---|
169 | void roar_libroar_nowarn(void); |
---|
170 | void roar_libroar_warn(void); |
---|
171 | #define roar_libroar_iswarn(cfg) (((cfg) == NULL ? roar_libroar_get_config_ptr() : (cfg))->nowarncounter ? 0 : 1) |
---|
172 | |
---|
173 | // get a buffer to a system local path (prefix). |
---|
174 | // name is the symbolic name of the path, e.g. "prefix-lib". |
---|
175 | // null_as_universal tells of NULL is considered as "universal". |
---|
176 | // if not set NULL is considered 'do not add product path, give root prefix'. |
---|
177 | // product is the name of the product in standard "product <id/vendor>" format. |
---|
178 | // provider is the "<id/vendor>" format. If NULL this is ignored. |
---|
179 | // Returns buffer which needs to be freed with roar_mm_free(). |
---|
180 | // Not all paths support product/provider part. If not supported they are ignored. |
---|
181 | char * roar_libroar_get_path(const char * name, int null_as_universal, const char * product, const char * provider) _LIBROAR_ATTR_USE_RESULT; |
---|
182 | |
---|
183 | // This is similar roar_libroar_get_path() with the following diffrences: |
---|
184 | // * No product, provider or universal attribute can be passed. |
---|
185 | // The result is as if they were 0, NULL, NULL. |
---|
186 | // * The returned buffer is some read-only memory which does not need to be |
---|
187 | // freed. |
---|
188 | const char * roar_libroar_get_path_static(const char * name); |
---|
189 | |
---|
190 | // list all known paths: |
---|
191 | ssize_t roar_libroar_list_path(const char ** list, size_t len, size_t offset) _LIBROAR_ATTR_USE_RESULT _LIBROAR_ATTR_NONNULL_ALL; |
---|
192 | |
---|
193 | #endif |
---|
194 | |
---|
195 | //ll |
---|