[0] | 1 | //roard.h: |
---|
| 2 | |
---|
[668] | 3 | /* |
---|
[4708] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011 |
---|
[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() |
---|
| 30 | int g_verbose; |
---|
| 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) |
---|
[444] | 57 | #include <pwd.h> |
---|
[1482] | 58 | #endif |
---|
| 59 | |
---|
[3202] | 60 | #ifdef ROAR_HAVE_H_SYS_TIME |
---|
[1198] | 61 | #include <sys/time.h> |
---|
[3202] | 62 | #endif |
---|
| 63 | #ifdef ROAR_HAVE_H_TIME |
---|
[1198] | 64 | #include <time.h> |
---|
[1482] | 65 | #endif |
---|
[242] | 66 | |
---|
[1993] | 67 | #ifdef ROAR_HAVE_LIBSLP |
---|
| 68 | #include <slp.h> |
---|
| 69 | #endif |
---|
| 70 | |
---|
[243] | 71 | /* |
---|
[242] | 72 | #ifdef __linux__ |
---|
[243] | 73 | #include <linux/unistd.h> |
---|
[242] | 74 | #include <linux/ioprio.h> |
---|
| 75 | #endif |
---|
[243] | 76 | */ |
---|
[242] | 77 | |
---|
[1917] | 78 | #define ROAR_SUBSYS_NONE 0x00 |
---|
| 79 | #define ROAR_SUBSYS_WAVEFORM 0x01 |
---|
| 80 | #define ROAR_SUBSYS_MIDI 0x02 |
---|
| 81 | #define ROAR_SUBSYS_CB 0x04 |
---|
| 82 | #define ROAR_SUBSYS_LIGHT 0x08 |
---|
[2232] | 83 | #define ROAR_SUBSYS_RAW 0x10 |
---|
[2681] | 84 | #define ROAR_SUBSYS_COMPLEX 0x20 |
---|
[2838] | 85 | #define ROAR_SUBSYS_RDTCS 0x40 |
---|
[1917] | 86 | |
---|
[2530] | 87 | // listeing code: |
---|
[4766] | 88 | #define ROAR_MAX_LISTEN_SOCKETS 16 |
---|
[2530] | 89 | |
---|
[3977] | 90 | union uniinst { |
---|
| 91 | void * vp; |
---|
| 92 | int si; |
---|
| 93 | }; |
---|
| 94 | |
---|
[4955] | 95 | enum output_format; |
---|
| 96 | |
---|
[3763] | 97 | // MFOI = Marked For Optional Include |
---|
| 98 | |
---|
[0] | 99 | //#include "buffer.h" |
---|
[4504] | 100 | #include "caps.h" |
---|
[4231] | 101 | #include "memlock.h" |
---|
[3763] | 102 | #include "codecfilter.h" /* MFOI */ |
---|
| 103 | #include "container_framework.h" /* MFOI */ |
---|
[4932] | 104 | #include "rolestack.h" |
---|
[0] | 105 | #include "client.h" |
---|
[4469] | 106 | #include "auth.h" |
---|
[3763] | 107 | #include "driver.h" /* MFOI */ |
---|
[0] | 108 | #include "output.h" |
---|
| 109 | #include "mixer.h" |
---|
| 110 | //#include "convert.h" |
---|
| 111 | #include "streams.h" |
---|
| 112 | #include "network.h" |
---|
| 113 | #include "commands.h" |
---|
| 114 | #include "req.h" |
---|
[3763] | 115 | #include "emul_esd.h" /* MFOI */ |
---|
| 116 | #include "emul_simple.h" /* MFOI */ |
---|
| 117 | #include "emul_rsound.h" /* MFOI */ |
---|
[3968] | 118 | #include "emul_rplay.h" /* MFOI */ |
---|
[4699] | 119 | #include "emul_gopher.h" /* MFOI */ |
---|
[0] | 120 | #include "sources.h" |
---|
[40] | 121 | #include "sample.h" |
---|
[4359] | 122 | #include "hwmixer.h" |
---|
[89] | 123 | #include "meta.h" |
---|
[244] | 124 | #include "midi.h" |
---|
[2446] | 125 | #include "ssynth.h" |
---|
[1816] | 126 | #include "light.h" |
---|
[2236] | 127 | #include "raw.h" |
---|
[2717] | 128 | #include "rdtcs.h" |
---|
[2945] | 129 | #include "waveform.h" |
---|
[3572] | 130 | #include "beep.h" |
---|
[245] | 131 | #include "lib.h" |
---|
[3353] | 132 | #include "plugins.h" |
---|
[0] | 133 | |
---|
[242] | 134 | |
---|
[0] | 135 | int alive; |
---|
[1494] | 136 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[1155] | 137 | int g_no_listen; |
---|
[1494] | 138 | #endif |
---|
[0] | 139 | |
---|
[246] | 140 | uint32_t g_pos; // current possition in output stream |
---|
| 141 | |
---|
[0] | 142 | int g_standby; |
---|
[920] | 143 | int g_autostandby; |
---|
[0] | 144 | |
---|
[3730] | 145 | #ifdef ROAR_SUPPORT_LISTEN |
---|
| 146 | struct roard_listen; |
---|
| 147 | #endif |
---|
| 148 | |
---|
[4811] | 149 | int main_loop (struct roar_audio_info * sa, int sysclocksync); |
---|
[574] | 150 | void cleanup_listen_socket (int terminate); |
---|
[0] | 151 | void clean_quit (void); |
---|
| 152 | void clean_quit_prep (void); |
---|
| 153 | |
---|
[3800] | 154 | void on_sig_int (int signum); |
---|
[2732] | 155 | void on_sig_term (int signum); |
---|
[248] | 156 | void on_sig_chld (int signum); |
---|
[2112] | 157 | void on_sig_usr1 (int signum); |
---|
[0] | 158 | |
---|
[1494] | 159 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[3731] | 160 | int get_listen(struct roard_listen ** sock, char *** sockname); |
---|
[4678] | 161 | int add_listen (char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info); |
---|
[3730] | 162 | #endif |
---|
| 163 | |
---|
| 164 | #ifdef ROAR_SUPPORT_LISTEN |
---|
[3253] | 165 | struct roard_listen { |
---|
[3802] | 166 | int used; |
---|
| 167 | struct roar_vio_calls sock; |
---|
[3128] | 168 | int proto; |
---|
| 169 | union { |
---|
| 170 | void * vp; |
---|
| 171 | int si; |
---|
| 172 | struct { |
---|
| 173 | int dir; |
---|
| 174 | struct roar_audio_info info; |
---|
| 175 | } stpl; |
---|
| 176 | } inst; |
---|
| 177 | } g_listen[ROAR_MAX_LISTEN_SOCKETS]; |
---|
[1494] | 178 | #endif |
---|
[0] | 179 | |
---|
[37] | 180 | int g_self_client; |
---|
| 181 | |
---|
[71] | 182 | int g_terminate; |
---|
| 183 | |
---|
[5102] | 184 | #ifndef ROAR_ROARD_BITS |
---|
| 185 | #define ROAR_ROARD_BITS 32 |
---|
| 186 | #endif |
---|
| 187 | |
---|
[1609] | 188 | struct roar_audio_info * g_sa, * g_max_sa; |
---|
| 189 | |
---|
[4442] | 190 | #define CONF_DEF_STRING "***default***" |
---|
| 191 | |
---|
[1609] | 192 | struct roard_config { |
---|
| 193 | uint32_t flags; |
---|
| 194 | struct { |
---|
| 195 | uint32_t flags; |
---|
| 196 | struct roar_mixer_settings mixer; |
---|
| 197 | int mixer_channels; |
---|
| 198 | } streams[ROAR_DIR_DIRIDS]; |
---|
[2017] | 199 | char * location; |
---|
[4421] | 200 | char * description; |
---|
[3039] | 201 | size_t jumbo_mtu; |
---|
[4245] | 202 | int memlock_level; |
---|
[4851] | 203 | #ifdef ROAR_HAVE_SYSTEM |
---|
| 204 | struct { |
---|
| 205 | const char * post_shutdown; |
---|
| 206 | } scripts; |
---|
| 207 | #endif |
---|
[1609] | 208 | } * g_config; |
---|
[0] | 209 | |
---|
[4101] | 210 | struct _counters { |
---|
| 211 | size_t clients, streams, |
---|
| 212 | samples, |
---|
| 213 | sources, outputs, |
---|
| 214 | mixers, bridges, |
---|
| 215 | listens; |
---|
| 216 | }; |
---|
| 217 | |
---|
| 218 | struct { |
---|
| 219 | struct _counters cur, sum; |
---|
| 220 | } g_counters; |
---|
| 221 | |
---|
| 222 | |
---|
[4955] | 223 | enum output_format { |
---|
| 224 | FORMAT_NATIVE = 1, |
---|
| 225 | FORMAT_WIKI, |
---|
| 226 | FORMAT_CSV, |
---|
| 227 | |
---|
| 228 | FORMAT_DEFAULT = FORMAT_NATIVE |
---|
| 229 | }; |
---|
| 230 | |
---|
[4101] | 231 | #define counters_init() memset(&g_counters, 0, sizeof(g_counters)) |
---|
| 232 | //#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) |
---|
| 233 | #define counters_inc(c,i) do { signed long int __i = (i); g_counters.cur.c += __i; if ( __i > 0 ) g_counters.sum.c += __i; } while (0) |
---|
| 234 | |
---|
| 235 | #define counters_get(g,c) ((g_counters.g.c)) |
---|
| 236 | |
---|
| 237 | void counters_print(int type, int force); |
---|
| 238 | |
---|
[0] | 239 | #endif |
---|
| 240 | |
---|
| 241 | //ll |
---|