source: roaraudio/roard/roard.c @ 3075:6da1778546fe

Last change on this file since 3075:6da1778546fe was 3041:5455976f2e01, checked in by phi, 14 years ago

better error messages even on non-unix systems

File size: 45.4 KB
RevLine 
[0]1//roard.c:
2
[668]3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
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
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
[0]25#include "roard.h"
26
[1494]27#ifdef ROAR_SUPPORT_LISTEN
[2530]28char * server[ROAR_MAX_LISTEN_SOCKETS];
[1494]29#endif
[60]30
[2104]31#if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_FS_POSIX)
32#define SUPPORT_PIDFILE
33char * pidfile = NULL;
34#endif
35
[2530]36#if defined(ROAR_HAVE_SETGID) || defined(ROAR_HAVE_SETUID)
37 int    setids    = 0;
38#endif
39
[1503]40#ifdef ROAR_HAVE_MAIN_ARGS
[0]41void usage (void) {
42 printf("Usage: roard [OPTIONS]...\n\n");
43
[68]44 printf("Misc Options:\n\n");
45 printf(
[775]46        " --daemon              - Bring the server into background after init\n"
[2970]47        " --verbose             - Be more verbose, can be used multiple times\n"
[71]48        " --terminate           - Terminate after last client quited\n"
[2109]49        " --start               - No op parameter (starting roard is default operation)\n"
[274]50        " --restart             - Trys to stop an old instance and start a new with new settings\n"
[2109]51        " --stop                - Stops a running roard (provide --pidfile!)\n"
52        " --shutdown            - Terminates a running roard (provide --pidfile!)\n"
[276]53        " --realtime            - Trys to get realtime priority,\n"
54        "                         give multible times for being more realtime\n"
[444]55        " --chroot DIR          - chroots to the given dir\n"
56        " --setgid              - GroupID to the audio group as specified via -G\n"
57        " --setuid              - UserID to the audio user as specified via -U\n"
[905]58        " --sysclocksync        - calculate exact sample rate using the system clock\n"
[2017]59        " --location  LOC       - Set lion readable location of server\n"
[2104]60#ifdef SUPPORT_PIDFILE
61        " --pidfile PIDFILE     - Write a pidfile at PIDFILE\n"
62#endif
[68]63       );
64
65 printf("\nAudio Options:\n\n");
[0]66 printf(
67        " -R  --rate   RATE     - Set server rate\n"
68        " -B  --bits   BITS     - Set server bits\n"
69        " -C  --chans  CHANNELS - Set server channels\n"
70       );
71
[2339]72 printf("\nStream Options:\n\n");
73 printf(
74        " --stream-flags D=F    - Set default flags for stream directions\n"
75        "                         D is the stream direction and F is a comma seperated\n"
76        "                         list of flags in form +flag or -flag to set or unset\n"
77        "                         a flag as default or remove it from the default\n"
78       );
79
[1923]80 printf("\nDriver Options: (obsolete, do not use, Use Ouput Options)\n\n");
[974]81 printf(" -d  --driver DRV      - Set the driver (default: %s)\n", ROAR_DRIVER_DEFAULT);
[0]82 printf(" -D  --device DEV      - Set the device\n");
83 printf(" -dO OPTS              - Set output options\n");
[973]84 printf(" --list-driver         - List all drivers\n");
[0]85
[932]86 printf("\nOutput Options:\n\n");
[974]87 printf(" -o  --odriver DRV     - Set the driver, use '--list-driver' to get a list\n");
[932]88 printf(" -O  --odevice DEV     - Set the device\n");
89 printf(" -oO OPTS              - Set output options\n");
90 printf(" -oN                   - Adds another output\n");
[961]91 printf(" -oP                   - Mark output as primary\n");
[932]92
[2485]93#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]94 printf("\nSource Options:\n\n");
95 printf(" -s  --source DRV      - Use DRV as input driver\n"
96        " -S           DEV      - Use DEV as input device\n"
97        " -sO          OPTS     - Use OPTS as input options\n"
[1512]98        " -sN                   - Adds another source\n"
[0]99        " -sP                   - Make souce as primary\n"
100       );
[2270]101 printf(" --list-sources        - List all sources\n");
[2485]102#endif
[0]103
[280]104 printf("\nCodec Filter Options:\n\n");
105 printf(" --list-cf             - List all codec filter\n"
106       );
[0]107
[2500]108#ifndef ROAR_WITHOUT_DCOMP_MIDI
[1923]109 printf("\nMIDI Options:\n\n");
[1924]110 printf(" --midi-no-console     - Disable console based MIDI synth\n"
[2444]111        " --midi-console-enable - Enables the console based MIDI synth\n"
[1924]112        " --midi-console DEV    - Set device for MIDI console\n"
[2489]113#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]114        " --ssynth-enable       - Enable simple software synth\n"
115        " --ssynth-disable      - Disable simple software synth\n"
[2489]116#endif
[1924]117       );
[2500]118#endif
[1923]119
[2494]120#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1923]121 printf("\nLight Control Options:\n\n");
122 printf(" --light-channels NUM  - Sets the number of channels for Light control (default: %i)\n",
123                                  LIGHT_CHANNELS_DEFAULT
124       );
[2494]125#endif
[1923]126
[2725]127#ifndef ROAR_WITHOUT_DCOMP_RDTCS
128 printf("\nRadio Date and Transmitter Control System Options:\n\n");
129 printf(" --rds-pi   PI         - Sets the RDS Programme Identification (PI)\n"
130        " --rds-ps   PS         - Sets the RDS Programme Service Name (PS)\n"
131        " --rds-pty  PTY        - Sets the RDS Programme Type (PTY)\n"
132        " --rds-tp              - Sets the RDS Traffic Programme (TP) flag\n"
133        " --rds-ct              - Enables sending of RDS Clock Time (CT)\n"
134       );
135#endif
136
[0]137 printf("\nServer Options:\n\n");
138 printf(" -t  --tcp             - Use TCP listen socket\n"
139        " -u  --unix            - Use UNIX Domain listen socket (default)\n"
[508]140#ifdef ROAR_HAVE_LIBDNET
141        " -n  --decnet          - use DECnet listen socket\n"
142#endif
[518]143        " -4                    - Use IPv4 connections (implies -t)\n"
144#ifdef PF_INET6
145        " -6                    - Use IPv6 connections (implies -t)\n"
146#endif
147#ifdef IPV6_ADDRFORM
148        " -64                   - Try to downgrade sockets from IPv6 into IPv4,\n"
149        "                         this is normaly not usefull.\n"
150#endif
[0]151        " -p  --port            - TCP Port to bind to\n"
152        " -b  --bind            - IP/Hostname to bind to\n"
[1115]153        "     --sock            - Filename for UNIX Domain Socket\n"
[2530]154        "     --proto PROTO     - Use PROTO as protocol on Socket\n"
155        "     --new-sock        - Parameters for new socket follows\n"
[1993]156#ifdef ROAR_HAVE_LIBSLP
157        "     --slp             - Enable OpenSLP support\n"
158#endif
[3039]159        " --jumbo-mtu MTU       - Sets the MTU for Jumbo Packets\n"
[450]160        " -G  GROUP             - Sets the group for the UNIX Domain Socket, (default: %s)\n"
[2737]161        "                         You need the permissions to change the GID\n"
[444]162        " -U  USER              - Sets the user for the UNIX Domain Socket, (default: do not set)\n"
[2737]163        "                         You need the permissions to change the UID (normaly only root has)\n"
[548]164        " --no-listen           - Do not listen for new clients\n"
165        "                         (only usefull for relaing, impleys --terminate)\n"
[274]166        " --client-fh           - Comunicate with a client over this handle\n"
[501]167        "                         (only usefull for relaing)\n"
[920]168        " --close-fh            - Closes the given fh\n"
169        " --standby             - Start in standby state\n"
170        " --auto-standby        - Automatical goes into standby if there are no streams\n",
[2755]171#ifdef ROAR_DEFAULT_SOCKGRP
[450]172        ROAR_DEFAULT_SOCKGRP
[2755]173#else
174        "(none)"
175#endif
[0]176       );
177// printf("\n Options:\n\n");
178 printf("\n");
179}
[1503]180#endif
[0]181
[2109]182int restart_server (char * server, int terminate) {
[579]183 struct roar_connection con;
[2111]184#ifdef ROAR_HAVE_KILL
185 char buf[80];
186 ssize_t l;
187 struct roar_vio_calls fh;
188 pid_t pid;
189 int ok;
190
191 if ( pidfile != NULL ) {
192  if ( roar_vio_open_file(&fh, pidfile, O_RDONLY, 0644) == -1 ) {
193   ROAR_WARN("restart_server(*): Can not read pidfile: %s", pidfile);
194  } else {
195   l = roar_vio_read(&fh, buf, 80);
196   roar_vio_close(&fh);
197   if ( l > 0 ) {
198    buf[l-1] = 0;
199    buf[79]  = 0;
200    pid = atoi(buf);
201    if ( terminate ) {
[2113]202     ok = kill(pid, SIGUSR1);
[2111]203    } else {
204     ok = kill(pid, SIGINT);
205    }
206    if ( ok == 0 ) {
207     return 0;
208    } else {
209     ROAR_WARN("restart_server(*): Can not kill roard by pidfile");
210    }
211   } else {
212    ROAR_WARN("restart_server(*): Can not find a PID in the pidfile");
213   }
214  }
215 }
216#endif
[2109]217
[579]218 if ( roar_connect(&con, server) == -1 ) {
219  return -1;
220 }
221
[2109]222 if ( roar_terminate(&con, terminate) == -1 ) {
[579]223  return -1;
224 }
225
226 return roar_disconnect(&con);
227}
228
[444]229#define R_SETUID 1
230#define R_SETGID 2
231
[1609]232int init_config (void) {
233 int i;
234
235 memset(g_config, 0, sizeof(struct roard_config));
236
237 for (i = 0; i < ROAR_DIR_DIRIDS; i++) {
238  g_config->streams[i].mixer_channels = 1;
239  g_config->streams[i].mixer.rpg_mul  = 1;
240  g_config->streams[i].mixer.rpg_div  = 1;
241  g_config->streams[i].mixer.scale    = 65535;
242  g_config->streams[i].mixer.mixer[0] = g_config->streams[i].mixer.scale;
243 }
244
[2291]245 g_config->streams[ROAR_DIR_PLAY    ].flags = ROAR_FLAG_META;
[2413]246 g_config->streams[ROAR_DIR_OUTPUT  ].flags = ROAR_FLAG_PASSMIXER;
[2264]247 g_config->streams[ROAR_DIR_FILTER  ].flags = ROAR_FLAG_SYNC;
[1899]248 g_config->streams[ROAR_DIR_MIDI_OUT].flags = ROAR_FLAG_SYNC;
[2160]249 g_config->streams[ROAR_DIR_BIDIR   ].flags = ROAR_FLAG_ANTIECHO;
[1899]250
[2017]251 g_config->location = "***default***";
252
[1609]253 return 0;
254}
255
[2530]256#ifdef ROAR_SUPPORT_LISTEN
257int init_listening (void) {
258 int i;
259
260 for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
261  g_listen_socket[i] = -1;
262  g_listen_proto[i]  = ROAR_PROTO_ROARAUDIO;
263  server[i]          = NULL;
264 }
265
266 return 0;
267}
268
269int add_listen (char * addr, int port, int sock_type, char * user, char * group, int proto) {
270#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
271 struct group   * grp  = NULL;
272#endif
273#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
274 struct passwd  * pwd  = NULL;
275#endif
276#ifdef ROAR_HAVE_UNIX
277 char * env_roar_proxy_backup;
278#endif
279 int    sockid = -1;
280 int    sock;
281 int    i;
282
283 if ( *addr != 0 ) {
284  for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
285   if ( g_listen_socket[i] == -1 ) {
286    sockid = i;
287    break;
288   }
289  }
290
291  if ( sockid == -1 )
292   return -1;
293
294  g_listen_proto[sockid] = proto;
295
296  ROAR_DBG("add_listen(*): proto=0x%.4x", proto);
297
298  if ( (g_listen_socket[sockid] = roar_socket_listen(sock_type, addr, port)) == -1 ) {
299#ifdef ROAR_HAVE_UNIX
300   if ( *addr == '/' ) {
301    if ( (env_roar_proxy_backup = getenv("ROAR_PROXY")) != NULL ) {
302     env_roar_proxy_backup = strdup(env_roar_proxy_backup);
303     unsetenv("ROAR_PROXY");
304    }
305    if ( (sock = roar_socket_connect(addr, port)) != -1 ) {
306     close(sock);
[3040]307     ROAR_ERR("Can not open listen socket: Socket allready in use");
[2530]308     return 1;
309    } else {
310     unlink(addr);
311     if ( (g_listen_socket[sockid] = roar_socket_listen(sock_type, addr, port)) == -1 ) {
[3040]312      ROAR_ERR("Can not open listen socket: %s", strerror(errno));
[2530]313      return 1;
314     }
315    }
316    if ( env_roar_proxy_backup != NULL ) {
317     setenv("ROAR_PROXY", env_roar_proxy_backup, 0);
318     free(env_roar_proxy_backup);
319    }
320#else
321   if (0) { // noop
322#endif
323   } else {
[3041]324    ROAR_ERR("Can not open listen socket: %s", strerror(errno));
[2530]325    return 1;
326   }
327  }
328
329#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
[2753]330  if ( group != NULL ) {
331   if ( (grp = getgrnam(group)) == NULL ) {
332    ROAR_ERR("Can not get GID for group %s: %s", group, strerror(errno));
333   }
[2530]334  }
335#endif
336#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
[2752]337  if ( user ) {
[2530]338   if ( (pwd = getpwnam(user)) == NULL ) {
339    ROAR_ERR("Can not get UID for user %s: %s", user, strerror(errno));
340   }
341  }
342#endif
343
344#if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_UNIX)
345  if ( *addr == '/' ) {
[2753]346   if ( grp || pwd ) {
347     if ( chown(addr, pwd ? pwd->pw_uid : -1, grp ? grp->gr_gid : -1) == -1 )
[2530]348      return 1;
[2753]349   }
[2530]350#ifdef ROAR_HAVE_GETUID
[2753]351   if ( grp ) {
[2530]352    if ( getuid() == 0 )
353     if ( chmod(addr, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1 )
354      return 1;
[2753]355   }
[2530]356#endif
357  }
358#endif
359 }
360
[2736]361 // in case we opened the listening socket correctly.
362 server[sockid] = addr;
[2530]363 return 0;
364}
365#endif
366
[2339]367int update_stream_flags (char * str) {
368 int    dir;
369 char * flags;
370 char * k;
371 int    op;
372 int    flag;
373
374 if ( (flags = strstr(str, "=")) == NULL )
375  return -1;
376
377 *flags = 0;
378  flags++;
379
380 if ( (dir = roar_str2dir(str)) == -1 )
381  return -1;
382
383 while (flags != NULL) {
384  k = flags;
385  flags = strstr(flags, ",");
386
387  if ( flags != NULL )
388   *(flags++) = 0;
389
390  switch (*k) {
[2340]391   case '+': k++; op = ROAR_SET_FLAG;   break;
392   case '-': k++; op = ROAR_RESET_FLAG; break;
[2339]393   default:
[2340]394     op = ROAR_SET_FLAG;
[2339]395  }
396
397  flag = 0;
398
399  if ( !strcmp(k, "sync") ) {
400   flag = ROAR_FLAG_SYNC;
401  } else if ( !strcmp(k, "meta") ) {
402   flag = ROAR_FLAG_META;
403  } else if ( !strcmp(k, "cleanmeta") ) {
404   flag = ROAR_FLAG_CLEANMETA;
405  } else if ( !strcmp(k, "pause") ) {
406   flag = ROAR_FLAG_PAUSE;
407  } else if ( !strcmp(k, "mute") ) {
408   flag = ROAR_FLAG_MUTE;
409  } else if ( !strcmp(k, "antiecho") ) {
410   flag = ROAR_FLAG_ANTIECHO;
[2413]411  } else if ( !strcmp(k, "passmixer") ) {
412   flag = ROAR_FLAG_PASSMIXER;
[2339]413  } else {
414   return -1;
415  }
416
417  g_config->streams[dir].flags |= flag;
418
[2340]419  if ( op == ROAR_RESET_FLAG )
[2339]420   g_config->streams[dir].flags -= flag;
421 }
422
423 return 0;
424}
425
[1145]426int add_output (char * drv, char * dev, char * opts, int prim, int count) {
[933]427 int stream;
428 struct roar_stream * s;
429 struct roar_stream_server * ss;
[938]430 char * k, * v;
[1208]431#ifdef ROAR_DRIVER_CODEC
432 char * to_free = NULL;
433#endif
[1926]434 int sync = 0, f_mmap = 0;
[1522]435 int32_t blocks = -1, blocksize = -1;
[1920]436 int dir = ROAR_DIR_OUTPUT;
[1991]437 int error = 0;
438 // DMX:
439 int32_t channel  = -1;
440 int32_t universe = -1;
441 uint16_t tu16;
[2085]442 float q = -32e6;
[933]443
[938]444 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
[933]445
[1145]446 if ( drv == NULL && count == 0 ) {
447  drv  = ROAR_DRIVER_DEFAULT;
448  prim = 1;
449  sync = 1;
[1208]450
451#ifdef ROAR_DRIVER_CODEC
452  if ( opts == NULL ) {
453   opts = to_free = strdup("codec=" ROAR_DRIVER_CODEC);
454  }
455#endif
[1145]456 }
457
[1227]458 if ( opts == NULL && count == 0 ) {
459  sync = 1;
460  prim = 1; // if ( prim == 0 ) prim = 1; -> prim allways = 1
461 }
462
[2785]463 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
464
[933]465 if ( (stream = streams_new()) == -1 ) {
[938]466  ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
[982]467  if ( prim ) alive = 0;
[933]468  return -1;
469 }
470
[2785]471 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
472
[933]473 streams_get(stream, &ss);
474 s = ROAR_STREAM(ss);
475
[2785]476 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
477
[2511]478 memset(&(s->info), 0xFF, sizeof(struct roar_audio_info)); // set everything to -1
[933]479
480 s->pos_rel_id = -1;
481// s->info.codec = codec;
482
[2785]483 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
484
[2788]485 if ( opts == NULL ) {
486  k = NULL;
487 } else {
488  k = strtok(opts, ",");
489 }
[2786]490
491 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s'): initial k='%s'(%p)", drv, dev, opts, k, k);
492
[938]493 while (k != NULL) {
494//  ROAR_WARN("add_output(*): opts: %s", k);
495
496  if ( (v = strstr(k, "=")) != NULL ) {
497   *v++ = 0;
498  }
499
500  ROAR_DBG("add_output(*): opts: k='%s', v='%s'", k, v);
501  if ( strcmp(k, "rate") == 0 ) {
502   s->info.rate = atoi(v);
503  } else if ( strcmp(k, "channels") == 0 ) {
504   s->info.channels = atoi(v);
505  } else if ( strcmp(k, "bits") == 0 ) {
506   s->info.bits = atoi(v);
507  } else if ( strcmp(k, "codec") == 0 ) {
[2511]508   if ( (s->info.codec = roar_str2codec(v)) == -1 ) {
[938]509    ROAR_ERR("add_output(*): unknown codec '%s'", v);
[1991]510    error++;
[938]511   }
[2085]512  } else if ( strcmp(k, "q") == 0 ) {
513   q = atof(v);
[1221]514  } else if ( strcmp(k, "blocks") == 0 ) {
515   blocks = atoi(v);
[1522]516  } else if ( strcmp(k, "blocksize") == 0 ) {
517   blocksize = atoi(v);
[1926]518  } else if ( strcmp(k, "mmap") == 0 ) {
519   f_mmap = 1;
[1919]520  } else if ( strcmp(k, "subsystem") == 0 ) {
521   if ( !strcasecmp(v, "wave") || !strcasecmp(v, "waveform") ) {
[1920]522    dir = ROAR_DIR_OUTPUT;
[2494]523#ifndef ROAR_WITHOUT_DCOMP_MIDI
[1919]524   } else if ( !strcasecmp(v, "midi") ) {
525    dir = ROAR_DIR_MIDI_OUT;
[2494]526#endif
527#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1919]528   } else if ( !strcasecmp(v, "light") ) {
529    dir = ROAR_DIR_LIGHT_OUT;
[2494]530#endif
531#ifndef ROAR_WITHOUT_DCOMP_RAW
[2234]532   } else if ( !strcasecmp(v, "raw") ) {
533    dir = ROAR_DIR_RAW_OUT;
[2494]534#endif
[2681]535   } else if ( !strcasecmp(v, "complex") ) {
536    dir = ROAR_DIR_COMPLEX_OUT;
[1919]537   } else {
[2494]538    ROAR_ERR("add_output(*): unknown/unsupported subsystem '%s'", k);
[1991]539    error++;
540   }
541  // DMX:
542  } else if ( strcmp(k, "channel") == 0 ) {
543   channel  = atoi(v);
544   if ( channel < 0 || channel > 65535 ) {
545    ROAR_ERR("add_output(*): Invalide channel (not within 0..65535): %i", channel);
546    channel = -1;
547    error++;
[1919]548   }
[1991]549  } else if ( strcmp(k, "universe") == 0 ) {
550   universe = atoi(v);
551   if ( universe < 0 || universe > 255 ) {
552    ROAR_ERR("add_output(*): Invalide universe (not within 0..255): %i", universe);
553    universe = -1;
554    error++;
555   }
556
[2115]557  } else if ( strcmp(k, "name") == 0 ) {
558   if ( streams_set_name(stream, v) == -1 ) {
559    ROAR_ERR("add_output(*): Can not set Stream name");
560    error++;
561   }
[1991]562
[1032]563  } else if ( strcmp(k, "meta") == 0 ) {
564   streams_set_flag(stream, ROAR_FLAG_META);
[1117]565  } else if ( strcmp(k, "sync") == 0 ) {
566   sync = 1;
[1221]567  } else if ( strcmp(k, "primary") == 0 ) {
568   prim = 1;
569
570  } else if ( strcmp(k, "cleanmeta") == 0 ) {
571   streams_set_flag(stream, ROAR_FLAG_CLEANMETA);
572  } else if ( strcmp(k, "autoconf") == 0 ) {
[1531]573   streams_set_flag(stream, ROAR_FLAG_AUTOCONF);
[2413]574  } else if ( strcmp(k, "recsource") == 0 ) {
575   streams_set_flag(stream, ROAR_FLAG_RECSOURCE);
576  } else if ( strcmp(k, "passmixer") == 0 ) {
577   streams_set_flag(stream, ROAR_FLAG_PASSMIXER);
[938]578  } else {
579   ROAR_ERR("add_output(*): unknown option '%s'", k);
[1991]580   error++;
581  }
582
583  if ( error ) {
[938]584   streams_delete(stream);
[982]585   if ( prim ) alive = 0;
[1208]586#ifdef ROAR_DRIVER_CODEC
587   if ( to_free != NULL )
588    free(to_free);
589#endif
[938]590   return -1;
591  }
592
593  k = strtok(NULL, ",");
594 }
595
[2785]596 ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
597
[2511]598 // set audio info...
599 switch (dir) {
600  case ROAR_DIR_LIGHT_OUT:
601    switch (s->info.codec) {
602     case ROAR_CODEC_DMX512:
603     case -1:
604       if ( s->info.rate == -1 )
605        s->info.rate = ROAR_OUTPUT_CFREQ;
606
607       s->info.channels =   0;
608       s->info.bits     =   8;
609       s->info.codec    = ROAR_CODEC_DMX512; // in case codec == -1
610      break;
611    }
612   break;
613  case ROAR_DIR_MIDI_OUT:
614    switch (s->info.codec) {
615     case ROAR_CODEC_MIDI:
616     case -1:
617       if ( s->info.rate == -1 )
618        s->info.rate    = ROAR_MIDI_TICKS_PER_BEAT;
619
620       s->info.channels = ROAR_MIDI_CHANNELS_DEFAULT;
621       s->info.bits     = ROAR_MIDI_BITS;
622       s->info.codec    = ROAR_CODEC_MIDI; // in case codec == -1
623      break;
624    }
625   break;
626  case ROAR_DIR_RAW_OUT:
627    if ( s->info.rate == -1 )
628     s->info.rate = 0;
629    if ( s->info.bits == -1 )
630     s->info.bits = 0;
631    if ( s->info.channels == -1 )
632     s->info.channels = 0;
633    if ( s->info.codec == -1 )
634     s->info.codec = 0;
635   break;
636 }
637
638 if ( s->info.rate == -1 )
639  s->info.rate = g_sa->rate;
640 if ( s->info.bits == -1 )
641  s->info.bits = g_sa->bits;
642 if ( s->info.channels == -1 )
643  s->info.channels = g_sa->channels;
644 if ( s->info.codec == -1 )
645  s->info.codec = g_sa->codec;
646
647 ROAR_DBG("add_output(*): s->info = {.rate=%i, .bits=%i, .channels=%i, .codec=%i}", s->info.rate, s->info.bits, s->info.channels, s->info.codec);
648
[1919]649 if ( streams_set_dir(stream, dir, 1) == -1 ) {
650  streams_delete(stream);
651  return -1;
652 }
653
[1208]654#ifdef ROAR_DRIVER_CODEC
655 if ( to_free != NULL )
656  free(to_free);
657#endif
658
[2511]659 if ( s->info.codec == ROAR_CODEC_ALAW || s->info.codec == ROAR_CODEC_MULAW )
[941]660  s->info.bits = 8; // needed to open OSS driver, will be overriden by codecfilter
661
[2511]662 ROAR_STREAM_SERVER(s)->codec_orgi = s->info.codec;
[933]663
[2364]664 if ( driver_openvio(&(ss->vio), &(ss->driver_id), drv, dev, &(s->info), -1, ss) == -1 ) {
[1581]665  ss->driver_id = -1; // don't close a driver not opened...
666  memset(&(ss->vio), 0, sizeof(struct roar_vio_calls));
[933]667  streams_delete(stream);
[938]668  ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
[982]669  if ( prim ) alive = 0;
[933]670  return -1;
671 }
672
[1528]673 roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAMID, &stream); // ignore errors here
674 roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAM,   s); // ignore errors here
675
[1221]676 if ( blocks != -1 )
677  roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DBLOCKS, &blocks);
678
[1522]679 if ( blocksize != -1 )
680  roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DBLKSIZE, &blocksize);
681
[1991]682 // TODO: we shoudld *really* check for errors here...
683 if ( channel != -1 ) {
684  tu16 = channel;
685  roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DMXSCHAN, &tu16);
686 }
687 if ( universe != -1 ) {
688  tu16 = universe;
689  roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DMXUNIV, &tu16);
690 }
691
[1156]692 ROAR_DBG("add_output(*): ss->driver_id=%i", ss->driver_id);
693
[938]694 streams_set_fh(stream, -1); // update some internal structures
695
[2087]696 if ( q > -1e6 ) {
697  ROAR_DBG("add_output(*): setting q=%f", q);
698  streams_ctl(stream, ROAR_CODECFILTER_CTL_SET_Q|ROAR_STREAM_CTL_TYPE_FLOAT, &q);
699 }
700
[2490]701 client_stream_add(g_self_client, stream);
[933]702
[1200]703 if ( prim ) {
[961]704  streams_mark_primary(stream);
[1200]705  s->pos_rel_id = stream;
706 }
[961]707
[1120]708 if ( sync ) {
[1117]709  streams_set_flag(stream, ROAR_FLAG_SYNC);
[1120]710 } else {
711  streams_reset_flag(stream, ROAR_FLAG_SYNC);
712 }
[1117]713
[1926]714 if ( f_mmap )
715  streams_set_flag(stream, ROAR_FLAG_MMAP);
716
[2511]717 ROAR_DBG("add_output(*): s->info = {.rate=%i, .bits=%i, .channels=%i, .codec=%i}", s->info.rate, s->info.bits, s->info.channels, s->info.codec);
[933]718 return 0;
[932]719}
720
[1993]721
722// SLP:
723void register_slp_callback(SLPHandle hslp, SLPError errcode, void * cookie) {
724 /* return the error code in the cookie */
725 *(SLPError*)cookie = errcode;
726}
727
728int register_slp (int unreg, char * sockname) {
729#ifdef ROAR_HAVE_LIBSLP
730 static int regged = 0;
731 static char * sn = NULL;
732 SLPError err;
733 SLPError callbackerr;
734 SLPHandle hslp;
735 char addr[1024];
736 char attr[1024] = "";
[2017]737 char * location;
[1993]738
739 if ( sockname != NULL )
740  sn = sockname;
741
[2016]742 snprintf(addr, sizeof(addr), ROAR_SLP_URL_TYPE "://%s", sn);
[1993]743
744 err = SLPOpen("en", SLP_FALSE, &hslp);
745
746 if (err != SLP_OK) {
747  ROAR_ERR("Error opening slp handle: Error #%i", err);
748  return -1;
749 }
750
751 if (!unreg) {
[2017]752
753  if ( SLPEscape(g_config->location, &location, SLP_FALSE) != SLP_OK ) {
754   ROAR_ERR("Error using SLPEscape() on server location, really bad!");
755   SLPClose(hslp);
756   return -1;
757  }
758
[1995]759  snprintf(attr, sizeof(attr), "(wave-rate=%i),(wave-channels=%i),(wave-bits=%i),"
[2494]760#ifndef ROAR_WITHOUT_DCOMP_LIGHT
761                               "(light-channels=%i),"
762#endif
763                               "(location=%s)",
[1995]764           g_sa->rate, g_sa->channels, g_sa->bits,
[2494]765#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[2017]766           g_light_state.channels,
[2494]767#endif
[2017]768           location
[1995]769          );
770
[1993]771  /* Register a service with SLP */
772  err = SLPReg(hslp,
773               addr,
774               SLP_LIFETIME_MAXIMUM,
775               0,
776               attr,
777               SLP_TRUE,
778               register_slp_callback,
779               &callbackerr);
[1994]780  regged = 1;
781 } else if ( unreg && regged ) {
782  err = SLPDereg(hslp, addr, register_slp_callback, &callbackerr);
783  regged = 0;
784 } else {
785  SLPClose(hslp);
786  return -1;
787 }
[1993]788
[1994]789 /* err may contain an error code that occurred as the slp library    */
790 /* _prepared_ to make the call.                                     */
791 if ( err != SLP_OK ) {
792  ROAR_ERR("Error (de)registering service with slp: Error #%i", err);
793  return -1;
794 }
795
796 /* callbackerr may contain an error code (that was assigned through */
797 /* the callback cookie) that occurred as slp packets were sent on    */
798 /* the wire */
799 if (callbackerr != SLP_OK) {
800  ROAR_ERR("Error (de)registering service with slp: Error #%i", callbackerr);
801  return -1;
[1993]802 }
803
804 SLPClose(hslp);
805 return 0;
806#else
807 return -1;
808#endif
809}
810
811
812// MAIN:
813
[1503]814#ifdef ROAR_HAVE_MAIN_ARGS
[0]815int main (int argc, char * argv[]) {
[1503]816#else
817int main (void) {
818#endif
819#ifdef ROAR_HAVE_MAIN_ARGS
[0]820 int i;
821 char * k;
[1503]822#endif
[2787]823#if defined(ROAR_SUPPORT_LISTEN) && defined(ROAR_HAVE_GETUID)
[905]824 char user_sock[80]  = {0};
[1494]825#endif
[1609]826 struct roar_audio_info sa, max_sa;
827 struct roard_config config;
[1486]828#ifdef ROAR_HAVE_FORK
[905]829 int    daemon       = 0;
[1486]830#endif
[905]831 int    realtime     = 0;
832 int    sysclocksync = 0;
[1207]833 char * driver    = NULL;
834 char * device    = NULL;
[1503]835#ifdef ROAR_HAVE_MAIN_ARGS
[1207]836 char * opts      = NULL;
[1503]837#endif
[60]838// char * server = ROAR_DEFAULT_SOCK_GLOBAL;
[1494]839#ifdef ROAR_SUPPORT_LISTEN
[2530]840 int    port       = ROAR_DEFAULT_PORT;
841 char * sock_addr  = NULL;
842 int    sock_proto = ROAR_PROTO_ROARAUDIO;
[1494]843#endif
[0]844 int               drvid;
[2486]845#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[550]846 char * s_drv     = "cf";
[1110]847 char * s_dev     = NULL;
[444]848 char * s_con     = NULL;
849 char * s_opt     = NULL;
850 int    s_prim    = 0;
[2486]851#endif
[1207]852 char * o_drv     = getenv("ROAR_DRIVER");
853 char * o_dev     = getenv("ROAR_DEVICE");
[932]854 char * o_opts    = NULL;
[961]855 int    o_prim    = 0;
[1145]856 int    o_count   = 0;
[2494]857#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1923]858 int    light_channels = LIGHT_CHANNELS_DEFAULT;
[2494]859#endif
[2751]860#ifdef ROAR_DEFAULT_SOCKGRP
[450]861 char * sock_grp  = ROAR_DEFAULT_SOCKGRP;
[2751]862#else
863 char * sock_grp  = NULL;
864#endif
[444]865 char * sock_user = NULL;
[1494]866#ifdef ROAR_SUPPORT_LISTEN
[517]867 int    sock_type = ROAR_SOCKET_TYPE_UNKNOWN;
[1494]868#endif
[1993]869#ifdef ROAR_HAVE_LIBSLP
870 int    reg_slp   = 0;
871#endif
[1486]872#ifdef ROAR_HAVE_CHROOT
[444]873 char * chrootdir = NULL;
[1486]874#endif
875#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
[446]876 struct group   * grp  = NULL;
[1486]877#endif
878#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
[446]879 struct passwd  * pwd  = NULL;
[1486]880#endif
881#ifdef ROAR_HAVE_GETSERVBYNAME
[446]882 struct servent * serv = NULL;
[1486]883#endif
[0]884 DRIVER_USERDATA_T drvinst;
[39]885 struct roar_client * self = NULL;
[508]886#ifdef ROAR_HAVE_LIBDNET
887 char decnethost[80];
888#endif
[2104]889#ifdef SUPPORT_PIDFILE
890 struct roar_vio_calls pidfile_vio;
891#endif
[0]892
[2784]893 ROAR_DBG("main(*): starting roard...");
894
[0]895 g_standby       =  0;
[920]896 g_autostandby   =  0;
[982]897 alive           =  1;
[1494]898#ifdef ROAR_SUPPORT_LISTEN
[1155]899 g_no_listen     =  0;
[1494]900#else
901 g_terminate     =  1;
902#endif
[0]903
[2970]904 g_verbose       = ROAR_DBG_INFO_NONE;
905
[0]906 sa.bits     = ROAR_BITS_DEFAULT;
907 sa.channels = ROAR_CHANNELS_DEFAULT;
908 sa.rate     = ROAR_RATE_DEFAULT;
909 sa.codec    = ROAR_CODEC_DEFAULT;
910
[1609]911 g_sa        = &sa;
912 g_max_sa    = &max_sa;
913
914 memcpy(g_max_sa, g_sa, sizeof(max_sa));
915
916 g_config = &config;
917
918 if ( init_config() == -1 ) {
919  ROAR_ERR("Can not init default config!");
920  return 1;
921 }
[0]922
[2968]923 // load config
924 roar_libroar_get_config();
925
[2530]926#ifdef ROAR_SUPPORT_LISTEN
927 if ( init_listening() == -1 ) {
928  ROAR_ERR("Can not init listening sockets!");
929  return 1;
930 }
931#endif
932
[2500]933#ifndef ROAR_WITHOUT_DCOMP_MIDI
[1924]934 if ( midi_init_config() == -1 ) {
935  ROAR_ERR("Can not init MIDI config!");
936  return 1;
937 }
[2500]938#endif
[60]939
[2489]940#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]941 if ( ssynth_init_config() == -1 ) {
942  ROAR_ERR("Can not init ssynth config!");
943  return 1;
944 }
[2489]945#endif
[2451]946
[2718]947#ifndef ROAR_WITHOUT_DCOMP_RDTCS
948 if ( rdtcs_init_config() == -1 ) {
949  ROAR_ERR("Can not init RDTCS config!");
950  return 1;
951 }
952#endif
953
[1494]954#ifdef ROAR_SUPPORT_LISTEN
[2767]955#ifndef ROAR_TARGET_WIN32
[2530]956 sock_addr = ROAR_DEFAULT_SOCK_GLOBAL;
[2767]957#else
958 sock_addr = ROAR_DEFAULT_HOST;
959#endif
960
[1753]961#ifdef ROAR_HAVE_GETUID
[1486]962 if ( getuid() != 0 && getenv("HOME") != NULL ) {
963  snprintf(user_sock, 79, "%s/%s", (char*)getenv("HOME"), ROAR_DEFAULT_SOCK_USER);
[2530]964  sock_addr = user_sock;
[60]965 }
[1753]966#endif
[60]967
[279]968 if ( getenv("ROAR_SERVER") != NULL )
[2530]969  sock_addr = getenv("ROAR_SERVER");
[1494]970#endif
[279]971
[63]972 if ( clients_init() == -1 ) {
973  ROAR_ERR("Can not init clients!");
974  return 1;
975 }
976
977 if ( streams_init() == -1 ) {
978  ROAR_ERR("Can not init streams!");
979  return 1;
980 }
981
[64]982 if ( (g_self_client = clients_new()) == -1 ) {
983  ROAR_ERR("Can not create self client!");
984  return 1;
985 }
986
[2485]987#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]988 if ( sources_init() == -1 ) {
989  ROAR_ERR("Can not init sources!");
990  return 1;
991 }
992
[64]993 if ( (sources_set_client(g_self_client)) == -1 ) {
994  ROAR_ERR("Can not init set source client!");
995  return 1;
996 }
[2485]997#endif
[64]998
[1503]999#ifdef ROAR_HAVE_MAIN_ARGS
[0]1000 for (i = 1; i < argc; i++) {
1001  k = argv[i];
1002
1003  if ( strcmp(k, "-h") == 0 || strcmp(k, "--help") == 0 ) {
1004   usage();
1005   return 0;
1006
[2109]1007  } else if ( strcmp(k, "--start") == 0 ) {
1008   // this is a no op
[579]1009  } else if ( strcmp(k, "--restart") == 0 ) {
[1494]1010#ifdef ROAR_SUPPORT_LISTEN
[2530]1011   if ( restart_server(sock_addr, 1) == -1 ) {
1012    ROAR_WARN("Can not terminate old server (not running at %s?), tring to continue anyway", sock_addr);
[579]1013   }
[1494]1014#else
1015   ROAR_ERR("--restart not supported");
1016#endif
[2109]1017  } else if ( strcmp(k, "--shutdown") == 0 ) {
1018#ifdef ROAR_SUPPORT_LISTEN
[2530]1019   if ( restart_server(sock_addr, 1) == -1 ) {
1020    ROAR_WARN("Can not terminate old server (not running at %s?)", sock_addr);
[2109]1021    return 1;
1022   }
1023   return 0;
1024#else
1025   ROAR_ERR("--shutdown not supported");
1026   return 1;
1027#endif
1028  } else if ( strcmp(k, "--stop") == 0 ) {
1029#ifdef ROAR_SUPPORT_LISTEN
[2530]1030   if ( restart_server(sock_addr, 0) == -1 ) {
1031    ROAR_WARN("Can not stop old server (not running at %s?)", sock_addr);
[2109]1032    return 1;
1033   }
1034   return 0;
1035#else
1036   ROAR_ERR("--stop not supported");
1037   return 1;
1038#endif
1039
[579]1040
[775]1041  } else if ( strcmp(k, "--demon") == 0 || strcmp(k, "--daemon") == 0 ) {
[1486]1042#ifdef ROAR_HAVE_FORK
[775]1043   daemon = 1;
[1486]1044#else
1045   ROAR_ERR("--daemon not supported");
1046#endif
[2970]1047  } else if ( strcmp(k, "--verbose") == 0 ) {
1048   g_verbose++;
[71]1049  } else if ( strcmp(k, "--terminate") == 0 ) {
1050   g_terminate = 1;
[905]1051  } else if ( strcmp(k, "--sysclocksync") == 0 ) {
1052   sysclocksync = 1000;
[275]1053  } else if ( strcmp(k, "--realtime") == 0 ) {
[276]1054   realtime++;
[444]1055  } else if ( strcmp(k, "--chroot") == 0 ) {
[1486]1056#ifdef ROAR_HAVE_CHROOT
[444]1057   chrootdir = argv[++i];
[1486]1058#else
1059   ROAR_ERR("--chroot not supported");
1060   i++;
1061#endif
[444]1062  } else if ( strcmp(k, "--setgid") == 0 ) {
[1486]1063#ifdef ROAR_HAVE_SETGID
[444]1064   setids |= R_SETGID;
[1486]1065#else
1066   ROAR_ERR("--setgid not supported");
1067#endif
[444]1068  } else if ( strcmp(k, "--setuid") == 0 ) {
[1486]1069#ifdef ROAR_HAVE_SETUID
[444]1070   setids |= R_SETUID;
[1486]1071#else
1072   ROAR_ERR("--setuid not supported");
1073#endif
[2017]1074  } else if ( strcmp(k, "--location") == 0 ) {
1075   g_config->location = argv[++i];
[2104]1076  } else if ( strcmp(k, "--pidfile") == 0 ) {
1077#ifdef SUPPORT_PIDFILE
1078   pidfile = argv[++i];
1079#else
1080   ROAR_ERR("--pidfile not supported");
1081   i++;
1082#endif
[68]1083
[280]1084  } else if ( strcmp(k, "--list-cf") == 0 ) {
1085   print_codecfilterlist();
1086   return 0;
1087
[0]1088  } else if ( strcmp(k, "-R") == 0 || strcmp(k, "--rate") == 0 ) {
1089   sa.rate = atoi(argv[++i]);
1090  } else if ( strcmp(k, "-B") == 0 || strcmp(k, "--bits") == 0 ) {
1091   sa.bits = atoi(argv[++i]);
1092  } else if ( strcmp(k, "-C") == 0 || strcmp(k, "--chans") == 0 ) {
1093   sa.channels = atoi(argv[++i]);
1094
[2339]1095  } else if ( strcmp(k, "--stream-flags") == 0 ) {
1096   if ( update_stream_flags(argv[++i]) == -1 ) {
1097    ROAR_ERR("Can not set stream flags");
1098    return 1;
1099   }
1100
[0]1101  } else if ( strcmp(k, "-d") == 0 || strcmp(k, "--driver") == 0 ) {
1102   driver = argv[++i];
1103   if ( strcmp(driver, "list") == 0 ) {
[974]1104    ROAR_WARN("The option is obsolete, use --list-driver!");
[0]1105    print_driverlist();
[973]1106    return 0;
[0]1107   }
1108  } else if ( strcmp(k, "-D") == 0 || strcmp(k, "--device") == 0 ) {
1109   device = argv[++i];
1110  } else if ( strcmp(k, "-dO") == 0 ) {
1111   opts = argv[++i];
[973]1112  } else if ( strcmp(k, "--list-driver") == 0 ) {
1113   print_driverlist();
1114   return 0;
[0]1115
[932]1116  } else if ( strcmp(k, "-o") == 0 || strcmp(k, "--odriver") == 0 ) {
1117   o_drv  = argv[++i];
1118  } else if ( strcmp(k, "-O") == 0 || strcmp(k, "--odevice") == 0 ) {
1119   o_dev  = argv[++i];
1120  } else if ( strcmp(k, "-oO") == 0 ) {
1121   o_opts = argv[++i];
[961]1122  } else if ( strcmp(k, "-oP") == 0 ) {
1123   o_prim = 1;
[932]1124  } else if ( strcmp(k, "-oN") == 0 ) {
[1145]1125   if ( add_output(o_drv, o_dev, o_opts, o_prim, o_count) != -1 )
1126    o_count++;
1127
[961]1128   o_drv  = o_dev = o_opts = NULL;
1129   o_prim = 0;
[932]1130
[0]1131  } else if ( strcmp(k, "-s") == 0 || strcmp(k, "--source") == 0 ) {
[2485]1132#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[550]1133   s_drv = argv[++i];
[2485]1134#else
1135   ROAR_ERR("main(*): No support for sources compiled in");
1136#endif
[550]1137  } else if ( strcmp(k, "-S") == 0 ) {
[2485]1138#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[1110]1139   s_dev = argv[++i];
[2485]1140#else
1141   ROAR_ERR("main(*): No support for sources compiled in");
1142#endif
[0]1143  } else if ( strcmp(k, "-sO") == 0 ) {
[2485]1144#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]1145   s_opt = argv[++i];
[2485]1146#else
1147   ROAR_ERR("main(*): No support for sources compiled in");
1148#endif
[0]1149  } else if ( strcmp(k, "-sC") == 0 ) {
[2485]1150#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]1151   s_con = argv[++i];
[2485]1152#else
1153   ROAR_ERR("main(*): No support for sources compiled in");
1154#endif
[0]1155  } else if ( strcmp(k, "-sP") == 0 ) {
[2485]1156#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]1157   s_prim = 1;
[2485]1158#else
1159   ROAR_ERR("main(*): No support for sources compiled in");
1160#endif
[1110]1161  } else if ( strcmp(k, "-sN") == 0 ) {
[2485]1162#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[1110]1163   if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) {
1164    ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv);
1165   }
1166   s_opt = s_dev = s_con = NULL;
1167   s_drv = "cf";
1168   s_prim = 0;
[2485]1169#else
1170   ROAR_ERR("main(*): No support for sources compiled in");
1171#endif
[2270]1172  } else if ( strcmp(k, "--list-sources") == 0 ) {
[2485]1173#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[2270]1174   print_sourcelist();
1175   return 0;
[2485]1176#else
1177   ROAR_ERR("main(*): No support for sources compiled in");
[2504]1178   return 1;
[2485]1179#endif
[0]1180
[1923]1181  } else if ( strcmp(k, "--light-channels") == 0 ) {
[2494]1182#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1923]1183   light_channels = atoi(argv[++i]);
[2494]1184#else
1185   ROAR_WARN("main(*): no light subsystem compiled in");
1186#endif
[1923]1187
[2725]1188  } else if ( strcmp(k, "--rds-pi") == 0 ) {
1189#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1190   g_rdtcs.rds.pi = atoi(argv[++i]);
1191#else
1192   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
1193#endif
[2728]1194  } else if ( strcmp(k, "--rds-ps") == 0 ) {
1195#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1196   if ( rdtcs_rds_set_ps(argv[++i]) == -1 ) {
[2729]1197    ROAR_ERR("Can not set RDS PS to '%s' (longer than 8 chars?)", argv[i]);
[2728]1198    return 1;
1199   }
1200#else
1201   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
1202#endif
1203  } else if ( strcmp(k, "--rds-pty") == 0 ) {
1204#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1205   if ( rdtcs_rds_set_pty(argv[++i]) == -1 ) {
[2729]1206    ROAR_ERR("Can not set RDS PTY to '%s'", argv[i]);
[2728]1207    return 1;
1208   }
1209#else
1210   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
1211#endif
1212  } else if ( strcmp(k, "--rds-tp") == 0 ) {
1213#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1214   if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_TP, 0) == -1 ) {
1215    ROAR_ERR("Can not set RDS TP flag");
1216    return 1;
1217   }
1218#else
1219   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
1220#endif
1221  } else if ( strcmp(k, "--rds-ct") == 0 ) {
1222#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1223   if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_CT, 0) == -1 ) {
1224    ROAR_ERR("Can not set RDS CT flag");
1225    return 1;
1226   }
1227#else
1228   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
1229#endif
1230
[2725]1231
[1924]1232  } else if ( strcmp(k, "--midi-no-console") == 0 ) {
[2487]1233#ifndef ROAR_WITHOUT_DCOMP_CB
[1924]1234   midi_config.init_cb = 0;
[2487]1235#else
1236   // no warning here as this is the disable option
1237#endif
[2444]1238  } else if ( strcmp(k, "--midi-console-enable") == 0 ) {
[2487]1239#ifndef ROAR_WITHOUT_DCOMP_CB
[2444]1240   midi_config.init_cb = 1;
[2487]1241#else
1242   ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in");
1243#endif
[1924]1244  } else if ( strcmp(k, "--midi-console") == 0 ) {
[2487]1245#ifndef ROAR_WITHOUT_DCOMP_CB
[1924]1246   midi_config.console_dev = argv[++i];
[2444]1247   midi_config.init_cb = 1;
[2487]1248#else
1249   ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in");
1250#endif
[1924]1251
[2451]1252  } else if ( strcmp(k, "--ssynth-enable") == 0 ) {
[2489]1253#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]1254   ssynth_conf.enable = 1;
[2489]1255#else
1256   ROAR_ERR("main(*): No support for ssynth compiled in");
1257#endif
[2451]1258  } else if ( strcmp(k, "--ssynth-disable") == 0 ) {
[2489]1259#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]1260   ssynth_conf.enable = 0;
[2489]1261#else
1262   // we can safely ignore the disable
1263#endif
[2451]1264
[0]1265  } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--port") == 0 ) {
[447]1266   // This is only usefull in INET not UNIX mode.
[1494]1267#ifdef ROAR_SUPPORT_LISTEN
[2530]1268   if ( *sock_addr == '/' )
1269    sock_addr = ROAR_DEFAULT_HOST;
[447]1270
[446]1271   errno = 0;
1272   if ( (port = atoi(argv[++i])) < 1 ) {
[1486]1273#ifdef ROAR_HAVE_GETSERVBYNAME
[446]1274    if ( (serv = getservbyname(argv[i], "tcp")) == NULL ) {
1275     ROAR_ERR("Unknown service: %s: %s", argv[i], strerror(errno));
1276     return 1;
1277    }
1278    // NOTE: we need to use ROAR_NET2HOST16() here even if s_port is of type int!
1279    ROAR_DBG("main(*): serv = {s_name='%s', s_aliases={...}, s_port=%i, s_proto='%s'}",
1280            serv->s_name, ROAR_NET2HOST16(serv->s_port), serv->s_proto);
1281    port = ROAR_NET2HOST16(serv->s_port);
[1486]1282#else
1283    ROAR_ERR("invalite port number: %s", argv[i]);
1284    return 1;
1285#endif
[446]1286   }
[1494]1287#endif
[1115]1288  } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 || strcmp(k, "--sock") == 0 ) {
[1494]1289#ifdef ROAR_SUPPORT_LISTEN
[2530]1290   sock_addr = argv[++i];
1291#endif
1292
1293  } else if ( strcmp(k, "--proto") == 0 ) {
1294#ifdef ROAR_SUPPORT_LISTEN
[2549]1295   if ( (sock_proto = roar_str2proto(argv[++i])) == -1 ) {
[2530]1296    ROAR_ERR("Unknown protocol: %s", argv[i]);
1297    return 1;
1298   }
[1494]1299#endif
[518]1300
[573]1301  } else if ( strcmp(k, "-t") == 0 || strcmp(k, "--tcp") == 0 ) {
[1494]1302#ifdef ROAR_SUPPORT_LISTEN
[518]1303   if ( sock_type != ROAR_SOCKET_TYPE_TCP && sock_type != ROAR_SOCKET_TYPE_TCP6 )
1304    sock_type = ROAR_SOCKET_TYPE_TCP;
1305
[2530]1306   if ( *sock_addr == '/' )
1307    sock_addr = ROAR_DEFAULT_HOST;
[1494]1308#endif
[518]1309
1310  } else if ( strcmp(k, "-4") == 0 ) {
[1494]1311#ifdef ROAR_SUPPORT_LISTEN
[517]1312   sock_type = ROAR_SOCKET_TYPE_TCP;
[2530]1313   if ( *sock_addr == '/' )
1314    sock_addr = ROAR_DEFAULT_HOST;
[1494]1315#endif
[518]1316  } else if ( strcmp(k, "-6") == 0 ) {
[1494]1317#ifdef ROAR_SUPPORT_LISTEN
[519]1318#ifdef PF_INET6
[518]1319   sock_type = ROAR_SOCKET_TYPE_TCP6;
[2530]1320   if ( *sock_addr == '/' )
1321    sock_addr = ROAR_DEFAULT_HOST;
[519]1322#else
1323    ROAR_ERR("No IPv6 support compiled in!");
1324    return 1;
1325#endif
[1494]1326#endif
[518]1327
[573]1328  } else if ( strcmp(k, "-u") == 0 || strcmp(k, "--unix") == 0 ) {
[1494]1329#ifdef ROAR_SUPPORT_LISTEN
[62]1330   // ignore this case as it is the default behavor.
[517]1331   sock_type = ROAR_SOCKET_TYPE_UNIX;
[1494]1332#endif
[518]1333
[573]1334  } else if ( strcmp(k, "-n") == 0 || strcmp(k, "--decnet") == 0 ) {
[1494]1335#ifdef ROAR_SUPPORT_LISTEN
[508]1336#ifdef ROAR_HAVE_LIBDNET
1337    port   = ROAR_DEFAULT_NUM;
1338    strcpy(decnethost, ROAR_DEFAULT_LISTEN_OBJECT);
[2530]1339    sock_addr = decnethost;
[517]1340    sock_type = ROAR_SOCKET_TYPE_DECNET;
[508]1341#else
1342    ROAR_ERR("No DECnet support compiled in!");
1343    return 1;
1344#endif
[1494]1345#endif
[2530]1346  } else if ( strcmp(k, "--new-sock") == 0 ) {
1347#ifdef ROAR_SUPPORT_LISTEN
1348   if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto) != 0 ) {
1349    ROAR_ERR("Can not open listen socket!");
1350    return 1;
1351   }
1352#endif
[518]1353
[1993]1354  } else if ( strcmp(k, "--slp") == 0 ) {
1355#ifdef ROAR_HAVE_LIBSLP
1356   reg_slp = 1;
1357#else
1358    ROAR_ERR("No OpenSLP support compiled in!");
1359    return 1;
1360#endif
1361
[3039]1362  } else if ( strcmp(k, "--jumbo-mtu") == 0 ) {
1363   g_config->jumbo_mtu = atoi(argv[++i]);
1364
[60]1365  } else if ( strcmp(k, "-G") == 0 ) {
[444]1366   sock_grp  = argv[++i];
1367  } else if ( strcmp(k, "-U") == 0 ) {
1368   sock_user = argv[++i];
[0]1369
[68]1370  } else if ( strcmp(k, "--no-listen") == 0 ) {
[1494]1371#ifdef ROAR_SUPPORT_LISTEN
[2530]1372   sock_addr   = "";
[548]1373   g_terminate = 1;
[1155]1374   g_no_listen = 1;
[1494]1375#endif
[68]1376  } else if ( strcmp(k, "--client-fh") == 0 ) {
1377   if ( clients_set_fh(clients_new(), atoi(argv[++i])) == -1 ) {
1378    ROAR_ERR("main(*): Can not set client's fh");
1379    return 1;
1380   }
[501]1381  } else if ( strcmp(k, "--close-fh") == 0 ) {
[1486]1382#ifdef ROAR_HAVE_IO_POSIX
[501]1383   close(atoi(argv[++i]));
[1486]1384#else
1385   i++;
1386   ROAR_WARN("can not close file handle %s (closing not supported)", argv[i]);
1387#endif
[68]1388
[920]1389  } else if ( strcmp(k, "--standby") == 0 ) {
1390   g_standby = 1;
1391  } else if ( strcmp(k, "--auto-standby") == 0 ) {
1392   g_autostandby = 1;
[0]1393  } else {
1394   usage();
1395   return 1;
1396  }
1397
1398 }
[1503]1399#endif
[0]1400
[2485]1401#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[1110]1402 if ( s_dev != NULL ) {
1403  if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) {
1404   ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv);
1405  }
1406 }
[2485]1407#endif
[1110]1408
[1145]1409 add_output(o_drv, o_dev, o_opts, o_prim, o_count);
[932]1410
[0]1411 ROAR_DBG("Server config: rate=%i, bits=%i, chans=%i", sa.rate, sa.bits, sa.channels);
1412
[2945]1413 if ( waveform_init() == -1 ) {
1414  ROAR_ERR("Can not initialize Waveform subsystem");
1415  return 1;
1416 }
1417
[2500]1418#ifndef ROAR_WITHOUT_DCOMP_MIDI
[1819]1419 if ( midi_init() == -1 ) {
[281]1420  ROAR_ERR("Can not initialize MIDI subsystem");
[1819]1421 }
[2500]1422#endif
[1819]1423
[2489]1424#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]1425 if ( ssynth_init() == -1 ) {
1426  ROAR_ERR("Can not initialize ssynth subsystem");
1427 }
[2489]1428#endif
[2451]1429
[2494]1430#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1819]1431 if ( light_init(light_channels) == -1 ) {
1432  ROAR_ERR("Can not initialize light control subsystem");
1433 }
[2494]1434#endif
[281]1435
[2718]1436#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1437 if ( rdtcs_init() == -1 ) {
1438  ROAR_ERR("Can not initialize RDTCS subsystem");
1439 }
1440#endif
1441
[1494]1442#ifdef ROAR_SUPPORT_LISTEN
[2530]1443 if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto) != 0 ) {
1444  ROAR_ERR("Can not open listen socket!");
1445  return 1;
[60]1446 }
[1494]1447#endif
[60]1448
[0]1449 if ( output_buffer_init(&sa) == -1 ) {
1450  ROAR_ERR("Can not init output buffer!");
1451  return 1;
1452 }
1453
[1145]1454 if ( driver == NULL ) {
1455  driver = "null";
1456 } else {
1457  ROAR_WARN("Usage of old driver interface. use -o not -d!");
1458 }
1459
[0]1460 if ( driver_open(&drvinst, &drvid, driver, device, &sa) == -1 ) {
1461  ROAR_ERR("Can not open output driver!");
1462  return 1;
1463 }
1464
[44]1465 if ( samples_init() == -1 ) {
1466  ROAR_ERR("Can not init samples!");
1467  return 1;
1468 }
1469
1470
[1486]1471 // we should handle this on microcontrollers, too.
[1753]1472#if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_TARGET_WIN32)
[0]1473 signal(SIGINT,  on_sig_int);
[2732]1474 signal(SIGTERM, on_sig_term);
[285]1475 signal(SIGCHLD, on_sig_chld);
[2112]1476 signal(SIGUSR1, on_sig_usr1);
[0]1477 signal(SIGPIPE, SIG_IGN);  // ignore broken pipes
[1486]1478#endif
[0]1479
[275]1480 if ( realtime ) {
[278]1481#ifdef DEBUG
1482  ROAR_WARN("compiled with -DDEBUG but realtime is enabled: for real realtime support compiel without -DDEBUG");
1483#endif
1484
[1486]1485#ifdef ROAR_HAVE_NICE
[275]1486  errno = 0;
[276]1487  nice(-5*realtime); // -5 for each --realtime
[1486]1488  if ( errno ) {
1489   ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno));
1490  }
1491#else
1492  ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno));
1493#endif
[277]1494/*
[276]1495#ifdef __linux__
[277]1496  if ( ioprio_set(IOPRIO_WHO_PROCESS, getpid(), IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0)) == -1 )
1497   ROAR_WARN("Can not set io priority: %s", strerror(errno));
[276]1498#endif
[277]1499*/
[275]1500 }
1501
[2756]1502#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
[444]1503 if ( setids & R_SETGID ) {
[2754]1504  if ( sock_grp == NULL ) {
1505   ROAR_ERR("Can not set GID if no groupname is supplied");
1506   return 1;
1507  }
[2584]1508  if ( (grp = getgrnam(sock_grp)) == NULL ) {
1509   ROAR_ERR("Can not get GID for group %s: %s", sock_grp, strerror(errno));
1510   return 1;
1511  }
[444]1512  if ( setgroups(0, (const gid_t *) NULL) == -1 ) {
1513   ROAR_ERR("Can not clear supplementary group IDs: %s", strerror(errno));
1514  }
[523]1515  if ( !grp || setgid(grp->gr_gid) == -1 ) {
[444]1516   ROAR_ERR("Can not set GroupID: %s", strerror(errno));
1517  }
1518 }
[1486]1519#endif
[444]1520
[0]1521
[39]1522 clients_set_pid(g_self_client, getpid());
[1753]1523#ifdef ROAR_HAVE_GETUID
[440]1524 clients_set_uid(g_self_client, getuid());
[1753]1525#endif
1526#ifdef ROAR_HAVE_GETGID
[440]1527 clients_set_gid(g_self_client, getgid());
[1753]1528#endif
[39]1529 clients_get(g_self_client, &self);
[37]1530
[39]1531 if ( self == NULL ) {
1532  ROAR_ERR("Can not get self client!");
1533  return 1;
1534 }
1535
[775]1536 strcpy(self->name, "RoarAudio daemon internal");
[68]1537
[2815]1538 if ( roar_nnode_free(&(self->nnode)) == -1 )
1539  return 1;
1540
1541 // not fully correct but ok as workaorund
1542 // so tools assume that roard runs on the same machine as
1543 // they in case they use AF_UNIX:
1544 if ( roar_nnode_new(&(self->nnode), ROAR_SOCKET_TYPE_UNIX) == -1 )
1545  return 1;
1546
[1486]1547#ifdef ROAR_HAVE_FORK
[775]1548 if ( daemon ) {
[68]1549  close(ROAR_STDIN );
1550  close(ROAR_STDOUT);
1551  close(ROAR_STDERR);
[1753]1552
[68]1553  if ( fork() )
[1486]1554   ROAR_U_EXIT(0);
[1753]1555
1556#ifdef ROAR_HAVE_SETSID
1557  setsid();
1558#endif
[1046]1559  clients_set_pid(g_self_client, getpid()); // reset pid as it changed
[68]1560 }
[1486]1561#endif
[68]1562
[2757]1563#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
1564 // early test for UID as we need this for the pidfile and the setuid()
1565 if ( sock_user != NULL ) {
1566  if ( (pwd = getpwnam(sock_user)) == NULL ) {
1567   ROAR_ERR("Can not get UID for user %s: %s", sock_user, strerror(errno));
1568   return 1;
1569  }
1570 }
1571#endif
1572
[2104]1573#ifdef SUPPORT_PIDFILE
[2106]1574 if ( pidfile != NULL ) {
1575  if ( roar_vio_open_file(&pidfile_vio, pidfile, O_WRONLY|O_CREAT, 0644) == -1 ) {
1576   ROAR_ERR("Can not write pidfile: %s", pidfile);
1577  } else {
1578   roar_vio_printf(&pidfile_vio, "%i\n", getpid());
1579   roar_vio_close(&pidfile_vio);
1580  }
[2765]1581#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
[2759]1582  if ( pwd || grp ) {
1583   if ( chown(pidfile, pwd ? pwd->pw_uid : -1, grp ? grp->gr_gid : -1) == -1 ) {
1584    ROAR_WARN("Can not change ownership of pidfile: %s: %s", pidfile, strerror(errno));
1585   }
1586  }
1587  if ( chmod(pidfile, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) == -1 ) {
1588   ROAR_WARN("Can not change permissions of pidfile: %s: %s", pidfile, strerror(errno));
1589  }
[2765]1590#endif
[2104]1591 }
1592#endif
1593
[1486]1594#ifdef ROAR_HAVE_CHROOT
[444]1595 if (chrootdir) {
1596  if ( chroot(chrootdir) == -1 ) {
1597   ROAR_ERR("Can not chroot to %s: %s", chrootdir, strerror(errno));
1598   return 2;
1599  }
1600  if ( chdir("/") == -1 ) {
1601   ROAR_ERR("Can not chdir to /: %s", strerror(errno));
1602   return 2;
1603  }
1604 }
[1486]1605#endif
[444]1606
[2756]1607#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
[444]1608 if ( setids & R_SETUID ) {
[2752]1609  if ( sock_user == NULL ) {
1610   ROAR_ERR("Can not set UID if no username is supplied");
1611   return 1;
1612  }
[444]1613  if ( !pwd || setuid(pwd->pw_uid) == -1 ) {
1614   ROAR_ERR("Can not set UserID: %s", strerror(errno));
1615   return 3;
1616  }
[1753]1617#ifdef ROAR_HAVE_GETUID
[444]1618  clients_set_uid(g_self_client, getuid());
[1753]1619#endif
[444]1620 }
[1486]1621#endif
[444]1622
[1993]1623 // Register with OpenSLP:
[2028]1624#ifdef ROAR_HAVE_LIBSLP
[1993]1625 if ( reg_slp ) {
[2530]1626  register_slp(0, sock_addr);
[1993]1627 }
[2028]1628#endif
[1993]1629
[0]1630 // start main loop...
[905]1631 main_loop(drvid, drvinst, &sa, sysclocksync);
[0]1632
1633 // clean up.
1634 clean_quit_prep();
1635 driver_close(drvinst, drvid);
1636 output_buffer_free();
1637
1638 return 0;
1639}
1640
[574]1641void cleanup_listen_socket (int terminate) {
[2530]1642 int i;
1643
[1993]1644 // Deregister from SLP:
[2028]1645#ifdef ROAR_HAVE_LIBSLP
[1993]1646 register_slp(1, NULL);
[2028]1647#endif
[580]1648
[1494]1649#ifdef ROAR_SUPPORT_LISTEN
[2530]1650 for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
1651  if ( g_listen_socket[i] != -1 ) {
[1486]1652#ifdef ROAR_HAVE_IO_POSIX
[2530]1653   close(g_listen_socket[i]);
[1486]1654#endif // #else is useless because we are in void context.
[60]1655
[2530]1656   g_listen_socket[i] = -1;
[576]1657
[1486]1658#ifdef ROAR_HAVE_UNIX
[2530]1659   if ( server[i] != NULL )
1660    if ( *(server[i]) == '/' )
1661     unlink(server[i]);
[1486]1662#endif
[2530]1663  }
[580]1664 }
[60]1665
[1494]1666#endif
1667
[574]1668 if ( terminate )
1669  g_terminate = 1;
1670}
1671
1672void clean_quit_prep (void) {
1673 cleanup_listen_socket(0);
[60]1674
[2485]1675#ifndef ROAR_WITHOUT_DCOMP_SOURCES
[0]1676 sources_free();
[2485]1677#endif
[0]1678 streams_free();
1679 clients_free();
[2489]1680#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
[2451]1681 ssynth_free();
[2489]1682#endif
[2487]1683#ifndef ROAR_WITHOUT_DCOMP_CB
[282]1684 midi_cb_stop(); // stop console beep
[2487]1685#endif
[2500]1686#ifndef ROAR_WITHOUT_DCOMP_MIDI
[281]1687 midi_free();
[2500]1688#endif
[2494]1689#ifndef ROAR_WITHOUT_DCOMP_LIGHT
[1819]1690 light_free();
[2494]1691#endif
[2718]1692#ifndef ROAR_WITHOUT_DCOMP_RDTCS
1693 rdtcs_free();
1694#endif
[2104]1695
[2945]1696 waveform_free();
1697
[2104]1698#ifdef SUPPORT_PIDFILE
1699 if ( pidfile != NULL )
1700  unlink(pidfile);
1701#endif
[0]1702}
1703
1704void clean_quit (void) {
1705 clean_quit_prep();
1706// driver_close(drvinst, drvid);
1707// output_buffer_free();
1708 exit(0);
1709}
1710
1711//ll
Note: See TracBrowser for help on using the repository browser.