[0] | 1 | //roard.h: |
---|
| 2 | |
---|
[668] | 3 | /* |
---|
[5961] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014 |
---|
[668] | 5 | * |
---|
| 6 | * This file is part of roard 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 | * RoarAudio 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[668] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[0] | 26 | #ifndef _ROARD_H_ |
---|
| 27 | #define _ROARD_H_ |
---|
| 28 | |
---|
[2970] | 29 | // configure ROAR_INFO() |
---|
[5194] | 30 | extern int g_verbose; |
---|
[2970] | 31 | #define ROAR_DBG_INFOVAR g_verbose |
---|
| 32 | |
---|
[4299] | 33 | // configure ROAR_*() |
---|
| 34 | #define ROAR_DBG_PREFIX "roard" |
---|
| 35 | |
---|
[1482] | 36 | // need to include this first as we need the config |
---|
| 37 | #include <roaraudio.h> |
---|
[3207] | 38 | #include <roaraudio/units.h> |
---|
[1964] | 39 | #include <libroarlight/libroarlight.h> |
---|
[2283] | 40 | #include <libroareio/libroareio.h> |
---|
[1482] | 41 | |
---|
[2726] | 42 | #include <ctype.h> |
---|
[1482] | 43 | |
---|
[3056] | 44 | #ifdef ROAR_HAVE_H_SIGNAL |
---|
[0] | 45 | #include <signal.h> |
---|
[1482] | 46 | #endif |
---|
| 47 | |
---|
[1537] | 48 | #if defined(ROAR_HAVE_SELECT) && defined(ROAR_HAVE_H_SYS_SELECT) |
---|
[0] | 49 | #include <sys/select.h> |
---|
[1482] | 50 | #endif |
---|
| 51 | |
---|
| 52 | #ifdef ROAR_HAVE_WAIT |
---|
[248] | 53 | #include <sys/wait.h> |
---|
[1482] | 54 | #endif |
---|
| 55 | |
---|
| 56 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
[5951] | 57 | #include <grp.h> |
---|
[444] | 58 | #include <pwd.h> |
---|
[1482] | 59 | #endif |
---|
| 60 | |
---|
[3202] | 61 | #ifdef ROAR_HAVE_H_SYS_TIME |
---|
[1198] | 62 | #include <sys/time.h> |
---|
[3202] | 63 | #endif |
---|
| 64 | #ifdef ROAR_HAVE_H_TIME |
---|
[1198] | 65 | #include <time.h> |
---|
[1482] | 66 | #endif |
---|
[242] | 67 | |
---|
[1993] | 68 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 69 | #include <slp.h> |
---|
| 70 | #endif |
---|
| 71 | |
---|
[243] | 72 | /* |
---|
[242] | 73 | #ifdef __linux__ |
---|
[243] | 74 | #include <linux/unistd.h> |
---|
[242] | 75 | #include <linux/ioprio.h> |
---|
| 76 | #endif |
---|
[243] | 77 | */ |
---|
[242] | 78 | |
---|
[1917] | 79 | #define ROAR_SUBSYS_NONE 0x00 |
---|
| 80 | #define ROAR_SUBSYS_WAVEFORM 0x01 |
---|
| 81 | #define ROAR_SUBSYS_MIDI 0x02 |
---|
| 82 | #define ROAR_SUBSYS_CB 0x04 |
---|
| 83 | #define ROAR_SUBSYS_LIGHT 0x08 |
---|
[2232] | 84 | #define ROAR_SUBSYS_RAW 0x10 |
---|
[2681] | 85 | #define ROAR_SUBSYS_COMPLEX 0x20 |
---|
[2838] | 86 | #define ROAR_SUBSYS_RDTCS 0x40 |
---|
[1917] | 87 | |
---|
[2530] | 88 | // listeing code: |
---|
[4766] | 89 | #define ROAR_MAX_LISTEN_SOCKETS 16 |
---|
[2530] | 90 | |
---|
[3977] | 91 | union uniinst { |
---|
| 92 | void * vp; |
---|
| 93 | int si; |
---|
| 94 | }; |
---|
| 95 | |
---|
[5140] | 96 | enum output_format { |
---|
| 97 | FORMAT_NATIVE = 1, |
---|
| 98 | FORMAT_WIKI, |
---|
| 99 | FORMAT_CSV, |
---|
| 100 | |
---|
| 101 | FORMAT_DEFAULT = FORMAT_NATIVE |
---|
| 102 | }; |
---|
| 103 | |
---|
[4955] | 104 | |
---|
[3763] | 105 | // MFOI = Marked For Optional Include |
---|
| 106 | |
---|
[0] | 107 | //#include "buffer.h" |
---|
[4504] | 108 | #include "caps.h" |
---|
[4231] | 109 | #include "memlock.h" |
---|
[3763] | 110 | #include "codecfilter.h" /* MFOI */ |
---|
| 111 | #include "container_framework.h" /* MFOI */ |
---|
[4932] | 112 | #include "rolestack.h" |
---|
[0] | 113 | #include "client.h" |
---|
[4469] | 114 | #include "auth.h" |
---|
[3763] | 115 | #include "driver.h" /* MFOI */ |
---|
[0] | 116 | #include "output.h" |
---|
| 117 | #include "mixer.h" |
---|
| 118 | //#include "convert.h" |
---|
| 119 | #include "streams.h" |
---|
| 120 | #include "network.h" |
---|
| 121 | #include "commands.h" |
---|
| 122 | #include "req.h" |
---|
[3763] | 123 | #include "emul_simple.h" /* MFOI */ |
---|
| 124 | #include "emul_rsound.h" /* MFOI */ |
---|
[0] | 125 | #include "sources.h" |
---|
[40] | 126 | #include "sample.h" |
---|
[4359] | 127 | #include "hwmixer.h" |
---|
[89] | 128 | #include "meta.h" |
---|
[244] | 129 | #include "midi.h" |
---|
[2446] | 130 | #include "ssynth.h" |
---|
[1816] | 131 | #include "light.h" |
---|
[2236] | 132 | #include "raw.h" |
---|
[2717] | 133 | #include "rdtcs.h" |
---|
[2945] | 134 | #include "waveform.h" |
---|
[3572] | 135 | #include "beep.h" |
---|
[245] | 136 | #include "lib.h" |
---|
[3353] | 137 | #include "plugins.h" |
---|
[0] | 138 | |
---|
[242] | 139 | |
---|
[5192] | 140 | extern int alive; |
---|
[1494] | 141 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[5192] | 142 | extern int g_no_listen; |
---|
[1494] | 143 | #endif |
---|
[0] | 144 | |
---|
[5414] | 145 | extern uint32_t g_pos; // current position in output stream |
---|
[246] | 146 | |
---|
[5192] | 147 | extern int g_standby; |
---|
| 148 | extern int g_autostandby; |
---|
[0] | 149 | |
---|
[3730] | 150 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 151 | struct roard_listen; |
---|
| 152 | #endif |
---|
| 153 | |
---|
[4811] | 154 | int main_loop (struct roar_audio_info * sa, int sysclocksync); |
---|
[574] | 155 | void cleanup_listen_socket (int terminate); |
---|
[0] | 156 | void clean_quit (void); |
---|
| 157 | void clean_quit_prep (void); |
---|
| 158 | |
---|
[3800] | 159 | void on_sig_int (int signum); |
---|
[2732] | 160 | void on_sig_term (int signum); |
---|
[248] | 161 | void on_sig_chld (int signum); |
---|
[2112] | 162 | void on_sig_usr1 (int signum); |
---|
[0] | 163 | |
---|
[1494] | 164 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[5754] | 165 | int get_listen(struct roard_listen ** sock, const char *** sockname); |
---|
| 166 | int add_listen (const char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info); |
---|
[3730] | 167 | #endif |
---|
| 168 | |
---|
| 169 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[5192] | 170 | extern struct roard_listen { |
---|
[3802] | 171 | int used; |
---|
| 172 | struct roar_vio_calls sock; |
---|
[3128] | 173 | int proto; |
---|
| 174 | union { |
---|
| 175 | void * vp; |
---|
| 176 | int si; |
---|
| 177 | struct { |
---|
| 178 | int dir; |
---|
| 179 | struct roar_audio_info info; |
---|
| 180 | } stpl; |
---|
| 181 | } inst; |
---|
| 182 | } g_listen[ROAR_MAX_LISTEN_SOCKETS]; |
---|
[1494] | 183 | #endif |
---|
[0] | 184 | |
---|
[5192] | 185 | extern int g_self_client; |
---|
[37] | 186 | |
---|
[5192] | 187 | extern int g_terminate; |
---|
[71] | 188 | |
---|
[5192] | 189 | extern struct roar_audio_info * g_sa, * g_max_sa; |
---|
[1609] | 190 | |
---|
[4442] | 191 | #define CONF_DEF_STRING "***default***" |
---|
| 192 | |
---|
[5194] | 193 | extern struct roard_config { |
---|
[1609] | 194 | uint32_t flags; |
---|
| 195 | struct { |
---|
[5624] | 196 | uint32_t flags; |
---|
[1609] | 197 | struct roar_mixer_settings mixer; |
---|
| 198 | int mixer_channels; |
---|
[5624] | 199 | int rpgmode; |
---|
[1609] | 200 | } streams[ROAR_DIR_DIRIDS]; |
---|
[2017] | 201 | char * location; |
---|
[4421] | 202 | char * description; |
---|
[5279] | 203 | char * contact; |
---|
| 204 | char * serial; |
---|
| 205 | char * uiurl; |
---|
[3039] | 206 | size_t jumbo_mtu; |
---|
[4245] | 207 | int memlock_level; |
---|
[4851] | 208 | #ifdef ROAR_HAVE_SYSTEM |
---|
| 209 | struct { |
---|
| 210 | const char * post_shutdown; |
---|
| 211 | } scripts; |
---|
| 212 | #endif |
---|
[1609] | 213 | } * g_config; |
---|
[0] | 214 | |
---|
[4101] | 215 | struct _counters { |
---|
| 216 | size_t clients, streams, |
---|
| 217 | samples, |
---|
| 218 | sources, outputs, |
---|
| 219 | mixers, bridges, |
---|
| 220 | listens; |
---|
| 221 | }; |
---|
| 222 | |
---|
[5194] | 223 | extern struct counters { |
---|
[4101] | 224 | struct _counters cur, sum; |
---|
| 225 | } g_counters; |
---|
| 226 | |
---|
| 227 | |
---|
[5345] | 228 | #define counters_init() memset(counters_getptr(), 0, sizeof(struct counters)) |
---|
[4101] | 229 | //#define counters_inc(c,i) do { signed long int __i = (i); if ( __i < 0 && __i > (g_counters.cur.c) ) { ROAR_WARN("counters_inc(c=%s, i=%li): Decrement request bigger than current counter value. Counter out of syn!", ) } while (0) |
---|
[5345] | 230 | #define counters_inc(c,i) do { signed long int __i = (i); counters_getptr()->cur.c += __i; if ( __i > 0 ) counters_getptr()->sum.c += __i; } while (0) |
---|
[4101] | 231 | |
---|
[5345] | 232 | #define counters_get(g,c) ((counters_getptr()->g.c)) |
---|
[4101] | 233 | |
---|
[5345] | 234 | struct counters * counters_getptr(void); |
---|
[4101] | 235 | void counters_print(int type, int force); |
---|
| 236 | |
---|
[0] | 237 | #endif |
---|
| 238 | |
---|
| 239 | //ll |
---|