Index: roard/.cvsignore
===================================================================
--- roard/.cvsignore	(revision 2802)
+++ 	(revision )
@@ -1,4 +1,0 @@
-roard
-empty.c
-driver_ftd2.c
-*.exe
Index: roard/.release-helper
===================================================================
--- roard/.release-helper	(revision 5244)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!RELEASE-HELPER:0.0beta0
-@RM driver_raw.c
-#!END
Index: roard/Makefile
===================================================================
--- roard/Makefile	(revision 5955)
+++ roard/Makefile	(revision 0)
@@ -1,39 +1,17 @@
 TARGETS=roard
 
-OBJ=roard.o driver.o mixer.o output.o signals.o loop.o clients.o streams.o network.o commands.o req.o sources.o sample.o meta.o codecfilter.o lib.o ssynth.o container_framework.o plugins.o memlock.o hwmixer.o auth.o caps.o rolestack.o
-SUBSYS=midi.o light.o raw.o rdtcs.o waveform.o beep.o
-DRV=driver_esd.o driver_ao.o driver_roar.o driver_oss.o driver_shout.o driver_sndio.o driver_dmx.o driver_pwmled.o driver_i2cdmx.o driver_sysclock.o driver_wmm.o driver_dstr.o driver_alsa.o driver_rsound.o driver_portaudio.o driver_pulsesimple.o driver_jack.o driver_artsc.o
-CF_CODEC=codecfilter_cmd.o codecfilter_vorbis.o codecfilter_celt.o codecfilter_speex.o codecfilter_alaw.o codecfilter_mulaw.o codecfilter_sndfile.o codecfilter_fishsound.o codecfilter_flac.o codecfilter_roardmx.o
-CF_CONTAINER=codecfilter_wave.o codecfilter_au.o codecfilter_uniraum.o
-EMUL=emul_simple.o emul_rsound.o
-HWMIXER=hwmixer_dstr.o hwmixer_oss.o
-
-CF=${CF_CONTAINER} ${CF_CODEC}
-
-include ../Makefile.conf
-include ../Makefile.inc
+OBJ=roard.o driver.o mixer.o output.o signals.o loop.o clients.o streams.o network.o commands.o req.o sources.o
+DRV=driver_esd.o driver_ao.o driver_roar.o
 
 #DEFINES        = -DDEBUG
-#DEFINES        = -DMONITOR_LATENCY
-INCLUDE   = -I../include -I./include
-CFLAGS   += $(DEBUG_g) $(Wall) $(OPTI_O) $(DEFINES) $(INCLUDE) $(INCPATH)
-LDFLAGS  += $(DEBUG_g) $(Wall) $(rdynamic) -L../lib/ $(LDPATH)
-DRVLIBS   = $(lib_esd) $(lib_ossaudio) $(lib_ao) $(lib_shout) $(pthread) $(lib_sndio) $(lib_rsound) $(lib_portaudio) $(lib_pablio) $(lib_asound) $(lib_winmm) $(lib_pulse_simple) $(lib_pulse) $(lib_jack) $(lib_artsc)
-CODEC_CELT= $(lib_celt) $(lib_celt0)
-CODECLIBS = $(lib_vorbisfile) $(lib_vorbisenc) $(lib_vorbis) $(lib_fishsound) $(lib_speex) $(lib_speexdsp) $(CODEC_CELT) $(lib_flac)
-CONTLIBS  = $(lib_oggz) $(lib_sndfile) $(lib_ogg) $(lib_uniraum)
-OWNLIBS   = $(LIBROAREIO) $(LIBROARLIGHT) $(LIBROARMIDI) $(LIBROARDSP) $(LIBROAR)
-LIBS      = $(DRVLIBS) $(CODECLIBS) $(CONTLIBS) $(OWNLIBS) $(lib_slp)
+INCLUDE = -I../include -I./include
+CFLAGS  = -g -Wall -O2 $(DEFINES) $(INCLUDE)
+LDFLAGS = -g -L../lib/ -lroar -lesd -lao
 
 all: ${TARGETS}
-	rm -f ../lib/${TARGETS} 2> /dev/null || true
-	cp $(cp_v) ${TARGETS} ../lib/
+	cp -v ${TARGETS} ../lib/
 clean:
 	rm -f ${TARGETS} *.o
 new: clean all
 
-run: roard
-	./roard $(ARGS)
-
-roard: ${OBJ} ${SUBSYS} ${DRV} ${CF} ${EMUL} ${HWMIXER}
-	${CC} ${LDFLAGS} -o roard ${OBJ} ${SUBSYS} ${DRV} ${CF} ${EMUL} ${HWMIXER} ${LIBS}
+roard: ${OBJ} ${DRV}
Index: roard/auth.c
===================================================================
--- roard/auth.c	(revision 6052)
+++ 	(revision )
@@ -1,263 +1,0 @@
-//auth.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#define _NONE ROAR_AUTH_T_AUTO
-
-// declared 'extern'
-struct auth_key g_auth_keyring[AUTH_KEYRING_LEN];
-
-int auth_init (void) {
- int i;
-
- memset(g_auth_keyring, 0, sizeof(g_auth_keyring));
-
- for (i = 0; i < AUTH_KEYRING_LEN; i++) {
-  g_auth_keyring[i].type = _NONE;
- }
-
-#if 0
- // test password for API tests...
- auth_addkey_password(ACCLEV_ALL, "test");
-#endif
-
-#if 0
- // test trust for API tests...
- auth_addkey_trust(ACCLEV_ALL, -1, 0, getuid()+1, -1, getgid()+1, -1);
-#endif
-
- return 0;
-}
-
-int auth_free (void) {
- return 0;
-}
-
-union auth_typeunion * auth_regkey_simple(int type, enum roard_client_acclev acclev) {
- struct auth_key * key;
- int i;
-
- for (i = 0; i < AUTH_KEYRING_LEN; i++) {
-  if ( (key = &(g_auth_keyring[i]))->type == _NONE ) {
-   memset(key, 0, sizeof(struct auth_key));
-   key->type   = type;
-   key->acclev = acclev;
-   return &(key->at_data);
-  }
- }
-
- return NULL;
-}
-
-static int _ck_cookie(struct auth_key * key, struct roar_auth_message * authmes) {
- if ( key->at_data.cookie.len == authmes->len ) {
-  if ( memcmp(key->at_data.cookie.cookie, authmes->data, authmes->len) ) {
-   return -1;
-  } else {
-   return 1;
-  }
- }
-
- return -1;
-}
-
-static int _ck_password(struct auth_key * key, struct roar_auth_message * authmes) {
- size_t len = strlen(key->at_data.password.password);
-
- // need to check here if we have a padding \0-byte.
-
- if ( len == authmes->len ) {
-  if ( memcmp(key->at_data.password.password, authmes->data, len) ) {
-   return -1;
-  } else {
-   return 1;
-  }
- }
-
- return -1;
-}
-
-static int _ck_trust(struct auth_key * key, struct roar_auth_message * authmes, struct roar_client_server * cs) {
- struct at_trust * t = &(key->at_data.trust);
- size_t i;
-
- (void)authmes;
-
- // we ship pids at the moment as cs does not contain a verifyed one.
-
- for (i = 0; i < t->uids_len; i++)
-  if ( t->uids[i] == ROAR_CLIENT(cs)->uid )
-   return 1;
-
- for (i = 0; i < t->gids_len; i++)
-  if ( t->gids[i] == ROAR_CLIENT(cs)->gid )
-   return 1;
-
- return -1;
-}
-
-int auth_client_ckeck(struct roar_client_server * cs, struct roar_auth_message * authmes, int * next) {
- struct auth_key * key;
- int i;
- int ret;
-
- if ( cs == NULL || authmes == NULL || next == NULL )
-  return -1;
-
- *next = -1;
-
- for (i = 0; i < AUTH_KEYRING_LEN; i++) {
-  if ( (key = &(g_auth_keyring[i]))->type == authmes->type ) {
-   ROAR_DBG("auth_client_ckeck(cs=%p, authmes=%p, next=%p{%i}): key=%p{.type=%i, ...}", cs, authmes, next, *next, key, key->type);
-   ret = -1;
-   switch (key->type) {
-    case ROAR_AUTH_T_NONE:
-      ret = 1;
-     break;
-    case ROAR_AUTH_T_PASSWORD:
-      ret = _ck_password(key, authmes);
-     break;
-    case ROAR_AUTH_T_COOKIE:
-      ret = _ck_cookie(key, authmes);
-     break;
-    case ROAR_AUTH_T_TRUST:
-      ret = _ck_trust(key, authmes, cs);
-     break;
-    case ROAR_AUTH_T_SYSUSER:
-    case ROAR_AUTH_T_RHOST:
-    default:
-      /* don't know what to do... */
-      return -1;
-     break;
-   }
-   switch (ret) {
-    case -1:
-      /* ignore this case and continue */
-     break;
-    case 0: // fatal auth error (server side auth cancel)
-      return 0;
-     break;
-    case 1:
-      cs->acclev = key->acclev;
-      return 1;
-     break;
-    default: /* error! */
-      return -1;
-     break;
-   }
-  }
- }
-
- // make a better guess:
-/*
- if ( authmes->type == ROAR_AUTH_T_PASSWORD ) {
-  *next = -1;
- } else {
-  *next = ROAR_AUTH_T_PASSWORD;
- }
-*/
-
- return -1;
-}
-
-int auth_addkey_anonymous(enum roard_client_acclev acclev) {
- if ( auth_regkey_simple(ROAR_AUTH_T_NONE, acclev) == NULL )
-  return -1;
- return 0;
-}
-
-int auth_addkey_password(enum roard_client_acclev acclev, const char * password) {
- union auth_typeunion * pw;
-
- if ( (pw = auth_regkey_simple(ROAR_AUTH_T_PASSWORD, acclev)) == NULL )
-  return -1;
-
- pw->password.password = password;
-
- return 0;
-}
-
-int auth_addkey_cookie(enum roard_client_acclev acclev, const void * cookie, const size_t len) {
- union auth_typeunion * key;
-
- if ( (key = auth_regkey_simple(ROAR_AUTH_T_COOKIE, acclev)) == NULL )
-  return -1;
-
- key->cookie.cookie = (void*)cookie;
- key->cookie.len    = len;
-
- return 0;
-}
-
-int auth_addkey_trust(enum roard_client_acclev acclev, ...) {
- union auth_typeunion * key;
- size_t i;
- va_list va;
- pid_t pid = -1;
- uid_t uid = -1;
- gid_t gid = -1;
- int err = 0;
-
- if ( (key = auth_regkey_simple(ROAR_AUTH_T_TRUST, acclev)) == NULL )
-  return -1;
-
- // zerosize all counters.
- memset(key, 0, sizeof(union auth_typeunion));
-
- va_start(va, acclev);
-
- do { // eval block we can leave with continue.
-
-#define _block(var,type,array)  i = 0; \
-                                do { \
-                                 if ( i == AT_TRUST_MAX_ENTRYS ) { err = 1; continue; } \
-                                 var = va_arg(va, type); \
-                                 key->trust.array[i] = var; \
-                                 i++; \
-                                } while (var != -1); \
-                                if ( err ) continue; \
-                                key->trust.array ## _len = i;
-
-
- _block(pid, pid_t, pids);
- _block(uid, uid_t, uids);
- _block(gid, gid_t, gids);
-
-#undef _block
-
- } while(0);
-
- va_end(va);
-
- if ( !err )
-  return 0;
-
- memset(key, 0, sizeof(union auth_typeunion));
-
- return -1;
-}
-
-//ll
Index: roard/beep.c
===================================================================
--- roard/beep.c	(revision 6052)
+++ 	(revision )
@@ -1,198 +1,0 @@
-//beep.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-// TODO: FIXME: can all this VIO stuff be replaced by one call to stream_add_buffer()?
-
-// TODO: FIXME: move them out of here into libroar:
-static ssize_t beep_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_buffer * rbuf;
-
- ROAR_DBG("beep_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- if ( vio->inst == NULL )
-  return 0;
-
- rbuf = vio->inst;
-
- if ( roar_buffer_shift_out(&rbuf, buf, &count) == -1 )
-  return -1;
-
- vio->inst = rbuf;
-
- return count;
-}
-
-static int     beep_close   (struct roar_vio_calls * vio) {
- ROAR_DBG("beep_close(vio=%p) = ?", vio);
-
- if ( vio->inst != NULL )
-  roar_buffer_free(vio->inst);
-
- ROAR_DBG("beep_close(vio=%p) = 0", vio);
- return 0;
-}
-
-static void beep_init_vio (struct roar_vio_calls * vio, void * inst) {
- ROAR_DBG("beep_init_vio(vio=%p, inst=%p) = ?", vio, inst);
-
- memset(vio, 0, sizeof(struct roar_vio_calls));
- vio->flags = ROAR_VIO_FLAGS_NONE;
- vio->refc  = 1;
- vio->inst  = inst;
- vio->read  = beep_read;
- vio->close = beep_close;
-
- ROAR_DBG("beep_init_vio(vio=%p, inst=%p) = (void)", vio, inst);
-}
-
-struct roar_buffer * beep_fill_buffer (struct roar_beep * beep, struct roar_audio_info * info) {
- struct roar_buffer          * buf;
- size_t frames  = beep->time * info->rate     / 1000;
- size_t samples = frames     * info->channels;
- size_t mod     = info->rate / beep->freq;
- char                        * data;
- void                        * bufdata;
- char   val;
- size_t pos;
- size_t chan;
-
- ROAR_DBG("beep_fill_buffer(beep=%p, info=%p) = ?", beep, info);
-
- if ( roar_buffer_new_data(&buf, samples, &bufdata) == -1 ) {
-  ROAR_DBG("beep_fill_buffer(beep=%p, info=%p) = NULL", beep, info);
-  return NULL;
- }
-
- data = (char*)bufdata;
-
- for (pos = 0; pos < frames; pos++) {
-  val = (pos % mod) < mod/2 ? -128 : 127;
-  for (chan = 0; chan < info->channels; chan++)
-   data[pos*info->channels + chan] = val;
- }
-
- ROAR_DBG("beep_fill_buffer(beep=%p, info=%p) = %p", beep, info, buf);
- return buf;
-}
-
-int beep_start (int client, struct roar_beep * beep) {
- struct roar_stream_server *  ss;
- struct roar_stream        *   s;
- struct roar_buffer        * buf;
- int stream;
-
- ROAR_DBG("beep_start(client=%i, beep=%p) = ?", client, beep);
-
- if ( beep->vol  == 0 )
-  beep->vol  = ROAR_BEEP_DEFAULT_VOL;
-
- if ( beep->time == 0 )
-  beep->time = ROAR_BEEP_DEFAULT_TIME;
-
- if ( beep->freq == 0 )
-  beep->freq = ROAR_BEEP_DEFAULT_FREQ;
-
- if ( beep->type == 0 )
-  beep->type = ROAR_BEEP_DEFAULT_TYPE;
-
- // x, y, z location '0' is allready centered.
-
- // TODO: remove the following lions as soon as we support non zero values
- if ( beep->z != 0 )
-  return -1;
-
- if ( beep->y != 0 )
-  return -1;
-
- ROAR_DBG("beep_start(client=%i, beep=%p) = ?", client, beep);
-
- if ((stream = streams_new()) == -1 )
-  return -1;
-
- ROAR_DBG("beep_start(client=%i, beep=%p): stream=%i", client, beep, stream);
-
- if ( client_stream_add(client, stream) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- if ( streams_set_name(stream, "Beep Source") == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- if ( streams_get(stream, &ss) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(s->info));
-
- s->info.channels = 2;
- s->info.bits     = 8;
-
- ss->mixer.mixer[0] = beep->x > 0 ?
-                        ((long)beep->vol * ((long)ROAR_BEEP_MAX_POS - (long)beep->x)/(long)ROAR_BEEP_MAX_POS) :
-                        beep->vol;
- ss->mixer.mixer[1] = beep->x < 0 ?
-                        ((long)beep->vol * ((long)ROAR_BEEP_MAX_POS + (long)beep->x)/(long)ROAR_BEEP_MAX_POS) :
-                        beep->vol;
- ss->mixer.scale    = ROAR_BEEP_MAX_VOL;
-
- ROAR_DBG("beep_start(client=%i, beep=%p): beep->x=%i, ss->mixer.mixer[] = {%u, %u}", client, beep, beep->x, ss->mixer.mixer[0], ss->mixer.mixer[1]);
-
- if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- if ( streams_set_role(stream, ROAR_ROLE_BEEP) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- if ( (buf = beep_fill_buffer(beep, &(s->info))) == NULL ) {
-  streams_delete(stream);
-  return -1;
- }
-
- ROAR_DBG("beep_start(client=%i, beep=%p): buf=%p", client, beep, buf);
-
- beep_init_vio(&(ss->vio), buf);
-
- if ( streams_set_fh(stream, -2) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- ROAR_DBG("beep_start(client=%i, beep=%p) = %i", client, beep, stream);
- return stream;
-}
-
-//ll
Index: roard/caps.c
===================================================================
--- roard/caps.c	(revision 6052)
+++ 	(revision )
@@ -1,90 +1,0 @@
-//caps.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-static uint32_t _g_caps_standards[] = {
- // message formats:
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO,  0, 0), // v. 0
-
- // command sets:
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO,  4, 0), // basic commands
-
- // well known numbers:
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO, 12, 0), // codecs
-
- // transports:
-#ifdef ROAR_HAVE_UNIX
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO, 23, 0), // UNIX
-#endif
-#ifdef ROAR_HAVE_LIBDNET
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO, 24, 0), // DECnet
-#endif
-#ifdef ROAR_HAVE_IPV4
- ROAR_STD_MAKE(ROAR_STDV_ROARAUDIO, 25, 0), // TCP
-#endif
-
- 0xFFFFFFFF // terminater
-};
-
-struct roar_stds g_caps_stds = {
- .stds_len = (sizeof(_g_caps_standards)/sizeof(*_g_caps_standards)) - 1,
- .stds     = _g_caps_standards
-};
-
-char * stds_string (void) {
- size_t len = g_caps_stds.stds_len * 14;
- char * ret = roar_mm_malloc(len);
- size_t off = 0;
- size_t i;
- int snpret;
- uint32_t cap;
- int version;
-
- if ( ret == NULL )
-  return NULL;
-
- for (i = 0; i < g_caps_stds.stds_len; i++) {
-  cap = g_caps_stds.stds[i];
-  version = ROAR_STD_VERSION(cap);
-  if ( version == 0 ) {
-   snpret = snprintf(ret+off, len-off, "%i-%i,", (int)ROAR_STD_VENDOR(cap), (int)ROAR_STD_STD(cap));
-  } else {
-   snpret = snprintf(ret+off, len-off, "%i-%i-%i,", (int)ROAR_STD_VENDOR(cap), (int)ROAR_STD_STD(cap), (int)version);
-  }
-  if ( snpret > 0 ) {
-   off += snpret;
-  } else {
-   roar_mm_free(ret);
-   return NULL;
-  }
- }
-
- ret[off-1] = 0;
-
- return ret;
-}
-
-//ll
Index: roard/clients.c
===================================================================
--- roard/clients.c	(revision 6052)
+++ roard/clients.c	(revision 0)
@@ -1,44 +1,5 @@
 //clients.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-/* ckport options:
- * ckport: ignore-symbol: roar_event_to_blob of target libroar0
- */
-
 #include "roard.h"
-
-// declared 'extern'
-struct roar_client_server * g_clients[ROAR_CLIENTS_MAX];
-
-static struct roard_proto_handle __protos[MAX_PROTOS] = {
- {.proto = ROAR_PROTO_ROARAUDIO, .lhandle = NULL, .type = ROARD_PROTO_TYPE_BUILDIN,
- .impl = {.buildin = 0}},
- {.proto = -1}
-};
-
-#define _CHECK_CID_RET(id,ret) if ( (id) < 0 || (id) > ROAR_CLIENTS_MAX || g_clients[(id)] == NULL ) return (ret)
-#define _CHECK_CID(id)         _CHECK_CID_RET((id), -1)
 
 int clients_init (void) {
@@ -48,9 +9,4 @@
   g_clients[i] = NULL;
 
- for (i = 0; __protos[i].proto != -1; i++);
-
- for (; i < MAX_PROTOS; i++)
-  __protos[i].proto = -1;
-
  return 0;
 }
@@ -60,5 +16,5 @@
 
  for (i = 0; i < ROAR_CLIENTS_MAX; i++)
-  if ( g_clients[i] != NULL )
+  if ( g_clients[i] )
    clients_delete(i);
 
@@ -69,26 +25,15 @@
  int i;
  int s;
- struct roar_client_server * ns;
  struct roar_client * n;
 
  for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
   if ( g_clients[i] == NULL ) {
-   ns = roar_mm_malloc(sizeof(struct roar_client_server));
-   n = ROAR_CLIENT(ns);
-
-   memset(ns, 0, sizeof(struct roar_client_server));
-
+   n = malloc(sizeof(struct roar_client));
    if ( n != NULL ) {
     n->pid    = -1;
-    n->uid    = -1;
-    n->gid    = -1;
     n->fh     = -1;
 
     *n->name = 0;
-
-    n->proto     = ROAR_PROTO_ROARAUDIO;
-    n->byteorder = ROAR_BYTEORDER_NETWORK;
-
-    n->acl   = NULL;
+    *n->host = 0;
 
     n->execed = -1;
@@ -96,17 +41,6 @@
      n->streams[s] = -1;
 
-    if ( roar_nnode_new(&(n->nnode), ROAR_SOCKET_TYPE_UNKNOWN) == -1 ) {
-     roar_mm_free(n);
-     return -1;
-    }
-
-    ns->blockc   = 0;
-    ns->waits    = NULL;
-    ns->acclev   = ACCLEV_NONE;
-
-    g_clients[i] = ns;
-
-    counters_inc(clients, 1);
-    roar_notify_core_emit_snoargs(ROAR_OE_BASICS_NEW, -1, i, ROAR_OT_CLIENT);
+    g_clients[i] = n;
+
     ROAR_DBG("clients_new(void) = %i", i);
     return i;
@@ -122,226 +56,23 @@
 }
 
-int clients_new_from_fh(int fh, int proto, int byteorder, int update_nnode) {
- return clients_new_from_fh2(fh, proto, byteorder, update_nnode, NULL, NULL, 0);
-}
-
-int clients_new_from_fh2(int fh, int proto, int byteorder,
-                         int update_nnode,
-                         struct roard_listen * lsock, struct sockaddr * sockaddr, socklen_t addrlen) {
- const struct roard_proto_handle * protohandle;
- struct roar_dl_librarypara * pluginpara;
- struct roar_vio_calls    vio;
- struct roar_client_server * cs;
- int supported = 0;
- int client;
-
- if ( fh == -1 ) {
-  roar_err_set(ROAR_ERROR_BADFH);
-  return -1;
- }
-
- if ( lsock == NULL ) {
-  switch (proto) {
-   case ROAR_PROTO_RSOUND:
-   case ROAR_PROTO_SIMPLE:
-     roar_err_set(ROAR_ERROR_FAULT);
-     return -1;
-    break;
-  }
- }
-
- if ( byteorder != ROAR_BYTEORDER_NETWORK )
-  return -1;
-
-
- if ( proto == ROAR_PROTO_RSOUND ) {
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-  client = emul_rsound_on_connect(fh, lsock);
-  switch (client) {
-   case -1: return -1; break;
-   case -2: return  0; break;
-   default: // TODO: write error handling
-     if ( clients_get_server(client, &cs) == -1 ) {
-      clients_delete(client);
-      return -1;
-     }
-
-     fh = ROAR_CLIENT(cs)->fh;
-    break;
-  }
-#else
-  roar_err_set(ROAR_ERROR_PROTONOSUP);
-  return -1;
-#endif
- } else {
-  client = clients_new();
-
-  if ( client == -1 ) {
-   ROAR_DBG("clients_new_from_fh2(*) = -1 // can not create new client");
-   return -1;
-  }
-
-  if ( clients_set_fh(client, fh) == -1 ) {
-   ROAR_ERR("clients_new_from_fh2(*): Can not set client's fh");
-
-   clients_delete(client);
-
-   ROAR_DBG("clients_new_from_fh2(*) = -1");
-   return -1;
-  }
- }
-
- if ( clients_get_server(client, &cs) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- if ( update_nnode ) {
-  if ( roar_nnode_free(&(ROAR_CLIENT(cs)->nnode)) != -1 ) {
-   if ( sockaddr != NULL && addrlen != 0 ) {
-    roar_nnode_new_from_sockaddr(&(ROAR_CLIENT(cs)->nnode), sockaddr, addrlen);
-   } else {
-    roar_nnode_new_from_fh(&(ROAR_CLIENT(cs)->nnode), fh, 1);
-   }
-  }
- }
-
- if ( clients_set_proto(client, proto) == -1 ) {
-  ROAR_WARN("clients_new_from_fh2(*): Setting proto(0x%.4x) of client %i failed.", proto, client);
-  clients_delete(client);
-  return -1;
- }
-
- switch (proto) {
-  case ROAR_PROTO_ROARAUDIO:
-    // nothing needed to be done here
-   break;
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-  case ROAR_PROTO_SIMPLE:
-    if ( emul_simple_on_connect(client, lsock) == -1 )
-     return -1;
-   break;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-  case ROAR_PROTO_RSOUND: // nothing to do here.
-   break;
-#endif
-  default:
-    // OS independiend code to close the socket:
-    if ( roar_vio_open_fh_socket(&vio, fh) == -1 )
-     return -1;
-
-    protohandle = clients_get_protohandle(proto);
-    supported = 0;
-    if ( protohandle != NULL ) {
-     if ( protohandle->lhandle != NULL )
-      roar_dl_context_restore(protohandle->lhandle);
-     switch (protohandle->type) {
-      case ROARD_PROTO_TYPE_BUILDIN:
-        //this should not end up here.
-        ROAR_WARN("net_get_new_client(lsock=%p): proto(%i) marked as buildin but isn't. BAD.", lsock, proto);
-        supported = 0;
-       break;
-      case ROARD_PROTO_TYPE_COMMON:
-        supported = 1;
-        if ( protohandle->impl.common->set_proto != NULL ) {
-         pluginpara = roar_dl_getpara(protohandle->lhandle); // will return NULL in case protohandle->lhandle is NULL.
-         if ( protohandle->impl.common->set_proto(client, &vio, &(cs->outbuf), &(cs->protoinst), protohandle->para, protohandle->paralen, pluginpara) == -1 ) {
-          supported = 0;
-         }
-         if ( pluginpara != NULL )
-          roar_dl_para_unref(pluginpara);
-        }
-       break;
-     }
-     if ( protohandle->lhandle != NULL )
-      roar_dl_context_store(protohandle->lhandle);
-    }
-
-    if ( !supported ) {
-     clients_delete(client);
-     //roar_vio_close(&vio);
-     return -1;
-    }
-   break;
- }
-
-
- return 0;
-}
-
 int clients_delete (int id) {
- struct roar_client_server * cs;
- const struct roard_proto_handle * proto;
- struct roar_dl_librarypara * pluginpara;
- struct roar_vio_calls vio;
- int i;
- int close_client_fh = 1;
-
- ROAR_DBG("clients_delete(id=%i) = ?", id);
-
- _CHECK_CID(id);
-
- cs = g_clients[id];
-
- proto = clients_get_protohandle(ROAR_CLIENT(cs)->proto);
- if ( proto != NULL ) {
-  if ( proto->lhandle != NULL )
-   roar_dl_context_restore(proto->lhandle);
-  switch (proto->type) {
-   case ROARD_PROTO_TYPE_BUILDIN:
-     /* noop */
-    break;
-   case ROARD_PROTO_TYPE_COMMON:
-     if ( proto->impl.common->unset_proto != NULL ) {
-      roar_vio_open_fh_socket(&vio, clients_get_fh(id));
-      pluginpara = roar_dl_getpara(proto->lhandle); // will return NULL in case protohandle->lhandle is NULL.
-      proto->impl.common->unset_proto(id, &vio, &(cs->outbuf), &(cs->protoinst), proto->para, proto->paralen, pluginpara);
-      if ( pluginpara != NULL )
-       roar_dl_para_unref(pluginpara);
-     }
-    break;
-  }
-  if ( proto->lhandle != NULL )
-   roar_dl_context_store(proto->lhandle);
- }
-
- if ( cs->waits != NULL ) {
-  for (i = 0; cs->waits[i] != NULL; i++)
-   roar_notify_core_unsubscribe(NULL, cs->waits[i]);
-
-  roar_mm_free(cs->waits);
-  cs->waits = NULL;
- }
-
- roar_notify_core_emit_snoargs(ROAR_OE_BASICS_DELETE, -1, id, ROAR_OT_CLIENT);
-
- counters_inc(clients, -1);
-
- if (ROAR_CLIENT(cs)->execed != -1) {
+ int i;
+
+ if ( g_clients[id] == NULL )
+  return -1;
+
+ if (g_clients[id]->execed != -1) {
 //  return streams_delete(g_clients[id]->execed);
-  ROAR_CLIENT(cs)->execed = -1;
-  close_client_fh = 0;
+  g_clients[id]->execed = -1;
  }
 
  for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
-  streams_delete(ROAR_CLIENT(cs)->streams[i]);
- }
-
- if ( ROAR_CLIENT(cs)->fh != -1 && close_client_fh )
-  close(ROAR_CLIENT(cs)->fh);
-
- roar_nnode_free(&(ROAR_CLIENT(cs)->nnode));
-
- if ( cs->inbuf != NULL )
-  roar_buffer_free(cs->inbuf);
-
- if ( cs->outbuf != NULL )
-  roar_buffer_free(cs->outbuf);
-
- if ( cs->protoinst != NULL )
-  roar_mm_free(cs->protoinst);
-
- roar_mm_free(cs);
+  streams_delete(g_clients[id]->streams[i]);
+ }
+
+ if ( g_clients[id]->fh != -1 )
+  close(g_clients[id]->fh);
+
+ free(g_clients[id]);
  g_clients[id] = NULL;
 
@@ -350,31 +81,6 @@
 }
 
-int clients_close      (int id, int nocheck_exec) {
- struct roar_client * c;
-
- ROAR_DBG("clients_close(id=%i) = ?", id);
-
- _CHECK_CID(id);
-
- c = ROAR_CLIENT(g_clients[id]);
-
- if ( c->fh == -1 ) {
-  ROAR_DBG("clients_delete(id=%i) = 0", id);
-  return 0;
- }
-
- if (nocheck_exec || c->execed != -1) {
-  close(c->fh);
-  c->fh = -1;
- }
-
- ROAR_DBG("clients_delete(id=%i) = 0", id);
- return 0;
-}
-
 int clients_get       (int id, struct roar_client ** client) {
- _CHECK_CID(id);
-
- *client = ROAR_CLIENT(g_clients[id]);
+ *client = g_clients[id];
 
  if ( *client == NULL )
@@ -384,146 +90,31 @@
 }
 
-int clients_get_server (int id, struct roar_client_server ** client) {
- _CHECK_CID(id);
-
- *client = g_clients[id];
-
- if ( *client == NULL )
-  return -1;
-
- return 0;
-}
-
 int clients_set_fh    (int id, int    fh) {
- struct roar_client * c;
-#if defined(SO_PEERCRED) && !defined(ROAR_BROKEN_PEERCRED)
- struct ucred cred;
- socklen_t cred_len = sizeof(cred);
-#endif
-
- _CHECK_CID(id);
-
- if ( (c = ROAR_CLIENT(g_clients[id])) == NULL )
-  return -1;
-
- c->fh = fh;
-
- if ( fh == -1 )
-  return 0;
-
-#if defined(SO_PEERCRED) && !defined(ROAR_BROKEN_PEERCRED)
- if (getsockopt(fh, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len) != -1) {
-  if ( cred.pid != 0 ) {
-   c->pid = cred.pid;
-   c->uid = cred.uid;
-   c->gid = cred.gid;
-  }
- } else {
-  ROAR_DBG("req_on_identify(): Can't get creds via SO_PEERCRED: %s", strerror(errno));
- }
-#elif defined(ROAR_HAVE_GETPEEREID)
- if (getpeereid(fh, &(c->uid), &(c->gid)) == -1) {
-  ROAR_DBG("req_on_identify(): Can't get creds via getpeereid(): %s", strerror(errno));
- }
-#endif
-
- return 0;
-}
-
-int clients_get_fh    (int id) {
- _CHECK_CID(id);
-
- return ROAR_CLIENT(g_clients[id])->fh;
+ if ( g_clients[id] == NULL )
+  return -1;
+
+ g_clients[id]->fh = fh;
+
+ return 0;
 }
 
 int clients_set_pid   (int id, int    pid) {
- _CHECK_CID(id);
-
- ROAR_CLIENT(g_clients[id])->pid = pid;
-
- return 0;
-}
-
-int clients_set_uid   (int id, int    uid) {
- _CHECK_CID(id);
-
- ROAR_CLIENT(g_clients[id])->uid = uid;
-
- return 0;
-}
-
-int clients_set_gid   (int id, int    gid) {
- _CHECK_CID(id);
-
- ROAR_CLIENT(g_clients[id])->gid = gid;
-
- return 0;
-}
-
-int clients_set_name   (int id, const char * name) {
- _CHECK_CID(id);
-
- strncpy(ROAR_CLIENT(g_clients[id])->name, name, ROAR_BUFFER_NAME-1);
- ROAR_CLIENT(g_clients[id])->name[ROAR_BUFFER_NAME-1] = 0;
-
- return 0;
-}
-
-int clients_set_proto (int id, int    proto) {
- int byteorder = ROAR_BYTEORDER_UNKNOWN;
-
- _CHECK_CID(id);
-
- switch (proto) {
-  case ROAR_PROTO_ROARAUDIO:
-  case ROAR_PROTO_ESOUND:
-  case ROAR_PROTO_RPLAY:
-  case ROAR_PROTO_SIMPLE:
-    byteorder = ROAR_BYTEORDER_NETWORK;
-   break;
- }
-
- ROAR_CLIENT(g_clients[id])->proto     = proto;
- ROAR_CLIENT(g_clients[id])->byteorder = byteorder;
-
- return 0;
-}
-
-int clients_block      (int id, int unblock) {
- _CHECK_CID(id);
-
- if ( unblock ) {
-  g_clients[id]->blockc--;
- } else {
-  g_clients[id]->blockc++;
- }
-
- return 0;
-}
-
-
-#define MAX_STREAMLESS 8
+ if ( g_clients[id] == NULL )
+  return -1;
+
+ g_clients[id]->pid = pid;
+
+ return 0;
+}
 
 int clients_check_all (void) {
-#ifdef ROAR_HAVE_SELECT
- struct roar_client * c;
  struct timeval tv;
- fd_set r, w, e;
- int i, j;
+ fd_set r, e;
+ int i;
  int ret;
  int fh;
  int max_fh = -1;
- int have = 0;
- struct {
-  int id;
-  int fh;
- } streamless[MAX_STREAMLESS];
- int have_streamless = 0;
- int have_stream;
-
- ROAR_DBG("clients_check_all(void) = ?");
 
  FD_ZERO(&r);
- FD_ZERO(&w);
  FD_ZERO(&e);
 
@@ -532,403 +123,91 @@
 
  for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
-  if ( (c = ROAR_CLIENT(g_clients[i])) == NULL )
-   continue;
-
-  ROAR_DBG("clients_check_all(void): i(client)=%i", i);
-
-  if ( (fh = c->fh) != -1 ) {
-   have++;
-
-   ROAR_DBG("clients_check_all(*): fh=%i", fh);
-
-   FD_SET(fh, &r);
-   FD_SET(fh, &e);
-
-   if ( g_clients[i]->outbuf != NULL ) {
-    FD_SET(fh, &w);
+  if ( g_clients[i] == NULL )
+   continue;
+
+  if ( (fh = g_clients[i]->fh) == -1 )
+   continue;
+
+  FD_SET(fh, &r);
+  FD_SET(fh, &e);
+
+  if ( fh > max_fh )
+   max_fh = fh;
+ }
+
+ if ( (ret = select(max_fh + 1, &r, NULL, &e, &tv)) < 1 ) {
+  return ret;
+ }
+
+ for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
+  if ( g_clients[i] == NULL )
+   continue;
+
+  if ( (fh = g_clients[i]->fh) == -1 )
+   continue;
+
+  if ( FD_ISSET(fh, &r) ) {
+   if ( g_clients[i]->execed == -1 ) {
+    clients_check(i);
+   } else {
+    streams_check(g_clients[i]->execed);
    }
-
-   if ( fh > max_fh )
-    max_fh = fh;
-  }
-
-  have_stream = 0;
-
-  for (j = 0; j < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; j++) {
-   ROAR_DBG("clients_check_all(void): i(client)=%i, j(stream)=%i", i, j);
-   if ( (fh = streams_get_fh(c->streams[j])) != -1 ) {
-    ROAR_DBG("clients_check_all(*): g_clients[i=%i]->streams[j=%i] = %i, fh = %i", i, j, c->streams[j], fh);
-    if ( fh > -1 ) {
-     FD_SET(fh, &r);
-
-     if ( fh > max_fh )
-      max_fh = fh;
-    } else if ( fh == -2 ) {
-     streams_check(c->streams[j]);
-    }
-
-    have_stream = 1;
-   }
-   //printf("D: client=%i, stream=%i, fh=%i\n", i, j, fh);
-  }
-
-  if ( !have_stream && have_streamless < MAX_STREAMLESS ) {
-   streamless[have_streamless  ].id = i;
-   if ( (streamless[have_streamless++].fh = c->fh) == -1 )
-    have_streamless--;
-  }
- }
-
- ROAR_DBG("clients_check_all(void): max_fh=%i", max_fh);
-
- if ( max_fh == -1 )
-  return 0;
-
- if ( (ret = select(max_fh + 1, &r, &w, &e, &tv)) < 1 ) {
-  return ret < 0 ? ret : have;
- }
-
- for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
-  if ( (c = ROAR_CLIENT(g_clients[i])) == NULL )
-   continue;
-
-  if ( (fh = c->fh) != -1 ) {
-   if ( FD_ISSET(fh, &r) ) {
-    if ( c->execed == -1 ) {
-     clients_check(i);
-     if ( g_clients[i] != NULL && ROAR_CLIENT(g_clients[i])->execed != -1 ) {
-      FD_CLR(fh, &r);
-     }
-/*
-    } else {
-     streams_check(g_clients[i]->execed);
-*/
-    }
-   }
-   if ( FD_ISSET(fh, &w) ) {
-    clients_flush(i);
-   }
-
-   if ( FD_ISSET(fh, &e) ) {
-    clients_delete(i);
-    continue;
-   }
-  }
-
-  if ( (c = ROAR_CLIENT(g_clients[i])) == NULL )
-   continue;
-
-  for (j = 0; j < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; j++) {
-   ROAR_DBG("clients_check_all(*): D: client=%i, stream=%i, g_clients[i=%i] = %p", i, j, i, g_clients[i]);
-   if ( g_clients[i] == NULL ) // streams_check() bellow can delete our client (why?)
-    break;
-
-   //ROAR_WARN("clients_check_all(*): client=%i: client exists", i);
-   ROAR_DBG("clients_check_all(*): client=%i, stream=%i: id=%i", i, j, c->streams[j]);
-
-   if ( (fh = streams_get_fh(c->streams[j])) != -1 ) {
-    ROAR_DBG("clients_check_all(*): client=%i, stream=%i: fh=%i", i, j, fh);
-    if ( fh > -1 && FD_ISSET(fh, &r) ) {
-     streams_check(c->streams[j]);
-    }
-   }
-  }
- }
-
- if ( have_streamless ) {
-   FD_ZERO(&r);
-   FD_ZERO(&w);
-
-   tv.tv_sec  = 0;
-   tv.tv_usec = 1;
-
-   max_fh = -1;
-
-   for (i = 0; i < have_streamless; i++) {
-    if ( g_clients[j = streamless[i].id] == NULL )
-     continue;
-
-    if ( ROAR_CLIENT(g_clients[j])->execed != -1 )
-     continue;
-
-    fh = streamless[i].fh;
-
-    ROAR_DBG("clients_check_all(void): fh=%i", fh);
-    FD_SET(fh, &r);
-
-    if ( g_clients[j]->outbuf != NULL ) {
-     FD_SET(fh, &w);
-    }
-
-    if ( fh > max_fh )
-     max_fh = fh;
-   }
-
-   if ( (ret = select(max_fh + 1, &r, &w, NULL, &tv)) < 0 ) {
-    return ret;
-   }
-
-   for (i = 0; i < have_streamless; i++) {
-    if ( FD_ISSET(streamless[i].fh, &r) ) {
-     clients_check(streamless[i].id);
-    }
-    if ( FD_ISSET(streamless[i].fh, &w) ) {
-     clients_flush(streamless[i].id);
-    }
-   }
- }
-
- ROAR_DBG("clients_check_all(void) = %i // have value", have);
- return have;
-#else
- ROAR_DBG("clients_check_all(void) = -1");
- return -1;
-#endif
+  }
+
+  if ( FD_ISSET(fh, &e) )
+   clients_delete(i);
+ }
+
+ return 0;
 }
 
 int clients_check     (int id) {
- struct roar_client_server * cs;
  struct roar_message    m;
  struct roar_connection con;
- struct roar_vio_calls  vio;
- struct roar_error_state errstate;
- const struct roard_proto_handle * proto;
- struct roar_dl_librarypara * pluginpara;
- int command_error;
  char * data = NULL;
  int oldcmd;
  int r;
- int rv = 0;
- uint32_t flags[2] = {COMMAND_FLAG_NONE, COMMAND_FLAG_NONE};
- uint32_t event;
-
- ROAR_DBG("clients_check(id=%i) = ?", id);
-
- _CHECK_CID(id);
-
- cs = g_clients[id];
-
- if ( ROAR_CLIENT(cs)->fh == -1 )
-  return -1;
-
- if ( roar_connect_fh(&con, ROAR_CLIENT(cs)->fh) == -1 ) {
-  ROAR_WARN("clients_check(id=%i): Can not create con object for client: %s", id, roar_errorstring);
- }
-
- ROAR_DBG("clients_check(id=%i): c->proto=%i", id, ROAR_CLIENT(cs)->proto);
-
- switch (ROAR_CLIENT(cs)->proto) {
-  case ROAR_PROTO_ROARAUDIO:
-    r = roar_recv_message(&con, &m, &data);
-
-    if ( r == -1 ) { // should we drop the client?
-     clients_delete(id);
-     return -1;
-    }
-
-    event = ROAR_NOTIFY_CMD2EVENT(m.cmd);
-
-    oldcmd = m.cmd;
-
-    roar_err_store(&errstate);
-    roar_err_clear_all();
-    r = command_exec(id, &m, &data, flags);
-    roar_err_update();
-    command_error = roar_error;
-    roar_err_restore(&errstate);
-
-    if ( r == -1 ) {
-     // use command_error to create an error frame here as soon as this is supported.
-     m.cmd     = ROAR_CMD_ERROR;
-     m.datalen = 0;
-     ROAR_DBG("clients_check(*): Exec of command faild!");
-    } else {
-     if ( m.cmd == oldcmd ) {
-      m.cmd     = ROAR_CMD_OK;
-      m.datalen = 0;
-     } else if ( m.cmd == ROAR_CMD_OK_STOP ) {
-      m.cmd     = ROAR_CMD_OK;
-      rv        = 1;
-     }
-    }
-    ROAR_DBG("clients_check(*): data=%p", data);
-
-    if ( flags[1] & COMMAND_FLAG_OUT_NOSEND ) {
-     roar_notify_core_emit_simple(event, id, -1, -1, -1, -1, NULL, 0);
-    } else {
-     roar_notify_core_emit_simple(event, id, -1, -1, m.cmd, -1, NULL, 0);
-     if ( roar_send_message(&con, &m, flags[1] & COMMAND_FLAG_OUT_LONGDATA ? data : NULL) == -1 ) {
-      ROAR_WARN("clients_check(id=%i): Can not send answer to client: %s", id, roar_errorstring);
-     }
-    }
-
-    if ( flags[1] & COMMAND_FLAG_OUT_CLOSECON )
-     clients_close(id, 1);
-
-    if ( flags[1] & COMMAND_FLAG_OUT_DELETE )
-     clients_delete(id);
-
-   break;
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-  case ROAR_PROTO_RSOUND:
-    rv = emul_rsound_check_client(id, NULL);
-    if ( rv == 0 ) { // loop as long as we don't get an error.
-     while (rv == 0)
-      rv = emul_rsound_check_client(id, NULL);
-     rv = 0; // restore
-    } else { // in case of error delete the client
-     if (
-#ifdef EAGAIN
-          errno != EAGAIN      &&
-#endif
-#ifdef EWOULDBLOCK
-          errno != EWOULDBLOCK &&
-#endif
-#ifdef EINTR
-          errno != EINTR       &&
-#endif
-          1 ) {
-      rv = clients_delete(id);
-     } else {
-      rv = 0;
-     }
-    }
-   break;
-#endif
-  default:
-    rv = -1;
-    proto = clients_get_protohandle(ROAR_CLIENT(cs)->proto);
-    if ( proto != NULL ) {
-     roar_vio_open_fh_socket(&vio, clients_get_fh(id));
-     if ( proto->lhandle != NULL )
-      roar_dl_context_restore(proto->lhandle);
-
-     switch (proto->type) {
-      case ROARD_PROTO_TYPE_BUILDIN:
-        ROAR_WARN("clients_check(id=%i): proto(%i) marked as buildin but isn't. BAD.", id, proto->proto);
-       break;
-      case ROARD_PROTO_TYPE_COMMON:
-        if ( proto->impl.common->handle != NULL ) {
-         pluginpara = roar_dl_getpara(proto->lhandle); // will return NULL in case protohandle->lhandle is NULL.
-         rv = proto->impl.common->handle(id, &vio, &(cs->outbuf), &(cs->protoinst), proto->para, proto->paralen, pluginpara);
-         if ( pluginpara != NULL )
-          roar_dl_para_unref(pluginpara);
-        }
-        if ( rv == -1 )
-         rv = clients_delete(id);
-       break;
-     }
-
-     if ( proto->lhandle != NULL )
-      roar_dl_context_store(proto->lhandle);
-    }
- }
-
- if ( data != NULL )
-  roar_mm_free(data);
-
- ROAR_DBG("clients_check(id=%i) = %i", id, rv);
- return rv;
-}
-
-int clients_flush      (int id) {
- struct roar_vio_calls             vio;
- struct roar_client_server       * cs;
- struct roar_client              * c;
- const struct roard_proto_handle * p;
- struct roar_dl_librarypara * pluginpara;
- size_t len;
- ssize_t ret;
- void * buf;
- int rv;
-
- _CHECK_CID(id);
-
- c = ROAR_CLIENT(cs = g_clients[id]);
-
- p = clients_get_protohandle(c->proto);
-
- if ( p == NULL )
-  return -1;
-
- roar_vio_open_fh_socket(&vio, clients_get_fh(id));
-
- switch (p->type) {
-  case ROARD_PROTO_TYPE_BUILDIN:
-    /* noop */
-   break;
-  case ROARD_PROTO_TYPE_COMMON:
-    if ( p->impl.common->flush != NULL ) {
-     if ( p->lhandle != NULL )
-      roar_dl_context_restore(p->lhandle);
-     pluginpara = roar_dl_getpara(p->lhandle); // will return NULL in case protohandle->lhandle is NULL.
-     rv = p->impl.common->flush(id, &vio, &(cs->outbuf), &(cs->protoinst), p->para, p->paralen, pluginpara);
-     if ( p->lhandle != NULL )
-      roar_dl_context_store(p->lhandle);
-     if ( pluginpara != NULL )
-      roar_dl_para_unref(pluginpara);
-     if ( rv == -1 )
-      rv = clients_delete(id);
-     return rv;
-    }
-   break;
- }
-
- if ( roar_buffer_get_len(cs->outbuf, &len) == -1 )
-  return -1;
-
- if ( roar_buffer_get_data(cs->outbuf, &buf) == -1 )
-  return -1;
-
- ret = roar_vio_write(&vio, buf, len);
-
- if ( ret < 1 && !(len == 0 && ret == 0) ) {
+
+ if ( g_clients[id] == NULL )
+  return -1;
+ if ( g_clients[id]->fh == -1 )
+  return -1;
+
+ con.fh = g_clients[id]->fh;
+
+ r = roar_recv_message(&con, &m, &data);
+
+ if ( r == -1 ) { // should we drop the client?
   clients_delete(id);
   return -1;
  }
 
- if ( ret == (ssize_t)len ) {
-  if ( roar_buffer_next(&(cs->outbuf)) == -1 ) {
-   clients_delete(id);
-   return -1;
-  }
+ roar_debug_message_print(&m);
+
+ oldcmd = m.cmd;
+
+ if ( (r = command_exec(id, &m, data)) == -1 ) {
+  m.cmd     = ROAR_CMD_ERROR;
+  m.datalen = 0;
+  ROAR_DBG("clients_check(*): Exec of command faild!");
  } else {
-  if ( roar_buffer_set_offset(cs->outbuf, ret) == -1 ) {
-   clients_delete(id);
-   return -1;
-  }
- }
-
- if ( cs->outbuf == NULL ) {
-  switch (p->type) {
-   case ROARD_PROTO_TYPE_BUILDIN:
-     /* noop */
-    break;
-   case ROARD_PROTO_TYPE_COMMON:
-     if ( p->impl.common->flushed != NULL ) {
-      if ( p->lhandle != NULL )
-       roar_dl_context_restore(p->lhandle);
-      pluginpara = roar_dl_getpara(p->lhandle); // will return NULL in case protohandle->lhandle is NULL.
-      rv = p->impl.common->flushed(id, &vio, &(cs->outbuf), &(cs->protoinst), p->para, p->paralen, pluginpara);
-      if ( p->lhandle != NULL )
-       roar_dl_context_store(p->lhandle);
-      if ( pluginpara != NULL )
-       roar_dl_para_unref(pluginpara);
-      if ( rv == -1 )
-       rv = clients_delete(id);
-      return rv;
-     }
-    break;
-  }
- }
-
- return 0;
-}
-
-int clients_send_mon  (struct roar_audio_info * sa) {
- int i;
-// int fh;
- int j;
- int keep_going;
+  if ( m.cmd == oldcmd ) {
+   m.cmd     = ROAR_CMD_OK;
+   m.datalen = 0;
+  }
+ }
+
+ roar_send_message(&con, &m, NULL);
+
+ if ( data )
+  free(data);
+
+ ROAR_DBG("clients_check(id=%i) = 0", id);
+ return 0;
+}
+
+int clients_send_mon  (struct roar_audio_info * sa, uint32_t pos) {
+ int i;
+ int fh;
 
  for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
@@ -936,30 +215,9 @@
    continue;
 
-  keep_going = 1;
-
-/*
   if ( (fh = g_clients[i]->fh) == -1 )
    continue;
-*/
-
-  ROAR_DBG("clients_send_mon(*): client=%i, execed=%i", i, ROAR_CLIENT(g_clients[i])->execed);
-
-/*
+
   if ( g_clients[i]->execed == -1 ) {
    // TODO: add some code to send a message to the client insetd of the raw data.
-*/
-   for (j = 0; keep_going && j < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; j++) {
-    //if ( (fh = streams_get_fh(g_clients[i]->streams[j])) != -1 ) {
-    ROAR_DBG("clients_send_mon(*): client=%i, stream=%i -> ?", i, j);
-    if ( ROAR_CLIENT(g_clients[i])->streams[j] != -1 ) {
-     ROAR_DBG("clients_send_mon(*): client=%i, stream=%i -> %i", i, j, ROAR_CLIENT(g_clients[i])->streams[j]);
-     streams_send_mon(ROAR_CLIENT(g_clients[i])->streams[j]);
-
-     // the client may be deleted here, check if it still exists:
-     if ( g_clients[i] == NULL )
-      keep_going = 0;
-    }
-   }
-/*
   } else {
 //   streams_check(g_clients[i]->execed);
@@ -968,28 +226,25 @@
 //    clients_delete(i); // delete client in case we could not write
   } 
-*/
- }
-
- // TODO: FIXME: should this really be -1?
- return -1;
-}
-
-int clients_send_filter(struct roar_audio_info * sa) {
- struct roar_client * c;
+ }
+
+ return -1;
+}
+
+int clients_send_filter(struct roar_audio_info * sa, uint32_t pos) {
  int i;
  int fh;
 
  for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
-  if ( (c = ROAR_CLIENT(g_clients[i])) == NULL )
-   continue;
-
-  if ( (fh = c->fh) == -1 )
-   continue;
-
-  if ( c->execed == -1 ) {
+  if ( g_clients[i] == NULL )
+   continue;
+
+  if ( (fh = g_clients[i]->fh) == -1 )
+   continue;
+
+  if ( g_clients[i]->execed == -1 ) {
    // TODO: add some code to send a message to the client insetd of the raw data.
   } else {
 //   streams_check(g_clients[i]->execed);
-   streams_send_filter(c->execed);
+   streams_send_filter(g_clients[i]->execed);
 //   if ( streams_send_mon(g_clients[i]->execed) == -1 )
 //    clients_delete(i); // delete client in case we could not write
@@ -1000,229 +255,30 @@
 }
 
-int clients_add_output (int id, struct roar_buffer ** buf) {
- struct roar_client_server   * cs;
-
- _CHECK_CID(id);
- cs = g_clients[id];
-
- if ( cs->outbuf == NULL ) {
-  cs->outbuf = *buf;
- } else {
-  return roar_buffer_moveinto(cs->outbuf, buf);
- }
-
- return 0;
-}
-
-// proto support
-const struct roard_proto_handle * clients_get_protohandle(const int proto) {
- size_t i;
-
- if ( proto < 0 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return NULL;
- }
-
- for (i = 0; i < (sizeof(__protos)/sizeof(*__protos)); i++)
-  if ( __protos[i].proto == proto )
-   return &(__protos[i]);
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-int clients_register_proto_common(const struct roar_dl_proto * proto, struct roar_dl_lhandle * lhandle) {
- const size_t len = sizeof(__protos)/sizeof(*__protos);
- size_t i;
-
- ROAR_DBG("clients_register_proto_common(proto=%p, lhandle=%p) = ?", proto, lhandle);
-
- if ( proto == NULL )
-  return -1;
-
- for (i = 0; __protos[i].proto != -1; i++);
-
- // i is now at pos of current EOS entry.
-
- // test if we have space for one more entry:
- if ( (i+1) >= len )
-  return -1;
-
- __protos[i].impl.common = proto;
-
- __protos[i].proto   = proto->proto;
- __protos[i].type    = ROARD_PROTO_TYPE_COMMON;
- __protos[i].lhandle = lhandle;
-
- return 0;
-}
-
-int clients_unregister_proto(int proto) {
- size_t i;
-
- if ( proto < 0 ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- for (i = 0; i < (sizeof(__protos)/sizeof(*__protos)); i++) {
-  if ( __protos[i].proto == proto ) {
-   memset(&(__protos[i]), 0, sizeof(*__protos));
-   __protos[i].proto = -1;
+int client_stream_exec   (int client, int stream) {
+ int i;
+
+ if ( g_clients[client] == NULL )
+  return -1;
+
+ for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
+  if ( g_clients[client]->streams[i] == stream ) {
+   g_clients[client]->execed = stream;
+   streams_set_fh(stream, g_clients[client]->fh);
    return 0;
   }
  }
 
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-void print_protolist        (enum output_format format) {
- struct roard_proto_handle * p;
- char flags[5] = "    ";
- char subsys[7] = "      ";
- const char * description;
- size_t i;
-
- switch (format) {
-  case FORMAT_NATIVE:
-    printf("  Protocol Flag Subsys - Description\n");
-    printf("------------------------------------------------------\n");
-    printf("  roar     bb   WM LRX - RoarAudio native protocol\n");
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-    printf("  simple   bb   WM LRX - PulseAudio simple protocol\n");
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-    printf("  rsound   bb   W      - RSound emulation\n");
-#endif
-   break;
-  case FORMAT_WIKI:
-    printf("||=Protocol =||=Flag =||=Subsys =||=Description              =||\n");
-    printf("||roar       ||bb     ||WM LRX   ||RoarAudio native protocol  ||\n");
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-    printf("||simple     ||bb     ||WM LRX   ||PulseAudio simple protocol ||\n");
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-    printf("||rsound     ||bb     ||W        ||RSound emulation           ||\n");
-#endif
-   break;
-  case FORMAT_CSV:
-    printf("Protocol,Flag,Subsys,Description\n");
-    printf("roar,bb,WM LRX,RoarAudio native protocol\n");
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-    printf("simple,bb,WM LRX,PulseAudio simple protocol\n");
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-    printf("rsound,bb,W,RSound emulation\n");
-#endif
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return;
- }
-
- for (i = 0; i < (sizeof(__protos)/sizeof(*__protos)); i++) {
-  p = &(__protos[i]);
-  if ( p->proto == -1 )
-   continue;
-
-  strncpy(flags, "    ", 4);
-  strncpy(subsys, "      ", 6);
-  description = "(none)";
-
-  if ( p->lhandle != NULL ) {
-   flags[0] = 'P';
-  } else {
-   flags[0] = 'b';
-  }
-
-  switch (p->type) {
-   case ROARD_PROTO_TYPE_BUILDIN:
-     continue;
-    break;
-   case ROARD_PROTO_TYPE_COMMON:
-     flags[1] = 'C';
-     description = p->impl.common->description;
-    break;
-  }
-
-  switch (format) {
-   case FORMAT_NATIVE:
-     printf("  %-8s %s %s - %s\n", roar_proto2str(p->proto), flags, subsys, description);
-    break;
-   case FORMAT_WIKI:
-     printf("||%s ||%s ||%s ||%s ||\n", roar_proto2str(p->proto), flags, subsys, description);
-    break;
-   case FORMAT_CSV:
-     printf("%s,%s,%s,%s\n", roar_proto2str(p->proto), flags, subsys, description);
-    break;
-  }
- }
-}
-
-int client_stream_exec   (int client, int stream) {
- struct roar_client * c;
- int i;
- int fh;
-
- _CHECK_CID(client);
-
-#if 0
- if ( g_clients[client] == NULL ) {
-  ROAR_WARN("client_stream_exec(client=%i, stream=%i) = -1 // client does not exist", client, stream);
-  return -1;
- }
-#endif
-
- c = ROAR_CLIENT(g_clients[client]);
+ return -1;
+}
+
+int client_stream_add    (int client, int stream) {
+ int i;
+
+ if ( g_clients[client] == NULL )
+  return -1;
 
  for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
-  if ( c->streams[i] == stream ) {
-   c->execed = stream;
-   if ( streams_is_ready(stream) == 0 ) {
-    streams_set_fh(stream, c->fh);
-    streams_set_socktype(stream, ROAR_SOCKET_TYPE_GENSTR);
-   } else {
-    ROAR_DBG("client_stream_exec(client=%i, stream=%i): fh=?", client, stream);
-    if ( (fh = c->fh) != -1 ) {
-     close(fh);
-     c->fh = -1;
-    }
-   }
-   ROAR_DBG("client_stream_exec(client=%i, stream=%i) = 0", client, stream);
-   return 0;
-  }
- }
-
- ROAR_WARN("client_stream_exec(client=%i, stream=%i) = -1 // client does not own stream", client, stream);
- return -1;
-}
-
-int client_stream_set_fh (int client, int stream, int fh) {
- int i;
-
- ROAR_DBG("client_stream_set_fh(client=%i, stream=%i, fh=%i) = ?", client, stream, fh);
-
- _CHECK_CID(client);
-
- for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
-  if ( ROAR_CLIENT(g_clients[client])->streams[i] == stream ) {
-   ROAR_DBG("client_stream_set_fh(client=%i, stream=%i, fh=%i): stream found, index %i", client, stream, fh, i);
-   return streams_set_fh(stream, fh);
-  }
- }
-
- ROAR_WARN("client_stream_set_fh(client=%i, stream=%i, fh=%i) = -1 // client does not own stream", client, stream, fh);
- return -1;
-}
-
-int client_stream_add    (int client, int stream) {
- int i;
-
- _CHECK_CID(client);
-
- for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
-  if ( ROAR_CLIENT(g_clients[client])->streams[i] == -1 ) {
-   ROAR_CLIENT(g_clients[client])->streams[i] = stream;
+  if ( g_clients[client]->streams[i] == -1 ) {
+   g_clients[client]->streams[i] = stream;
    streams_set_client(stream, client);
    return 0;
@@ -1236,11 +292,12 @@
  int i;
 
- _CHECK_CID(client);
+ if ( g_clients[client] == NULL )
+  return -1;
 
  for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
-  if ( ROAR_CLIENT(g_clients[client])->streams[i] == stream ) {
-   ROAR_CLIENT(g_clients[client])->streams[i] = -1;
-
-   if ( stream == ROAR_CLIENT(g_clients[client])->execed ) {
+  if ( g_clients[client]->streams[i] == stream ) {
+   g_clients[client]->streams[i] = -1;
+
+   if ( stream == g_clients[client]->execed ) {
     ROAR_DBG("client_stream_delete(client=%i, stream=%i): stream is execed one, deleting client!", client, stream);
     clients_delete(client);
@@ -1256,132 +313,3 @@
 }
 
-int client_stream_move   (int client, int stream) {
- int old_client = streams_get_client(stream);
-
- ROAR_DBG("client_stream_move(client=%i, stream=%i): old_client = %i", client, stream, old_client);
-
- if ( old_client != -1 )
-  if ( client_stream_delete(old_client, stream) == -1 )
-   return -1;
-
- return client_stream_add(client, stream); 
-}
-
-
-// notify thingys
-int clients_wait    (int client, struct roar_event * events, size_t num) {
- struct roar_client_server * cs;
- size_t i, c;
-
- ROAR_DBG("clients_wait(client=%i, events=%p, num=%llu) = ?", client, events, (long long unsigned int)num);
-
- _CHECK_CID(client);
-
- cs = g_clients[client];
-
- if ( cs->waits != NULL )
-  return -1;
-
- cs->waits = roar_mm_malloc((num+1) * sizeof(struct roar_subscriber *));
-
- if ( cs->waits == NULL )
-  return -1;
-
- if ( clients_block(client, 0) != 0 )
-  return -1;
-
- for (i = 0; i < num; i++) {
-#if defined(DEBUG) && 0
-  dbg_notify_cb(NULL, &(events[i]), cs);
-#endif
-  cs->waits[i] = roar_notify_core_subscribe(NULL, &(events[i]), clients_ncb_wait, cs);
-  if ( cs->waits[i] == NULL ) {
-   for (c = 0; c < i; c++)
-    roar_notify_core_unsubscribe(NULL, cs->waits[c]);
-   roar_mm_free(cs->waits);
-   cs->waits = NULL;
-   clients_block(client, 1);
-   return -1;
-  }
- }
-
- cs->waits[num] = NULL;
-
- ROAR_DBG("clients_wait(client=%i, events=%p, num=%llu) = 0", client, events, (long long unsigned int)num);
- return 0;
-}
-
-void clients_ncb_wait(struct roar_notify_core * core, struct roar_event * event, void * userdata) {
- struct roar_client_server * cs = userdata;
- struct roar_message m;
- struct roar_connection con;
- uint16_t * u16 = (uint16_t *) m.data;
- size_t tmp;
- size_t i;
-
- ROAR_DBG("clients_ncb_wait(core=%p, event=%p, userdata=%p) = ?", core, event, userdata);
-
- for (i = 0; cs->waits[i] != NULL; i++)
-  roar_notify_core_unsubscribe(NULL, cs->waits[i]);
-
- roar_mm_free(cs->waits);
- cs->waits = NULL;
-
- // protocol depended handling...
- memset(&m, 0, sizeof(m));
- m.cmd = ROAR_CMD_OK;
- u16[0] = ROAR_HOST2NET16(0); // Version
- u16[1] = ROAR_HOST2NET16(0); // flags
-
- tmp = sizeof(m.data) - 4;
-
- roar_event_to_blob(event, m.data + 4, &tmp);
-
- m.datalen = tmp + 4;
-
- roar_connect_fh(&con, ROAR_CLIENT(cs)->fh);
- roar_send_message(&con, &m, NULL);
- // ...end of protocol depended handling.
-
-// clients_block(, 1);
- // TODO: FIXME: bad hack...
- cs->blockc--;
-}
-
-
-// acclev:
-static struct {
- const enum roard_client_acclev acclev;
- const char *                   name;
-} _g_acclevs[] = {
- {ACCLEV_NONE,    "none"   },
- {ACCLEV_IDENTED, "idented"},
- {ACCLEV_CONCTL,  "conctl" },
- {ACCLEV_GUEST,   "guest"  },
- {ACCLEV_USER,    "user"   },
- {ACCLEV_PWRUSER, "pwruser"},
- {ACCLEV_ALL,     "all"    },
- {-1, NULL}
-};
-
-enum roard_client_acclev clients_str2acclev(const char * acclev) {
- int i;
-
- for (i = 0; _g_acclevs[i].name != NULL; i++)
-  if ( !strcasecmp(_g_acclevs[i].name, acclev) )
-   return _g_acclevs[i].acclev;
-
- return ACCLEV_ERROR;
-}
-
-const char * clients_acclev2str(const enum roard_client_acclev acclev) {
- int i;
-
- for (i = 0; _g_acclevs[i].name != NULL; i++)
-  if ( _g_acclevs[i].acclev == acclev )
-   return _g_acclevs[i].name;
-
- return NULL;
-}
-
 //ll
Index: roard/codecfilter.c
===================================================================
--- roard/codecfilter.c	(revision 6052)
+++ 	(revision )
@@ -1,423 +1,0 @@
-//codecfilter.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#define ROAR_REQUIRE_LIBVORBISFILE
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_CF_CMD
-#if !defined(ROAR_HAVE_UNIX) || !defined(ROAR_HAVE_BSDSOCKETS) || !defined(ROAR_HAVE_IO_POSIX)
-#define ROAR_WITHOUT_CF_CMD
-#endif
-#endif
-
-#define _DUMMY_FILTER(codec,name,desc,flags,subsystem,delay) {(codec),(name),(desc),NULL,NULL,(flags),(subsystem), \
-                                                              NULL, NULL, NULL, NULL, NULL, NULL, (delay), NULL    }
-
-#define _PCM_FILTER(codec) _DUMMY_FILTER(codec, "PCM", "Native PCM Support", \
-                                         ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, \
-                                         ROAR_SUBSYS_WAVEFORM, codecfilter_delay_zero)
-
-struct roar_codecfilter g_codecfilter[] = {
- _DUMMY_FILTER(-1, "null", "null codec filter", ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE, NULL),
- _PCM_FILTER(ROAR_CODEC_PCM_S_LE),
- _PCM_FILTER(ROAR_CODEC_PCM_S_BE),
- _PCM_FILTER(ROAR_CODEC_PCM_S_PDP),
- _PCM_FILTER(ROAR_CODEC_PCM_U_LE),
- _PCM_FILTER(ROAR_CODEC_PCM_U_BE),
- _PCM_FILTER(ROAR_CODEC_PCM_U_PDP),
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- _DUMMY_FILTER(ROAR_CODEC_MIDI, "MIDI", "Native MIDI Support",
-               ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_MIDI, NULL),
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- {ROAR_CODEC_DMX512,      "DMX512", "Native DMX512 Support", NULL, NULL,
-                          ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT,
-                                          NULL, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_zero, NULL},
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
- {ROAR_CODEC_RDS,         "RDS", "Native RDS Support", NULL, NULL,
-                          ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_RDTCS,
-                                          NULL, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_zero, NULL},
-#endif
-
-/*
-#ifdef ROAR_HAVE_LIBSNDFILE
- {ROAR_CODEC_RIFF_WAVE, "sndfile", "libsndfile codec filter", NULL, ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE,
-  cf_sndfile_open, cf_sndfile_close, NULL, cf_sndfile_write, cf_sndfile_read, NULL},
-#else
-*/
-#ifndef ROAR_WITHOUT_CF_WAVE
- {ROAR_CODEC_RIFF_WAVE, "RIFF/WAVE", "RIFF/WAVE", NULL, NULL,
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, ROAR_SUBSYS_WAVEFORM,
-  cf_wave_open, cf_wave_close, NULL, cf_wave_write, cf_wave_read, NULL, NULL, cf_wave_ctl},
-#endif
-//#endif
-
-#ifndef ROAR_WITHOUT_CF_AU
- {ROAR_CODEC_AU, "AU", "AU", NULL, NULL,
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU, ROAR_SUBSYS_WAVEFORM,
-  cf_au_open, cf_au_close, NULL, cf_au_write, cf_au_read, NULL, NULL, cf_au_ctl},
-#endif
-
-#if 0
-#ifdef ROAR_HAVE_LIBRAUM
- {ROAR_CODEC_RAUM, "RAUM", "RAUM Container Format", NULL, cf_raum_setup, ROAR_CODECFILTER_WRITE,
-  ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI|ROAR_SUBSYS_LIGHT|ROAR_SUBSYS_RAW|ROAR_SUBSYS_COMPLEX,
-  cont_fw_cf_open, cont_fw_cf_close, NULL, cont_fw_cf_write, cont_fw_cf_read, cont_fw_cf_flush, NULL, cont_fw_cf_ctl},
-#endif
-#endif
-#ifdef ROAR_HAVE_LIBUNIRAUM
- {ROAR_CODEC_RAUM, "uniraum", "RAUM Container Format", NULL, NULL, ROAR_CODECFILTER_READ,
-  ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI|ROAR_SUBSYS_LIGHT|ROAR_SUBSYS_RAW|ROAR_SUBSYS_COMPLEX,
-  cf_uniraum_open, cf_uniraum_close, NULL, cf_uniraum_write, cf_uniraum_read, cf_uniraum_flush, NULL, cf_uniraum_ctl}, 
-#endif
-
-#ifdef ROAR_HAVE_LIBOGG
- {ROAR_CODEC_OGG, "Ogg", "Ogg Container Format", NULL, NULL, ROAR_CODECFILTER_NONE,
-  ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI,
-  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
-#endif
-
-#ifdef ROAR_SUPPORT_ALAW
- {ROAR_CODEC_ALAW, "alaw", "A-Law", NULL, NULL,
-#ifdef ROAR_SUPPORT_ALAW_RW
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN,
-#else
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN,
-#endif
-  ROAR_SUBSYS_WAVEFORM,
-  cf_alaw_open, cf_alaw_close, NULL,
-#ifdef ROAR_SUPPORT_ALAW_RW
-  cf_alaw_write,
-#else
-  NULL,
-#endif
-  cf_alaw_read, NULL, codecfilter_delay_zero, NULL},
-#endif
-
-#ifdef ROAR_SUPPORT_MULAW
- {ROAR_CODEC_MULAW, "mulaw", "mu-Law", NULL, NULL,
-#ifdef ROAR_SUPPORT_MULAW_RW
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN,
-#else
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_PRETHRU_NN,
-#endif
-  ROAR_SUBSYS_WAVEFORM,
-  cf_mulaw_open, cf_mulaw_close, NULL,
-#ifdef ROAR_SUPPORT_MULAW_RW
-  cf_mulaw_write,
-#else
-  NULL,
-#endif
-  cf_mulaw_read, NULL, codecfilter_delay_zero, NULL},
-#endif
-
-#ifndef ROAR_WITHOUT_CF_CMD
-#ifdef ROAR_HAVE_BIN_OGG123
- {ROAR_CODEC_OGG_GENERAL, "cmd",  "ogg123",
-  ROAR_HAVE_BIN_OGG123 " -q -d raw -f - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-#endif
-
-#ifdef ROAR_HAVE_LIBVORBISFILE
- {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL, NULL,
-#ifdef ROAR_HAVE_LIBVORBISENC
- ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU,
-#else
- ROAR_CODECFILTER_READ,
-#endif
- ROAR_SUBSYS_WAVEFORM,
- cf_vorbis_open, cf_vorbis_close, NULL, cf_vorbis_write, cf_vorbis_read, NULL, codecfilter_delay_fulldyn, cf_vorbis_ctl},
-#else
-#ifndef ROAR_WITHOUT_CF_CMD
-#ifdef ROAR_HAVE_BIN_OGG123
- {ROAR_CODEC_OGG_VORBIS, "cmd",  "ogg123",
-  ROAR_HAVE_BIN_OGG123 " -q -d raw -f - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-#endif
-#endif
-
-#ifdef ROAR_HAVE_LIBFISHSOUND
- {ROAR_CODEC_OGG_SPEEX, "fishsound",  "libfishsound Xiph Codec library",
-  NULL, NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_fishsound_open, cf_fishsound_close, NULL, NULL, cf_fishsound_read, NULL, codecfilter_delay_fulldyn, NULL},
-
- {ROAR_CODEC_OGG_FLAC, "fishsound",  "libfishsound Xiph Codec library",
-  NULL, NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_fishsound_open, cf_fishsound_close, NULL, NULL, cf_fishsound_read, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-
-#ifndef ROAR_WITHOUT_CF_CMD
-#ifdef ROAR_HAVE_BIN_TIMIDITY
- {ROAR_CODEC_MIDI_FILE, "MIDIFILE", "timidity MIDI synth",
-  ROAR_HAVE_BIN_TIMIDITY " -Or1sl -s %R -o - -", NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-#endif
-
-#ifdef ROAR_HAVE_LIBCELT
- {ROAR_CODEC_ROAR_CELT, "RoarCELT", "RoarAudio CELT", NULL, NULL,
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU,
-  ROAR_SUBSYS_WAVEFORM,
-  cf_celt_open, cf_celt_close, NULL, cf_celt_write, cf_celt_read, NULL, cf_celt_delay, NULL},
-#endif
-
-#ifdef ROAR_HAVE_LIBSPEEX
- {ROAR_CODEC_ROAR_SPEEX, "RoarSpeex", "RoarAudio Speex", NULL, NULL,
-  ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU,
-  ROAR_SUBSYS_WAVEFORM,
-  cf_speex_open, cf_speex_close, NULL, cf_speex_write, cf_speex_read, NULL, NULL, NULL},
-#endif
-
-#ifndef ROAR_WITHOUT_CF_CMD
-#if defined(ROAR_HAVE_BIN_FLAC) && !defined(ROAR_HAVE_LIBFLAC)
- {ROAR_CODEC_FLAC, "cmd",  "flac",
-#if BYTE_ORDER == BIG_ENDIAN
-  ROAR_HAVE_BIN_FLAC " --silent --force-raw-format --sign=signed --endian=big -d - -o -",
-#elif BYTE_ORDER == LITTLE_ENDIAN
-  ROAR_HAVE_BIN_FLAC " --silent --force-raw-format --sign=signed --endian=little -d - -o -",
-#else
-  "false",
-#endif
-  NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_cmd_open, NULL, NULL, NULL, NULL, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-#endif
-
-#ifdef ROAR_HAVE_LIBFLAC
- {ROAR_CODEC_FLAC, "FLAC", "flac codec", NULL, NULL, ROAR_CODECFILTER_READ, ROAR_SUBSYS_WAVEFORM,
-  cf_flac_open, cf_flac_close, NULL, NULL, cf_flac_read, NULL, codecfilter_delay_fulldyn, NULL},
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- _DUMMY_FILTER(ROAR_CODEC_ROARDMX, "RoarDMX", "Native RoarDMX Support",
-               ROAR_CODECFILTER_READ|ROAR_CODECFILTER_WRITE|ROAR_CODECFILTER_PRETHRU_NN, ROAR_SUBSYS_LIGHT, NULL),
-#endif
-
- {-1, NULL, NULL, NULL, NULL, ROAR_CODECFILTER_NONE, ROAR_SUBSYS_NONE,
-  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} // end of list
-};
-
-void print_codecfilterlist (void) {
- int i;
- int flags;
- char mode[5];
- char delay[6];
- char subsys[7] = "      ";
- uint_least32_t d;
-
- printf("  Codec        Filtername   Mode Subsys Delay - Description\n");
- printf("-------------------------------------------------------------\n");
-
- for (i = 0; g_codecfilter[i].name != NULL; i++) {
-  strncpy(subsys, "      ", 6);
-
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_WAVEFORM )
-   subsys[0] = 'W';
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_MIDI )
-   subsys[1] = 'M';
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_CB )
-   subsys[2] = 'C';
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_LIGHT )
-   subsys[3] = 'L';
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_RAW )
-   subsys[4] = 'R';
-  if ( g_codecfilter[i].subsystems & ROAR_SUBSYS_COMPLEX )
-   subsys[5] = 'X';
-
-  flags = g_codecfilter[i].flags;
-
-  if ( flags == ROAR_CODECFILTER_NONE ) {
-   strcpy(mode, "none");
-  } else {
-   strcpy(mode, "    ");
-   if ( flags & ROAR_CODECFILTER_READ )
-    mode[0] = 'r';
-   if ( flags & ROAR_CODECFILTER_WRITE )
-    mode[1] = 'w';
-   if ( flags & ROAR_CODECFILTER_PRETHRU )
-    mode[2] = 'P';
-   if ( flags & ROAR_CODECFILTER_PRETHRU_NN )
-    mode[2] = 'p';
-  }
-
-  *delay = 0;
-  if ( g_codecfilter[i].codec == -1 ) { // null codec filter
-   strcpy(delay, "0ms");
-  } else if ( g_codecfilter[i].delay == NULL ) {
-   strcpy(delay, "?");
-  } else {
-   if ( codecfilter_delay(NULL, i, &d) == -1 ) {
-    strcpy(delay, "dyn");
-   } else {
-    snprintf(delay, 5, "%ims", (int)(d/(uint_least32_t)1000));
-   }
-  }
- 
-  printf("  %-12s %-12s %-4s %6s %-5s - %s\n",
-             roar_codec2str(g_codecfilter[i].codec),
-             g_codecfilter[i].name,
-             mode,
-             subsys,
-             delay,
-             g_codecfilter[i].desc
-             );
- }
-}
-
-int codecfilter_open (CODECFILTER_USERDATA_T * inst,
-                 int * codecfilter_id, char * codecfilter /* NOTE: this is not part of struct roar_codecfilter's def! */,
-                 int codec, struct roar_stream_server * info) {
- int i;
- struct roar_codecfilter   * filter = NULL;
-
- *codecfilter_id = -1;
-
- ROAR_DBG("codecfilter_open(*): codecfilter='%s', info->id=%i", codecfilter, ROAR_STREAM(info)->id);
-
- for (i = 0; g_codecfilter[i].name != NULL; i++) {
-  ROAR_DBG("codecfilter_open(*): g_codecfilter[i].codec <-> codec => %i <-> %i", g_codecfilter[i].codec, codec);
-  if ( g_codecfilter[i].codec == codec ) {
-   if ( !codecfilter || strcmp(codecfilter, g_codecfilter[i].name) == 0 ) {
-    *codecfilter_id = i;
-    filter = &g_codecfilter[i];
-    break;
-   }
-  }
- }
-
- info->codecfilter = *codecfilter_id;
-
- if (*codecfilter_id != -1) {
-  if ( filter->open != NULL ) {
-   if ( (i = filter->open(inst, codec, info, filter)) == -1 ) {
-    info->codecfilter = *codecfilter_id = -1;
-   }
-   return i;
-  } else {
-   // in case we can not open the filter we will not use it
-   *codecfilter_id   = -1;
-   info->codecfilter = -1;
-  }
-  return 0;
- }
-
- return -1; // we found no filter -> ok
-}
-
-int codecfilter_close(CODECFILTER_USERDATA_T   inst, int codecfilter) {
- ROAR_DBG("codecfilter_close(inst=%p, codecfilter=%i) = ?", inst, codecfilter);
-
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].close )
-  return g_codecfilter[codecfilter].close(inst);
-
- return 0;
-}
-
-int codecfilter_pause(CODECFILTER_USERDATA_T   inst, int codecfilter, int newstate) {
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].pause )
-  return g_codecfilter[codecfilter].pause(inst, newstate);
-
- return 0;
-}
-
-int codecfilter_write(CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len) {
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].write )
-  return g_codecfilter[codecfilter].write(inst, buf, len);
-
- return 0;
-}
-
-int codecfilter_read (CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len) {
- if ( codecfilter == -1 )
-  return -1;
-
- errno = 0;
-
- if ( g_codecfilter[codecfilter].read )
-  return g_codecfilter[codecfilter].read(inst, buf, len);
-
- return 0;
-}
-
-int codecfilter_flush(CODECFILTER_USERDATA_T   inst, int codecfilter) {
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].flush )
-  return g_codecfilter[codecfilter].flush(inst);
-
- return 0;
-}
-
-int codecfilter_delay(CODECFILTER_USERDATA_T   inst, int codecfilter, uint_least32_t * delay) {
- ROAR_DBG("codecfilter_delay(inst=%p, codecfilter=%i, *delay=?) = ?", inst, codecfilter);
-
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].delay )
-  return g_codecfilter[codecfilter].delay(inst, delay);
-
- return -1;
-}
-
-int codecfilter_ctl  (CODECFILTER_USERDATA_T   inst, int codecfilter, int_least32_t cmd, void * data) {
- ROAR_DBG("codecfilter_ctl(inst=%p, codecfilter=%i, cmd=0x%.8x, data=%p) = ?", inst, codecfilter, cmd, data);
- if ( codecfilter == -1 )
-  return -1;
-
- if ( g_codecfilter[codecfilter].ctl )
-  return g_codecfilter[codecfilter].ctl(inst, cmd, data);
-
- return -1;
-}
-
-
-int codecfilter_delay_fulldyn(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay) {
- *delay = 0; // just to be sure
- return -1;
-}
-
-int codecfilter_delay_zero(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay) {
- // this codec does not create any addition latency.
-
- *delay = 0;
- return 0;
-}
-
-//ll
Index: roard/codecfilter_alaw.c
===================================================================
--- roard/codecfilter_alaw.c	(revision 6052)
+++ 	(revision )
@@ -1,97 +1,0 @@
-//codecfilter_alaw.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-/* ckport options:
- * ckport: ignore-symbol: roardsp_conv_pcm162alaw of target libroardsp0
- * ckport: ignore-symbol: roardsp_conv_alaw2pcm16 of target libroardsp0
- */
-
-#include "roard.h"
-
-#ifdef ROAR_SUPPORT_ALAW
-
-int cf_alaw_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct roar_stream * s = ROAR_STREAM(info);
-
- (void)codec, (void)filter;
-
- *inst = (CODECFILTER_USERDATA_T) info;
-
- s->info.bits  = 16;
- s->info.codec = ROAR_CODEC_DEFAULT;
-
- return 0;
-}
-
-int cf_alaw_close(CODECFILTER_USERDATA_T   inst) {
- (void)inst;
- return 0;
-}
-
-int cf_alaw_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct roar_stream_server * s = ROAR_STREAM_SERVER(inst);
-
- if ( (len = stream_vio_s_read(s, buf, len/2)) < 1 ) {
-  return len;
- }
-
- roardsp_conv_alaw2pcm16((int16_t *)buf, buf, len);
-
- return len*2;
-}
-
-#ifdef ROAR_SUPPORT_ALAW_RW
-int cf_alaw_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct roar_stream_server * s = ROAR_STREAM_SERVER(inst);
- char * out;
-
- // TODO: add a more effect way to use memory than allways alloc/freeing it.
- //       maybe by keeping a buffer over instanzes or by using ca global buffer
- //       with an refrenze counter so we can free it on last use
-
- len /= 2;
-
- if ( (out = (char*)roar_mm_malloc(len)) == NULL )
-  return -1;
-
- roardsp_conv_pcm162alaw(out, (int16_t*)buf, len);
-
- len = stream_vio_s_write(s, out, len);
-
- roar_mm_free(out);
-
- if ( len > 0 ) {
-  return len*2;
- } else {
-  return -1;
- }
-}
-#endif
-
-#endif
-
-//ll
Index: roard/codecfilter_au.c
===================================================================
--- roard/codecfilter_au.c	(revision 6052)
+++ 	(revision )
@@ -1,302 +1,0 @@
-//codecfilter_au.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_CF_AU
-
-int cf_au_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_au_inst * self = roar_mm_malloc(sizeof(struct codecfilter_au_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- (void)codec, (void)filter;
-
- if ( self == NULL )
-  return -1;
-
- self->stream               = info;
- self->vstream              = NULL;
- self->opened               = 0;
-
- *inst = (CODECFILTER_USERDATA_T) self;
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- s->info.codec = ROAR_CODEC_PCM_S_BE;
-
- return 0;
-}
-
-int cf_au_close(CODECFILTER_USERDATA_T   inst) {
-// struct codecfilter_au_inst * self = (struct codecfilter_au_inst *) inst;
-
- if ( !inst )
-  return -1;
-
- roar_mm_free(inst);
- return 0;
-}
-
-int cf_au_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_au_inst * self = (struct codecfilter_au_inst *) inst;
- int r = -1;
- char tbuf[ROAR_AU_MIN_HEADER_LEN];
- uint32_t * header = (uint32_t*)tbuf;
- struct roar_stream * ps = ROAR_STREAM(self->stream);
- struct roar_stream *  s;
- struct roar_audio_info info;
- char * extra_header;
- int codec = -1;
- int vid, fh;
- int i;
-
- if ( self->opened ) {
-  return stream_vio_s_read(self->stream, buf, len);
- } else {
-  if (stream_vio_s_read(self->stream, tbuf, ROAR_AU_MIN_HEADER_LEN) != ROAR_AU_MIN_HEADER_LEN) {
-   return -1;
-  }
-
-  for (i = 0; i < ROAR_AU_MIN_HEADER_LEN/4; i++) {
-   header[i] = ROAR_NET2HOST32(header[i]);
-   ROAR_DBG("cf_au_read(inst=%p, buf=%p, len=%i): header[%i] = 0x%.8x", inst, buf, len, i, header[i]);
-  }
-
-
-  // test the header, is this really a AU stream?
-  if ( header[0] != ROAR_AU_MAGIC )
-   return -1;
-
-  if ( header[1] != ROAR_AU_MIN_HEADER_LEN ) {
-   header[1] -= ROAR_AU_MIN_HEADER_LEN;
-
-   if ( header[1] > (uint32_t)32768U ) // do not allow more than 32KiB header...
-    return -1;
-
-   if ( (extra_header = roar_mm_malloc(header[1])) == NULL )
-    return -1;
-
-   if ( stream_vio_s_read(self->stream, extra_header, header[1]) != (ssize_t)header[1] ) {
-    roar_mm_free(extra_header);
-    return -1;
-   }
-
-   roar_mm_free(extra_header);
-  }
-
-  // TODO: write better code here!
-
-  if ( (fh = streams_get_fh(ps->id)) == -1 ) {
-   return -1;
-  }
-
-  if ( (vid = streams_new_virtual(ps->id, &(self->vstream))) == -1 ) {
-   return -1;
-  }
-
-  ROAR_DBG("cf_au_read(*): self->vstream=%p", self->vstream);
-
-  s = ROAR_STREAM(self->vstream);
-
-  s->info.rate = header[4];
-
-  s->info.channels = header[5];
-
-  switch (header[3]) {
-   case ROAR_AU_CID_MULAW:
-     s->info.bits  =  8;
-     codec         =  ROAR_CODEC_MULAW;
-    break;
-   case ROAR_AU_CID_ALAW:
-     s->info.bits  =  8;
-     codec         =  ROAR_CODEC_ALAW;
-    break;
-   case ROAR_AU_CID_PCM_S_8:
-     s->info.bits  =  8;
-     codec         =  ROAR_CODEC_PCM_S_BE;
-    break;
-   case ROAR_AU_CID_PCM_S_16:
-     s->info.bits  = 16;
-     codec         =  ROAR_CODEC_PCM_S_BE;
-    break;
-   case ROAR_AU_CID_PCM_S_24:
-     s->info.bits  = 24;
-     codec         =  ROAR_CODEC_PCM_S_BE;
-    break;
-   case ROAR_AU_CID_PCM_S_32:
-     s->info.bits  = 32;
-     codec         =  ROAR_CODEC_PCM_S_BE;
-    break;
-   default:
-     return -1;
-  }
-
-  s->info.codec             = codec;
-  self->vstream->codec_orgi = codec;
-
-  memcpy(&info, &(s->info), sizeof(struct roar_audio_info));
-
-  if ( streams_set_fh(vid, fh) == -1 ) {
-   return -1;
-  }
-
-/*
-  if ( roar_vio_open_pass(&(self->vstream->vio), &(self->stream->vio)) == -1 ) {
-   return -1;
-  }
-*/
-
-  memcpy(&(self->vstream->vio), &(self->stream->vio), sizeof(struct roar_vio_calls));
-
-  if ( streams_set_null_io(ps->id) == -1 ) {
-   return -1;
-  }
-
-  memcpy(&(ps->info), &info, sizeof(struct roar_audio_info));
-
-  self->opened = 1;
-
-  errno = EAGAIN;
-  return -1;
- }
-
- return r;
-}
-
-int cf_au_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_au_inst * self = (struct codecfilter_au_inst *) inst;
- struct roar_stream         * s    = ROAR_STREAM(self->stream);
- void     * headerdata;
- uint32_t * header;
- uint32_t codec;
- int      sid;
- int      i;
-
- ROAR_DBG("cf_au_write(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
- ROAR_DBG("cf_au_write(inst=%p, buf=%p, len=%i): self->opened=%i", inst, buf, len, self->opened);
-
- if ( self->opened ) {
-  return stream_vio_s_write(self->stream, buf, len);
- } else {
-
-  if ( s->fh == -1 ) {
-   errno = EAGAIN;
-   return -1;
-  }
-
-  sid = ROAR_STREAM(self->stream)->id;
-
-  if ( stream_prethru_destroy(sid) == -1 ) {
-   return -1;
-  }
-
-  if ( stream_prethru_add_data(sid, &headerdata, ROAR_AU_MIN_HEADER_LEN) == -1 ) {
-   return -1;
-  }
-
-  header = headerdata;
-
-  switch (s->info.codec) {
-   case ROAR_CODEC_PCM_S_BE:
-     switch (s->info.bits) {
-      case  8: codec = ROAR_AU_CID_PCM_S_8;  break;
-      case 16: codec = ROAR_AU_CID_PCM_S_16; break;
-      case 24: codec = ROAR_AU_CID_PCM_S_24; break;
-      case 32: codec = ROAR_AU_CID_PCM_S_32; break;
-      default:
-        ROAR_ERR("cf_au_write(*) bits per sample not supported!");
-        return -1;
-       break;
-     }
-    break;
-   default:
-     ROAR_ERR("cf_au_write(*) Codec not supported!: %s(%i)", roar_codec2str(s->info.codec), s->info.codec);
-     return -1;
-    break;
-  }
-
-  ROAR_DBG("cf_au_write(*) Codec supported!");
-
-  header[0] = ROAR_AU_MAGIC;
-  header[1] = ROAR_AU_MIN_HEADER_LEN;
-  header[2] = ROAR_AU_DATASIZE;
-  header[3] = codec;
-  header[4] = s->info.rate;
-  header[5] = s->info.channels;
-
-  for (i = 0; i < ROAR_AU_MIN_HEADER_LEN/4; i++)
-   header[i] = ROAR_HOST2NET32(header[i]);
-
-  if ( stream_vio_s_write(self->stream, header, ROAR_AU_MIN_HEADER_LEN) != ROAR_AU_MIN_HEADER_LEN )
-   return -1;
-
-  self->opened = 1;
-
-  errno = EAGAIN;
-//  return -1;
-
-  len = stream_vio_s_write(self->stream, buf, len);
-
-  cf_au_close(inst);
-  ROAR_STREAM_SERVER(s)->codecfilter = -1;
-
-  return len;
-
-//  return stream_vio_s_write(self->stream, buf, len);
- }
-
- return -1;
-}
-
-int cf_au_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data) {
- struct codecfilter_au_inst * self = (struct codecfilter_au_inst *) inst;
- int_least32_t type = cmd & ROAR_STREAM_CTL_TYPEMASK;
-
- (void)data;
-
- cmd -= type;
-
- ROAR_DBG("cf_au_ctl(*): command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-
- switch (cmd) {
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_VIRTUAL_DELETE):
-    streams_delete(ROAR_STREAM(self->stream)->id);
-    return 0;
-   break;
-  default:
-    ROAR_DBG("cf_au_ctl(*): Unknown command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-    return -1;
- }
-
- return -1;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_celt.c
===================================================================
--- roard/codecfilter_celt.c	(revision 6052)
+++ 	(revision )
@@ -1,332 +1,0 @@
-//codecfilter_celt.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#ifdef ROAR_HAVE_LIBCELT
-
-#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
-typedef celt_int16 celt_int16_t;
-#endif
-
-int cf_celt_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_celt_inst * self = roar_mm_malloc(sizeof(struct codecfilter_celt_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- (void)codec, (void)filter;
-
- if ( self == NULL )
-  return -1;
-
-/*
- CELTMode * mode;
- CELTEncoder * encoder;
- CELTDecoder * decoder;
- int frame_size;
- int lookahead;
- int out_size;
- char * ibuf;
- char * obuf;
- char * rest;
- int s_buf;
- int f_rest; /-* how much is in rest? *-/
-*/
-
- self->stream               = info;
- self->frame_size           = 256;
- self->lookahead            = self->frame_size;
- self->encoder              = NULL;
- self->decoder              = NULL;
- self->opened_encoder       = 0;
- self->opened_decoder       = 0;
- self->s_buf                = s->info.channels * self->frame_size * 2;
- self->ibuf                 = roar_mm_malloc(self->s_buf);
- self->obuf                 = roar_mm_malloc(self->s_buf);
- self->i_rest               = roar_mm_malloc(self->s_buf);
- self->o_rest               = roar_mm_malloc(self->s_buf);
- self->fi_rest              = 0;
- self->fo_rest              = 0;
-
- if ( !(self->ibuf && self->obuf && self->i_rest && self->o_rest) ) {
-  if ( self->ibuf != NULL )
-   roar_mm_free(self->ibuf);
-
-  if ( self->obuf != NULL )
-   roar_mm_free(self->obuf);
-
-  if ( self->i_rest != NULL )
-   roar_mm_free(self->o_rest);
-
-  if ( self->o_rest != NULL )
-   roar_mm_free(self->o_rest);
-
-  roar_mm_free(self);
-  return -1;
- }
-
-#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
- self->mode                 = celt_mode_create(s->info.rate, self->frame_size, NULL);
-#else
- self->mode                 = celt_mode_create(s->info.rate, s->info.channels, self->frame_size, NULL);
-#endif
-
- if ( !self->mode ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- if ( s->dir == ROAR_DIR_PLAY ) {
-#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
-   self->decoder = celt_decoder_create(self->mode, s->info.channels, NULL);
-#else
-   self->decoder = celt_decoder_create(self->mode);
-#endif
- } else if ( s->dir == ROAR_DIR_MONITOR || s->dir == ROAR_DIR_OUTPUT ) {
-#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
-   self->encoder = celt_encoder_create(self->mode, s->info.channels, NULL);
-#else
-   self->encoder = celt_encoder_create(self->mode);
-#endif
- } else if ( s->dir == ROAR_DIR_BIDIR || s->dir == ROAR_DIR_RECPLAY ) {
-#ifdef ROAR_HAVE_CELT_VERSION_0_7_1
-   self->decoder = celt_decoder_create(self->mode, s->info.channels, NULL);
-   self->encoder = celt_encoder_create(self->mode, s->info.channels, NULL);
-#else
-   self->decoder = celt_decoder_create(self->mode);
-   self->encoder = celt_encoder_create(self->mode);
-#endif
- } else {
-  celt_mode_destroy(self->mode);
-  roar_mm_free(self);
-  return -1;
- }
-
- *inst = (CODECFILTER_USERDATA_T) self;
-
- s->info.codec = ROAR_CODEC_DEFAULT;
- s->info.bits  = 16; // CELT hardcoded
-
- return 0;
-}
-
-int cf_celt_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_celt_inst * self = (struct codecfilter_celt_inst *) inst;
-
- if ( !inst )
-  return -1;
-
- if ( self->encoder != NULL )
-  celt_encoder_destroy(self->encoder);
-
- if ( self->decoder != NULL )
-  celt_decoder_destroy(self->decoder);
-
- if ( self->mode != NULL )
-  celt_mode_destroy(self->mode);
-
- if ( self->ibuf != NULL )
-  roar_mm_free(self->ibuf);
-
- if ( self->obuf != NULL )
-  roar_mm_free(self->obuf);
-
- if ( self->i_rest != NULL )
-  roar_mm_free(self->i_rest);
-
- if ( self->o_rest != NULL )
-  roar_mm_free(self->o_rest);
-
- roar_mm_free(inst);
- return 0;
-}
-
-int cf_celt_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_celt_inst * self = (struct codecfilter_celt_inst *) inst;
- int r = 0;
- uint16_t fs;
- char * cbuf;
- char magic[ROAR_CELT_MAGIC_LEN];
-
-// printf("buf=%p, len=%i\n", buf, len);
-
- if ( !self->opened_decoder ) {
-  errno = ENOSYS;
-  if ( stream_vio_s_read(self->stream, magic, ROAR_CELT_MAGIC_LEN) != ROAR_CELT_MAGIC_LEN )
-   return -1;
-  if ( memcmp(magic, ROAR_CELT_MAGIC, ROAR_CELT_MAGIC_LEN) != 0 )
-   return -1;
-
-  errno = 0;
-  self->opened_decoder = 1;
- }
-
- if ( self->fi_rest ) {
-  memcpy(buf, self->i_rest, self->fi_rest);
-  r += self->fi_rest;
-  self->fi_rest = 0;
- }
-
- while ( r <= (len - self->s_buf) ) {
-  if ( stream_vio_s_read(self->stream, &fs, 2) != 2 )
-   break;
-
-  fs = ROAR_NET2HOST16(fs);
-
-//  ROAR_WARN("0:fs=%i", fs);
-
-  if ( fs > self->s_buf )
-   return -1;
-
-  if ( stream_vio_s_read(self->stream, self->ibuf, fs) != fs )
-   return -1;
-
-  cbuf = buf + r;
-
-//  printf("buf=%p, r=%i // cbuf=%p\n", buf, r, cbuf);
-  if ( celt_decode(self->decoder, (unsigned char *) self->ibuf, fs, (celt_int16_t *) cbuf) < 0 )
-   return -1;
-
-  r += self->s_buf;
- }
-
- if ( r < len ) {
-//  printf("r < len!\n");
-  if ( stream_vio_s_read(self->stream, &fs, 2) == 2 ) {
-   fs = ROAR_NET2HOST16(fs);
-//  ROAR_WARN("1:fs=%i", fs);
-//   printf("next: fs=%i\n", fs);
-   if ( fs > self->s_buf )
-    return -1;
-   if ( stream_vio_s_read(self->stream, self->ibuf, fs) == fs ) {
-//    printf("got data!\n");
-    if ( celt_decode(self->decoder, (unsigned char *) self->ibuf, fs, (celt_int16_t *) self->obuf) >= 0 ) {
-//     printf("{ // decode rest\n");
-//     printf(" r=%i // need %i Bytes\n", r, len - r);
-//     printf(" memcpy(buf+%i, self->obuf, %i) = ?\n", r, len - r);
-     memcpy(buf+r, self->obuf, len - r);
-     self->fi_rest = self->s_buf + r - len;
-     memcpy(self->i_rest, self->obuf + len - r, self->fi_rest);
-//     printf(" len=%i, r=%i, fi_rest=%i, s_buf=%i\n", len, r, self->fi_rest, self->s_buf);
-     r = len;
-//     printf("}\n");
-    }
-   }
-  }
- }
-
- ROAR_DBG("cf_celt_read(inst=%p, buf=%p, len=%i) = %i", inst, buf, len, r);
- return r;
-}
-
-#define BS (ROAR_STREAM(self->stream)->info.channels * 32)
-int cf_celt_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_celt_inst * self = (struct codecfilter_celt_inst *) inst;
- int have = 0;
- int org_len = len;
- int diff;
- int fs2 = self->frame_size * 2 * ROAR_STREAM(self->stream)->info.channels;
- int sid;
- uint16_t pkglen_net, pkglen;
- unsigned char cbits[BS+2];
- void * prethru;
-
- if ( !self->opened_encoder ) {
-  sid = ROAR_STREAM(self->stream)->id;
-
-  if ( stream_prethru_destroy(sid) == -1 ) {
-   return -1;
-  }
-
-  if ( stream_prethru_add_data(sid, &prethru, ROAR_CELT_MAGIC_LEN) == -1 ) {
-   return -1;
-  }
-
-  memcpy(prethru, ROAR_CELT_MAGIC, ROAR_CELT_MAGIC_LEN);
-
-  if ( stream_vio_s_write(self->stream, ROAR_CELT_MAGIC, ROAR_CELT_MAGIC_LEN) != ROAR_CELT_MAGIC_LEN )
-   return -1;
-  self->opened_encoder = 1;
- }
-
- if ( (self->fo_rest + len) > fs2 ) {
-  if ( self->fo_rest ) {
-   memcpy(self->obuf, self->o_rest, self->fo_rest);
-   have = self->fo_rest;
-   self->fo_rest = 0;
-  }
-
-  memcpy(self->obuf+have, buf, (diff=fs2-have));
-  buf += diff;
-  len -= diff;
-
-  pkglen     = celt_encode(self->encoder, (celt_int16_t *) self->obuf, NULL, cbits+2, BS);
-  pkglen_net = ROAR_HOST2NET16(pkglen);
-  *(uint16_t*)cbits = pkglen_net;
-
-  if ( stream_vio_s_write(self->stream, cbits, pkglen+2) == -1 )
-   return -1;
-
-  while (len >= fs2) {
-   pkglen     = celt_encode(self->encoder, (celt_int16_t *) buf, NULL, cbits+2, BS);
-   pkglen_net = ROAR_HOST2NET16(pkglen);
-   *(uint16_t*)cbits = pkglen_net;
-
-   if ( stream_vio_s_write(self->stream, cbits, pkglen+2) == -1 )
-    return -1;
-   len -= fs2;
-   buf += fs2;
-  }
- }
-
- if ( len ) {
-  memcpy(self->o_rest + self->fo_rest, buf, len);
-  self->fo_rest += len;
-  len            = 0;
- } 
-
- return org_len;
-}
-
-int cf_celt_delay(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay) {
- struct codecfilter_celt_inst * self = (struct codecfilter_celt_inst *) inst;
-
- ROAR_DBG("cf_celt_delay(*) = ?");
-
- if ( self == NULL ) {
-  *delay = (1000000 * 256) / ROAR_RATE_DEFAULT;
-  return 0;
- } else {
-  *delay = (1000000 * self->frame_size) / ROAR_STREAM(self->stream)->info.rate;
-  ROAR_DBG("cf_celt_delay(*): frame_size=%i, rate=%i, *delay=%i",
-                  self->frame_size, ROAR_STREAM(self->stream)->info.rate, *delay);
-  return 0;
- }
-
- return -1;
-}
-
-#endif
-//ll
Index: roard/codecfilter_cmd.c
===================================================================
--- roard/codecfilter_cmd.c	(revision 6052)
+++ 	(revision )
@@ -1,120 +1,0 @@
-//codecfilter_cmd.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#if defined(ROAR_HAVE_UNIX) && defined(ROAR_HAVE_BSDSOCKETS) && defined(ROAR_HAVE_IO_POSIX)
-#define _CAN_OPERATE
-#endif
-
-#if !defined(ROAR_WITHOUT_CF_CMD) && defined(_CAN_OPERATE)
-
-#define CMDMAXLEN 1024
-
-int cf_cmd_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                             struct roar_stream_server * info,
-                                             struct roar_codecfilter   * filter) {
- int socks[2];
- int execed = -1;
- char cmd[CMDMAXLEN+1] = {0};
- char * tmp = NULL;
- char   tb[CMDMAXLEN+1];
- char * o = filter->options;
- int i;
-
- if ( !o )
-  return -1;
-
- for (i = 0; i < CMDMAXLEN && *o != 0; i++, o++) {
-  if ( *o == '%' ) {
-//   printf("ol: *o='%c' (escape)\n", *o);
-   tmp = NULL;
-
-   o++;
-   if ( *o == 0 ) {
-    break;
-   } else if ( *o == 'R' ) {
-    tmp = tb;
-    snprintf(tb, CMDMAXLEN, "%i", g_sa->rate);
-   } else if ( *o == 'B' ) {
-    tmp = tb;
-    snprintf(tb, CMDMAXLEN, "%i", g_sa->bits);
-   } else if ( *o == 'C' ) {
-    tmp = tb;
-    snprintf(tb, CMDMAXLEN, "%i", g_sa->channels);
-   }
-
-//   printf("*o='%c', tmp=%p\n", *o, tmp);
-
-   if ( tmp ) {
-    for (; i < CMDMAXLEN && *tmp != 0; i++, tmp++)
-     cmd[i] = *tmp;
-    i--;
-   }
-  } else {
-//   printf("ol: *o='%c' (copy to cmd[i=%i])\n", *o, i);
-   cmd[i] = *o;
-  }
- }
-
- cmd[i+1] = 0;
-
- //printf("cmd='%s'\n", cmd);
-
- if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) {
-  return -1;
- }
-
- if ( lib_run_bg(cmd, ROAR_STREAM(info)->fh, socks[1], ROAR_STDERR, socks, 2) == -1 )
-  return -1;
-
- if ( info->client != -1 ) {
-  execed = g_clients[info->client]->execed;
-
-  if ( execed != -1 ) {
-   if ( g_streams[execed] == info ) {
-    g_clients[info->client]->fh = socks[0];
-   } else {
-    close(ROAR_STREAM(info)->fh);
-   }
-  } else {
-   close(ROAR_STREAM(info)->fh);
-  }
- } else {
-  close(ROAR_STREAM(info)->fh);
- }
-
- ROAR_STREAM(info)->fh = socks[0];
- ROAR_STREAM(info)->info.codec = ROAR_CODEC_DEFAULT;
- close(socks[1]);
-
- info->codecfilter = -1;
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_fishsound.c
===================================================================
--- roard/codecfilter_fishsound.c	(revision 6052)
+++ 	(revision )
@@ -1,251 +1,0 @@
-//codecfilter_fishsound.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBFISHSOUND
-
-int cf_fishsound_decoded_float (FishSound * fsound, float ** pcm, long frames, void * user_data) {
- struct codecfilter_fishsound_inst * self = (struct codecfilter_fishsound_inst *) user_data;
- struct roar_stream * stream = ROAR_STREAM(self->stream);
- struct roar_buffer * buf;
- int i;
- double s;
- union {
-  void    * v;
-  char    * c;
-  int16_t * i16;
-  int32_t * i32;
- } data;
-
- ROAR_DBG("cf_fishsound_decoded_float(fsound=%p, pcm=%p, frames=%li, user_data=%p) = ?", fsound, pcm, frames, user_data);
-
- ROAR_DBG("cf_fishsound_decoded_float(*): self->opened=%i", self->opened);
-
- if (!self->opened) {
-   fish_sound_command(fsound, FISH_SOUND_GET_INFO, &(self->fsinfo),
-                       sizeof(FishSoundInfo));
- }
-
- if ( roar_buffer_new_data(&buf, frames*stream->info.bits*stream->info.channels/8, &(data.v)) == -1 )
-  return -1;
-
- frames *= self->fsinfo.channels;
-
- switch (stream->info.bits) {
-  case  8:
-    for (i = 0; i < frames; i++) {
-     s  = ((float*)pcm)[i];
-     s *= 127;
-     data.c[i] = s;
-    }
-   break;
-  case 16:
-    for (i = 0; i < frames; i++) {
-     s  = ((float*)pcm)[i];
-     s *= 32767;
-     data.i16[i] = s;
-    }
-   break;
-  case 32:
-    for (i = 0; i < frames; i++) {
-     s  = ((float*)pcm)[i];
-     s *= 2147483647;
-     data.i32[i] = s;
-    }
-   break;
-  default:
-    return -1;
- }
-
- if ( self->buffer == NULL ) {
-  self->buffer = buf;
- } else {
-  if ( roar_buffer_moveinto(self->buffer, &buf) == -1 ) {
-   roar_buffer_free(buf);
-   return -1;
-  }
- }
-
- // shouldn't that be zero?
- return -1;
-}
-
-int cf_fishsound_read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data) {
- FishSound * fsound = (FishSound *)user_data;
-
- fish_sound_prepare_truncation(fsound, op->granulepos, op->e_o_s);
- fish_sound_decode(fsound, op->packet, op->bytes);
-
- return 0;
-}
-
-int cf_fishsound_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_fishsound_inst * self = roar_mm_malloc(sizeof(struct codecfilter_fishsound_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- if ( !self )
-  return -1;
-
- if ( s->dir != ROAR_DIR_PLAY ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- self->stream               = info;
- self->opened               = 0;
- self->buffer               = NULL;
- self->fsound               = fish_sound_new(FISH_SOUND_DECODE, &(self->fsinfo));
-
- fish_sound_set_interleave(self->fsound, 1);
- fish_sound_set_decoded_float_ilv(self->fsound, cf_fishsound_decoded_float, (void*)self);
-
- self->oggz = oggz_new(OGGZ_READ);
-
- oggz_set_read_callback(self->oggz, -1, cf_fishsound_read_packet, self->fsound);
-
- *inst = (CODECFILTER_USERDATA_T) self;
-
- return 0;
-}
-
-int cf_fishsound_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_fishsound_inst * self = (struct codecfilter_fishsound_inst *) inst;
-
- if ( inst == NULL )
-  return -1;
-
- oggz_close(self->oggz);
- fish_sound_delete(self->fsound);
-
- if ( self->buffer != NULL )
-  roar_buffer_free(self->buffer);
-
- roar_mm_free(inst);
- return 0;
-}
-
-int cf_fishsound_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_fishsound_inst * self = (struct codecfilter_fishsound_inst *) inst;
- struct roar_stream * s = ROAR_STREAM(self->stream);
- long inlen;
- int need_data = 0;
- struct roar_buffer_stats stats;
- size_t stlen;
-
- ROAR_DBG("cf_fishsound_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
-
-/*
- if ( self->opened ) {
-//  return stream_vio_s_read(self->stream, buf, len);
- } else {
-/-*
-  if (stream_vio_s_read(self->stream, tbuf, 44) != 44) {
-   return -1;
-  }
-*ä/
-
-  self->opened = 1;
-
-  errno = EAGAIN;
-  return -1;
- }
-*/
-
- if ( self->buffer == NULL ) {
-  need_data = 1;
- } else {
-  if ( roar_buffer_ring_stats(self->buffer, &stats) == -1 )
-   return -1;
-
-  if ( stats.bytes < len )
-   need_data = 1;
- }
-
- ROAR_DBG("cf_fishsound_read(*): need_data=%i, self->opened=%i", need_data, self->opened);
-
-// while (need_data) {
-  if ( (inlen = stream_vio_s_read(self->stream, buf, len)) == -1 ) {
-//   if ( errno != EAGAIN ) {
-    return -1;
-/*
-   } else {
-    return -1;
-   }
-*/
-  } else {
-   if ( inlen == 0 )
-    return 0;
-
-   oggz_read_input(self->oggz, (unsigned char *)buf, inlen);
-
-   if( self->buffer != NULL ) {
-    if ( roar_buffer_ring_stats(self->buffer, &stats) == -1 )
-     return -1;
-
-    if ( stats.bytes < len ) {
-     need_data = 1;
-    } else {
-     need_data = 0;
-    }
-   }
-  }
-// }
-
- ROAR_DBG("cf_fishsound_read(*): need_data=%i, self->opened=%i", need_data, self->opened);
-
- if ( need_data ) {
-  errno = EAGAIN;
-  return -1;
- }
-
- if ( !self->opened ) {
-  s->info.channels = self->fsinfo.channels;
-  s->info.rate     = self->fsinfo.samplerate;
-  s->info.bits     = g_sa->bits;
-  s->info.codec    = ROAR_CODEC_NATIVE;
-  self->opened     = 1;
-  errno            = EAGAIN;
-  ROAR_DBG("cf_fishsound_read(inst=%p, buf=%p, len=%i) = -1 // errno=EAGAIN", inst, buf, len);
-  return -1;
- }
-
- // ok, now we should have all the data we want...
-
- stlen = len;
- if ( roar_buffer_shift_out(&(self->buffer), buf, &stlen) == -1 ) {
-  ROAR_DBG("cf_fishsound_read(inst=%p, buf=%p, len=%i) = -1 // roar_buffer_shift_out() failed", inst, buf, len);
-  return -1;
- }
-
- ROAR_DBG("cf_fishsound_read(inst=%p, buf=%p, len=%i) = %i", inst, buf, len, (int)stlen);
- return stlen;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_flac.c
===================================================================
--- roard/codecfilter_flac.c	(revision 6052)
+++ 	(revision )
@@ -1,325 +1,0 @@
-//codecfilter_flac.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#include <roaraudio/units.h>
-
-#ifdef ROAR_HAVE_LIBFLAC
-
-FLAC__StreamDecoderReadStatus cf_flac_cb_read(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) {
- struct codecfilter_flac_inst * self = client_data;
- ssize_t ret;
-
- ROAR_DBG("cf_flac_cb_read(decoder=%p, buffer=%p, bytes=%p{%u}, client_data=%p) = ?", decoder, buffer, bytes, *bytes, client_data);
-
- ret = stream_vio_s_read(self->ss, buffer, *bytes);
-
- self->decoder.readret = ret;
-
- self->decoder.readc++;
-
- if (ret == -1) {
-  *bytes = 0;
-
-#ifdef EAGAIN
- if ( errno == EAGAIN ) {
-  ROAR_DBG("cf_flac_cb_read(decoder=%p, buffer=%p, bytes=%p{%u}, client_data=%p) = FLAC__STREAM_DECODER_READ_STATUS_CONTINUE", decoder, buffer, bytes, *bytes, client_data);
-  return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- }
-#endif
-
-  ROAR_DBG("cf_flac_cb_read(decoder=%p, buffer=%p, bytes=%p{%u}, client_data=%p) = FLAC__STREAM_DECODER_READ_STATUS_ABORT", decoder, buffer, bytes, *bytes, client_data);
-  return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- } else {
-  *bytes = ret;
-
-  if ( ret == 0 && self->decoder.readc == 1 ) {
-   ROAR_DBG("cf_flac_cb_read(decoder=%p, buffer=%p, bytes=%p{%u}, client_data=%p) = FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM", decoder, buffer, bytes, *bytes, client_data);
-   return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
-  }
-  ROAR_DBG("cf_flac_cb_read(decoder=%p, buffer=%p, bytes=%p{%u}, client_data=%p) = FLAC__STREAM_DECODER_READ_STATUS_CONTINUE", decoder, buffer, bytes, *bytes, client_data);
-  return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- }
-}
-
-FLAC__StreamDecoderWriteStatus cf_flac_cb_write(const FLAC__StreamDecoder * decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) {
- struct codecfilter_flac_inst * self = client_data;
- struct roar_buffer * buf;
- struct roar_interleave is;
- size_t buflen = _32BIT * frame->header.blocksize * frame->header.channels;
- void * bufdata;
- int32_t * c;
- size_t i;
- int32_t shift = 32 - frame->header.bits_per_sample;
-
- ROAR_DBG("cf_flac_cb_write(decoder=%p, frame=%p, buffer=%p, client_data=%p) = ?", decoder, frame, buffer, client_data);
-
- if ( roar_interl_init(&is, frame->header.channels, 32) == -1 ) {
-  ROAR_DBG("cf_flac_cb_write(decoder=%p, frame=%p, buffer=%p, client_data=%p) = FLAC__STREAM_DECODER_WRITE_STATUS_ABORT", decoder, frame, buffer, client_data);
-  return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
-
- if ( roar_buffer_new_data(&buf, buflen, &bufdata) == -1 ) {
-  ROAR_DBG("cf_flac_cb_write(decoder=%p, frame=%p, buffer=%p, client_data=%p) = FLAC__STREAM_DECODER_WRITE_STATUS_ABORT", decoder, frame, buffer, client_data);
-  return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
-
- roar_interl_encode_ext(&is, (void**)buffer, bufdata, buflen);
-
- roar_interl_uninit(&is);
-
- if ( shift ) {
-  buflen /= 4;
-  for (c = bufdata, i = 0; i < buflen; i++) {
-   c[i] <<= shift;
-  }
- }
-
- if ( self->decoder.written == NULL ) {
-  self->decoder.written = buf;
- } else {
-  if ( roar_buffer_moveinto(self->decoder.written, &buf) == -1 ) {
-   roar_buffer_free(buf);
-   return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
-  }
- }
-
- ROAR_DBG("cf_flac_cb_write(decoder=%p, frame=%p, buffer=%p, client_data=%p) = FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE", decoder, frame, buffer, client_data);
-
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
-}
-
-void cf_flac_cb_metadata(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) {
- struct codecfilter_flac_inst * self = client_data;
- const FLAC__StreamMetadata_VorbisComment * vc;
- FLAC__uint32 i;
- struct roar_stream_rpg rpg;
- const char * key, * value;
- char keycopy[ROAR_META_MAX_NAMELEN];
- int type;
- float rpg_track = 0, rpg_album = 0, rpg_final = 0;
-
- if ( metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT ) {
-  ROAR_DBG("cf_flac_cb_metadata(decoder=%p, metadata=%p, client_data=%p): have METADATA_TYPE_VORBIS_COMMENT", decoder, metadata, client_data);
-
-  stream_meta_clear(ROAR_STREAM(self->ss)->id);
-
-  vc = &(metadata->data.vorbis_comment);
-
-  for (i = 0; i < vc->num_comments; i++) {
-   //printf("c='%s'\n", vc->comments[i].entry);
-   key = (const char *)vc->comments[i].entry;
-   value = strstr(key, "=");
-   if ( value == NULL )
-    continue;
-
-   if ( (value - key + 1) > sizeof(keycopy) )
-    continue;
-
-   memcpy(keycopy, key, value - key);
-   keycopy[sizeof(keycopy)-1] = 0;
-   keycopy[value - key] = 0;
-
-   value++;
-
-   //printf("keycopy='%s', value='%s'\n", keycopy, value);
-
-   type = roar_meta_inttype(keycopy);
-   if ( type == -1 )
-    continue;
-
-   if ( stream_meta_add(ROAR_STREAM(self->ss)->id, type, "", value) == -1 ) {
-    ROAR_WARN("cf_flac_cb_metadata(..., client_data=%p{ROAR_STREAM(.ss)->id=%i}): Can not add meta data: %s",
-              self->ss, ROAR_STREAM(self->ss)->id, roar_error2str(roar_error));
-   }
-
-    if ( strcmp(keycopy, "REPLAYGAIN_TRACK_PEAK") == 0 ) {
-     rpg_track = 1/atof(value);
-/*
-    } else if ( strcmp(key, "REPLAYGAIN_TRACK_GAIN") == 0 ) {
-     rpg_track = powf(10, atof(value)/20);
-*/
-    } else if ( strcmp(keycopy, "REPLAYGAIN_ALBUM_PEAK") == 0 ) {
-     rpg_album = 1/atof(value);
-/*
-    } else if ( strcmp(key, "REPLAYGAIN_ALBUM_GAIN") == 0 ) {
-     rpg_album = powf(10, atof(value)/20);
-*/
-    }
-
-  }
-
- if ( streams_get_rpg(ROAR_STREAM(self->ss)->id, &rpg) != -1 ) {
-  rpg_final = 0;
-
-  switch (rpg.mode) {
-   case ROAR_RPGMODE_NONE: rpg_final =  0.; break;
-   case ROAR_RPGMODE_USER: rpg_final = -1.; break;
-   case ROAR_RPGMODE_ALBUM: rpg_final = rpg_album; break;
-   case ROAR_RPGMODE_TRACK: rpg_final = rpg_track; break;
-   case ROAR_RPGMODE_ALBUMTRACK: rpg_final = rpg_album ? rpg_album : rpg_track; break;
-   case ROAR_RPGMODE_TRACKALBUM: rpg_final = rpg_track ? rpg_track : rpg_album; break;
-  }
-
-  if ( rpg_final > 0 ) {
-   self->ss->mixer.rpg_div = 2718;
-   self->ss->mixer.rpg_mul = (float)rpg_final*2718;
-  } else if ( !rpg_final ) {
-   self->ss->mixer.rpg_div = 1;
-   self->ss->mixer.rpg_mul = 1;
-  }
- }
-
-  stream_meta_finalize(ROAR_STREAM(self->ss)->id);
- }
-
- ROAR_DBG("cf_flac_cb_metadata(decoder=%p, metadata=%p, client_data=%p) = (void)", decoder, metadata, client_data);
-}
-
-void cf_flac_cb_error(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) {
- ROAR_DBG("cf_flac_cb_error(decoder=%p, status=%i, client_data=%p) = (void)", decoder, (int)status, client_data);
-}
-
-int cf_flac_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_flac_inst * self;
-
- if ( ROAR_STREAM(info)->dir != ROAR_DIR_PLAY )
-  return -1;
-
- self = roar_mm_malloc(sizeof(struct codecfilter_flac_inst));
-
- if (self == NULL)
-  return -1;
-
- memset(self, 0, sizeof(struct codecfilter_flac_inst));
-
- self->ss = info;
-
- self->decoder.decoder = FLAC__stream_decoder_new();
-
- if ( self->decoder.decoder == NULL ) {
-  roar_mm_free(self);
-  return -1;
- }
-
-#ifndef ROAR_HAVE_FLAC_VERSION_1_2_1
- FLAC__stream_decoder_set_read_callback(self->decoder.decoder, cf_flac_cb_read);
- FLAC__stream_decoder_set_write_callback(self->decoder.decoder, cf_flac_cb_write);
- FLAC__stream_decoder_set_metadata_callback(self->decoder.decoder, cf_flac_cb_metadata);
- FLAC__stream_decoder_set_error_callback(self->decoder.decoder, cf_flac_cb_error);
- FLAC__stream_decoder_set_client_data(self->decoder.decoder, self);
-#endif
-
- FLAC__stream_decoder_set_metadata_respond(self->decoder.decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
-#ifdef ROAR_HAVE_FLAC_VERSION_1_2_1
- FLAC__stream_decoder_init_stream(self->decoder.decoder, cf_flac_cb_read, NULL, NULL, NULL, NULL, cf_flac_cb_write, cf_flac_cb_metadata, cf_flac_cb_error, self);
-#else
- FLAC__stream_decoder_init(self->decoder.decoder);
-#endif
-
- *inst = self;
-
- return 0;
-}
-
-int cf_flac_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_flac_inst * self = inst;
-
- if ( self->decoder.decoder != NULL ) {
-  FLAC__stream_decoder_delete(self->decoder.decoder);
- }
-
- roar_mm_free(self);
-
- return 0;
-}
-
-int cf_flac_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_flac_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_flac_inst * self = inst;
- struct roar_audio_info * info = &(ROAR_STREAM(self->ss)->info);
- struct roar_buffer_stats stats;
- size_t ret;
- FLAC__StreamDecoderState state;
-
- if ( self->decoder.written == NULL ) {
-  stats.bytes = 0;
- } else {
-  if ( roar_buffer_ring_stats(self->decoder.written, &stats) == -1 )
-   return -1;
- }
-
- self->decoder.readret = 1;
- self->decoder.readc   = 0;
-
- while ( self->decoder.readret > 0 && stats.bytes < len ) {
-  if ( !FLAC__stream_decoder_process_single(self->decoder.decoder) ) {
-   break;
-  }
-
-  state = FLAC__stream_decoder_get_state(self->decoder.decoder);
-
-  if ( state == FLAC__STREAM_DECODER_END_OF_STREAM || state == FLAC__STREAM_DECODER_ABORTED )
-   break;
-
-  if ( self->decoder.written == NULL && state == FLAC__STREAM_DECODER_READ_FRAME ) {
-   return -1;
-  }
-
-  if ( self->decoder.written == NULL ) {
-   stats.bytes = 0;
-  } else {
-   if ( roar_buffer_ring_stats(self->decoder.written, &stats) == -1 )
-    return -1;
-  }
- }
-
- if ( stats.bytes ) {
-  ret = len;
-
-  if ( roar_buffer_shift_out(&(self->decoder.written), buf, &ret) == -1 ) {
-   return -1;
-  }
-
-  info->codec    = ROAR_CODEC_DEFAULT;
-  info->bits     = 32;
-  info->channels = FLAC__stream_decoder_get_channels(self->decoder.decoder);
-  info->rate     = FLAC__stream_decoder_get_sample_rate(self->decoder.decoder);
-
-  return ret;
- } else {
-  return self->decoder.readret == -1 ? -1 : 0;
- }
-}
-
-int cf_flac_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-
-//ll
Index: roard/codecfilter_mulaw.c
===================================================================
--- roard/codecfilter_mulaw.c	(revision 6052)
+++ 	(revision )
@@ -1,97 +1,0 @@
-//codecfilter_mulaw.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-/* ckport options:
- * ckport: ignore-symbol: roardsp_conv_pcm162mulaw of target libroardsp0
- * ckport: ignore-symbol: roardsp_conv_mulaw2pcm16 of target libroardsp0
- */
-
-#include "roard.h"
-
-#ifdef ROAR_SUPPORT_MULAW
-
-int cf_mulaw_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct roar_stream * s = ROAR_STREAM(info);
-
- (void)codec, (void)filter;
-
- *inst = (CODECFILTER_USERDATA_T) info;
-
- s->info.bits  = 16;
- s->info.codec = ROAR_CODEC_DEFAULT;
-
- return 0;
-}
-
-int cf_mulaw_close(CODECFILTER_USERDATA_T   inst) {
- (void)inst;
- return 0;
-}
-
-int cf_mulaw_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct roar_stream_server * s = ROAR_STREAM_SERVER(inst);
-
- if ( (len = stream_vio_s_read(s, buf, len/2)) < 1 ) {
-  return len;
- }
-
- roardsp_conv_mulaw2pcm16((int16_t *)buf, buf, len);
-
- return len*2;
-}
-
-#ifdef ROAR_SUPPORT_MULAW_RW
-int cf_mulaw_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct roar_stream_server * s = ROAR_STREAM_SERVER(inst);
- char * out;
-
- // TODO: add a more effect way to use memory than allways alloc/freeing it.
- //       maybe by keeping a buffer over instanzes or by using ca global buffer
- //       with an refrenze counter so we can free it on last use
-
- len /= 2;
-
- if ( (out = (char*)roar_mm_malloc(len)) == NULL )
-  return -1;
-
- roardsp_conv_pcm162mulaw(out, (int16_t*)buf, len);
-
- len = stream_vio_s_write(s, out, len);
-
- roar_mm_free(out);
-
- if ( len > 0 ) {
-  return len*2;
- } else {
-  return -1;
- }
-}
-#endif
-
-#endif
-
-//ll
Index: roard/codecfilter_raum.c
===================================================================
--- roard/codecfilter_raum.c	(revision 6052)
+++ 	(revision )
@@ -1,151 +1,0 @@
-//codecfilter_raum.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBRAUM
-#include <raum.h>
-
-// PCBs:
-int cf_raum_pcb_open  (struct cont_fw_parent_inst * self,
-                       int                          codec,
-                       struct roar_stream_server  * stream,
-                       struct roar_codecfilter    * filter) {
- struct roar_stream * s = ROAR_STREAM(stream);
- RAUMState * state;
- int flags = 0;
-
- ROAR_DBG("cf_raum_pcb_open(*) = ?");
-
- if ( stream == NULL )
-  return -1;
-
- switch (s->dir) {
-  case ROAR_DIR_COMPLEX_IN:
-  case ROAR_DIR_PLAY:
-    flags = O_RDONLY;
-   break;
-  case ROAR_DIR_COMPLEX_OUT:
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_OUTPUT:
-    flags = O_WRONLY;
-   break;
-  default:
-    return -1;
- }
-
- state = RAUMOpenVIO(&(self->vio), flags);
-
- if ( state == NULL )
-  return -1;
-
- cont_fw_set_uinst(self, state);
-
- ROAR_DBG("cf_raum_pcb_open(*) = 0");
- return 0;
-}
-
-int cf_raum_pcb_close (struct cont_fw_parent_inst * self) {
- void * state;
-
- ROAR_DBG("cf_raum_pcb_close(*) = ?");
-
- if ( cont_fw_get_uinst(self, &state) == -1 )
-  return -1;
-
- ROAR_DBG("cf_raum_pcb_close(*) = ?");
- return RAUMClose(state);
-}
-
-int cf_raum_pcb_new_child(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- void                      * ps;
- RAUMStream * stream;
- int dir = ROAR_DIR_PLAY;
-
- ROAR_DBG("cf_raum_pcb_new_child(self=%p, child=%p) = ?", self, child);
-
- if ( streams_get(child->child, &ss) == -1 )
-  return -1;
-
- if ( (s = ROAR_STREAM(ss)) == NULL )
-  return -1;
-
- if ( cont_fw_get_uinst(self, &ps) == -1 )
-  return -1;
-
- if ( ps == NULL )
-  return -1;
-
- if ( (stream = RAUMStreamNewSimple(s->info.rate, s->info.channels, s->info.bits, s->info.codec, dir)) == NULL )
-  return -1;
-
- if ( RAUMAddStream(ps, stream) == -1 ) {
-  RAUMStreamClose(stream);
-  return -1;
- }
-
- child->u_inst = stream;
-
- ROAR_DBG("cf_raum_pcb_new_child(self=%p, child=%p) = 0", self, child);
- return 0;
-}
-
-// CCBs:
-ssize_t cf_raum_ccb_read (struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len) {
- ROAR_DBG("cf_raum_ccb_read(self=%p, child=%p, buf=%p, len=%lu) = ?", self, child, buf, (unsigned long)len);
- return RAUMStreamRead(child->u_inst, buf, len);
-}
-ssize_t cf_raum_ccb_write(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len) {
- ROAR_DBG("cf_raum_ccb_write(self=%p, child=%p, buf=%p, len=%lu) = ?", self, child, buf, (unsigned long)len);
- return RAUMStreamWrite(child->u_inst, buf, len);
-}
-int     cf_raum_ccb_close(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child) {
- ROAR_DBG("cf_raum_ccb_close(self=%p, child=%p) = ?", self, child);
- return RAUMStreamClose(child->u_inst);
-}
-
-// SETUP:
-CONT_FW_SETUP_TYPE(cf_raum_setup) {
- ROAR_DBG("cf_raum_setup(*) = ?");
-
- // PCBs:
- self->pcb.open      = cf_raum_pcb_open;
- self->pcb.close     = cf_raum_pcb_close;
- self->pcb.new_child = cf_raum_pcb_new_child;
-
- // CCBs:
- self->ccb.read      = cf_raum_ccb_read;
- self->ccb.write     = cf_raum_ccb_write;
- self->ccb.close     = cf_raum_ccb_close;
-
- ROAR_DBG("cf_raum_setup(*) = 0");
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_roardmx.c
===================================================================
--- roard/codecfilter_roardmx.c	(revision 6052)
+++ 	(revision )
@@ -1,196 +1,0 @@
-//codecfilter_roardmx.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-
-static inline int __read_sset(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) {
- uint16_t channel;
- uint8_t value;
- int i, c;
-
- // we ignore errors here at the moment as 0 not < -1
- c = roar_roardmx_message_numchannels(mes);
- ROAR_DBG("light_check_stream(id=%i): Number of subframes: %u", id, c);
-
- for (i = 0; i < c; i++) {
-  if ( roar_roardmx_message_get_chanval(mes, &channel, &value, i) == -1 )
-   return -1;
-
-  if ( g_light_state.channels < channel ) {
-   ROAR_WARN("light_check_stream(id=%i): Writing on non extisting DMX channel %u", id, channel);
-   continue;
-  } else {
-   g_light_state.state[channel]   = value;
-   g_light_state.changes[channel] = 0xFF; // the channel changed
-  }
- }
-
- return 0;
-}
-
-static inline int __read_rangeset(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) {
- uint16_t start, end;
- uint8_t value;
- size_t p;
- int i, c;
-
- // we ignore errors here at the moment as 0 not < -1
- c = roar_roardmx_message_numchannels(mes);
- ROAR_DBG("__read_rangeset(id=%i, ...): Number of subframes: %u", id, c);
-
- for (i = 0; i < c; i++) {
-  ROAR_DBG("__read_rangeset(id=%i, ...): i=%i", id, i);
-
-  if ( roar_roardmx_message_get_rangeval(mes, &start, &end, &value, i) == -1 ) {
-   ROAR_WARN("__read_rangeset(id=%i, ...): Can not read subframe: %i: %s", id, i, roar_errorstring);
-   return -1;
-  }
-
-  ROAR_DBG("__read_rangeset(id=%i, ...): i=%i, start=%u, end=%u, value=%u", id, i, start, end, value);
-
-  if ( start > end ) {
-   ROAR_WARN("__read_rangeset(id=%i, ...): Bad RoarDMX Rangeset frame: start > end.", id);
-   continue;
-  }
-
-  if ( g_light_state.channels < end ) {
-   ROAR_WARN("__read_rangeset(id=%i, ...): Range out of DMX universe: %u-%u", id, start, end);
-   continue;
-  }
-
-  for (p = start; p <= end; p++) {
-   g_light_state.state[p]   = value;
-   g_light_state.changes[p] = 0xFF; // the channel changed 
-  }
- }
-
- return 0;
-}
-
-static inline int __read_events(int id, struct roar_stream_server * ss, struct roar_roardmx_message * mes) {
- const uint8_t * events;
- size_t len;
-
- (void)id, (void)ss;
-
- if ( roar_roardmx_message_get_events(mes, &events, &len) == -1 )
-  return -1;
-
- return light_dmxevent_add(events, len);
-}
-
-int cf_light_roardmx_read(int id, struct roar_stream_server * ss) {
- struct roar_roardmx_message  mes;
- unsigned char type;
-
- if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 )
-  return -1;
-
- if ( roar_roardmx_message_get_type(&mes, &type) == -1 )
-  return -1;
-
- switch (type) {
-  case ROAR_ROARDMX_TYPE_SSET: return __read_sset(id, ss, &mes); break;
-  case ROAR_ROARDMX_TYPE_RANGESET: return __read_rangeset(id, ss, &mes); break;
-  case ROAR_ROARDMX_TYPE_EVENT: return __read_events(id, ss, &mes); break;
- }
-
- roar_err_set(ROAR_ERROR_NSTYPE);
- return -1;
-}
-
-static inline int __write_events(int id, struct roar_stream_server * ss) {
- struct roar_roardmx_message  mes;
- const uint8_t * events;
- size_t len;
-
- if ( light_dmxevent_read(&events, &len) == -1 )
-  return -1;
-
- // check if we need to send events at all:
- if ( len == 0 )
-  return 0;
-
- // ok, now let's build the message:
- if ( roar_roardmx_message_new_event(&mes) == -1 )
-  return -1;
-
- if ( roar_roardmx_message_add_events(&mes, events, len) == -1 )
-  return -1;
-
- // and send it:
- if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 )
-  return -1;
-
- return 0;
-}
-
-static inline int __write_channels(int id, struct roar_stream_server * ss) {
- struct roar_roardmx_message  mes;
- int have_message = 0;
- int i;
-
- for (i = 0; i < g_light_state.channels; i++) {
-  if ( g_light_state.outputchanges[i] ) {
-   if ( !have_message )
-    if ( roar_roardmx_message_new_sset(&mes) == -1 )
-     return -1;
-
-   have_message = 2;
-
-   if ( roar_roardmx_message_add_chanval(&mes, i, g_light_state.output[i]) == -1 ) {
-    if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 )
-     return -1;
-
-    if ( roar_roardmx_message_new_sset(&mes) == -1 )
-     return -1;
-
-    have_message = 1;
-   }
-  }
- }
-
- if ( have_message == 2 )
-  if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 )
-   return -1;
-
- return 0;
-}
-
-int cf_light_roardmx_write(int id, struct roar_stream_server * ss) {
- if ( __write_events(id, ss) == -1 )
-  return -1;
-
- if ( __write_channels(id, ss) == -1 )
-  return -1;
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_sndfile.c
===================================================================
--- roard/codecfilter_sndfile.c	(revision 6052)
+++ 	(revision )
@@ -1,181 +1,0 @@
-//codecfilter_sndfile.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBSNDFILE
-
-int cf_sndfile_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_sndfile_inst * obj;
-
- (void)codec, (void)filter;
-
- if ( (obj = (struct codecfilter_sndfile_inst *) roar_mm_malloc(sizeof(struct codecfilter_sndfile_inst))) == NULL )
-  return -1;
-
- memset(obj, 0, sizeof(struct codecfilter_sndfile_inst));
-
- obj->stream = info;
-
- ROAR_STREAM(info)->info.codec = ROAR_CODEC_DEFAULT;
-
- *inst = (CODECFILTER_USERDATA_T) obj;
-
-/*
- s->info.bits  = 16;
- s->info.codec = ROAR_CODEC_DEFAULT;
-*/
-
- ROAR_WARN("cf_sndfile_open(*) = 0");
-
- return 0;
-}
-
-int cf_sndfile_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_sndfile_inst * obj = (struct codecfilter_sndfile_inst *) inst;
-
- if ( obj->state != NULL )
-  sf_close(obj->state);
-
- roar_mm_free(obj);
-
- return 0;
-}
-
-int cf_sndfile_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_sndfile_inst * obj = (struct codecfilter_sndfile_inst *) inst;
- struct roar_stream * s = ROAR_STREAM(obj->stream);
- int ret;
-
- if ( obj->opened ) {
-  len /= obj->bytes;
-
-  if ( obj->bytes == 2 ) {
-   if ( (ret = sf_read_short(obj->state, (short*)buf, len)) == -1 )
-    return -1;
-  } else if ( obj->bytes == 4 ) {
-   if ( (ret = sf_read_int(obj->state, (int*)buf, len)) == -1 )
-    return -1;
-  } else {
-   errno = ENOSYS;
-   return -1;
-  }
-
-  return ret * obj->bytes;
- } else {
-  if ( (obj->state = sf_open_fd(s->fh, SFM_READ, &(obj->info), 0)) == NULL ) {
-   ROAR_ERR("cf_sndfile_read(*): can not sf_open_fd(*)!");
-   return -1;
-  }
-  ROAR_WARN("cf_sndfile_read(*): obj->info={.format=0x%.8x, .samplerate=%i, .channels=%i}", obj->info.format, obj->info.samplerate, obj->info.channels);
-
-  s->info.codec    = ROAR_CODEC_DEFAULT;
-  s->info.rate     = obj->info.samplerate;
-  s->info.channels = obj->info.channels;
-
-  obj->bytes       = 2;
-  if ( (obj->info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_24 ||
-       (obj->info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_32   ) {
-   obj->bytes      = 4;
-  }
-
-  s->info.bits     = obj->bytes * 8;
-
-  obj->opened      = 1;
-  errno = EAGAIN;
- }
-
- return -1;
-}
-
-int cf_sndfile_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_sndfile_inst * obj = (struct codecfilter_sndfile_inst *) inst;
- struct roar_stream * s = ROAR_STREAM(obj->stream);
- int ret;
-
- ROAR_WARN("cf_sndfile_write(*): obj->opened=%i", obj->opened);
-
- if ( !obj->opened ) {
-  if ( s->fh == -1 ) {
-   errno = EAGAIN;
-   return -1;
-  }
-
-  switch (s->info.codec) {
-   case ROAR_CODEC_PCM_S_LE:
-   case ROAR_CODEC_PCM_S_BE:
-     switch (s->info.bits) {
-      case  8:
-        obj->info.format = SF_FORMAT_PCM_S8;
-       break;
-      case 16:
-        obj->info.format = SF_FORMAT_PCM_16;
-       break;
-      case 24:
-        obj->info.format = SF_FORMAT_PCM_24;
-       break;
-      case 32:
-        obj->info.format = SF_FORMAT_PCM_32;
-       break;
-     }
-     //obj->info.format |= s->info.codec == ROAR_CODEC_PCM_S_LE ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG;
-     obj->info.format |= SF_ENDIAN_FILE;
-     obj->info.format |= SF_FORMAT_WAV;
-    break;
-   default:
-     ROAR_ERR("cf_sndfile_write(*): codec(%s) not supported!", roar_codec2str(s->info.bits));
-     return -1;
-    break;
-  }
-
-  obj->info.samplerate = s->info.rate;
-  obj->info.channels   = s->info.channels;
-  obj->info.sections   = 1;
-  obj->info.frames     = 182592; // 2147483647;
-  obj->info.seekable   = 1;
-  obj->info.format     = 0x00010002;
-
-  if ( (obj->state = sf_open_fd(s->fh, SFM_WRITE, &(obj->info), 0)) == NULL ) {
-   ROAR_ERR("cf_sndfile_write(*): can not sf_open_fd(*)!");
-   ROAR_ERR("cf_sndfile_write(*): s->fh=%i", s->fh);
-   ROAR_ERR("cf_sndfile_write(*): obj->info={.format=0x%.8x, .samplerate=%i, .channels=%i}", obj->info.format, obj->info.samplerate, obj->info.channels);
-   return -1;
-  }
-
-  obj->opened = 1;
-//  errno = EAGAIN;
- }
-
- ROAR_WARN("cf_sndfile_write(*): obj->opened=%i", obj->opened);
- ret = sf_write_raw(obj->state, (void*) buf, len);
- ROAR_WARN("cf_sndfile_write(inst=%p, buf=%p, len=%i) = %i", inst, buf, len, ret);
- return ret;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_speex.c
===================================================================
--- roard/codecfilter_speex.c	(revision 6052)
+++ 	(revision )
@@ -1,418 +1,0 @@
-//codecfilter_speex.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#ifdef ROAR_HAVE_LIBSPEEX
-
-/*
- Format:
- (all numbers are in network byte order)
-
- MAGIC of site MAGIC_LEN
- MODE NUMMBER of size 2 Byte
- { // frames
-   FRAME LENGTH of size 2 Byte
-   FRAME DATA of size FRAME LENGTH Byte
- }
-*/
-
-#define _FS (_16BIT * (self->stereo ? 2 : 1))
-
-#define _HAVE_CCFG(x) (self->codec_config != NULL && (self->codec_config->para_set & (x)))
-
-int cf_speex_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_speex_inst * self = roar_mm_malloc(sizeof(struct codecfilter_speex_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- *inst = NULL;
-
- if (!self)
-  return -1;
-
- s->info.codec    = ROAR_CODEC_DEFAULT;
- s->info.bits     = 16; // speex hardcoded
-
- switch (s->info.channels) {
-  case 1: self->stereo = 0; break;
-  case 2: self->stereo = 1; break;
-  default:
-    roar_mm_free(self);
-    return -1;
- }
-
- // do as much to preper the startup of stereo encoder as possible
- if ( self->stereo ) {
-  self->stereo_callback.callback_id = SPEEX_INBAND_STEREO;
-  self->stereo_callback.func        = speex_std_stereo_request_handler;
-  self->stereo_callback.data       = &(self->stereo_state);
- }
-
- self->encoder = NULL;
- self->decoder = NULL;
-
- self->stream  = info;
-
- self->cd      = NULL;
-
- self->i_rest  = NULL;
- self->fi_rest = 0;
- self->o_rest  = NULL;
- self->fo_rest = 0;
-
- self->codec_config = roar_libroar_config_codec_get(ROAR_CODEC_ROAR_SPEEX, 0);
-
- speex_bits_init(&(self->bits));
-
- *inst = (void*) self;
-
- return 0;
-}
-
-int cf_speex_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_speex_inst * self = (struct codecfilter_speex_inst *) inst;
-
- if (!self)
-  return -1;
-
- if ( self->encoder )
-  speex_encoder_destroy(self->encoder);
-
- self->encoder = NULL;
-
- if ( self->decoder )
-  speex_decoder_destroy(self->decoder);
-
- self->decoder = NULL;
-
- speex_bits_destroy(&(self->bits));
-
- if ( self->cd != NULL )
-  roar_mm_free(self->cd);
-
- if ( self->i_rest != NULL )
-  roar_mm_free(self->i_rest);
-
- roar_mm_free((void*)self);
-
- return 0;
-}
-
-int cf_speex_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_speex_inst * self = (struct codecfilter_speex_inst *) inst;
- int mode;
- uint16_t ui;
- int tmp;
- int still_todo = len / _FS;
- int ret = 0;
- int fs2; // = self->frame_size * _16BIT * channels;
- char magic[ROAR_SPEEX_MAGIC_LEN];
- SpeexStereoState stereo = SPEEX_STEREO_STATE_INIT;
-
- ROAR_DBG("cf_speex_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
-
- if ( ! self->decoder ) {
-  ROAR_DBG("cf_speex_read(*): no decoder, starting one!");
-
-  if ( stream_vio_s_read(self->stream, magic, ROAR_SPEEX_MAGIC_LEN) != ROAR_SPEEX_MAGIC_LEN )
-   return 0;
-
-  if ( memcmp(magic, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN) != 0 )
-   return -1;
-
-  if ( stream_vio_s_read(self->stream, &ui, 2) != 2 )
-   return 0;
-
-  mode = ROAR_NET2HOST16(ui);
-
-  switch (mode) {
-   case ROAR_SPEEX_MODE_NB:  self->decoder = speex_decoder_init(&speex_nb_mode);  break;
-   case ROAR_SPEEX_MODE_WB:  self->decoder = speex_decoder_init(&speex_wb_mode);  break;
-   case ROAR_SPEEX_MODE_UWB: self->decoder = speex_decoder_init(&speex_uwb_mode); break;
-   default: return 0;
-  }
-
-  tmp=1;
-  speex_decoder_ctl(self->decoder, SPEEX_SET_ENH, &tmp);
-
-  if ( self->stereo ) {
-   memcpy(&(self->stereo_state), &stereo, sizeof(self->stereo_state));
-   speex_decoder_ctl(self->decoder, SPEEX_SET_HANDLER, &(self->stereo_callback));
-  }
-
-
-  speex_decoder_ctl(self->decoder, SPEEX_GET_FRAME_SIZE, &(self->frame_size));
-
-  fs2 = self->frame_size * _FS;
-
-  ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2);
-
-  if ( self->cd == NULL ) {
-   self->cd = roar_mm_malloc(fs2);
-   if ( self->cd == NULL )
-    return 0;
-  }
-
-  if ( self->i_rest == NULL ) {
-   self->i_rest = roar_mm_malloc(fs2);
-   if ( self->i_rest == NULL )
-    return 0;
-  }
- }
- fs2 = self->frame_size * _FS;
-
- ROAR_DBG("cf_speex_read(*): Have a working decoder!");
-
- ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2);
- ROAR_DBG("cf_speex_read(*): i_rest is %i bytes after cd", ((void*)self->i_rest - (void*)self->cd));
-
-
- if ( self->fi_rest ) {
-  if ( self->fi_rest > (still_todo*_FS) ) {
-   ROAR_DBG("cf_speex_read(*): using data from input rest buffer: len=%i (no need to read new data)", self->fi_rest);
-   still_todo *= _FS; // we will set this to zero one way or another,
-                         // so we don't need to care about soring a 'wrong' value here.
-   memcpy(buf, self->i_rest, still_todo);
-   memmove(self->i_rest, self->i_rest + still_todo, self->fi_rest - still_todo);
-   self->fi_rest -= still_todo;
-   ret += still_todo;
-   still_todo = 0;
-  } else {
-   ROAR_DBG("cf_speex_read(*): using data from input rest buffer: len=%i", self->fi_rest);
-   memcpy(buf, self->i_rest, self->fi_rest);
-   buf += self->fi_rest;
-   still_todo -= self->fi_rest/_FS;
-   ret += self->fi_rest;
-   self->fi_rest = 0;
-  }
- }
-
- while (still_todo) {
-  ROAR_DBG("cf_speex_read(*): we sill need %i frames", still_todo);
-  if ( stream_vio_s_read(self->stream, &ui, 2) != 2 )
-   return -1;
-
-  ui = ROAR_NET2HOST16(ui);
-
-  if ( ui > ROAR_SPEEX_MAX_CC )
-   return 0;
-
-  if ( stream_vio_s_read(self->stream, self->cc, ui) != ui )
-   break;
-
-  speex_bits_read_from(&(self->bits), self->cc, ui);
-
-  speex_decode_int(self->decoder, &(self->bits), self->cd);
-
-  if ( self->stereo) {
-   speex_decode_stereo_int(self->cd, self->frame_size, &(self->stereo_state));
-  }
-
-  if ( self->frame_size > still_todo ) {
-   memcpy(buf, self->cd, still_todo*_FS);
-   ret += still_todo*_FS;
-   self->fi_rest = (self->frame_size - still_todo)*_FS;
-   ROAR_DBG("cf_speex_read(*): self->fi_rest=%i, off=%i", self->fi_rest, still_todo*_FS);
-   memcpy(self->i_rest, (self->cd)+(still_todo*_FS), self->fi_rest);
-   still_todo = 0;
-  } else {
-   memcpy(buf, self->cd, fs2);
-   buf        += fs2;
-   ret        += fs2;
-   still_todo -= self->frame_size;
-  }
- }
-
- if ( still_todo ) {
-  ROAR_DBG("cf_speex_read(*): could not read all reqquested data, returning %i byte less", still_todo*_FS);
- }
-
- ROAR_DBG("cf_speex_read(*) = %i", ret);
-
- return ret;
-}
-
-int cf_speex_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_speex_inst * self = (struct codecfilter_speex_inst *) inst;
- uint16_t mode = ROAR_SPEEX_MODE_UWB;
- int tmp;
- int fs2;
- int ret = 0;
- int need_extra;
- int sid;
- void * prethru;
-
-/*
- TODO: Befor this realy works there must be a working way to set the number of channels and bits
-       for monetoring clients. Else this will produce some thing stange as a 'mono' file that realy
-       contains stereo.
-*/
-
- ROAR_DBG("cf_speex_write(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
-
- if ( ! self->encoder ) {
-  sid = ROAR_STREAM(self->stream)->id;
-
-  if ( stream_prethru_destroy(sid) == -1 ) {
-   return -1;
-  }
-
-  if ( stream_prethru_add_data(sid, &prethru, ROAR_SPEEX_MAGIC_LEN) == -1 ) {
-   return -1;
-  }
-
-  memcpy(prethru, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN);
-
-  if ( stream_vio_s_write(self->stream, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN) != ROAR_SPEEX_MAGIC_LEN )
-   return -1;
-
-  switch (mode) {
-   case ROAR_SPEEX_MODE_NB:  self->encoder = speex_encoder_init(&speex_nb_mode);  break;
-   case ROAR_SPEEX_MODE_WB:  self->encoder = speex_encoder_init(&speex_wb_mode);  break;
-   case ROAR_SPEEX_MODE_UWB: self->encoder = speex_encoder_init(&speex_uwb_mode); break;
-   default: return -1;
-  }
-
-  mode = ROAR_HOST2NET16(mode);
-
-  if ( stream_prethru_add_data(sid, &prethru, 2) == -1 ) {
-   return -1;
-  }
-
-  *(uint16_t*)prethru = mode;
-
-  if ( stream_vio_s_write(self->stream, &mode, 2) != 2 )
-   return -1;
-
-  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_COMPLEXITY) ) {
-   tmp = self->codec_config->complexity / 256;
-  } else {
-   tmp = 8;
-  }
-  speex_encoder_ctl(self->encoder, SPEEX_SET_COMPLEXITY,    &tmp);
-
-  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_Q) ) {
-   tmp = self->codec_config->q / 256;
-   speex_encoder_ctl(self->encoder, SPEEX_SET_QUALITY,      &tmp);
-  }
-
-  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_VBR) ) {
-   tmp = self->codec_config->vbr ? 1 : 0;
-   speex_encoder_ctl(self->encoder, SPEEX_SET_VBR,          &tmp);
-  }
-
-  if ( _HAVE_CCFG(ROAR_LIBROAR_CONFIG_PSET_DTX) ) {
-   tmp = self->codec_config->dtx ? 1 : 0;
-   speex_encoder_ctl(self->encoder, SPEEX_SET_DTX,          &tmp);
-  }
-
-  speex_encoder_ctl(self->encoder, SPEEX_GET_FRAME_SIZE, &(self->frame_size));
-
-  fs2 = self->frame_size * _FS;
-
-  if ( self->cd == NULL ) {
-   self->cd = roar_mm_malloc(fs2 + 2);
-   if ( self->cd == NULL )
-    return 0;
-  }
-
-  if ( self->o_rest == NULL ) {
-   self->o_rest = roar_mm_malloc(fs2);
-   if ( self->o_rest == NULL )
-    return 0;
-  }
- }
-
- fs2 = self->frame_size * _FS;
-
- if ( self->fo_rest ) { // ignore the rest for the moment
-  if ( (self->fo_rest + len) > fs2 ) {
-   need_extra = fs2 - self->fo_rest;
-   memcpy(self->o_rest + self->fo_rest, buf, need_extra);
-
-   speex_bits_reset(&(self->bits));
-
-   if ( self->stereo )
-    speex_encode_stereo_int((spx_int16_t *) self->o_rest, self->frame_size, &(self->bits));
-
-   speex_encode_int(self->encoder, (spx_int16_t *) self->o_rest, &(self->bits));
-
-   tmp = mode = speex_bits_write(&(self->bits), self->cd + 2, fs2);
-
-   mode = ROAR_HOST2NET16(mode);
-   *(uint16_t*)(self->cd) = mode;
-   if ( stream_vio_s_write(self->stream, self->cd, tmp + 2) != (tmp + 2) )
-    return -1;
-
-   buf += need_extra;
-   ret += need_extra;
-   len -= need_extra;
-   self->fo_rest = 0;
-  } else { // just add the data to o_rest
-   memcpy(self->o_rest + self->fo_rest, buf, len);
-   self->fo_rest += len;
-   return len;
-  }
- }
-
- // TODO: do we realy need such a loop?
- while (len > fs2) {
-//  ROAR_WARN("cf_speex_write(*): Discarding a full block of data as non-o_rest encoding is not supported!");
-//  ROAR_WARN("cf_speex_write(*): Block info: len=%i, fs2=%i", len, fs2);
-
-  speex_bits_reset(&(self->bits));
-
-  if ( self->stereo )
-   speex_encode_stereo_int((spx_int16_t *) buf, self->frame_size, &(self->bits));
-
-  speex_encode_int(self->encoder, (spx_int16_t *) buf, &(self->bits));
-
-  tmp = mode = speex_bits_write(&(self->bits), self->cd + 2, fs2);
-
-  mode = ROAR_HOST2NET16(mode);
-
-  *(uint16_t*)(self->cd) = mode;
-
-  if ( stream_vio_s_write(self->stream, self->cd, tmp + 2) != (tmp + 2) )
-   return -1;
-
-  len -= fs2;
-  buf += fs2;
-  ret += fs2;
- }
-
- if ( len ) { // we still have some data, add this to o_rest
-  memcpy(self->o_rest, buf, len);
-  self->fo_rest = len;
-  ret += len;
- }
-
- return ret;
-}
-
-#endif
-
-//ll
Index: roard/codecfilter_uniraum.c
===================================================================
--- roard/codecfilter_uniraum.c	(revision 6052)
+++ 	(revision )
@@ -1,719 +1,0 @@
-//codecfilter_wave.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBUNIRAUM
-
-#include <uniraum/uniraum.h>
-
-#define MAX_STREAMS 4
-
-struct codecfilter_uniraum_inst; 
-
-struct codecfilter_uniraum_inst_stream {
- size_t refc;
- struct codecfilter_uniraum_inst * parent;
- struct roar_stream_server * ss;
- int stream;
- uniraum_stream_t * uniraumstream;
- uniraum_mapping_t * uniraummapping;
- uniraum_data_t * dataqueue;
-};
-
-struct codecfilter_uniraum_inst {
- size_t refc;
- struct roar_stream_server * ss;
- struct roar_vio_calls vio;
- uniraum_file_t * file;
- struct codecfilter_uniraum_inst_stream stream[MAX_STREAMS];
- size_t streams;
- int got_eof;
- int is_execed;
-};
-
-static inline void __stream_ref(struct codecfilter_uniraum_inst_stream * self);
-static inline void __stream_unref(struct codecfilter_uniraum_inst_stream * self);
-static inline int __read_more_data(struct codecfilter_uniraum_inst * self, int stream);
-static inline void __stream_pushdata(struct codecfilter_uniraum_inst_stream * self);
-static inline void __stream_setup_vio(struct codecfilter_uniraum_inst_stream * self);
-
-static inline void __inst_ref(struct codecfilter_uniraum_inst * self) {
- self->refc++;
-}
-
-static inline void __inst_unref(struct codecfilter_uniraum_inst * self) {
- self->refc--;
- if ( self->refc )
-  return;
- uniraum_unref(self->file);
- self->file = NULL;
- roar_mm_free(self);
-}
-
-struct codecfilter_uniraum_inst_stream * __stream_get(struct codecfilter_uniraum_inst * self, int stream) {
- size_t i;
-
- for (i = 0; i < MAX_STREAMS; i++) {
-  if ( self->stream[i].refc && self->stream[i].stream == stream ) {
-   __stream_ref(&(self->stream[i]));
-   return &(self->stream[i]);
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return NULL;
-}
-
-struct codecfilter_uniraum_inst_stream * __stream_new(struct codecfilter_uniraum_inst * self, int stream) {
- struct codecfilter_uniraum_inst_stream * ret;
- size_t i;
-
- ret = __stream_get(self, stream);
- if ( ret != NULL ) {
-  __stream_unref(ret);
-  roar_err_set(ROAR_ERROR_EXIST);
-  return NULL;
- }
-
- for (i = 0; i < MAX_STREAMS; i++) {
-  ret = &(self->stream[i]);
-  if ( !ret->refc ) {
-   memset(ret, 0, sizeof(*ret));
-   ret->refc = 1;
-   ret->parent = self;
-   ret->ss = NULL;
-   ret->stream = stream;
-   ret->uniraumstream = NULL;
-   ret->uniraummapping = NULL;
-   ret->dataqueue = NULL;
-   if ( streams_new_virtual(ROAR_STREAM(self->ss)->id, &(ret->ss)) == -1 ) {
-    ret->refc = 0;
-    return NULL;
-   }
-   __stream_setup_vio(ret);
-   __stream_ref(ret);
-   self->streams++;
-   return ret;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOSPC);
- return NULL;
-}
-
-static inline void __stream_ref(struct codecfilter_uniraum_inst_stream * self) {
- self->refc++;
-}
-
-static inline void __stream_unref(struct codecfilter_uniraum_inst_stream * self) {
- self->refc--;
- if ( self->refc )
-  return;
- self->parent->streams--;
- __inst_unref(self->parent);
- uniraum_stream_unref(self->uniraumstream);
- uniraum_mapping_unref(self->uniraummapping);
- roar_buffer_free(self->dataqueue);
- roar_mm_free(self);
-}
-
-static ssize_t        __v_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct codecfilter_uniraum_inst_stream * self = vio->inst;
- ssize_t done = 0;
- size_t len;
- int ret;
-
- ROAR_DBG("__v_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- while (count) {
-  ROAR_DBG("__v_read(vio=%p, buf=?, count=?): %llu bytes left to do", vio, (long long unsigned int)count);
-  len = count;
-  if ( self->dataqueue == NULL ) {
-   len = 0;
-  } else if ( roar_buffer_shift_out(&(self->dataqueue), buf, &len) == -1 ) {
-   ROAR_DBG("__v_read(vio=%p, buf=%p, count=?): roar_errorstring=%s", vio, buf, roar_errorstring);
-   break;
-  }
-
-  if ( len == 0 ) {
-   __stream_pushdata(self);
-   len = count;
-   if ( self->dataqueue == NULL ) {
-    len = 0;
-   } else if ( roar_buffer_shift_out(&(self->dataqueue), buf, &len) == -1 ) {
-    ROAR_DBG("__v_read(vio=%p, buf=%p, count=?): roar_errorstring=%s", vio, buf, roar_errorstring);
-    break;
-   }
-   ROAR_DBG("__v_read(vio=%p, buf=?, count=?) = ?", vio);
-   if ( len == 0 ) {
-    do {
-     ret = __read_more_data(self->parent, self->stream);
-    } while (ret == 0 && self->dataqueue == NULL);
-    //__stream_pushdata(self);
-    len = count;
-    ROAR_DBG("__v_read(vio=%p, buf=?, count=?): self->dataqueue=%p, buf=%p", vio, self->dataqueue, buf);
-    if ( roar_buffer_shift_out(&(self->dataqueue), buf, &len) == -1 ) {
-     ROAR_DBG("__v_read(vio=%p, buf=?, count=?): roar_errorstring=%s", vio, roar_errorstring);
-     break;
-    }
-   }
-  }
-
-  buf   += len;
-  count -= len;
-  done  += len;
- }
-
- ROAR_DBG("__v_read(vio=%p, buf=%p, count=?) = %lli", vio, buf, (long long int)done);
- return done;
-}
-
-static ssize_t        __v_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- // TODO: add support here to write a stream.
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static roar_off_t     __v_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static int            __v_sync    (struct roar_vio_calls * vio) {
- // TODO: add support here to flush the mapping of this stream and stuff.
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static int            __v_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static int            __v_close   (struct roar_vio_calls * vio) {
- // TODO: add support here to terminate the stream and write KICK command and sttuff.
- __stream_unref(vio->inst);
- roar_vio_clear_calls(vio);
- return 0;
-}
-
-static inline void __stream_setup_vio(struct codecfilter_uniraum_inst_stream * self) {
- struct roar_vio_calls * vio = &(self->ss->vio);
- roar_vio_clear_calls(vio);
- vio->inst  = self;
- vio->read  = __v_read;
- vio->write = __v_write;
- vio->lseek = __v_lseek;
- vio->sync  = __v_sync;
- vio->ctl   = __v_ctl;
- vio->close = __v_close;
- __stream_ref(self);
-}
-
-
-static inline void __stream_pushdata(struct codecfilter_uniraum_inst_stream * self) {
- uniraum_req_t * req = NULL;
- uniraum_data_t * data;
- int queue_filled;
-
- ROAR_DBG("__stream_pushdata(self=%p) = ?", self);
-
- do {
-  ROAR_DBG("__stream_pushdata(self=%p) = ?", self);
-  do {
-   ROAR_DBG("__stream_pushdata(self=%p): self->uniraummapping=%p", self, self->uniraummapping);
-   data = uniraum_mapping_dataout(self->uniraummapping);
-   queue_filled = data != NULL;
-   ROAR_DBG("__stream_pushdata(self=%p): queue_filled=%i", self, queue_filled);
-   if ( queue_filled ) {
-    if ( roar_buffer_moveintoqueue(&(self->dataqueue), &data) == -1 ) {
-     ROAR_ERR("__stream_pushdata(self=%p): lost data (can not push into queue): %s", self, roar_errorstring);
-     uniraum_data_unref(data);
-     queue_filled = 0;
-    }
-   }
-  } while (queue_filled);
-
-  req = uniraum_stream_reqout(self->uniraumstream);
-  ROAR_DBG("__stream_pushdata(self=%p): req=%p", self, req);
-  if ( req != NULL ) {
-   if ( uniraum_reqget_type(req) == ROAR_CMD_ADD_DATA ) {
-    ROAR_DBG("__stream_pushdata(self=%p): self->uniraummapping=%p, req=%p is data.", self, self->uniraummapping, req);
-    if ( uniraum_mapping_reqin(self->uniraummapping, req) == -1 ) {
-     ROAR_ERR("__stream_pushdata(self=%p): Can not push data into mapping. Bad.", self);
-    }
-   }
-   uniraum_requnref(req);
-  }
- } while (req != NULL);
-}
-
-static inline int __handle_meta_data(struct codecfilter_uniraum_inst * self, uniraum_req_t * in, int stream) {
- struct codecfilter_uniraum_inst_stream * streamobj;
- int server_stream = -1;
- const char * key;
- const char * value;
- int mode;
-
- if ( stream == -1 ) {
-  server_stream = ROAR_STREAM(self->ss)->id;
- } else {
-  streamobj = __stream_get(self, stream);
-  if ( streamobj == NULL )
-   return -1;
-  server_stream = ROAR_STREAM(streamobj->ss)->id;
-  __stream_unref(streamobj);
- }
-
- if ( uniraum_reqget_meta(in, &key, &value, &mode) == -1 ) {
-  roar_err_set(uniraum_error(self->file));
-  return -1;
- }
-
- switch (mode) {
-  case ROAR_META_MODE_SET:
-    return stream_meta_set(server_stream, roar_meta_inttype(key), key, value);
-   break;
-  case ROAR_META_MODE_ADD:
-    return stream_meta_add(server_stream, roar_meta_inttype(key), key, value);
-   break;
-  case ROAR_META_MODE_CLEAR:
-    return stream_meta_clear(server_stream);
-   break;
-  case ROAR_META_MODE_FINALIZE:
-    return stream_meta_finalize(server_stream);
-   break;
-  case ROAR_META_MODE_DELETE:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-static inline int __handle_req_global(struct codecfilter_uniraum_inst * self, uniraum_req_t * in, int type) {
- ROAR_DBG("__handle_req_global(self=%p, in=%p, type=%i) = ?", self, in, type);
-
- switch (type) {
-  case ROAR_CMD_NOOP:
-  case ROAR_CMD_CAPS:
-  case ROAR_CMD_RAUM_SEEKTABLE:
-    // NOOPs.
-    return 0;
-   break;
-  case ROAR_CMD_QUIT:
-    self->got_eof = 1;
-    ROAR_DBG("__handle_req_global(self=%p, in=%p, type=%i) = 0 // EOF mark", self, in, type);
-    return 0;
-   break;
-  case ROAR_CMD_SET_META:
-    return __handle_meta_data(self, in, -1);
-   break;
-  default:
-    ROAR_DBG("__handle_req_global(self=%p, in=%p, type=%i) = 0 // error=NSTYPE", self, in, type);
-    roar_err_set(ROAR_ERROR_NSTYPE);
-    return -1;
-   break;
- }
-}
-
-static inline void __handle_req_stream_update_codec(struct roar_audio_info * info) {
- switch (info->codec) {
-  case ROAR_CODEC_RAUM_VORBIS:
-    info->codec = ROAR_CODEC_OGG_VORBIS;
-   break;
-  case ROAR_CODEC_RAUM_FLAC:
-   break;
- }
-}
-
-static inline int __handle_req_stream(struct codecfilter_uniraum_inst * self, uniraum_req_t * in, int type, int stream) {
- struct codecfilter_uniraum_inst_stream * streamobj;
- struct roar_audio_info info;
- int stream_dir = -1;
- int ret = -1;
- int err;
-
- ROAR_DBG("__handle_req_stream(self=%p, in=%p, type=%i, stream=%i) = ?", self, in, type, stream);
-
- if ( type == ROAR_CMD_NEW_STREAM ) {
-  streamobj = __stream_new(self, stream);
-  if ( streamobj == NULL )
-   return -1;
-
-  streamobj->uniraumstream = uniraum_stream_new(in);
-  ret = streamobj->uniraumstream == NULL ? -1 : 0;
- } else {
-  streamobj = __stream_get(self, stream);
-  if ( streamobj == NULL )
-   return -1;
-  ret = uniraum_stream_reqin(streamobj->uniraumstream, in);
-  ROAR_DBG("__handle_req_stream(self=%p, in=%p, type=%i, stream=%i): ret=%i", self, in, type, stream, ret);
- }
-
- if ( ret == -1 ) {
-  err = roar_error;
-  __stream_unref(streamobj);
-  roar_err_set(err);
-  ROAR_DBG("__handle_req_stream(self=%p, in=%p, type=%i, stream=%i) = -1 // error=%s", self, in, type, stream, roar_errorstring);
-  return -1;
- }
-
- switch (type) {
-  case ROAR_CMD_RAUM_SEEKTABLE:
-  case ROAR_CMD_ADD_DATA:
-  case ROAR_CMD_KICK:
-    // NOOPs.
-    ret = 0;
-   break;
-  case ROAR_CMD_SET_META:
-    ret = __handle_meta_data(self, in, stream);
-   break;
-  case ROAR_CMD_EXEC_STREAM:
-    self->is_execed = stream;
-    ret = 0;
-   break;
-  case ROAR_CMD_NEW_STREAM:
-    stream_dir = uniraum_stream_get_dir(streamobj->uniraumstream);
-    info = ROAR_STREAM(streamobj->ss)->info = *uniraum_stream_get_auinfo(streamobj->uniraumstream);
-    __handle_req_stream_update_codec(&(ROAR_STREAM(streamobj->ss)->info));
-    ROAR_DBG("__handle_req_stream(self=%p, in=%p, type=%i, stream=%i): stream_dir=%i, codec=%s", self, in, type, stream, stream_dir, roar_codec2str(ROAR_STREAM(streamobj->ss)->info.codec));
-    streamobj->ss->codec_orgi = ROAR_STREAM(streamobj->ss)->info.codec;
-    streams_set_dir(ROAR_STREAM(streamobj->ss)->id, stream_dir, 1);
-    streams_set_fh(ROAR_STREAM(streamobj->ss)->id, -2);
-    streamobj->uniraummapping = uniraum_mapping_new(stream,
-                                                    UNIRAUM_IN, ROAR_VIO_DFT_RAW,
-                                                    &info);
-   break;
-  case ROAR_CMD_SET_VOL:
-  case ROAR_CMD_SET_STREAM_PARA:
-  default:
-    roar_err_set(ROAR_ERROR_NSTYPE);
-    ret = -1;
-   break;
- }
-
- err = roar_error;
-
- __stream_pushdata(streamobj);
- __stream_unref(streamobj);
-
- roar_err_set(err);
- ROAR_DBG("__handle_req_stream(self=%p, in=%p, type=%i, stream=%i) = %i // error=%s", self, in, type, stream, ret, roar_errorstring);
- return ret;
-}
-
-static inline int __handle_req(struct codecfilter_uniraum_inst * self, uniraum_req_t * in, int type, int stream) {
- ROAR_DBG("__handle_req(self=%p, in=%p, type=%i, stream=%i) = ?", self, in, type, stream);
-
- if ( stream == -1 ) {
-  return __handle_req_global(self, in, type);
- } else {
-  return __handle_req_stream(self, in, type, stream);
- }
-}
-
-static inline int __read_more_data_execed(struct codecfilter_uniraum_inst * self) {
-/*
-ssize_t          uniraum_read_execed (uniraum_file_t * state,       void * buf, size_t len);
-uniraum_req_t *  uniraum_reqdata(int stream, uniraum_pos_t pos, const void * data, size_t len);
-uniraum_req_t *  uniraum_reqend_stream(int stream, uniraum_pos_t pos);
-*/
-
- uniraum_req_t * data = NULL;
- char buf[1024];
- ssize_t ret;
-
- ROAR_DBG("__read_more_data_execed(self=%p) = ?", self);
-
- ret = uniraum_read_execed(self->file, buf, sizeof(buf));
- if ( ret < 0 ) {
-  ROAR_DBG("__read_more_data_execed(self=%p) = -1 // EOF?", self);
-  self->got_eof = 1;
-  roar_err_set(uniraum_error(self->file));
-  return -1;
- } else if ( ret == 0 ) {
-  self->got_eof = 1;
- } else {
-  data = uniraum_reqdata(self->is_execed, 0, buf, ret);
- }
-
- if ( data == NULL ) {
-  ROAR_DBG("__read_more_data_execed(self=%p) = -1", self);
-  roar_err_set(uniraum_error(self->file));
-  return -1;
- }
-
- __handle_req_stream(self, data, uniraum_reqget_type(data), self->is_execed);
- uniraum_requnref(data);
-
- ROAR_DBG("__read_more_data_execed(self=%p) = 0", self);
- return 0;
-}
-
-static inline int __read_more_data(struct codecfilter_uniraum_inst * self, int stream) {
- uniraum_req_t * in;
- int instream;
- int intype;
- int err;
-
- ROAR_DBG("__read_more_data(self=%p, stream=%i) = ?", self, stream);
-
- if ( self->got_eof ) {
-  roar_err_set(ROAR_ERROR_NONE);
-  return -1;
- } else if ( self->is_execed != -1 ) {
-  if ( self->is_execed == stream ) {
-   __read_more_data_execed(self);
-   ROAR_DBG("__read_more_data(self=%p, stream=%i) = 0", self, stream);
-   return 0;
-  } else {
-   roar_err_set(ROAR_ERROR_BADSTATE);
-   return -1;
-  }
- }
-
- ROAR_DBG("__read_more_data(self=%p, stream=%i) = ?", self, stream);
-
- do {
-  in = uniraum_reqin(self->file);
-  if ( in == NULL ) {
-   err = uniraum_error(self->file);
-   if ( err == ROAR_ERROR_AGAIN ) {
-    if ( uniraum_read(self->file) == -1 ) {
-     roar_err_set(uniraum_error(self->file));
-     ROAR_DBG("__read_more_data(self=%p, stream=%i): Can not read input data (EOF?): %s", self, stream, roar_errorstring);
-     self->got_eof = 1;
-     return -1;
-    }
-    in = uniraum_reqin(self->file);
-    if ( in == NULL ) {
-     roar_err_set(uniraum_error(self->file));
-     return -1;
-    }
-   } else {
-    roar_err_set(err);
-    return -1;
-   }
-  }
-  intype   = uniraum_reqget_type(in);
-  instream = uniraum_reqget_stream(in);
-  __handle_req(self, in, intype, instream);
-  uniraum_requnref(in);
- } while ( self->is_execed == -1 && !self->got_eof &&
-           ((stream != -1 && stream != instream) || (stream == -1 && intype != ROAR_CMD_ADD_DATA)) );
-
- ROAR_DBG("__read_more_data(self=%p, stream=%i) = 0", self, stream);
- return 0;
-}
-
-static ssize_t        __s_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- ROAR_DBG("__s_read(vio=%p, buf=%p, count=?) = ?", vio, buf);
- return stream_vio_s_read(((struct codecfilter_uniraum_inst*)vio->inst)->ss, buf, count);
-}
-static ssize_t        __s_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- return stream_vio_s_write(((struct codecfilter_uniraum_inst*)vio->inst)->ss, buf, count);
-}
-static roar_off_t     __s_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-static int            __s_sync    (struct roar_vio_calls * vio) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-static int            __s_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- return stream_vio_s_ctl(((struct codecfilter_uniraum_inst*)vio->inst)->ss, cmd, data);
-}
-static int            __s_close   (struct roar_vio_calls * vio) {
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-static inline void __init_s_vio(struct codecfilter_uniraum_inst * self) {
- roar_vio_clear_calls(&(self->vio));
- self->vio.inst  = self;
- self->vio.read  = __s_read;
- self->vio.write = __s_write;
- self->vio.lseek = __s_lseek;
- self->vio.sync  = __s_sync;
- self->vio.ctl   = __s_ctl;
- self->vio.close = __s_close;
-}
-
-static inline int __open_file(struct codecfilter_uniraum_inst * self) {
- int dir;
- int flags;
-
- ROAR_DBG("__open_file(self=%p) = ?", self);
-
- if ( self->file != NULL ) {
-  ROAR_DBG("__open_file(self=%p) = -1 // error=ALREADY", self);
-  roar_err_set(ROAR_ERROR_ALREADY);
-  return -1;
- }
-
- dir = streams_get_ssdir(ROAR_STREAM(self->ss)->id);
-
- switch (dir) {
-  case STREAM_DIR_IN:
-    flags = O_RDONLY;
-   break;
-  case STREAM_DIR_OUT:
-    flags = O_WRONLY;
-   break;
-  case STREAM_DIR_BIDIR:
-    flags = O_RDWR;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- __init_s_vio(self);
-
- ROAR_DBG("__open_file(self=%p) = ?", self);
-
- self->file = uniraum_openvio(&(self->vio), flags);
- if ( self->file == NULL ) {
-  roar_err_set(uniraum_error(NULL));
-  ROAR_DBG("__open_file(self=%p): Can not open uniraum file object: %s", self, roar_errorstring);
-  return -1;
- }
-
- ROAR_DBG("__open_file(self=%p) = 0", self);
- return 0;
-}
-
-int cf_uniraum_open (CODECFILTER_USERDATA_T * inst, int codec,
-                     struct roar_stream_server * info,
-                     struct roar_codecfilter   * filter) {
- struct codecfilter_uniraum_inst * self;
-
- self = roar_mm_malloc(sizeof(struct codecfilter_uniraum_inst));
- if ( self == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct codecfilter_uniraum_inst));
- self->refc = 1;
- self->ss   = info;
- self->file = NULL;
- self->got_eof = 0;
- self->is_execed = -1;
-
- *inst = self;
-
- return 0;
-}
-
-int cf_uniraum_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_uniraum_inst * self = inst;
-
- __inst_unref(self);
-
- ROAR_DBG("cf_uniraum_close(inst=%p) = 0", inst);
- return 0;
-}
-
-int cf_uniraum_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_uniraum_inst * self = inst;
-
- if ( self->file == NULL )
-  if ( __open_file(self) == -1 )
-   return -1;
-
- roar_err_set(ROAR_ERROR_BADFH);
- return -1;
-}
-
-int cf_uniraum_read (CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_uniraum_inst * self = inst;
- ROAR_DBG("cf_uniraum_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
-
- if ( self == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( self->file == NULL )
-  if ( __open_file(self) == -1 )
-   return -1;
-
- if ( !self->streams )
-  __read_more_data(self, -1);
-
- if ( self->got_eof ) {
-  ROAR_DBG("cf_uniraum_read(inst=%p, buf=%p, len=%i) = 0 // EOF", inst, buf, len);
-  return 0;
- } else {
-  ROAR_DBG("cf_uniraum_read(inst=%p, buf=%p, len=%i) = -1 // errno=EAGAIN", inst, buf, len);
-  errno = EAGAIN;
-  return -1;
- }
-}
-
-int cf_uniraum_flush(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_uniraum_inst * self = inst;
- int r = uniraum_write(self->file);
-
- if ( r == -1 )
-  roar_err_set(uniraum_error(self->file));
-
- return r;
-}
-
-int cf_uniraum_ctl  (CODECFILTER_USERDATA_T   inst, int cmd, void * data) {
- struct codecfilter_uniraum_inst * self = inst;
- int_least32_t type = cmd & ROAR_STREAM_CTL_TYPEMASK;
-
- cmd -= type;
-
- ROAR_DBG("cf_uniraum_ctl(*): cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-          cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-
- switch (cmd) {
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_META_UPDATE):
-    if ( type != ROAR_STREAM_CTL_TYPE_VOID )
-     return -1;
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  default:
-    ROAR_DBG("cf_uniraum_ctl(*): Unknown command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
- }
-}
-
-
-#endif
-
-//ll
Index: roard/codecfilter_vorbis.c
===================================================================
--- roard/codecfilter_vorbis.c	(revision 6052)
+++ 	(revision )
@@ -1,560 +1,0 @@
-//codecfilter_vorbis.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#define ROAR_REQUIRE_LIBVORBISFILE
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBVORBISFILE
-
-#define FIFAC ((float)((uint64_t)1<<(ROAR_VORBIS_BITS-1)))
-
-int _g_cf_vorbis_vfvio_return_err (void) {
- return -1;
-}
-
-ov_callbacks _g_cf_vorbis_vfvio = {
-  .read_func  = cf_vorbis_vfvio_read,
-  .seek_func  = (int    (*)(void *, ogg_int64_t, int      )) _g_cf_vorbis_vfvio_return_err,
-  .close_func = (int    (*)(void *                        )) _g_cf_vorbis_vfvio_return_err,
-  .tell_func  = (long   (*)(void *                        )) _g_cf_vorbis_vfvio_return_err
-};
-
-size_t cf_vorbis_vfvio_read (void *ptr, size_t size, size_t nmemb, void *datasource) {
- ssize_t r;
-
- r = stream_vio_s_read(ROAR_STREAM_SERVER(datasource), ptr, size*nmemb);
-
- ROAR_DBG("cf_vorbis_vfvio_read(ptr=%p, size=%lu, nmemb=%lu, datasource=%p): r=%i", ptr, (unsigned long int)size, (unsigned long int)nmemb, datasource, r);
-
- if ( r == -1 ) {
-  ROAR_DBG("cf_vorbis_vfvio_read(ptr=%p, size=%lu, nmemb=%lu, datasource=%p) = 0 // roar_error=%i(%s)", ptr, (unsigned long int)size, (unsigned long int)nmemb, datasource, roar_error, roar_error2str(roar_error));
-  return 0;
- }
-
- if ( r > 0 ) {
-  roar_err_clear_all();
- }
-
- r /= size;
- 
- ROAR_DBG("cf_vorbis_vfvio_read(ptr=%p, size=%lu, nmemb=%lu, datasource=%p) = %i", ptr, (unsigned long int)size, (unsigned long int)nmemb, datasource, r);
- return r;
-}
-
-int cf_vorbis_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_vorbis_inst * self = roar_mm_malloc(sizeof(struct codecfilter_vorbis_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- (void)codec, (void)filter;
-
- if ( self == NULL )
-  return -1;
-
- self->current_section      = -1;
- self->last_section         = -1;
- self->opened               =  0;
- self->got_it_running       =  0;
- self->stream               = info;
-// self->outlen               = ROAR_OUTPUT_BUFFER_SAMPLES * s->info.channels * s->info.bits / 8; // optimal size
-#ifdef ROAR_HAVE_LIBVORBISENC
- self->encoding               = 0;
- self->encoder.v_base_quality = 0.3;
- self->encoder.srn            = -1;
-#endif
-
- ROAR_DBG("cf_vorbis_open(*): info->id=%i", ROAR_STREAM(info)->id);
-
- *inst = (CODECFILTER_USERDATA_T) self;
-
-#if ROAR_CODEC_DEFAULT == ROAR_CODEC_PCM_S_LE
- self->bigendianp = 0;
- s->info.codec = ROAR_CODEC_DEFAULT;
-#else
- self->bigendianp = 1;
- s->info.codec = ROAR_CODEC_PCM_S_BE; // force because ROAR_CODEC_DEFAULT can be something non-BE, too.
-#endif
-
- s->info.bits  = 16;
-
- if ( s->dir == ROAR_DIR_PLAY ) {
-  return 0;
- } else if ( s->dir == ROAR_DIR_MONITOR || s->dir == ROAR_DIR_OUTPUT ) {
-#ifdef ROAR_HAVE_LIBVORBISENC
-  // set up the encoder here
-// this is delayed to the write function
-/*
- if ( cf_vorbis_encode_start(self) == -1 ) {
-  roar_mm_free(self);
-  return -1;
- }
-*/
- s->info.bits  = ROAR_VORBIS_BITS;
-#else
- roar_mm_free(self);
- return -1;
-#endif
- } else {
-  roar_mm_free(self);
-  return -1;
- }
-
- return 0;
-}
-
-int cf_vorbis_close(CODECFILTER_USERDATA_T   inst) {
- struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst;
-
- if ( self == NULL )
-  return -1;
-
- if ( self->got_it_running )
-  ov_clear(&(self->vf));
-
-#ifdef ROAR_HAVE_LIBVORBISENC
- if ( self->encoding ) {
-  cf_vorbis_encode_end(self);
- }
-#endif
-
- roar_mm_free(self);
- return 0;
-}
-
-int cf_vorbis_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
-#ifdef ROAR_HAVE_LIBVORBISENC
- struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst;
- struct roar_stream * s = ROAR_STREAM(self->stream);
- ogg_packet header;
- ogg_packet header_comm;
- ogg_packet header_code;
- float ** encbuf;
- int i, c;
- int chans;
- int end;
- int sid;
- void * prethrubuf;
-#if ROAR_VORBIS_BITS == 8
- int8_t  * data = (int8_t  *) buf;
-#elif ROAR_VORBIS_BITS == 16
- int16_t * data = (int16_t *) buf;
-#elif ROAR_VORBIS_BITS == 32
- int32_t * data = (int32_t *) buf;
-#else
-#error value of ROAR_VORBIS_BITS not supported
-#endif
-
- if ( ! self->opened ) {
-  if ( !self->encoding ) {
-   if ( cf_vorbis_encode_start(self) == -1 ) {
-    return -1;
-   }
-  }
-
-  sid = ROAR_STREAM(self->stream)->id;
-
-  vorbis_analysis_headerout(&(self->encoder.vd), &(self->encoder.vc), &header, &header_comm, &header_code);
-
-  ogg_stream_packetin(&(self->encoder.os), &header);
-  ogg_stream_packetin(&(self->encoder.os), &header_comm);
-  ogg_stream_packetin(&(self->encoder.os), &header_code);
-
-  stream_prethru_destroy(sid);
-
-  while (ogg_stream_flush(&(self->encoder.os), &(self->encoder.og))) {
-   if ( stream_vio_s_write(self->stream, self->encoder.og.header, self->encoder.og.header_len)
-                                                                 != self->encoder.og.header_len ||
-        stream_vio_s_write(self->stream, self->encoder.og.body,   self->encoder.og.body_len  )
-                                                                 != self->encoder.og.body_len     ) {
-    roar_mm_free(self); // TODO: do we need addional cleanup?
-    return -1;
-   }
-   // we ignore errors at the moment...
-   if ( stream_prethru_add_data(sid, &prethrubuf, self->encoder.og.header_len + self->encoder.og.body_len) != -1 ) {
-    memcpy(prethrubuf,                               self->encoder.og.header, self->encoder.og.header_len);
-    memcpy(prethrubuf + self->encoder.og.header_len, self->encoder.og.body,   self->encoder.og.body_len  );
-   }
-  }
-  self->opened = 1;
- } else {
-  encbuf = vorbis_analysis_buffer(&(self->encoder.vd), len /* TODO: need to lookup the menaing of this */);
-  chans  = s->info.channels;
-  end    = len*8/(ROAR_VORBIS_BITS*chans);
-
-  if ( chans == 1 ) { // use optimized code
-   for (i = 0; i < end; i++)
-    encbuf[0][i] = data[i]/FIFAC;
-
-  } else if ( chans == 2 ) { // use optimized code
-   for (i = 0; i < end; i++) {
-    encbuf[0][i] = data[2*i  ]/FIFAC;
-    encbuf[1][i] = data[2*i+1]/FIFAC;
-   }
-  } else { // use generic multi channel code
-   for (i = 0; i < end; i++) {
-    for (c = 0; c < chans; c++) {
-     encbuf[c][i] = data[chans*i+c]/FIFAC;
-    }
-   }
-  }
-
-  vorbis_analysis_wrote(&(self->encoder.vd), i);
-
-  if ( cf_vorbis_encode_flushout(self) == -1 )
-   return -1;
- }
-
-  return len; // we assume every thing was written (at least into our dsp anaylises buffer
-#else
- roar_err_set(ROAR_ERROR_NOSYS);
- roar_err_to_errno();
- return -1;
-#endif
-}
-int cf_vorbis_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst;
- long r;
- long todo = len;
- long done = 0;
- int ret;
-
- ROAR_DBG("cf_vorbis_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
-
- self->opened++;
- if ( self->opened == 16 ) {
-
-  ROAR_DBG("cf_vorbis_read(*): opening...");
-  if ( (ret = ov_open_callbacks((void*)self->stream, &(self->vf), NULL, 0, _g_cf_vorbis_vfvio)) < 0 ) {
-   ROAR_DBG("cf_vorbis_read(*): ret=%i", ret);
-   ROAR_DBG("cf_vorbis_read(*) = 0");
-   return 0;
-  }
-
-  ROAR_DBG("cf_vorbis_read(*) = -1 // errno=EAGAIN");
-  roar_err_set(ROAR_ERROR_AGAIN);
-  roar_err_to_errno();
-  return -1;
- }
-
- if ( self->opened < 16 ) {
-  ROAR_DBG("cf_vorbis_read(*) = -1 // errno=EAGAIN");
-  roar_err_set(ROAR_ERROR_AGAIN);
-  roar_err_to_errno();
-  return -1;
- }
-
-
- self->got_it_running = 1;
-
- while (todo) {
-  r = ov_read(&(self->vf), buf+done, todo, self->bigendianp, 2, 1, &(self->current_section));
-  ROAR_DBG("cf_vorbis_read(*): r=%li", r);
-  if ( r == OV_HOLE ) {
-   ROAR_DBG("cf_vorbis_read(*): Hole in stream");
-  } else if ( r < 1 ) {
-   break;
-  } else {
-   if ( self->last_section != self->current_section )
-    if ( cf_vorbis_update_stream(self) == -1 )
-     return 0;
-
-   self->last_section = self->current_section;
-   todo -= r;
-   done += r;
-  }
- }
-
- ROAR_DBG("ov_read(*) = %li", (long int)done);
-
- if ( done == 0 ) {
-  // do some EOF handling...
-  return 0;
- } else {
-  return len;
- }
-}
-
-int cf_vorbis_update_stream (struct codecfilter_vorbis_inst * self) {
-#ifdef ROAR_SUPPORT_META
- vorbis_info *vi = ov_info(&(self->vf), -1);
- char **ptr = ov_comment(&(self->vf), -1)->user_comments;
- char key[ROAR_META_MAX_NAMELEN] = {0}, value[LIBROAR_BUFFER_MSGDATA] = {0};
- struct roar_stream * s = ROAR_STREAM(self->stream);
- struct roar_stream_rpg rpg;
- int type;
- int j, h = 0;
- float rpg_track = 0, rpg_album = 0, rpg_final;
- int meta_ok;
-
- s->info.channels = vi->channels;
- s->info.rate     = vi->rate;
- s->info.bits     = 16;
-#if ROAR_CODEC_DEFAULT == ROAR_CODEC_PCM_S_LE
- s->info.codec    = ROAR_CODEC_DEFAULT;
-#else
- s->info.codec    = ROAR_CODEC_PCM_S_BE;
-#endif
-
- stream_meta_clear(s->id);
-
- while(*ptr){
-  meta_ok = 1;
-
-   for (j = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) {
-    if ( j == ROAR_META_MAX_NAMELEN ) {
-     ROAR_ERR("cf_vorbis_update_stream(*): invalid meta data on stream %i: meta data key too long", s->id);
-     meta_ok = 0;
-     j = 0;
-     break;
-    }
-    key[j] = (*ptr)[j];
-   }
-   key[j] = 0;
-
-   if ( meta_ok ) {
-    for (j++, h = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) {
-     if ( h == LIBROAR_BUFFER_MSGDATA ) {
-      ROAR_ERR("update_stream(*): invalid meta data on stream %i: meta data value for key '%s' too long", s->id, key);
-      meta_ok = 0;
-      h = 0;
-      break;
-     }
-     value[h++] = (*ptr)[j];
-    }
-    value[h]   = 0;
-   }
-
-   if ( meta_ok ) {
-    type = roar_meta_inttype(key);
-    if ( type != -1 )
-     stream_meta_set(s->id, type, "", value);
-
-    ROAR_DBG("cf_vorbis_update_stream(*): Meta %-16s: %s", key, value);
-
-    if ( strcmp(key, "REPLAYGAIN_TRACK_PEAK") == 0 ) {
-     rpg_track = 1/atof(value);
-/*
-    } else if ( strcmp(key, "REPLAYGAIN_TRACK_GAIN") == 0 ) {
-     rpg_track = powf(10, atof(value)/20);
-*/
-    } else if ( strcmp(key, "REPLAYGAIN_ALBUM_PEAK") == 0 ) {
-     rpg_album = 1/atof(value);
-/* 
-    } else if ( strcmp(key, "REPLAYGAIN_ALBUM_GAIN") == 0 ) {
-     rpg_album = powf(10, atof(value)/20);
-*/
-    }
-   }
-
-   ptr++;
- }
-
- if ( streams_get_rpg(ROAR_STREAM(self->stream)->id, &rpg) != -1 ) {
-  rpg_final = 0;
-
-  switch (rpg.mode) {
-   case ROAR_RPGMODE_NONE: rpg_final =  0.; break;
-   case ROAR_RPGMODE_USER: rpg_final = -1.; break;
-   case ROAR_RPGMODE_ALBUM: rpg_final = rpg_album; break;
-   case ROAR_RPGMODE_TRACK: rpg_final = rpg_track; break;
-   case ROAR_RPGMODE_ALBUMTRACK: rpg_final = rpg_album ? rpg_album : rpg_track; break;
-   case ROAR_RPGMODE_TRACKALBUM: rpg_final = rpg_track ? rpg_track : rpg_album; break;
-  }
-
-  if ( rpg_final > 0 ) {
-   self->stream->mixer.rpg_div = 2718;
-   self->stream->mixer.rpg_mul = (float)rpg_final*2718;
-  } else if ( !rpg_final ) {
-   self->stream->mixer.rpg_div = 1;
-   self->stream->mixer.rpg_mul = 1;
-  }
- }
-
- stream_meta_finalize(s->id);
-#endif
- //printf("RPG: mul=%i, div=%i\n", self->stream->mixer.rpg_mul, self->stream->mixer.rpg_div);
- return 0;
-}
-
-int cf_vorbis_encode_start  (struct codecfilter_vorbis_inst * self) {
-#ifdef ROAR_HAVE_LIBVORBISENC
- int srn = self->encoder.srn; // this value is allrady inited...
-#ifdef ROAR_SUPPORT_META
- int len = 0;
- int i;
- int types[ROAR_META_MAX_PER_STREAM];
-#endif
- int sid = ROAR_STREAM(self->stream)->id;
- float v_base_quality = self->encoder.v_base_quality;
- char val[LIBROAR_BUFFER_MSGDATA];
-
-  val[LIBROAR_BUFFER_MSGDATA-1] = 0;
-
-  memset(&(self->encoder), 0, sizeof(self->encoder));
-
-  self->encoding = 1;
-  self->encoder.srn = srn + 1;
-  self->encoder.v_base_quality = v_base_quality;
-
-  vorbis_info_init(&(self->encoder.vi));
-  vorbis_comment_init(&(self->encoder.vc));
-  vorbis_comment_add_tag(&(self->encoder.vc), "SERVER", "RoarAudio");
-  vorbis_comment_add_tag(&(self->encoder.vc), "ENCODER", "RoarAudio Vorbis codecfilter");
-
-#ifdef ROAR_SUPPORT_META
-  if ( (len = stream_meta_list(sid, types, ROAR_META_MAX_PER_STREAM)) != -1 ) {
-   for (i = 0; i < len; i++) {
-//int stream_meta_get     (int id, int type, char * name, char * val, size_t len);
-    if ( stream_meta_get(sid, types[i], NULL, val, LIBROAR_BUFFER_MSGDATA-1) == 0 )
-     vorbis_comment_add_tag(&(self->encoder.vc), (char * /* remove this later, it has been fixed upstream */)roar_meta_strtype(types[i]), val);
-   }
-  }
-#endif
-
-  ROAR_DBG("cf_vorbis_encode_start(*): q=%f", v_base_quality);
-
-  if( vorbis_encode_init_vbr(&(self->encoder.vi), (long) ROAR_STREAM(self->stream)->info.channels,
-                                                  (long) ROAR_STREAM(self->stream)->info.rate,
-                                                  v_base_quality) != 0 ) {
-   ROAR_ERR("cf_vorbis_encode_start(*): Can not vorbis_encode_init_vbr(*)!");
-   vorbis_info_clear(&(self->encoder.vi)); // TODO: do we need to free vc also?
-   return -1;
-  }
-
-  vorbis_analysis_init(&(self->encoder.vd), &(self->encoder.vi));
-  vorbis_block_init(&(self->encoder.vd), &(self->encoder.vb));
-
-  ROAR_DBG("cf_vorbis_encode_start(*): srn=%i", self->encoder.srn);
-                                     //  "RA"<<16 + PID<<8 + Stream ID
-  ogg_stream_init(&(self->encoder.os),
-                   (((0x5241 + self->encoder.srn) & 0xffff)<<16) +
-                   ( (getpid()                    & 0x00ff)<< 8) +
-                   (  sid                         & 0x00ff));
- return 0;
-#else
- return -1;
-#endif
-}
-
-int cf_vorbis_encode_end    (struct codecfilter_vorbis_inst * self) {
-#ifdef ROAR_HAVE_LIBVORBISENC
- if ( self->encoding ) {
-  // try to flush up to an EOS page...
-  vorbis_analysis_buffer(&(self->encoder.vd), 2*ROAR_MAX_CHANNELS);
-  vorbis_analysis_wrote(&(self->encoder.vd), 0);
-  cf_vorbis_encode_flushout(self);
-
-  // clean up...
-  ogg_stream_clear(&(self->encoder.os));
-  vorbis_block_clear(&(self->encoder.vb));
-  vorbis_dsp_clear(&(self->encoder.vd));
-  vorbis_info_clear(&(self->encoder.vi));
-  self->opened = 0;
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int cf_vorbis_encode_flushout(struct codecfilter_vorbis_inst * self) {
-#ifdef ROAR_HAVE_LIBVORBISENC
- while ( vorbis_analysis_blockout(&(self->encoder.vd), &(self->encoder.vb)) == 1 ) {
-  vorbis_analysis(&(self->encoder.vb), &(self->encoder.op));
-  vorbis_bitrate_addblock(&(self->encoder.vb));
-
-  while ( vorbis_bitrate_flushpacket(&(self->encoder.vd), &(self->encoder.op)) ) {
-   ogg_stream_packetin(&(self->encoder.os), &(self->encoder.op));
-
-   while( ogg_stream_pageout(&(self->encoder.os), &(self->encoder.og)) ) {
-    if (
-         stream_vio_s_write(self->stream, self->encoder.og.header, self->encoder.og.header_len) == -1 ||
-         stream_vio_s_write(self->stream, self->encoder.og.body,   self->encoder.og.body_len  ) == -1   ) {
-     return -1;
-    }
-   }
-  }
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int cf_vorbis_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data) {
- struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst;
- int_least32_t type = cmd & ROAR_STREAM_CTL_TYPEMASK;
-
- cmd -= type;
-
- switch (cmd) {
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_META_UPDATE):
-    if ( type != ROAR_STREAM_CTL_TYPE_VOID )
-     return -1;
-
-    ROAR_DBG("cf_vorbis_ctl(*): stoping stream...");
-    if ( cf_vorbis_encode_end(self) == -1 )
-     return -1;
-    ROAR_DBG("cf_vorbis_ctl(*): restarting stream...");
-    if ( cf_vorbis_encode_start(self) == -1 )
-     return -1;
-
-    return 0;
-   break;
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_SET_Q):
-    if ( type != ROAR_STREAM_CTL_TYPE_FLOAT )
-     return -1;
-
-    ROAR_DBG("cf_vorbis_ctl(*): setting quality to q=%f", *(float*)data);
-
-    self->encoder.v_base_quality = *(float*)data / 10;
-
-    if ( self->encoding ) {
-     ROAR_DBG("cf_vorbis_ctl(*): we are allready encoding, restart...");
-     ROAR_DBG("cf_vorbis_ctl(*): stoping stream...");
-     if ( cf_vorbis_encode_end(self) == -1 )
-      return -1;
-     ROAR_DBG("cf_vorbis_ctl(*): restarting stream...");
-     if ( cf_vorbis_encode_start(self) == -1 )
-      return -1;
-    }
-
-    return 0;
-   break;
-  default:
-    ROAR_DBG("cf_vorbis_ctl(*): Unknown command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-    return -1;
- }
-
- return -1;
-}
-
-#endif
-//ll
Index: roard/codecfilter_wave.c
===================================================================
--- roard/codecfilter_wave.c	(revision 6052)
+++ 	(revision )
@@ -1,299 +1,0 @@
-//codecfilter_wave.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_CF_WAVE
-
-int cf_wave_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter) {
- struct codecfilter_wave_inst * self = roar_mm_malloc(sizeof(struct codecfilter_wave_inst));
- struct roar_stream * s = ROAR_STREAM(info);
-
- if ( !self )
-  return -1;
-
- self->stream               = info;
- self->vstream              = NULL;
- self->opened               = 0;
-
- *inst = (CODECFILTER_USERDATA_T) self;
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
- return 0;
-}
-
-int cf_wave_close(CODECFILTER_USERDATA_T   inst) {
-// struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst;
-
- if ( !inst )
-  return -1;
-
- roar_mm_free(inst);
- return 0;
-}
-
-int cf_wave_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst;
- int r = -1;
- char tbuf[44];
- struct roar_stream * ps = ROAR_STREAM(self->stream);
- struct roar_stream *  s;
- struct roar_audio_info info;
- uint16_t tmp16;
- uint32_t tmp32;
- int codec = -1;
- int vid, fh;
-
- if ( self->opened ) {
-  return stream_vio_s_read(self->stream, buf, len);
- } else {
-  if (stream_vio_s_read(self->stream, tbuf, 44) != 44) {
-   return -1;
-  }
-
-  // test the header, is this really a RIFF WAVE stream?
-  if ( strncmp(tbuf, "RIFF", 4) != 0 )
-   return -1;
-
-  if ( strncmp(tbuf+8, "WAVEfmt ", 8) != 0 )
-   return -1;
-
-  if ( strncmp(tbuf+36, "data", 4) != 0 )
-   return -1;
-
-  // TODO: write better code here!
-
-  if ( (fh = streams_get_fh(ps->id)) == -1 ) {
-   return -1;
-  }
-
-  if ( (vid = streams_new_virtual(ps->id, &(self->vstream))) == -1 ) {
-   return -1;
-  }
-
-  ROAR_DBG("cf_wave_read(*): self->vstream=%p", self->vstream);
-
-  s = ROAR_STREAM(self->vstream);
-
-  memcpy(&tmp32, tbuf+24, 4);
-  s->info.rate = ROAR_LE2HOST32(tmp32);
-
-  memcpy(&tmp16, tbuf+22, 2);
-  s->info.channels = ROAR_LE2HOST16(tmp16);
-
-  memcpy(&tmp16, tbuf+34, 2);
-  s->info.bits = ROAR_LE2HOST16(tmp16);
-
-  memcpy(&tmp16, tbuf+20, 2);
-
-  switch (ROAR_LE2HOST16(tmp16)) {
-   case ROAR_RIFF_WAVE_CID_PCM:
-     if ( s->info.bits == 8 ) {
-      codec = ROAR_CODEC_PCM_U_LE;
-     } else {
-      codec = ROAR_CODEC_PCM_S_LE;
-     }
-    break;
-   case ROAR_RIFF_WAVE_CID_ALAW:
-     codec = ROAR_CODEC_ALAW;
-    break;
-   case ROAR_RIFF_WAVE_CID_MULAW:
-     codec = ROAR_CODEC_MULAW;
-    break;
-   case ROAR_RIFF_WAVE_CID_RSOUND:
-     memcpy(&tmp16, tbuf+42, 2);
-     switch (ROAR_LE2HOST16(tmp16)) {
-      case ROAR_RIFF_WAVE_RSID_S16_LE:
-        s->info.bits = 16;
-        codec        = ROAR_CODEC_PCM_S_LE;
-       break;
-      case ROAR_RIFF_WAVE_RSID_S16_BE:
-        s->info.bits = 16;
-        codec        = ROAR_CODEC_PCM_U_BE;
-       break;
-      case ROAR_RIFF_WAVE_RSID_U16_LE:
-        s->info.bits = 16;
-        codec        = ROAR_CODEC_PCM_U_LE;
-       break;
-      case ROAR_RIFF_WAVE_RSID_U16_BE:
-        s->info.bits = 16;
-        codec        = ROAR_CODEC_PCM_U_BE;
-       break;
-      case ROAR_RIFF_WAVE_RSID_S8:
-        s->info.bits = 8;
-        codec        = ROAR_CODEC_PCM_S_LE;
-       break;
-      case ROAR_RIFF_WAVE_RSID_U8:
-        s->info.bits = 8;
-        codec        = ROAR_CODEC_PCM_U_LE;
-       break;
-      default:
-        return -1;
-     }
-    break;
-   case ROAR_RIFF_WAVE_CID_IEEE_FLOAT:
-   default:
-     return -1;
-  }
-
-   s->info.codec            = codec;
-  self->vstream->codec_orgi = codec;
-
-  memcpy(&info, &(s->info), sizeof(struct roar_audio_info));
-
-  if ( streams_set_fh(vid, fh) == -1 ) {
-   return -1;
-  }
-
-/*
-  if ( roar_vio_open_pass(&(self->vstream->vio), &(self->stream->vio)) == -1 ) {
-   return -1;
-  }
-*/
-
-  memcpy(&(self->vstream->vio), &(self->stream->vio), sizeof(struct roar_vio_calls));
-
-  if ( streams_set_null_io(ps->id) == -1 ) {
-   return -1;
-  }
-
-  memcpy(&(ps->info), &info, sizeof(struct roar_audio_info));
-
-  self->opened = 1;
-
-  errno = EAGAIN;
-  return -1;
- }
-
- return r;
-}
-
-int cf_wave_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst;
- struct roar_stream           * s    = ROAR_STREAM(self->stream);
- void   * header;
- int32_t  tmp32;
- int16_t  tmp16;
- int16_t  bits;
- int16_t  codec;
- int      sid;
-
- ROAR_DBG("cf_wave_write(inst=%p, buf=%p, len=%i) = ?", inst, buf, len);
- ROAR_DBG("cf_wave_write(inst=%p, buf=%p, len=%i): self->opened=%i", inst, buf, len, self->opened);
-
- if ( self->opened ) {
-  return stream_vio_s_write(self->stream, buf, len);
- } else {
-
-  if ( s->fh == -1 ) {
-   errno = EAGAIN;
-   return -1;
-  }
-
-  sid = ROAR_STREAM(self->stream)->id;
-
-  if ( stream_prethru_destroy(sid) == -1 ) {
-   return -1;
-  }
-
-  if ( stream_prethru_add_data(sid, &header, 44) == -1 ) {
-   return -1;
-  }
-
-  memcpy(header   , "RIFF\367\377\377\177WAVEfmt \020", 17);
-  memcpy(header+36, "data\313\377\377\177", 8);
-
-  switch (s->info.codec) {
-   case ROAR_CODEC_PCM_S_LE:
-     codec = 0x0001;
-    break;
-   default:
-     ROAR_ERR("cf_wave_write(*) Codec not supported!");
-     return -1;
-    break;
-  }
-
-  ROAR_DBG("cf_wave_write(*) Codec supported!");
-
-  bits = s->info.bits;
-  memcpy(header+24, &(s->info.rate    ), 4);
-  memcpy(header+22, &(s->info.channels), 2);
-  memcpy(header+34, &bits, 2);
-
-  tmp16 = s->info.channels * bits / 8;
-  memcpy(header+32, &tmp16, 2);
-  tmp32 = tmp16 * s->info.rate;
-  memcpy(header+28, &tmp32, 4);
-  memcpy(header+20, &codec, 2);
-
-  if ( stream_vio_s_write(self->stream, header, 44) != 44 )
-   return -1;
-
-  self->opened = 1;
-
-  errno = EAGAIN;
-//  return -1;
-
-  len = stream_vio_s_write(self->stream, buf, len);
-
-  cf_wave_close(inst);
-  ROAR_STREAM_SERVER(s)->codecfilter = -1;
-
-  return len;
-
-//  return stream_vio_s_write(self->stream, buf, len);
- }
-
- return -1;
-}
-
-int cf_wave_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data) {
- struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst;
- int_least32_t type = cmd & ROAR_STREAM_CTL_TYPEMASK;
-
- cmd -= type;
-
- ROAR_DBG("cf_wave_ctl(*): command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-
- switch (cmd) {
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_VIRTUAL_DELETE):
-    streams_delete(ROAR_STREAM(self->stream)->id);
-    return 0;
-   break;
-  default:
-    ROAR_DBG("cf_wave_ctl(*): Unknown command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-    return -1;
- }
-
- return -1;
-}
-
-#endif
-
-//ll
Index: roard/commands.c
===================================================================
--- roard/commands.c	(revision 6052)
+++ roard/commands.c	(revision 0)
@@ -1,84 +1,29 @@
 //commands.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-#if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_MINIMAL)
-#define _NAME(x) (x)
-#else
-#define _NAME(x) ((char*)NULL)
-#endif
+struct roar_command g_commands[COMMAND_MAX_COMMANDS] = {
+  {ROAR_CMD_NOOP,         "NOOP",         req_on_noop},
+  {ROAR_CMD_IDENTIFY,     "IDENTIFY",     req_on_identify},
+  {ROAR_CMD_AUTH,         "AUTH",         req_on_auth},
+  {ROAR_CMD_NEW_STREAM,   "NEW_STREAM",   req_on_new_stream},
+  {ROAR_CMD_SET_META,     "SET_META",     req_on_set_meta},
+  {ROAR_CMD_EXEC_STREAM,  "EXEC_STREAM",  req_on_exec_stream},
+  {ROAR_CMD_QUIT,         "QUIT",         clients_delete},
 
-struct roar_command g_commands[COMMAND_MAX_COMMANDS] = {
-  {ROAR_CMD_NOOP,         _NAME("NOOP"),         req_on_noop,         ACCLEV_NONE},
-  {ROAR_CMD_IDENTIFY,     _NAME("IDENTIFY"),     req_on_identify,     ACCLEV_NONE},
-  {ROAR_CMD_AUTH,         _NAME("AUTH"),         req_on_auth,         ACCLEV_IDENTED},
-  {ROAR_CMD_WHOAMI,       _NAME("WHOAMI"),       req_on_whoami,       ACCLEV_NONE},
+  {ROAR_CMD_SERVER_OINFO, "SERVER_OINFO", req_on_server_oinfo},
+  {ROAR_CMD_GET_STANDBY,  "GET_STANDBY",  req_on_get_standby},
+  {ROAR_CMD_SET_STANDBY,  "SET_STANDBY",  req_on_set_standby},
+  {ROAR_CMD_EXIT,         "EXIT",         req_on_exit},
 
+  {ROAR_CMD_LIST_CLIENTS, "LIST_CLIENTS", req_on_list_clients},
+  {ROAR_CMD_LIST_STREAMS, "LIST_STREAMS", req_on_list_streams},
+  {ROAR_CMD_GET_CLIENT,   "GET_CLIENT",   req_on_get_client},
+  {ROAR_CMD_GET_STREAM,   "GET_STREAM",   req_on_get_stream},
+  {ROAR_CMD_KICK,         "KICK",         req_on_kick},
 
-  {ROAR_CMD_NEW_STREAM,   _NAME("NEW_STREAM"),   req_on_new_stream,   ACCLEV_USER},
+  {ROAR_CMD_ADD_DATA,     "ADD_DATA",     req_on_add_data},
 
-#ifdef ROAR_SUPPORT_META
-  {ROAR_CMD_SET_META,     _NAME("SET_META"),     req_on_set_meta,     ACCLEV_PWRUSER},
-  {ROAR_CMD_GET_META,     _NAME("GET_META"),     req_on_get_meta,     ACCLEV_GUEST},
-  {ROAR_CMD_LIST_META,    _NAME("LIST_META"),    req_on_list_meta,    ACCLEV_GUEST},
-#endif
-
-  {ROAR_CMD_EXEC_STREAM,  _NAME("EXEC_STREAM"),  req_on_exec_stream,  ACCLEV_PWRUSER},
-  {ROAR_CMD_QUIT,         _NAME("QUIT"),         req_on_quit, ACCLEV_NONE},
-
-  {ROAR_CMD_CON_STREAM,   _NAME("CON_STREAM"),   req_on_con_stream,   ACCLEV_PWRUSER},
-  {ROAR_CMD_PASSFH,       _NAME("PASSFH"),       req_on_passfh,       ACCLEV_PWRUSER},
-
-  {ROAR_CMD_GETTIMEOFDAY, _NAME("GETTIMEOFDAY"), req_on_gettimeofday, ACCLEV_NONE},
-  {ROAR_CMD_SERVER_INFO,  _NAME("SERVER_INFO"),  req_on_server_info,  ACCLEV_NONE},    // allow this early so the client
-                                                                                       // can decide early if this server
-                                                                                       // provieds all needed features
-  {ROAR_CMD_SERVER_OINFO, _NAME("SERVER_OINFO"), req_on_server_oinfo, ACCLEV_IDENTED}, // same as above
-  {ROAR_CMD_CAPS,         _NAME("CAPS"),         req_on_caps,         ACCLEV_IDENTED}, // and again the same
-  {ROAR_CMD_GET_STANDBY,  _NAME("GET_STANDBY"),  req_on_get_standby,  ACCLEV_GUEST},
-  {ROAR_CMD_SET_STANDBY,  _NAME("SET_STANDBY"),  req_on_set_standby,  ACCLEV_PWRUSER}, // should this be set to ACCLEV_ALL?
-  {ROAR_CMD_EXIT,         _NAME("EXIT"),         req_on_exit,         ACCLEV_ALL},
-
-  {ROAR_CMD_LIST_CLIENTS, _NAME("LIST_CLIENTS"), req_on_list_clients, ACCLEV_GUEST},
-  {ROAR_CMD_LIST_STREAMS, _NAME("LIST_STREAMS"), req_on_list_streams, ACCLEV_GUEST},
-  {ROAR_CMD_GET_CLIENT,   _NAME("GET_CLIENT"),   req_on_get_client,   ACCLEV_GUEST},
-  {ROAR_CMD_GET_STREAM,   _NAME("GET_STREAM"),   req_on_get_stream,   ACCLEV_GUEST},
-  {ROAR_CMD_KICK,         _NAME("KICK"),         req_on_kick,         ACCLEV_PWRUSER},
-  {ROAR_CMD_ATTACH,       _NAME("ATTACH"),       req_on_attach,       ACCLEV_PWRUSER},
-  {ROAR_CMD_SET_VOL,      _NAME("SET_VOL"),      req_on_set_vol,      ACCLEV_PWRUSER},
-  {ROAR_CMD_GET_VOL,      _NAME("GET_VOL"),      req_on_get_vol,      ACCLEV_GUEST},
-  {ROAR_CMD_GET_STREAM_PARA, _NAME("GET_STREAM_PARA"), req_on_get_stream_para, ACCLEV_GUEST},
-  {ROAR_CMD_SET_STREAM_PARA, _NAME("SET_STREAM_PARA"), req_on_set_stream_para, ACCLEV_PWRUSER},
-
-  {ROAR_CMD_ADD_DATA,     _NAME("ADD_DATA"),     req_on_add_data,     ACCLEV_PWRUSER},
-
-  {ROAR_CMD_BEEP,         _NAME("BEEP"),         req_on_beep,         ACCLEV_USER},
-
-  {ROAR_CMD_WAIT,         _NAME("WAIT"),         req_on_wait,         ACCLEV_USER},
-
-  {ROAR_CMD_EOL,          _NAME("END OF LIST"),  NULL,                ACCLEV_NONE}
+  {ROAR_CMD_EOL,          "END OF LIST",  NULL}
  };
 
@@ -98,39 +43,20 @@
 }
 
-int command_exec (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+int command_exec (int client, struct roar_message * mes, char * data) {
  int cmd = command_get_id_by_cmd(mes->cmd);
- int (*func)(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-#ifdef DEBUG
- int ret;
-#endif
+ int (*func)(int client, struct roar_message * mes, char * data);
 
  if ( cmd == -1 )
   return -1;
 
- // NOTE: This is optimized for speed here, so we do not call clients_get().
- // we maybe should do but current just don't. /client/ must be valid anyway.
- if ( g_commands[cmd].minacclev > g_clients[client]->acclev ) {
-  ROAR_WARN("command_exec(client=%i, mes=%p{.cmd=%i,...}, data=%p, flags=%p) = -1 // client not allowed to use command %s", client, mes, (int)mes->cmd, data, flags, g_commands[cmd].name);
+ if ( (func = g_commands[cmd].handler) == NULL )
   return -1;
- }
-
- if ( (func = g_commands[cmd].handler) == NULL ) {
-  ROAR_WARN("command_exec(client=%i, mes=%p{.cmd=%i,...}, data=%p, flags=%p) = -1 // unknown command", client, mes, (int)mes->cmd, data, flags);
-  return -1;
- }
 
  ROAR_DBG("command_exec(*): Execing command %i(%s) via %p", cmd, g_commands[cmd].name, func);
 
-#ifdef DEBUG
- ROAR_DBG("command_exec(client=%i, mes=%p{.cmd=%i,...}, data=%p{%p}, flags=%p): func=%p", client, mes, (int)mes->cmd, data, *data, flags, func);
- ret = func(client, mes, data, flags);
- ROAR_DBG("command_exec(client=%i, mes=%p{.cmd=%i,...}, data=%p{%p}, flags=%p) = %i", client, mes, (int)mes->cmd, data, *data, flags, ret);
- return ret;
-#else
- return func(client, mes, data, flags);
-#endif
+ return func(client, mes, data);
 }
 
-int command_get_name (int command, const char ** name) {
+int command_get_name (int command, char ** name) {
  int cmd = command_get_id_by_cmd(command);
 
Index: roard/container_framework.c
===================================================================
--- roard/container_framework.c	(revision 6052)
+++ 	(revision )
@@ -1,396 +1,0 @@
-//container_framework.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#define _DECL()  struct cont_fw_child_vio_inst * inst
-#define _CHECK() if ( vio == NULL ) \
-                 return -1
-#define _CINST() if ( (inst = vio->inst) == NULL ) \
-                  return -1
-#define _PREP()  _CHECK(); \
-                 _CINST()
-#define _BASIC() _DECL();  \
-                 _PREP()
-
-// Parent:
-int     cont_fw_new     (struct cont_fw_parent_inst ** inst) {
- struct cont_fw_parent_inst * self;
-
- if ( inst == NULL )
-  return -1;
-
- if ( (self = roar_mm_malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) {
-  *inst = NULL;
-  return -1;
- }
-
- memset(self, 0, sizeof(struct cont_fw_parent_inst));
-
- self->stream.id = -1;
- self->state     = ROAR_STREAMSTATE_INITING;
-
- if ( cont_pvio_open(&(self->vio), self) == -1 ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- *inst = self;
- return 0;
-}
-
-int     cont_fw_delete  (struct cont_fw_parent_inst  * inst) {
- int i;
-
- ROAR_DBG("cont_fw_delete(inst=%p) = ?", inst);
-
- if ( inst == NULL )
-  return -1;
-
- ROAR_DBG("cont_fw_delete(inst=%p) = ?", inst);
-
- // check if there are streams to close...
- for (i = 0; i < CONT_FW_MAX_CHILDS; i++) {
-  if ( inst->child[i] != NULL ) {
-   ROAR_DBG("cont_fw_delete(inst=%p) = -1 // there are still open childs", inst);
-   return -1;
-  }
- }
-
- ROAR_DBG("cont_fw_delete(inst=%p) = ?", inst);
-
- if ( inst->pcb.close != NULL )
-  inst->pcb.close(inst);
-
- roar_mm_free(inst);
-
- ROAR_DBG("cont_fw_delete(inst=%p) = 0", inst);
-
- return 0;
-}
-
-int     cont_fw_set_uinst(struct cont_fw_parent_inst  * inst, void  * u_inst) {
- if ( inst == NULL )
-  return -1;
-
- inst->u_inst = u_inst;
-
- return 0;
-}
-
-int     cont_fw_get_uinst(struct cont_fw_parent_inst  * inst, void ** u_inst) {
- if ( inst == NULL || u_inst == NULL )
-  return -1;
-
- *u_inst = inst->u_inst;
-
- return 0;
-}
-
-// VIO Client:
-int     cont_fw_new_child(struct cont_fw_parent_inst  * inst, int id) {
- struct cont_fw_child_vio_inst * self;
- struct roar_stream_server     * ss;
- int i;
- int cid = -1;
-
- ROAR_DBG("cont_fw_new_child(inst=%p, id=%i) = ?", inst, id);
-
- if ( inst == NULL || id == -1 )
-  return -1;
-
- if ( streams_get(id, &ss) == -1 )
-  return -1;
-
- for (i = 0; i < CONT_FW_MAX_CHILDS; i++) {
-  if ( inst->child[i] == NULL ) {
-   cid = i;
-   break;
-  }
- }
-
- if ( cid == -1 )
-  return -1;
-
- if ( (self = roar_mm_malloc(sizeof(struct cont_fw_child_vio_inst))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct cont_fw_child_vio_inst));
-
- self->parent = inst;
- self->child  = id;
- self->u_inst = NULL;
-
- inst->child[i] = self;
-
- if ( inst->pcb.new_child != NULL ) {
-  if ( inst->pcb.new_child(inst, self) == -1 ) {
-   inst->child[i] = NULL;
-   roar_mm_free(self);
-   return -1;
-  }
- }
-
- // no error possible here.
- cont_fw_init_vio(&(ss->vio), self);
-// ss->ready = 1;
-
- streams_set_fh(id, -2); // update some internal structures
-
- ROAR_DBG("cont_fw_new_child(inst=%p, id=%i) = 0", inst, id);
- return 0;
-}
-
-int     cont_fw_init_vio(struct roar_vio_calls * vio, void * inst) {
- if ( vio == NULL )
-  return -1;
-
- memset(vio, 0, sizeof(struct roar_vio_calls));
- vio->flags = ROAR_VIO_FLAGS_NONE;
- vio->refc  = 1;
- vio->inst  = inst;
- vio->read  = cont_fw_read;
- vio->write = cont_fw_write;
- vio->sync  = cont_fw_sync;
- vio->close = cont_fw_close;
-
- return 0;
-}
-
-ssize_t cont_fw_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- _BASIC();
-
- if ( inst->parent->ccb.read != NULL )
-  return inst->parent->ccb.read(inst->parent, inst, buf, count);
-
- return -1;
-}
-
-ssize_t cont_fw_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- _BASIC();
-
- if ( inst->parent->ccb.write != NULL )
-  return inst->parent->ccb.write(inst->parent, inst, buf, count);
-
- return -1;
-}
-
-roar_off_t   cont_fw_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence);
-
-int     cont_fw_sync    (struct roar_vio_calls * vio) {
- _BASIC();
-
- if ( inst->parent->ccb.flush != NULL )
-  return inst->parent->ccb.flush(inst->parent, inst);
-
- return 0;
-}
-
-int     cont_fw_close   (struct roar_vio_calls * vio) {
- _DECL();
- int r = 0;
- int i;
-
- _PREP();
-
- if ( cont_fw_sync(vio) == -1 )
-  r = -1;
-
- if ( inst->parent->ccb.close != NULL )
-  if ( inst->parent->ccb.close(inst->parent, inst) == -1 )
-   r = -1;
-
- for (i = 0; i < CONT_FW_MAX_CHILDS; i++) {
-  if ( inst->parent->child[i] == inst ) {
-   inst->parent->child[i] = NULL;
-  }
- }
-
- roar_mm_free(inst);
-
- return  r;
-}
-
-int     cont_fw_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-// VIO Parent:
-int     cont_pvio_open    (struct roar_vio_calls * vio, void * inst) {
- memset(vio, 0, sizeof(struct roar_vio_calls));
- vio->flags = ROAR_VIO_FLAGS_NONE;
- vio->refc  = 1;
-
- vio->inst  = inst;
-
- vio->read     = cont_pvio_read;
- vio->write    = cont_pvio_write;
- vio->lseek    = cont_pvio_lseek;
- vio->sync     = cont_pvio_sync;
- vio->ctl      = cont_pvio_ctl;
- vio->close    = cont_pvio_close;
-
- return 0;
-}
-
-ssize_t cont_pvio_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- return stream_vio_s_read(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream, buf, count);
-}
-
-ssize_t cont_pvio_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- ROAR_DBG("cont_pvio_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long) count);
- return stream_vio_s_write(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream, buf, count);
-}
-
-roar_off_t   cont_pvio_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence) {
- return roar_vio_lseek(&(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream->vio), offset, whence);
-}
-
-int     cont_pvio_sync    (struct roar_vio_calls * vio) {
- return roar_vio_sync(&(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream->vio));
-}
-
-int     cont_pvio_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- return roar_vio_ctl(&(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream->vio), cmd, data);
-}
-
-int     cont_pvio_close   (struct roar_vio_calls * vio) {
- return roar_vio_close(&(((struct cont_fw_parent_inst*)(vio->inst))->stream.stream->vio));
-}
-
-// CF:
-int cont_fw_cf_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                             struct roar_stream_server * info,
-                                             struct roar_codecfilter   * filter) {
- struct cont_fw_parent_inst * self;
- CONT_FW_SETUP_TYPE((*setup));
-
- ROAR_DBG("cont_fw_cf_open(*) = ?");
-
- if ( cont_fw_new(&self) == -1 )
-  return -1;
-
- self->stream.codec  = codec;
- self->stream.id     = ROAR_STREAM(info)->id;
- self->stream.stream = info;
- self->stream.filter = filter;
-
- ROAR_DBG("cont_fw_cf_open(*) = ?");
-
- if ( (setup = filter->setup) != NULL ) {
-  if ( setup(self, codec, filter) == -1 ) {
-   cont_fw_delete(self);
-   return -1;
-  }
- }
-
- ROAR_DBG("cont_fw_cf_open(*) = ?");
-
- *inst = self;
-
- ROAR_DBG("cont_fw_cf_open(*) = 0");
- return 0;
-}
-
-int cont_fw_cf_close(CODECFILTER_USERDATA_T   inst) {
- ROAR_DBG("cont_fw_cf_close(*) = ?");
- return cont_fw_delete(inst);
-}
-
-int cont_fw_cf_pause(CODECFILTER_USERDATA_T   inst, int newstate);
-
-
-// no direct read or writing...
-int cont_fw_cf_write(CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- struct cont_fw_parent_inst * self = (void*)inst;
-
- ROAR_DBG("cont_fw_cf_write(*) = ?");
-
- if ( self->state == ROAR_STREAMSTATE_INITING ) {
-  if ( self->pcb.open != NULL ) {
-   if ( self->pcb.open(self, self->stream.codec, self->stream.stream, self->stream.filter) == -1 ) {
-    return -1;
-   }
-  }
-  self->state = ROAR_STREAMSTATE_NEW;
-
-  ROAR_DBG("cont_fw_cf_write(*) = 0");
-  return 0;
- } else {
-  ROAR_DBG("cont_fw_cf_write(*) = -1");
-  return -1;
- }
-}
-
-int cont_fw_cf_read (CODECFILTER_USERDATA_T   inst, char * buf, int len) {
- ROAR_DBG("cont_fw_cf_read(*) = -1");
- return -1;
-}
-
-int cont_fw_cf_flush(CODECFILTER_USERDATA_T   inst) {
- struct cont_fw_parent_inst * self = (void*)inst;
-
- ROAR_DBG("cont_fw_cf_flush(*) = ?");
-
- if ( self->pcb.flush != NULL )
-  return self->pcb.flush(self);
-
- return 0;
-}
-
-int cont_fw_cf_delay(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-
-int cont_fw_cf_ctl  (CODECFILTER_USERDATA_T   inst, int cmd, void * data) {
- struct cont_fw_parent_inst * self = (void*)inst;
- int_least32_t type = cmd & ROAR_STREAM_CTL_TYPEMASK;
-
- ROAR_DBG("cont_fw_cf_ctl(*) = ?");
-
- cmd -= type;
-
- ROAR_DBG("cont_fw_cf_ctl(*): command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-
- if ( data == NULL && type != ROAR_STREAM_CTL_TYPE_VOID )
-  return -1;
-
- switch (cmd) {
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_VIRTUAL_DELETE):
-    return 0;
-   break;
-  case ROAR_CODECFILTER_CTL2CMD(ROAR_CODECFILTER_CTL_VIRTUAL_NEW):
-    if ( type != ROAR_STREAM_CTL_TYPE_INT )
-     return -1;
-
-    return cont_fw_new_child(self, *(int*)data);
-   break;
-  default:
-    ROAR_DBG("cont_fw_cf_ctl(*): Unknown command: cmd=0x%.8x, type=0x%.8x, pcmd=0x%.8x",
-                    cmd, type, ROAR_CODECFILTER_CTL2CMD(cmd));
-    return -1;
- }
-
- return -1;
-}
-
-//ll
Index: roard/driver.c
===================================================================
--- roard/driver.c	(revision 6052)
+++ roard/driver.c	(revision 0)
@@ -1,270 +1,49 @@
-//driver.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
 struct roar_driver g_driver[] = {
- { "null", "null audio driver", NULL, STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-   NULL, NULL, NULL},
+ { "null", "null audio driver", "/dev/null", NULL, NULL, NULL, NULL, NULL, NULL},
 #ifdef ROAR_HAVE_ESD
- { "esd", "EsounD audio driver", "localhost, remote.host.dom", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-   NULL, NULL, driver_esd_open_vio},
+ { "esd", "EsounD audio driver", "localhost, remote.host.dom", driver_esd_open, driver_esd_close, driver_esd_pause, driver_esd_write, driver_esd_read, driver_esd_flush},
 #endif
- { "roar", "RoarAudio driver", "localhost, remote.host.dom", STREAM_DIR_OUT, DRV_FLAG_NONE,
-   ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI|ROAR_SUBSYS_LIGHT|ROAR_SUBSYS_COMPLEX,
-   NULL, NULL, driver_roar_open_vio},
-#ifndef ROAR_WITHOUT_VIO_DSTR
- { "dstr", "VIO DSTR driver", "/some/file", STREAM_DIR_OUT, DRV_FLAG_FHSEC,
-   ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI|ROAR_SUBSYS_LIGHT|ROAR_SUBSYS_RAW|ROAR_SUBSYS_COMPLEX,
-   NULL, NULL, driver_dstr_open_vio},
+ { "roar", "RoarAudio driver", "localhost, remote.host.dom", driver_roar_open, driver_roar_close, driver_roar_pause, driver_roar_write, driver_roar_read, driver_roar_flush},
+#ifdef ROAR_HAVE_LIBAO
+ { "ao", "libao audio driver", "DRIVER", driver_ao_open, driver_ao_close, driver_ao_pause, driver_ao_write, driver_ao_read, driver_ao_flush},
 #endif
-#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS)
-#ifndef ROAR_DEFAULT_OSS_DEV
-#define ROAR_DEFAULT_OSS_DEV "no default device"
-#endif
- { "oss", "Open Sound System", ROAR_DEFAULT_OSS_DEV, STREAM_DIR_BIDIR, DRV_FLAG_FHSEC, ROAR_SUBSYS_WAVEFORM,
-   NULL, NULL, driver_oss_open},
-#endif
-#ifdef ROAR_HAVE_LIBAO
- { "ao", "libao audio driver", "DRIVER", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-   NULL, NULL, driver_ao_open_vio},
-#endif
-#ifdef ROAR_HAVE_LIBSHOUT
- {"shout", "libshout streaming", "http://user:pw@host:port/mount.ogg", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_shout_open_vio},
-#endif
-#ifdef ROAR_HAVE_LIBSNDIO
- {"sndio", "OpenBSD sndio", "/dev/audio, /tmp/aucat-<uid>/default", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM|ROAR_SUBSYS_MIDI,
-  NULL, NULL, driver_sndio_open},
-#endif
-#ifdef ROAR_HAVE_LIBRSOUND
- {"rsound", "RSound", "servername", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_rsound_open},
-#endif
-#ifdef _DRIVER_PORTAUDIO_CAN_OPERATE
- {"portaudio", "PortAudio", NULL, STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_portaudio_open},
-#endif
-#ifdef ROAR_HAVE_LIBASOUND
- {"alsa", "ALSA", "???", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, NULL, driver_alsa_open_vio},
-#endif
-#ifdef ROAR_HAVE_LIBWINMM
- {"wmm", "Win32 MM", "???", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, NULL, driver_wmm_open_vio},
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_DMX
- {"dmx", "DMX512 driver", "/dev/dmx", STREAM_DIR_OUT, DRV_FLAG_FHSEC, ROAR_SUBSYS_LIGHT,
-  NULL, NULL, driver_dmx_open_vio},
-#endif
-#if !defined(ROAR_WITHOUT_DCOMP_PWMLED) && !defined(ROAR_WITHOUT_VIO_DSTR)
- {"pwmled", "PWM LED driver", "/dev/ttyS0", STREAM_DIR_OUT, DRV_FLAG_FHSEC, ROAR_SUBSYS_LIGHT,
-  NULL, NULL, driver_pwmled_open_vio},
-#endif
-#ifdef ROAR_HAVE_DRIVER_I2CDMX
- {"i2cdmx", "I^2C DMX Interface driver", "/dev/i2c-1", STREAM_DIR_BIDIR, DRV_FLAG_NONE, ROAR_SUBSYS_LIGHT,
-  NULL, NULL, driver_i2cdmx_open_vio},
-#endif
-#ifdef ROAR_HAVE_DRIVER_SYSCLOCK
- {"sysclock", "System Clock Clock Source", NULL, STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_sysclock_open_vio},
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
- {"cdriver", "RoarAudio Client driver", "driver#device", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_cdriver_open},
-#endif
-#ifdef ROAR_HAVE_LIBPULSE
- {"pulsesimple", "PulseAudio Simple", "server", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_pulsesimple_open},
-#endif
-#ifdef ROAR_HAVE_LIBJACK
-#if 0
- // this is currently just a driver stub.
- {"jack", "JACK", "???", STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_jack_open_vio},
-#endif
-#endif
-#ifdef ROAR_HAVE_LIBARTSC
- {"artsc", "aRts plain C API", NULL, STREAM_DIR_OUT, DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-  NULL, NULL, driver_artsc_open_vio},
-#endif
- {NULL, NULL, NULL, STREAM_DIR_NONE, DRV_FLAG_NONE, 0, NULL, NULL, NULL} // end of list
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} // end of list
                                 };
 
-void print_driverlist (enum output_format format) {
+void print_driverlist (void) {
  int i;
- char subsys[7] = "      ";
- char mode[5]   = "    ";
-
- switch (format) {
-  case FORMAT_NATIVE:
-    printf("  Driver       Mode Flag Subsys - Description (devices)\n");
-    printf("---------------------------------------------------------------\n");
-   break;
-  case FORMAT_WIKI:
-    printf("||=Driver =||=Mode =||=Flag =||=Subsys =||=Description =||=Devices =||\n");
-   break;
-  case FORMAT_CSV:
-    printf("Driver,Mode,Flag,Subsys,Description,Devices\n");
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return;
- }
 
  for (i = 0; g_driver[i].name != NULL; i++) {
-  strncpy(subsys, "      ", 6);
-  strncpy(mode,   "    ",   4);
-
-  if ( g_driver[i].mode & STREAM_DIR_IN )
-   mode[0] = 'r';
-  if ( g_driver[i].mode & STREAM_DIR_OUT )
-   mode[1] = 'w';
-
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_WAVEFORM )
-   subsys[0] = 'W';
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_MIDI )
-   subsys[1] = 'M';
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_CB )
-   subsys[2] = 'C';
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_LIGHT )
-   subsys[3] = 'L';
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_RAW )
-   subsys[4] = 'R';
-  if ( g_driver[i].subsystems & ROAR_SUBSYS_COMPLEX )
-   subsys[5] = 'X';
-
-  switch (format) {
-   case FORMAT_NATIVE:
-     if ( g_driver[i].devices != NULL ) {
-      printf("  %-12s %4s %c%c%c%c %6s - %s (devices: %s)\n", g_driver[i].name,
-                    mode,
-                    ' ', /* unused Flag */
-                    g_driver[i].flags & DRV_FLAG_FHSEC                                                         ? 's' : ' ',
-                    g_driver[i].open     != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? 'S' : ' ',
-                    g_driver[i].vio_init != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? 'V' : ' ',
-                    subsys,
-                    g_driver[i].desc, g_driver[i].devices);
-     } else {
-      printf("  %-12s %4s %c%c%c%c %6s - %s\n", g_driver[i].name,
-                    mode,
-                    ' ', /* unused Flag */
-                    g_driver[i].flags & DRV_FLAG_FHSEC                                                         ? 's' : ' ',
-                    g_driver[i].open     != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? 'S' : ' ',
-                    g_driver[i].vio_init != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? 'V' : ' ',
-                    subsys,
-                    g_driver[i].desc);
-     }
-    break;
-   case FORMAT_WIKI:
-     printf("||=%-12s =|| %s || %s%s%s ||%s ||%s ||%s ||\n", g_driver[i].name, mode[0] == ' ' ? mode+1 : mode,
-                    g_driver[i].flags & DRV_FLAG_FHSEC                                                         ? "s" : " ",
-                    g_driver[i].open     != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? "S" : " ",
-                    g_driver[i].vio_init != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? "V" : " ",
-                    subsys,
-                    g_driver[i].desc, g_driver[i].devices == NULL ? "" : g_driver[i].devices);
-    break;
-   case FORMAT_CSV:
-     printf("%s,%s,%s%s%s,%s,%s,%s\n", g_driver[i].name, mode,
-                    g_driver[i].flags & DRV_FLAG_FHSEC                                                         ? "s" : " ",
-                    g_driver[i].open     != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? "S" : " ",
-                    g_driver[i].vio_init != NULL || (g_driver[i].open == NULL && g_driver[i].vio_init == NULL) ? "V" : " ",
-                    subsys,
-                    g_driver[i].desc, g_driver[i].devices == NULL ? "" : g_driver[i].devices);
-    break;
-  }
+  printf("  %-8s - %s (devices: %s)\n", g_driver[i].name, g_driver[i].desc, g_driver[i].devices);
  }
 }
 
-int driver_openvio(struct roar_vio_calls * calls,
-                 int * driver_id, char * driver /* NOTE: this is not part of struct roar_driver's def! */,
-                 char * device, struct roar_audio_info * info, int fh,
-                 struct roar_stream_server * sstream) {
+int driver_open (DRIVER_USERDATA_T * inst, int * driver_id, char * driver, char * device, struct roar_audio_info * info) {
  int i;
 
-#ifdef ROAR_DRIVER_DEFAULT
  if ( driver == NULL )
   driver = ROAR_DRIVER_DEFAULT;
-#else
- if ( driver == NULL )
-  return -1;
-#endif
-
-#ifdef ROAR_DRIVER_DEVICE
- if ( device == NULL )
-  device = ROAR_DRIVER_DEVICE;
-#endif
-
- ROAR_DBG("driver_openvio(*): searching for driver '%s'...", driver);
 
  for (i = 0; g_driver[i].name != NULL; i++) {
   if ( strcmp(g_driver[i].name, driver) == 0 ) {
-   ROAR_DBG("driver_openvio(*): found driver: id = %i", i);
+   ROAR_DBG("driver_open(*): found driver: id = %i", i);
 
    *driver_id = i;
 
-   ROAR_DBG("driver_openvio(*): driver found: %s -> %i", driver, i);
-
-   if ( g_driver[i].vio_init == NULL ) {
-    if ( g_driver[i].open == NULL ) { // this is the null driver
-     memset(calls, 0, sizeof(struct roar_vio_calls));
-     calls->flags = ROAR_VIO_FLAGS_NONE;
-     calls->refc  = 1;
-     calls->read  = roar_vio_null_rw;
-     calls->write = roar_vio_null_rw;
-     return 0;
-    }
-
-    ROAR_WARN("driver_openvio(*): driver(%s) uses old non-vio interface!", driver);
-    ROAR_ERR("driver_openvio(calls=%p, driver_id={%i}, driver='%s', device='%s', info=%p, fh=%i): not a VIO driver!",
-        calls, i, driver, device, info, fh);
-    return -1;
-   }
-
-   // if this driver does not support input we need to check if it is used in input mode.
-   if ( !(g_driver[i].mode & STREAM_DIR_IN) ) {
-    if ( sstream == NULL )
-     return -1;
-
-    if ( streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_RECSOURCE) ) {
-     if ( streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF) == 1 ) {
-      if ( streams_reset_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_RECSOURCE) == -1 )
-       return -1;
-     } else {
-      ROAR_WARN("driver_openvio(*): driver(%s) is not abled to record data and autoconf flag is not set.", driver);
-      return -1;
-     }
-    }
-   }
-
-   ROAR_DBG("driver_openvio(*): Opening VIO driver %s(%i)...", driver, i);
-   return g_driver[i].vio_init(calls, device, info, fh, sstream);
+   if ( g_driver[i].open )
+    return g_driver[i].open(inst, device, info);
+   return 0;
   }
  }
+
  return -1;
 }
 
-int driver_closevio(struct roar_vio_calls * calls, int driver) {
- ROAR_DBG("driver_closevio(calls=%p, driver=%i) = ?", calls, driver);
+int driver_close(DRIVER_USERDATA_T   inst, int driver) {
+ ROAR_DBG("driver_close(inst=%p, driver=%i) = ?", inst, driver);
 
  if ( driver == -1 )
@@ -272,83 +51,47 @@
 
  if ( g_driver[driver].close )
-  return g_driver[driver].close((DRIVER_USERDATA_T)calls);
-
- if ( calls->close != NULL )
-  roar_vio_close(calls);
+  return g_driver[driver].close(inst);
 
  return 0;
 }
 
-int driver_set_volume(int stream, struct roar_mixer_settings * mixer) {
- struct roar_stream_server * ss;
-
- if ( (ss = g_streams[stream]) == NULL )
+int driver_pause(DRIVER_USERDATA_T   inst, int driver, int newstate) {
+ if ( driver == -1 )
   return -1;
 
- if ( !streams_get_flag(stream, ROAR_FLAG_HWMIXER) )
-  return 0;
+ if ( g_driver[driver].pause )
+  return g_driver[driver].pause(inst, newstate);
 
- if ( ss->driver_id == -1 )
+ return 0;
+}
+
+int driver_write(DRIVER_USERDATA_T   inst, int driver, char * buf, int len) {
+ if ( driver == -1 )
   return -1;
 
- return roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_VOLUME, (void*)mixer);
+ if ( g_driver[driver].write )
+  return g_driver[driver].write(inst, buf, len);
+
+ return 0;
 }
 
+int driver_read (DRIVER_USERDATA_T   inst, int driver, char * buf, int len) {
+ if ( driver == -1 )
+  return -1;
 
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
-int driver_cdriver_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- char * driver;
- char * delm;
- int ret;
+ if ( g_driver[driver].read )
+  return g_driver[driver].read(inst, buf, len);
 
- (void)sstream;
+ return 0;
+}
 
- ROAR_DBG("driver_cdriver_open(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
+int driver_flush(DRIVER_USERDATA_T   inst, int driver) {
+ if ( driver == -1 )
+  return -1;
 
- if ( fh != -1 ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
+ if ( g_driver[driver].flush )
+  return g_driver[driver].flush(inst);
 
- if (device == NULL) {
-  driver = NULL;
- } else {
-  driver = roar_mm_strdup(device);
-
-  if ( (delm = strstr(driver, "#")) == NULL ) {
-   device = NULL;
-  } else {
-   *delm  = 0;
-   device = strstr(device, "#") + 1;
-  }
- }
-
- ROAR_DBG("driver_cdriver_open(*): CALL roar_cdriver_open(inst=%p, driver='%s', device='%s', info=%p, dir=ROAR_DIR_PLAY)", inst, driver, device, info);
- ret = roar_cdriver_open(inst, driver, device, info, ROAR_DIR_PLAY);
- ROAR_DBG("driver_cdriver_open(*): RET %i", ret);
-
- if ( driver != NULL )
-  roar_mm_free(driver);
-
- return ret;
-}
-#endif
-
-int  driver_dummy_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- (void)vio;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( *(const int*)data == ROAR_SOCKET_BLOCK )
-     return 0;
-
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
- }
+ return 0;
 }
 
Index: roard/driver_alsa.c
===================================================================
--- roard/driver_alsa.c	(revision 6052)
+++ 	(revision )
@@ -1,380 +1,0 @@
-//driver_alsa.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *      Copyright (C) Hans-Kristian 'maister' Arntzen - 2010
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBASOUND
-
-#define ALSA_PCM_NEW_HW_PARAMS_API
-
-static snd_pcm_format_t driver_alsa_roar_fmt_to_alsa(struct roar_audio_info * info) {
- snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN;
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-    switch (info->bits) {
-     case  8: format = SND_PCM_FORMAT_S8;      break;
-     case 16: format = SND_PCM_FORMAT_S16_LE;  break;
-     case 24: format = SND_PCM_FORMAT_S24_3LE; break;
-     case 32: format = SND_PCM_FORMAT_S32_LE;  break;
-    }
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    switch (info->bits) {
-     case  8: format = SND_PCM_FORMAT_S8;      break;
-     case 16: format = SND_PCM_FORMAT_S16_BE;  break;
-     case 24: format = SND_PCM_FORMAT_S24_3BE; break;
-     case 32: format = SND_PCM_FORMAT_S32_BE;  break;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_LE:
-    switch (info->bits) {
-     case  8: format = SND_PCM_FORMAT_U8;      break;
-     case 16: format = SND_PCM_FORMAT_U16_LE;  break;
-     case 24: format = SND_PCM_FORMAT_U24_3LE; break;
-     case 32: format = SND_PCM_FORMAT_U32_LE;  break;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_BE:
-    switch (info->bits) {
-     case  8: format = SND_PCM_FORMAT_U8;      break;
-     case 16: format = SND_PCM_FORMAT_U16_BE;  break;
-     case 24: format = SND_PCM_FORMAT_U24_3BE; break;
-     case 32: format = SND_PCM_FORMAT_U32_BE;  break;
-    }
-   break;
-  case ROAR_CODEC_ALAW:
-    format = SND_PCM_FORMAT_A_LAW;
-   break;
-  case ROAR_CODEC_MULAW:
-    format = SND_PCM_FORMAT_MU_LAW;
-   break;
-  case ROAR_CODEC_GSM:
-    format = SND_PCM_FORMAT_GSM;
-   break;
- }
-
- return format;
-}
-
-static int driver_alsa_set_params(roar_alsa_t * device) {
- unsigned int      buffer_time = 32000; // 32ms buffer if possible.
-                                        // *_buffer_time_near() will pick something as close as possible.
- snd_pcm_uframes_t frames      = ROAR_OUTPUT_BUFFER_SAMPLES;
- int               rc;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_malloc(&device->params) < 0 )
-  return -1;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_any(device->handle, device->params) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_set_access(device->handle, device->params, SND_PCM_ACCESS_RW_INTERLEAVED) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_set_format(device->handle, device->params, device->format) < 0)
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- ROAR_DBG("driver_alsa_set_params(device=%p): device->info.channels=%i", device, device->info.channels);
-
- if ( snd_pcm_hw_params_set_channels(device->handle, device->params, device->info.channels) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_set_rate(device->handle, device->params, device->info.rate, 0) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_set_buffer_time_near(device->handle, device->params, &buffer_time, NULL) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- if ( snd_pcm_hw_params_set_period_size_near(device->handle, device->params, &frames, NULL) < 0 )
-  goto error;
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- rc = snd_pcm_hw_params(device->handle, device->params);
- if (rc < 0) {
-  ROAR_ERR("driver_alsa_open_vio(*): unable to set hw parameters: %s", snd_strerror(rc));
-  goto error;
- }
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = ?", device);
-
- snd_pcm_hw_params_free(device->params);
-
- ROAR_DBG("driver_alsa_set_params(device=%p) = 0", device);
-
- return 0;
-
-error:
- snd_pcm_hw_params_free(device->params);
- ROAR_DBG("driver_alsa_set_params(device=%p) = -1", device);
- return -1;
-}
-
-int driver_alsa_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- roar_alsa_t     * interface;
- char            * alsa_dev;
- int               rc;
- int               autoconf;
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- if ( fh != -1 )
-  return -1;
-
- if ( (interface = roar_mm_calloc(1, sizeof(roar_alsa_t))) == NULL )
-  return -1;
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- if ( device == NULL ) {
-  alsa_dev = "default";
- } else {
-  alsa_dev = device;
- }
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- rc = snd_pcm_open(&(interface->handle), alsa_dev, SND_PCM_STREAM_PLAYBACK, 0); 
- if ( rc < 0 ) {
-  ROAR_ERR("driver_alsa_open_vio(*): Unable to open PCM device: %s", snd_strerror(rc));
-  roar_mm_free(interface);
-  return -1;
- }
-
- // Setting sample format, yay.
- interface->format = driver_alsa_roar_fmt_to_alsa(info);
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- // We did not find a codec
- if ( interface->format == SND_PCM_FORMAT_UNKNOWN ) {
-  autoconf = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
-  if ( autoconf == -1 ) {
-   ROAR_ERR("driver_alsa_open_vio(*): Could not get autoconf flag.");
-   goto init_error;
-  }
-
-  if ( autoconf ) {
-   info->bits  = 16;
-
-#if   ROAR_CODEC_DEFAULT == ROAR_CODEC_PCM_S_LE
-   interface->format = SND_PCM_FORMAT_S16_LE;
-   info->codec       = ROAR_CODEC_PCM_S_LE;
-#elif ROAR_CODEC_DEFAULT == ROAR_CODEC_PCM_S_BE
-   interface->format = SND_PCM_FORMAT_S16_BE;
-   info->codec       = ROAR_CODEC_PCM_S_BE;
-#else
-   ROAR_ERR("driver_alsa_open_vio(*): ALSA only support little- or big-endian sample format. Please select -oO codec=pcm_s_le or pcm_s_be");
-   goto init_error;
-#endif
-   ROAR_WARN("driver_alsa_open_vio(*): Supplied codec type not available. Using 16 bit sample format.");
-  } else {
-   ROAR_ERR("driver_alsa_open_vio(*): can not set requested codec, set codec manually with -oO codec=<codec>.");
-   goto init_error;
-  }
- }
-
- memcpy(&(interface->info), info, sizeof(struct roar_audio_info));
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- if ( driver_alsa_set_params(interface) < 0 )
-  goto init_error;
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = ?", inst, device, info, fh, sstream);
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->inst     = (void*) interface;
- inst->write    = driver_alsa_write;
- inst->close    = driver_alsa_close;
- inst->sync     = driver_alsa_sync;
- inst->ctl      = driver_alsa_ctl;
-
- ROAR_DBG("driver_alsa_open_vio(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = 0", inst, device, info, fh, sstream);
-
- return 0;
-
-init_error:
- snd_pcm_close(interface->handle);
- roar_mm_free(interface);
- return -1;
-}
-
-int driver_alsa_close(struct roar_vio_calls * vio) {
- roar_alsa_t * device = vio->inst;
-
- if ( device->handle != NULL ) {
-  snd_pcm_drain(device->handle);
-  snd_pcm_close(device->handle);
- }
-
- roar_mm_free(device);
-
- return 0;
-}
-
-static ssize_t driver_alsa_write_int(struct roar_vio_calls * vio, void *buf, size_t size) {
- roar_alsa_t       * device    = vio->inst;
- snd_pcm_sframes_t  write_size = snd_pcm_bytes_to_frames(device->handle, size);
- snd_pcm_sframes_t  rc;
-
- ROAR_DBG("driver_alsa_write(vio=%p, buf=%p, size=%llu) = ?", vio, buf, (long long unsigned int)size);
-
- rc = snd_pcm_writei(device->handle, buf, write_size);
-
- if ( rc == -EPIPE || rc == -EINTR || rc == -ESTRPIPE ) {
-  if ( snd_pcm_recover(device->handle, rc, 1) < 0 )
-   return -1;
-  return size;
- } else if (rc < 0) {
-  ROAR_ERR("driver_alsa_write(*): Error from snd_pcm_writei(*): %s", snd_strerror(rc));
-  return -1;
- }  
-
- return snd_pcm_frames_to_bytes(device->handle, rc);
-}
-
-ssize_t driver_alsa_write(struct roar_vio_calls * vio, void *buf, size_t size) {
- char*   mutable_buf = (char*)buf;
- ssize_t have        = 0;
- ssize_t ret;
-
- while (size) {
-  ret = driver_alsa_write_int(vio, mutable_buf, size);
-  if ( ret < 0 )
-   return -1;
-
-  have        += ret;
-  mutable_buf += ret;
-  size        -= ret;
- }
-
- return have;
-}
-
-int driver_alsa_sync(struct roar_vio_calls * vio) {
- roar_alsa_t       * device    = vio->inst;
- return snd_pcm_drain(device->handle);
-}
-
-/* Stop the driver, set new params, and restart */
-/* Not been able to test this function. */
-/* Assuming that params can be reset after halting the PCM device */
-static int driver_alsa_reopen_device(roar_alsa_t * device) {
-
- if ( snd_pcm_drop(device->handle) < 0 ) {
-  ROAR_ERR("driver_alsa_reopen_device(*): snd_pcm_drop() failed.");
-  return -1;
- }
-
- if ( driver_alsa_set_params(device) < 0 ) {
-  ROAR_ERR("driver_alsa_reopen_device(*): driver_alsa_set_params() failed.");
-  return -1;
- }
-
- return 0;
-}
-
-/* Not completely tested.
- * Tested:
- * ROAR_VIO_CTL_GET_DELAY
- * ROAR_VIO_CTL_SET_SSTREAMID
- * ROAR_VIO_CTL_SET_SSTREAM
- */
-
-int driver_alsa_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- roar_alsa_t       * device    = vio->inst;
- snd_pcm_sframes_t alsa_delay;
-
- ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_DELAY:
-    if ( snd_pcm_delay(device->handle, &alsa_delay) < 0 )
-     return -1;
-    else {
-     *(uint_least32_t *)data = snd_pcm_frames_to_bytes(device->handle, alsa_delay);
-     ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_DELAY(0x%.8x), data=%p): %i bytes.", vio, cmd, data, (int)(*(uint_least32_t*)data));
-    }
-   break;
-
-  case ROAR_VIO_CTL_SET_SSTREAMID:
-    device->ssid = *(int *)data;
-    ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=ROAR_VIO_CTL_SET_SSTREAMID(0x%.8x), data=%p): ssid=%i", vio, cmd, data, device->ssid);
-   break;
-
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    device->sstream = data;
-    ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=ROAR_VIO_CTL_SET_SSTREAM(0x%.8x), data=%p): sstream=%p", vio, cmd, data, device->sstream);
-   break;
-
-  case ROAR_VIO_CTL_GET_AUINFO:
-    ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_AUINFO(0x%.8x), data=%p) = ?", vio, cmd, data);
-    memcpy(data, &(device->info), sizeof(struct roar_audio_info));
-   break;
-
-  case ROAR_VIO_CTL_SET_AUINFO:
-    ROAR_DBG("driver_alsa_ctl(vio=%p, cmd=ROAR_VIO_CTL_SET_AUINFO(0x%.8x), data=%p) = ?", vio, cmd, data);
-    memcpy(&(device->info), data, sizeof(struct roar_audio_info));
-    return driver_alsa_reopen_device(device);
-   break;
-
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( *(int*)data == ROAR_SOCKET_BLOCK )
-     return 0;
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-
-  default:
-   return -1;
- }
-
- return 0;
-}
-
-#endif
-
Index: roard/driver_ao.c
===================================================================
--- roard/driver_ao.c	(revision 6052)
+++ roard/driver_ao.c	(revision 0)
@@ -1,63 +1,12 @@
-//driver_ao.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
+//driver_esd.c:
 
 #include "roard.h"
-#ifdef ROAR_HAVE_LIBAO
 
-static int _driver_ao_usage_counter = 0;
-
-void driver_ao_init (void) {
- if ( _driver_ao_usage_counter++ == 0 )
-  ao_initialize();
-
-#ifdef ROAR_HAVE_AO_APPEND_GLOBAL_OPTION
- ao_append_global_option("client_name", "roard");
-#endif
-}
-
-void driver_ao_uninit (void) {
- if ( _driver_ao_usage_counter-- == 1 )
-  ao_shutdown();
-}
-
-int driver_ao_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
-//int driver_ao_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) {
+int driver_ao_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) {
  ao_device        * aodevice;
  ao_sample_format     format;
  int driver;
- int autoconfig = 0;
 
- ROAR_WARN("The libao driver is obsolete, use another!");
-
- if ( fh != -1 )
-  return -1;
-
- if ( sstream != NULL ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
- }
-
- driver_ao_init();
+ ao_initialize();
 
  if ( device == NULL ) {
@@ -66,94 +15,49 @@
   if ( (driver = ao_driver_id(device)) == -1 ) {
    ROAR_ERR("Can not open audio device via libao's driver '%s'", device);
-   driver_ao_uninit();
    return -1;
   }
  }
 
- memset(&format, 0, sizeof(format));
-
  format.bits        = info->bits;
  format.channels    = info->channels;
  format.rate        = info->rate;
-
- if ( info->bits == 8 ) {
-  ROAR_WARN("This is the libao driver in 8 bit mode, It's not known to me if I need to provide data in signed or in unsigned mode. If your musik sounds strange try -oO codec=pcm_s_le or -oO codec=pcm_u_be");
-/* NOTE: the following is only true for EsounD driver, not for OSS driver, don't know for the others
-  switch (info->codec) {
-   case ROAR_CODEC_PCM_U_LE:
-   case ROAR_CODEC_PCM_U_BE:
-   case ROAR_CODEC_PCM_U_PDP:
-     format.byte_format = AO_FMT_NATIVE;
-    break;
-   default:
-     ROAR_ERR("Can not open audio device via libao: codec not supported. You may want to try -oO codec=pcm_u_le or -oO codec=pcm,bits=16");
-     driver_ao_uninit();
-     return -1;
-    break;
-  }
-*/
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-    format.byte_format = AO_FMT_LITTLE;
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    format.byte_format = AO_FMT_BIG;
-   break;
-  default:
-    if ( autoconfig ) {
-     format.byte_format = AO_FMT_NATIVE;
-     info->codec = ROAR_CODEC_DEFAULT;
-    } else {
-     ROAR_ERR("Can not open audio device via libao: codec not supported. You may want to try -oO codec=pcm");
-     driver_ao_uninit();
-     return -1;
-    }
-   break;
- }
+ format.byte_format = AO_FMT_NATIVE;
 
  aodevice = ao_open_live(driver, &format, NULL /* no options */);
 
- if ( aodevice == NULL && autoconfig ) {
-  format.byte_format = AO_FMT_NATIVE;
-  format.bits        = 16;
-  info->codec        = ROAR_CODEC_DEFAULT;
-  info->bits         = 16;
-  aodevice = ao_open_live(driver, &format, NULL /* no options */);
- }
-
  if ( aodevice == NULL ) {
   ROAR_ERR("Can not open audio device via libao.");
-  driver_ao_uninit();
   return -1;
  }
 
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
- inst->inst     = (void*) aodevice;
- inst->write    = driver_ao_write;
- inst->close    = driver_ao_close;
- inst->ctl      = driver_dummy_ctl;
+ *((ao_device**)inst) = aodevice;
 
  return 0;
 }
 
-int driver_ao_close(struct roar_vio_calls * vio) {
+int driver_ao_close(DRIVER_USERDATA_T   inst) {
 
- ao_close((ao_device*)vio->inst);
+ ao_close((ao_device*)inst);
 
- driver_ao_uninit();
+ ao_shutdown();
 
+ return -1;
+}
+
+int driver_ao_pause(DRIVER_USERDATA_T   inst, int newstate) {
+ return -1;
+}
+
+int driver_ao_write(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ return ao_play((ao_device*)inst, buf, len);
+}
+
+int driver_ao_read(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ return -1;
+}
+
+int driver_ao_flush(DRIVER_USERDATA_T   inst) {
  return 0;
 }
 
-ssize_t driver_ao_write(struct roar_vio_calls * vio, void *buf, size_t count) {
- if ( ao_play((ao_device*)(vio->inst), buf, count) == 0 )
-  return -1;
- return count;
-}
-
-#endif
 //ll
Index: roard/driver_artsc.c
===================================================================
--- roard/driver_artsc.c	(revision 6052)
+++ 	(revision )
@@ -1,214 +1,0 @@
-//driver_artsc.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBARTSC
-
-#define INIT     +1
-#define SHUTDOWN -1
-
-static int driver_artsc_init_shutdown (int action) {
- static int state = 0;
-
- if ( action != INIT && action != SHUTDOWN )
-  return -1;
-
- if ( state == 0 && action == INIT ) {
-  if ( arts_init() != 0 )
-   return -1;
- } else if ( state == 1 && action == SHUTDOWN ) {
-  arts_free();
- }
-
- state += action;
-
- return 0;
-}
-
-int     driver_artsc_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct roar_artsc * self = NULL;
- int autoconfig           = 0;
-
- (void)sstream;
-
- ROAR_WARN("The aRtsc driver is obsolete/broken, use another!");
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- if ( fh != -1 || device != NULL )
-  return -1;
-
- if ( sstream != NULL ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
- }
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- self = roar_mm_malloc(sizeof(struct roar_artsc));
-
- if ( self == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct roar_artsc));
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- if ( driver_artsc_init_shutdown(INIT) == -1 ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- if ( info->codec != ROAR_CODEC_DEFAULT ) {
-  if ( autoconfig ) {
-   info->codec = ROAR_CODEC_DEFAULT;
-  } else {
-   return -1;
-  }
- }
-
- if ( info->bits != 16 ) {
-  if ( autoconfig ) {
-   info->bits = 16;
-  }
- }
-
- self->info   = info;
- self->stream = arts_play_stream(info->rate, info->bits, info->channels, "roard");
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- if ( self->stream == NULL && autoconfig ) {
-  info->bits   = 16;
-  self->stream = arts_play_stream(info->rate, info->bits, info->channels, "roard");
- }
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- if ( self->stream == NULL ) {
-  roar_mm_free(self);
-  driver_artsc_init_shutdown(SHUTDOWN);
-  ROAR_DBG("driver_artsc_open_vio(*) = -1");
-  return -1;
- }
-
- ROAR_DBG("driver_artsc_open_vio(*) = ?");
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->inst     = (void*) self;
- inst->write    = driver_artsc_write;
- inst->close    = driver_artsc_close;
- inst->ctl      = driver_artsc_ctl;
-
- ROAR_DBG("driver_artsc_open_vio(*) = 0");
- return 0;
-}
-
-ssize_t driver_artsc_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct roar_artsc * self = vio->inst;
- int ret;
-
- ROAR_DBG("driver_artsc_write(*) = ?");
-
- ret = arts_write(self->stream, buf, count);
-
- if ( ret >= 0 ) {
-  ROAR_DBG("driver_artsc_write(*) = %i", ret);
-  return ret;
- }
-
- ROAR_DBG("driver_artsc_write(*) = -1");
- return -1;
-}
-
-int     driver_artsc_close   (struct roar_vio_calls * vio) {
- struct roar_artsc * self = vio->inst;
-
- arts_close_stream(self->stream);
-
- roar_mm_free(self);
-
- return driver_artsc_init_shutdown(SHUTDOWN);
-}
-
-int     driver_artsc_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct roar_artsc * self = vio->inst;
- ssize_t bps;
- int ret;
- uint_least32_t tmp;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_DBLKSIZE:
-    ret = arts_stream_get(self->stream, ARTS_P_PACKET_SIZE);
-    if ( ret > 0 ) {
-     *(uint_least32_t *)data = ret;
-     return 0;
-    }
-   break;
-  case ROAR_VIO_CTL_GET_DELAY:
-    ret = arts_stream_get(self->stream, ARTS_P_TOTAL_LATENCY);
-    if ( ret < 0 )
-     return -1;
-    bps = roar_info2bitspersec(self->info);
-    if ( bps < 0 )
-     return -1;
-
-    tmp  = bps / (ssize_t)8;
-    tmp *= ret;
-    tmp /= (uint_least32_t)1000;
-
-    *(uint_least32_t *)data = tmp;
-
-    return 0;
-  case ROAR_VIO_CTL_NONBLOCK:
-    switch (*(int*)data) {
-     case ROAR_SOCKET_NONBLOCK:
-       ret = arts_stream_set(self->stream, ARTS_P_BLOCKING, 0);
-       if ( ret == 0 )
-        return 0;
-       return -1;
-      break;
-     case ROAR_SOCKET_BLOCK:
-       ret = arts_stream_set(self->stream, ARTS_P_BLOCKING, 1);
-       if ( ret == 1 )
-        return 0;
-       return -1;
-      break;
-    }
-   break;
-  default:
-    return -1;
- }
-
- return -1;
-}
-
-#endif
-
-//ll
Index: roard/driver_dmx.c
===================================================================
--- roard/driver_dmx.c	(revision 6052)
+++ 	(revision )
@@ -1,120 +1,0 @@
-//driver_dmx.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_DMX
-
-int driver_dmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct roar_vio_defaults def;
- struct roar_vio_calls * vio;
- int err;
- const char * dev = device;
- char * dev_default_dmx4linux = NULL;
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 )
-  return -1;
-
- vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
- if ( vio == NULL )
-  return -1;
- roar_vio_clear_calls(vio);
-
- if ( fh == -1 ) {
-  if ( dev == NULL )
-   dev = roar_env_get("DMX");
-
-  if ( dev == NULL ) {
-   dev_default_dmx4linux = roar_libroar_get_path("dev-default-dmx4linux", 0, NULL, NULL);
-   dev = dev_default_dmx4linux;
-  }
-
-  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
-   err = roar_error;
-   roar_mm_free(vio);
-   if ( dev_default_dmx4linux != NULL )
-    roar_mm_free(dev_default_dmx4linux);
-   roar_error = err;
-   return -1;
-  }
-  if ( dev_default_dmx4linux != NULL )
-   roar_mm_free(dev_default_dmx4linux);
- } else {
-  if ( roar_vio_open_fh(vio, fh) == -1 ) {
-   err = roar_error;
-   roar_mm_free(vio);
-   roar_error = err;
-   return -1;
-  }
- }
-
- vio->flags |= ROAR_VIO_FLAGS_FREESELF;
-
- roar_vio_open_pass(inst, vio);
- inst->write = driver_dmx_write;
- inst->ctl   = driver_dmx_ctl;
-
- info->codec = ROAR_CODEC_DMX512;
-
- if ( sstream != NULL )
-  driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
-
- return 0;
-}
-
-ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
- if ( vio == NULL || buf == NULL )
-  return -1;
-
- if ( count != 512 )
-  return -1;
-
- if ( roar_vio_lseek(vio->inst, 0, SEEK_SET) == (roar_off_t)-1 )
-  return -1;
-
- return roar_vio_write(vio->inst, buf, count);
-}
-
-int driver_dmx_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
-
- if ( vio == NULL )
-  return -1;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
-    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
-   break;
-  default:
-   roar_err_set(ROAR_ERROR_BADRQC);
-   return -1;
- }
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/driver_dstr.c
===================================================================
--- roard/driver_dstr.c	(revision 6052)
+++ 	(revision )
@@ -1,57 +1,0 @@
-//driver_dstr.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_VIO_DSTR
-int driver_dstr_open_vio  (struct roar_vio_calls * inst,
-                           char * device,
-                           struct roar_audio_info * info,
-                           int fh,
-                           struct roar_stream_server * sstream) {
- struct roar_vio_defaults def;
-
- if ( fh == -1 ) {
-  if ( device == NULL )
-   return -1;
-
-  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY|O_CREAT|O_TRUNC, 0644) == -1 )
-   return -1;
-
-  if ( roar_vio_open_dstr(inst, device, &def, 1) == -1 )
-   return -1;
- } else {
-  if ( roar_vio_open_fh(inst, fh) == -1 )
-   return -1;
- }
-
- if ( sstream != NULL )
-  _LIBROAR_IGNORE_RET(roar_vio_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream));
-
- return 0;
-}
-#endif
-
-//ll
Index: roard/driver_esd.c
===================================================================
--- roard/driver_esd.c	(revision 6052)
+++ roard/driver_esd.c	(revision 0)
@@ -1,72 +1,66 @@
 //driver_esd.c:
 
+#include "roard.h"
+
 /*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
+ We could use inst as our fh directly. But esd works with unsigned at 8 bits and
+ signed at 16 bits per sample. (why???) so we need to convert because we get signed at both,
+ 8 and 16 bits per sample. so we use inst as an array of two ints: 0: fh, 1: are we in 8 bit mode?
+*/
 
-#include "roard.h"
-#ifdef ROAR_HAVE_ESD
+int driver_esd_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) {
+ esd_format_t format = ESD_STREAM | ESD_PLAY;
+ char name[80] = "roard";
+ int * di = malloc(sizeof(int)*2);
 
-int driver_esd_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- esd_format_t format = ESD_STREAM | ESD_PLAY;
- const char * name = "roard";
-
- (void)sstream;
-
- if ( fh != -1 )
+ if ( di == NULL )
   return -1;
 
- if ( info->bits >= 16 ) {
-  info->bits  = 16;
-  format     |= ESD_BITS16;
-  info->codec = ROAR_CODEC_PCM_S;
- } else if ( info->bits < 16 ) {
-  info->bits  =  8;
-  format     |= ESD_BITS8;
-  info->codec = ROAR_CODEC_PCM_U;
+ *inst = (DRIVER_USERDATA_T)di;
+
+ format |= info->bits     == 16 ? ESD_BITS16 : ESD_BITS8;
+ format |= info->channels ==  2 ? ESD_STEREO : ESD_MONO;
+
+ di[1] = info->bits == 8;
+
+ di[0] = esd_play_stream_fallback(format, info->rate, device, name);
+
+ if ( di[0] == -1 ) {
+  free(di);
+  *inst = NULL;
+  return -1;
  }
-
- if ( info->channels >= 2 ) {
-  info->channels  = 2;
-  format         |= ESD_STEREO;
- } else {
-  info->channels  = 1;
-  format         |= ESD_MONO;
- }
-
- fh = esd_play_stream_fallback(format, info->rate, device, name);
-
-
- // test for error.
- if ( fh == -1 )
-  return -1;
-
- roar_vio_open_fh_socket(inst, fh);
-
- roar_vio_shutdown(inst, ROAR_VIO_SHUTDOWN_READ);
 
  return 0;
 }
 
+int driver_esd_close(DRIVER_USERDATA_T   inst) {
+ int fh = *(int*)inst;
 
-#endif
+ free((void*)inst);
+
+ return esd_close(fh);
+}
+
+int driver_esd_pause(DRIVER_USERDATA_T   inst, int newstate) {
+ return -1;
+}
+
+int driver_esd_write(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ int * di = (int*)inst;
+
+ if ( di[1] )
+  roar_conv_codec_s2u8(buf, buf, len);
+
+ return write(di[0], buf, len);
+}
+
+int driver_esd_read(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ return read(*(int*)inst, buf, len);
+}
+
+int driver_esd_flush(DRIVER_USERDATA_T   inst) {
+ return 0;
+}
+
 //ll
Index: roard/driver_i2cdmx.c
===================================================================
--- roard/driver_i2cdmx.c	(revision 6052)
+++ 	(revision )
@@ -1,509 +1,0 @@
-//driver_i2cdmx.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_DRIVER_I2CDMX
-
-#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
-
-// hard disable SPI mode.
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
-#undef ROAR_HAVE_H_LINUX_SPI_SPIDEV
-#endif
-
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
-#include <linux/spi/spidev.h>
-#include <sys/ioctl.h>
-
-#define TRANSFER_DELAY 50
-#define TRANSFER_SPEED 100000
-#define TRANSFER_BPW   8
-#define TRANSFER_CHANS 24
-#define TRANSFER_SIZE  (TRANSFER_CHANS+6)
-#define SPI_DEVICE     "file://dev/spidev0.0"
-#endif
-
-#define DEFAULT_DEVICE  "/dev/i2c-1"
-
-#define DEV_TYPE        0x01 /* RI2C_DEV_BRIDGE */
-#define DEV_SUBTYPE     0x01 /* RI2C_SUBTYPE_BRIDGE_CONVERTER */
-#define DEVSTATUS_READY 0x01 /* RI2C_STATUS0_DEVICE_READY */
-#define CAPS0_DMX512    0x10 /* RI2C_CAPS0_BRIDGE_DMX512 */
-
-#define MIN_ADDR        0x20
-#define MAX_ADDR        0x70
-#define MAX_BUSSES      8
-
-#define ADDR_IFVERSION  0
-#define ADDR_DEVSTATUS  1
-#define ADDR_COMMAND    2
-#define ADDR_DEVERROR   3
-#define ADDR_BANK       4
-#define ADDR_DATA       5
-#define ADDR_VENDOR     (ADDR_BANK+2)
-#define ADDR_TYPE       (ADDR_BANK+3)
-#define ADDR_SUBTYPE    (ADDR_BANK+4)
-#define ADDR_PVENDOR    (ADDR_BANK+10)
-#define ADDR_PTYPE      (ADDR_BANK+11)
-#define ADDR_PSUBTYPE   (ADDR_BANK+12)
-#define ADDR_CAPS0      (ADDR_BANK+13)
-
-#define COMMAND_DEVINFO 0x00
-#define COMMAND_DMX     0x3f
-
-struct driver_i2cdmx {
- struct roar_vio_calls vio;
- struct roar_vio_calls spi;
- int have_spi;
- uint8_t slave;
- size_t startaddr;
- size_t len;
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
- char txtransfer[TRANSFER_SIZE];
- char rxtransfer[TRANSFER_SIZE];
-#endif
-};
-
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
-static int __spi_transfer(struct driver_i2cdmx * self, size_t offset_in, size_t offset_out, size_t len) {
- struct spi_ioc_transfer transfer_buffer = {
-  .tx_buf = (unsigned long) self->txtransfer,
-  .rx_buf = (unsigned long) self->rxtransfer,
-  .len = len,
-  .delay_usecs = TRANSFER_DELAY,
-  .speed_hz = TRANSFER_SPEED,
-  .bits_per_word = TRANSFER_BPW,
- };
- struct roar_vio_sysio_ioctl ctl = {.cmd = SPI_IOC_MESSAGE(1), .argp = &transfer_buffer};
-
- self->txtransfer[0] = 1; // command
- self->txtransfer[1] = len;
- self->txtransfer[2] = (offset_in & 0xFF00) >> 8;
- self->txtransfer[3] =  offset_in & 0x00FF;
- self->txtransfer[4] = (offset_in & 0xFF00) >> 8;
- self->txtransfer[5] =  offset_in & 0x00FF;
-
- if ( roar_vio_ctl(&(self->spi), ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == -1 )
-  return -1;
-
- return 0;
-}
-#endif
-
-static inline int __i2c_set_slave(struct driver_i2cdmx * self) {
- struct roar_vio_sysio_ioctl ctl = {.cmd = I2C_SLAVE, .argp = (void*)(int)self->slave};
-
- return roar_vio_ctl(&(self->vio), ROAR_VIO_CTL_SYSIO_IOCTL, &ctl);
-}
-
-static inline int16_t __i2c_read(struct driver_i2cdmx * self, size_t off) {
- union i2c_smbus_data data = {.byte = 0};
- struct i2c_smbus_ioctl_data args = {.read_write = I2C_SMBUS_READ, .command = off, .size = I2C_SMBUS_BYTE_DATA, .data = &data};
- struct roar_vio_sysio_ioctl ctl = {.cmd = I2C_SMBUS, .argp = &args};
- int ret = roar_vio_ctl(&(self->vio), ROAR_VIO_CTL_SYSIO_IOCTL, &ctl);
-
- if ( ret == -1 )
-  return (int16_t)-1;
-
- return (int16_t)(uint16_t)(uint8_t)data.byte;
-}
-
-static inline int __i2c_write(struct driver_i2cdmx * self, size_t off, const uint8_t value) {
- union i2c_smbus_data data = {.byte = value};
- struct i2c_smbus_ioctl_data args = {.read_write = I2C_SMBUS_WRITE, .command = off, .size = I2C_SMBUS_BYTE_DATA, .data = &data};
- struct roar_vio_sysio_ioctl ctl = {.cmd = I2C_SMBUS, .argp = &args};
-
- return roar_vio_ctl(&(self->vio), ROAR_VIO_CTL_SYSIO_IOCTL, &ctl);
-}
-
-static inline int __i2c_write_block(struct driver_i2cdmx * self, size_t off, const uint8_t * value) {
- union i2c_smbus_data data;
- struct i2c_smbus_ioctl_data args = {.read_write = I2C_SMBUS_WRITE, .command = off, .size = I2C_SMBUS_I2C_BLOCK_BROKEN, .data = &data};
- struct roar_vio_sysio_ioctl ctl = {.cmd = I2C_SMBUS, .argp = &args};
- size_t i;
-
- for (i = 0; i < sizeof(data.block); i++)
-  data.block[i] = 0xAF;
-
- data.block[0] = I2C_SMBUS_BLOCK_MAX;
-
- for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
-  data.block[i+1] = value[i];
-
- return roar_vio_ctl(&(self->vio), ROAR_VIO_CTL_SYSIO_IOCTL, &ctl);
-}
-
-static inline int __i2c_command(struct driver_i2cdmx * self, uint8_t command) {
- int16_t ret;
-
- if ( __i2c_write(self, ADDR_COMMAND, command) == -1 )
-  return -1;
-
- ret = __i2c_read(self, ADDR_DEVERROR);
- if ( ret == (int16_t)-1 )
-  return -1;
-
- if ( ret == ROAR_ERROR_NONE )
-  return 0;
-
- roar_err_set(ret);
- return -1;
-}
-
-static inline int __i2c_start_dmx(struct driver_i2cdmx * self) {
- return __i2c_command(self, COMMAND_DMX);
-}
-
-static int __open_test_device_type(int16_t vendor, int16_t type, int16_t subtype) {
- if ( vendor == -1 || type == -1 || subtype == -1 )
-  return -1;
-
- if ( vendor != ROAR_VID_ROARAUDIO || type != DEV_TYPE || subtype != DEV_SUBTYPE ) {
-  roar_err_set(ROAR_ERROR_TYPEMM);
-  return -1;
- }
-
- return 0;
-}
-
-static int __open_test_device(struct driver_i2cdmx * self) {
- int16_t ret;
- int16_t vendor, type, subtype;
-
-#define __check_response(resp,test,error) if ( (resp) == (int16_t)-1 ) return -1; if ( !(test) ) { roar_err_set((error)); return -1; }
-
- // test for device interface version
- ret = __i2c_read(self, ADDR_IFVERSION);
- __check_response(ret, ret == 0, ROAR_ERROR_NSVERSION);
-
- // test for device overall status
- ret = __i2c_read(self, ADDR_DEVSTATUS);
- __check_response(ret, ret & DEVSTATUS_READY, ROAR_ERROR_BADSTATE);
-
- // Request device infos
- if ( __i2c_command(self, COMMAND_DEVINFO) == -1 )
-  return -1;
-
- // Check device infos
- // first check device type, then parent device type:
- vendor  = __i2c_read(self, ADDR_VENDOR);
- type    = __i2c_read(self, ADDR_TYPE);
- subtype = __i2c_read(self, ADDR_SUBTYPE);
-
- if ( __open_test_device_type(vendor, type, subtype) == -1 ) {
-  vendor  = __i2c_read(self, ADDR_PVENDOR);
-  type    = __i2c_read(self, ADDR_PTYPE);
-  subtype = __i2c_read(self, ADDR_PSUBTYPE);
-
-  if (  __open_test_device_type(vendor, type, subtype) == -1 )
-   return -1;
- }
-
- // check for DMX512 support:
-
- ret = __i2c_read(self, ADDR_CAPS0);
- __check_response(ret, ret & CAPS0_DMX512, ROAR_ERROR_TYPEMM);
-
- return 0;
-}
-
-static int __open_scan_devices(struct driver_i2cdmx * self) {
- uint8_t i;
-
- for (i = MIN_ADDR; i < MAX_ADDR; i++) {
-  self->slave = i;
-
-  if ( __i2c_set_slave(self) == -1 )
-   continue;
-
-  if ( __open_test_device(self) == -1 )
-   continue;
-
-  return 0;
- }
-
- self->slave = 0;
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-static int __open_device_and_slave(struct driver_i2cdmx * self, int autoconf, const char * device) {
- char filename[40];
- char * p;
- int need_autoconf = 0;
- int ret;
- int err;
-
- // test if the device exist.
- if ( roar_vio_open_dstr_simple(&(self->vio), device, ROAR_VIOF_READWRITE) == 0 ) {
-  need_autoconf = 1;
- } else {
-  // the device doesn't exist. We guss it is in form $device/$slaveid.
-  strncpy(filename, device, sizeof(filename));
-  p = strrchr(filename, '/');
-  if ( p == NULL ) {
-   // it doesn't seem to be in the given form so it seems it was just a device name of an missingd evice.
-   roar_err_set(ROAR_ERROR_NOENT);
-   return -1;
-  }
-
-  *p = 0;
-  p++;
-
-  // now we have the device name in filename, and the slave ID in p.
-  self->slave = atoi(p);
-
-  // little test to protect the user from doing dumb things.
-  if ( self->slave == 0 ) {
-   roar_err_set(ROAR_ERROR_INVAL);
-   return -1;
-  }
-
-  if ( roar_vio_open_dstr_simple(&(self->vio), filename, ROAR_VIOF_READWRITE) == -1 )
-   return -1;
- }
-
- // ok, the bus is now open. Let's open the device:
-
- if ( need_autoconf ) {
-  ret = __open_scan_devices(self);
- } else {
-  ret = __i2c_set_slave(self);
-  if ( ret == 0 )
-   ret = __open_test_device(self);
- }
-
- if ( ret == -1 ) {
-  err = roar_error;
-  roar_vio_close(&(self->vio));
-  roar_err_set(err);
- }
-
- return ret;
-}
-
-static int __open_scan_busses(struct driver_i2cdmx * self) {
- char filename[20];
- int i;
- int ret;
-
- for (i = 0; i < MAX_BUSSES; i++) {
-  snprintf(filename, sizeof(filename), "/dev/i2c-%i", i);
-  ret = __open_device_and_slave(self, 1, filename);
-  if ( ret == 0 )
-   return 0;
- }
-
- roar_err_set(ROAR_ERROR_NOENT);
- return -1;
-}
-
-static int __i2c_write_channel(struct driver_i2cdmx * self, size_t channel, uint8_t value) {
- size_t bank, offset;
-
- bank = channel/32;
- offset = bank*32;
-
- if ( __i2c_write(self, ADDR_BANK, bank) == -1 )
-  return -1;
-
- return __i2c_write(self, ADDR_DATA+channel-offset, value);
-}
-
-static int __i2c_write_channel_block(struct driver_i2cdmx * self, size_t channel, const uint8_t * value) {
- size_t bank, offset;
-
- bank = channel/32;
- offset = bank*32;
-
- if ( __i2c_write(self, ADDR_BANK, bank) == -1 )
-  return -1;
-
- return __i2c_write_block(self, ADDR_DATA+channel-offset, value);
-}
-
-static ssize_t        __vio_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_i2cdmx * self;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = vio->inst;
-
- if ( count != 512 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( __i2c_start_dmx(self) == -1 )
-  return -1;
-
- memset(buf, 0, count); // optimize this...
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
- memcpy(buf, self->rxtransfer+6, sizeof(self->rxtransfer)-6);
-#endif
- return 0;
-}
-
-static ssize_t        __vio_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_i2cdmx * self;
- size_t i;
-// size_t endaddr;
- size_t todo;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = vio->inst;
-
- if ( count != 512 ) {
-  roar_err_set(ROAR_ERROR_INVAL);
-  return -1;
- }
-
- if ( __i2c_start_dmx(self) == -1 )
-  return -1;
-
-/*
- for (i = self->startaddr, endaddr = self->startaddr + self->len; i < endaddr; i++)
-  if ( __i2c_write_channel(self, i, ((uint8_t*)buf)[i]) == -1 )
-   return -1;
- */
-
- i = self->startaddr;
- todo = self->len;
- while (todo) {
-  if ( todo >= I2C_SMBUS_BLOCK_MAX ) {
-   if ( __i2c_write_channel_block(self, i, &(((const uint8_t*)buf)[i])) == -1 )
-    return -1;
-   i += I2C_SMBUS_BLOCK_MAX;
-   todo -= I2C_SMBUS_BLOCK_MAX;
-  } else {
-   if ( __i2c_write_channel(self, i, ((uint8_t*)buf)[i]) == -1 )
-    return -1;
-   i++;
-   todo--;
-  }
- }
-#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV
- memcpy(self->txtransfer+6, buf, sizeof(self->txtransfer)-6);
- __spi_transfer(self, 0, 0, TRANSFER_CHANS);
-#endif
-
- return count;
-}
-
-static int            __vio_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_i2cdmx * self;
-
- if ( vio == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    if ( ROAR_STREAM(data)->dir != ROAR_DIR_LIGHT_OUT && ROAR_STREAM(data)->dir != ROAR_DIR_LIGHT_IN ) {
-     ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
-    }
-    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
-   break;
-  default:
-   roar_err_set(ROAR_ERROR_BADRQC);
-   return -1;
- }
-
- return 0;
-}
-
-static int            __vio_close   (struct roar_vio_calls * vio) {
- struct driver_i2cdmx * self = vio->inst;
- roar_vio_close(&(self->vio));
- if ( self->have_spi )
-  roar_vio_close(&(self->spi));
- roar_mm_free(self);
- return 0;
-}
-
-int driver_i2cdmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_i2cdmx * self;
- int autoconf = 1;
- int ret;
-
- if ( fh != -1 ) {
-  roar_err_set(ROAR_ERROR_NOSYS);
-  return -1;
- }
-
- self = roar_mm_malloc(sizeof(struct driver_i2cdmx));
- if ( self == NULL ) {
-  return -1;
- }
- memset(self, 0, sizeof(*self));
- self->have_spi  = 0;
- self->startaddr = 0;
- self->len       = info->channels;
-
- info->bits      = 8;
- info->codec     = ROAR_CODEC_DMX512;
-
- if ( device == NULL && !autoconf ) {
-  device = DEFAULT_DEVICE;
- }
-
- if ( device == NULL ) {
-  ret = __open_scan_busses(self);
- } else {
-  ret = __open_device_and_slave(self, autoconf, device);
- }
-
- if ( ret == -1 ) {
-  roar_mm_free_noerror(self);
-  return -1;
- }
-
-#if defined(ROAR_HAVE_H_LINUX_SPI_SPIDEV) && defined(SPI_DEVICE)
- if ( roar_vio_open_dstr_simple(&(self->spi), SPI_DEVICE, ROAR_VIOF_READWRITE) == 0 )
-  self->have_spi = 1;
-#endif
-
- roar_vio_clear_calls(inst);
- inst->inst  = self;
- inst->read  = __vio_read;
- inst->write = __vio_write;
- inst->close = __vio_close;
- inst->ctl   = __vio_ctl;
-
- return 0;
-}
-#endif
Index: roard/driver_jack.c
===================================================================
--- roard/driver_jack.c	(revision 6052)
+++ 	(revision )
@@ -1,263 +1,0 @@
-//driver_jack.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *      Copyright (C) Nedko Arnaudov <nedko@arnaudov.name> - 2010
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBJACK
-
-static void unregister_ports(struct driver_jack * self) {
- while(self->channels--) {
-  if ( self->ports_in != NULL )
-   if ( self->ports_in [self->channels] != NULL )
-    jack_port_unregister(self->client, self->ports_in [self->channels]);
-  if ( self->ports_out[self->channels] != NULL )
-   jack_port_unregister(self->client, self->ports_out[self->channels]);
- }
-}
-
-int driver_jack_open_vio  (struct roar_vio_calls * inst,
-                           char * device,
-                           struct roar_audio_info * info,
-                           int fh,
-                           struct roar_stream_server * sstream) {
- struct driver_jack * self;
- char port_name[128];
- jack_nframes_t new_rate;
- int autoconfig            = 0;
- int recsource             = 0;
-
- // we are not FH Safe, return error if fh != -1:
- if ( fh != -1 )
-  return -1;
-
- if ( sstream != NULL ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
-  recsource  = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_RECSOURCE);
- }
-
- // set up VIO:
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->read     = driver_jack_read;
- inst->write    = driver_jack_write;
- inst->lseek    = NULL; // no seeking on this device
- inst->sync     = driver_jack_sync;
- inst->ctl      = driver_jack_ctl;
- inst->close    = driver_jack_close;
-
- // set up internal struct:
- if ( (self = roar_mm_malloc(sizeof(struct driver_jack))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct driver_jack));
-
- inst->inst     = self;
-
- if ( (self->client = jack_client_open("roard", JackNullOption, NULL)) == NULL ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- new_rate = jack_get_sample_rate(self->client);
-
- // need to check if we need to change stream's parameters:
- if ( info->rate != new_rate || info->bits != 32 || info->codec != ROAR_CODEC_DEFAULT ) {
-  if ( autoconfig ) {
-   // we are allowed to change the parameters
-   info->rate  = new_rate;
-   info->bits  = 32;
-   info->codec = ROAR_CODEC_DEFAULT;
-  } else {
-   // we are not allowed to change the parameters
-   ROAR_WARN("driver_jack_open_vio(*): Can not open jack driver with given parameters, try -oO ...,autoconf");
-   goto free_close;
-  }
- }
-
- if ( recsource )
-  if ( (self->ports_in = roar_mm_malloc(sizeof(jack_port_t *) * info->channels)) == NULL )
-   goto free_close;
-
- if ( (self->ports_out = roar_mm_malloc(sizeof(jack_port_t *) * info->channels)) == NULL )
-  goto free_ins;
-
- // NULL ports so we do not segfaul if something goes wrong.
- if ( self->ports_in != NULL )
-  memset(self->ports_in, 0, sizeof(jack_port_t *) * info->channels);
- memset(self->ports_in, 0, sizeof(jack_port_t *) * info->channels);
-
- for (self->channels = 0; self->channels < info->channels; self->channels++) {
-  if ( recsource ) {
-   snprintf(port_name, sizeof(port_name), "in_%03u", self->channels);
-   if ( (self->ports_in [self->channels] = jack_port_register(self->client, port_name,
-                                                              JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)) == NULL )
-    goto unregister_ports;
-  }
-
-  snprintf(port_name, sizeof(port_name), "out_%03u", self->channels);
-  if ( (self->ports_out[self->channels] = jack_port_register(self->client, port_name,
-                                                             JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == NULL ) {
-   jack_port_unregister(self->client, self->ports_in[self->channels]);
-   goto unregister_ports;
-  }
- }
-
- if (jack_activate(self->client) != 0)
-  goto unregister_ports;
-
- return 0;
-
-unregister_ports:
- unregister_ports(self);
-free_ins:
- if ( self->ports_in != NULL )
-  roar_mm_free(self->ports_in);
-free_close:
- jack_client_close(self->client);
- roar_mm_free(self);
- return -1; // error
-}
-
-ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_jack * self = vio->inst;
- // read up to count bytes into buf.
- // return the number of bits read.
- return -1;
-}
-
-ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_jack * self = vio->inst;
- // write up to count bytes from buf.
- // return the number of written bytes.
- return -1;
-}
-
-int     driver_jack_sync    (struct roar_vio_calls * vio) {
- struct driver_jack * self = vio->inst;
- // init to sync data to device.
- // sync does not need to be complet when this function returns.
- return 0;
-}
-
-int     driver_jack_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_jack * self = vio->inst;
- // function for a lot control features.
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_NAME:
-    if ( data == NULL )
-     return -1;
-
-    *(char**)data = "driver_jack";
-    return 0;
-   break;
-  case ROAR_VIO_CTL_GET_FH:
-  case ROAR_VIO_CTL_GET_READ_FH:
-  case ROAR_VIO_CTL_GET_WRITE_FH:
-  case ROAR_VIO_CTL_GET_SELECT_FH:
-  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
-  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
-/* Return FH if possible:
-    *(int*)data = FH...;
-*/
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_SET_NOSYNC:
-    vio->sync = NULL;
-    return 0;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    // control if read and write calls should block untill all data is read or written.
-    // state is in *(int*)data and could be:
-    //  ROAR_SOCKET_BLOCK    - Block untill the data is read or written
-    //  ROAR_SOCKET_NONBLOCK - Return as soon as possible
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_AUINFO:
-  case ROAR_VIO_CTL_SET_AUINFO:
-    // get or set audio info, data is a struct roar_audio_info*.
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_DBLKSIZE:
-  case ROAR_VIO_CTL_SET_DBLKSIZE:
-    // get or set block size used, data is uint_least32_t*, number of bytes.
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_DBLOCKS:
-  case ROAR_VIO_CTL_SET_DBLOCKS:
-    // get or set number of blocks used, data is uint_least32_t*.
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    // set server stream object for this stream, data is struct roar_stream_server*
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_SET_SSTREAMID:
-    // set stream ID for this stream, data is int*
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_SET_VOLUME:
-    // set volume for this device, data is struct roar_mixer_settings*
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  case ROAR_VIO_CTL_GET_DELAY:
-    // get delay of this stream, data is uint_least32_t*, in bytes
-    // there is more about delay. please ask.
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-int     driver_jack_close   (struct roar_vio_calls * vio) {
- struct driver_jack * self = vio->inst;
- // close and free everything in here...
-
- jack_deactivate(self->client);
- unregister_ports(self);
- jack_client_close(self->client);
-
- roar_mm_free(self);
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/driver_oss.c
===================================================================
--- roard/driver_oss.c	(revision 6052)
+++ 	(revision )
@@ -1,593 +1,0 @@
-//driver_oss.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS)
-
-
-#define _get(vio,obj) (((struct driver_oss*)((vio)->inst))->obj)
-
-int driver_oss_init_vio(struct roar_vio_calls * vio, struct driver_oss * inst) {
- if ( vio == NULL )
-  return -1;
-
- memset(vio, 0, sizeof(struct roar_vio_calls));
- vio->flags    = ROAR_VIO_FLAGS_NONE;
- vio->refc     = 1;
-
- vio->write    = driver_oss_write;
- vio->read     = driver_oss_read;
- vio->sync     = driver_oss_sync;
- vio->ctl      = driver_oss_ctl;
- vio->close    = driver_oss_close_vio;
-
- vio->inst     = (void*) inst;
-
- return 0;
-}
-
-int driver_oss_open_device(struct driver_oss * self) {
- int    flags  = 0;
- int    rw     = 0;
- int    fh     = self->fh;
- char * device = self->device;
-
- if ( fh != -1 )
-  return 0;
-
-#ifdef ROAR_DEFAULT_OSS_DEV
- if ( device == NULL )
-  device = ROAR_DEFAULT_OSS_DEV;
-#endif
-
- if ( device == NULL ) {
-  ROAR_ERR("driver_oss_open_device(*): no default device found, you need to specify one manuelly");
-  return -1;
- }
-
- if ( self->ssid != -1 ) {
-  rw = streams_get_flag(self->ssid, ROAR_FLAG_RECSOURCE);
- }
-
- if ( rw ) {
-  flags |= O_RDWR;
- } else {
-  flags |= O_WRONLY;
- }
-
- if ( (fh = open(device, flags, 0644)) == -1 ) {
-  ROAR_ERR("driver_oss_open_device(*): Can not open OSS device: %s: %s", device, strerror(errno));
-  return -1;
- }
-
- self->fh          = fh;
- self->need_config = 1;
-
- return 0;
-}
-
-int driver_oss_config_device(struct driver_oss * self) {
- int                      fh   =   self->fh;
- struct roar_audio_info * info = &(self->info);
- int tmp, ctmp;
- char * es;
- int autoconfig         = 0;
- int need_update_server = 0;
-
- if ( fh == -1 )
-  return -1;
-
- if ( self->ssid != -1 ) {
-  autoconfig = streams_get_flag(self->ssid, ROAR_FLAG_AUTOCONF);
- }
-
- ROAR_DBG("driver_oss_config_device(self=%p): ssid=%i, autoconfig=%i", self, self->ssid, autoconfig);
-
-#ifdef SNDCTL_DSP_CHANNELS
- tmp = info->channels;
-
- if ( ioctl(fh, SNDCTL_DSP_CHANNELS, &tmp) == -1 ) {
-  ROAR_ERR("driver_oss_config_device(*): can not set number of channels");
-  return -1;
- }
-
- if ( tmp != info->channels ) {
-  if ( autoconfig ) {
-   need_update_server = 1;
-   self->info.channels = tmp;
-  } else {
-   ROAR_ERR("driver_oss_config_device(*): can not set requested numer of channels, OSS suggested %i channels, to use this restart with -oO channels=%i or set codec manuelly via -oO channels=num", tmp, tmp);
-   return -1;
-  }
- }
-#else
- switch (info->channels) {
-  case  1: tmp = 0; break;
-  case  2: tmp = 1; break;
-  default: return -1;
- }
-
- if ( ioctl(fh, SNDCTL_DSP_STEREO, &tmp) == -1 ) {
-  ROAR_ERR("driver_oss_config_device(*): can not set number of channels");
-  return -1;
- }
-#endif
-
- if ( autoconfig ) {
-  if ( info->bits > 16 ) {
-   info->bits = 32;
-   need_update_server = 1;
-  }
-
-  if ( info->bits == 32 ) {
-   switch (info->codec) {
-#ifndef AFMT_S32_LE
-    case ROAR_CODEC_PCM_S_LE:
-#endif
-#ifndef AFMT_S32_BE
-    case ROAR_CODEC_PCM_S_BE:
-#endif
-    case ROAR_CODEC_PCM_U_LE:
-    case ROAR_CODEC_PCM_U_BE:
-      info->bits = 16;
-      need_update_server = 1;
-     break;
-   }
-  }
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-    switch (info->bits) {
-     case  8: tmp = AFMT_S8;     break;
-     case 16: tmp = AFMT_S16_LE; break;
-//     case 24: tmp = AFMT_S24_PACKED; break;
-#ifdef AFMT_S32_LE
-     case 32: tmp = AFMT_S32_LE; break;
-#endif
-     default: return -1;
-    }
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    switch (info->bits) {
-     case  8: tmp = AFMT_S8;     break;
-     case 16: tmp = AFMT_S16_BE; break;
-//     case 24: tmp = AFMT_S24_PACKED; break;
-#ifdef AFMT_S32_BE
-     case 32: tmp = AFMT_S32_BE; break;
-#endif
-     default: return -1;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_LE:
-    switch (info->bits) {
-     case  8: tmp = AFMT_U8;     break;
-     case 16: tmp = AFMT_U16_LE; break;
-     default: return -1;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_BE:
-    switch (info->bits) {
-     case  8: tmp = AFMT_U8;     break;
-     case 16: tmp = AFMT_U16_BE; break;
-     default: return -1;
-    }
-  case ROAR_CODEC_ALAW:
-    tmp = AFMT_A_LAW;
-   break;
-  case ROAR_CODEC_MULAW:
-    tmp = AFMT_MU_LAW;
-   break;
-#ifdef AFMT_VORBIS
-  case ROAR_CODEC_OGG_VORBIS:
-    tmp = AFMT_VORBIS;
-   break;
-#endif
-  default:
-    return -1;
-   break;
- }
-
- ctmp = tmp;
-#ifdef SNDCTL_DSP_SETFMT
- if ( ioctl(fh, SNDCTL_DSP_SETFMT, &tmp) == -1 ) {
-#else
- if ( ioctl(fh, SNDCTL_DSP_SAMPLESIZE, &tmp) == -1 ) {
-#endif
-  ROAR_ERR("driver_oss_config_device(*): can not set sample format");
-  return -1;
- }
-
- if ( tmp != ctmp ) {
-  if ( autoconfig ) {
-   need_update_server = 1;
-   switch (tmp) {
-    case AFMT_S8    : self->info.bits =  8; self->info.codec = ROAR_CODEC_PCM;      break;
-    case AFMT_U8    : self->info.bits =  8; self->info.codec = ROAR_CODEC_PCM_U_LE; break;
-    case AFMT_S16_LE: self->info.bits = 16; self->info.codec = ROAR_CODEC_PCM_S_LE; break;
-    case AFMT_S16_BE: self->info.bits = 16; self->info.codec = ROAR_CODEC_PCM_S_BE; break;
-    case AFMT_U16_LE: self->info.bits = 16; self->info.codec = ROAR_CODEC_PCM_U_LE; break;
-    case AFMT_U16_BE: self->info.bits = 16; self->info.codec = ROAR_CODEC_PCM_U_BE; break;
-#ifdef AFMT_S32_LE
-    case AFMT_S32_LE: self->info.bits = 32; self->info.codec = ROAR_CODEC_PCM_S_LE; break;
-#endif
-#ifdef AFMT_S32_BE
-    case AFMT_S32_BE: self->info.bits = 32; self->info.codec = ROAR_CODEC_PCM_S_BE; break;
-#endif
-/*
-    case AFMT_A_LAW : self->info.bits =  8; self->info.codec = ROAR_CODEC_ALAW;     break;
-    case AFMT_MU_LAW: self->info.bits =  8; self->info.codec = ROAR_CODEC_MULAW;    break;
-#ifdef AFMT_VORBIS
-    case AFMT_VORBIS: self->info.codec = ROAR_CODEC_OGG_VORBIS;                     break;
-#endif
-*/
-    case AFMT_A_LAW:
-    case AFMT_MU_LAW:
-#ifdef AFMT_VORBIS
-    case AFMT_VORBIS:
-#endif
-      ROAR_WARN("driver_oss_config_device(*): Auto config failed: OSS Codec %i needs a codecfilter!", tmp);
-      ROAR_ERR("driver_oss_config_device(*): can not set requested codec, set codec manuelly via -oO codec=somecodec");
-      return -1;
-     break;
-    default:
-      ROAR_WARN("driver_oss_config_device(*): Auto config failed: unknown OSS Codec %i", tmp);
-      ROAR_ERR("driver_oss_config_device(*): can not set requested codec, set codec manuelly via -oO codec=somecodec");
-      return -1;
-     break;
-   }
-  } else {
-   es = NULL;
-   switch (tmp) {
-    case AFMT_S8    : es = "bits=8,codec=pcm";       break;
-    case AFMT_U8    : es = "bits=8,codec=pcm_u_le";  break;
-    case AFMT_S16_LE: es = "bits=16,codec=pcm_s_le"; break;
-    case AFMT_S16_BE: es = "bits=16,codec=pcm_s_be"; break;
-    case AFMT_U16_LE: es = "bits=16,codec=pcm_u_le"; break;
-    case AFMT_U16_BE: es = "bits=16,codec=pcm_u_be"; break;
-#ifdef AFMT_S32_LE
-    case AFMT_S32_LE: es = "bits=32,codec=pcm_s_le"; break;
-#endif
-#ifdef AFMT_S32_BE
-    case AFMT_S32_BE: es = "bits=32,codec=pcm_s_be"; break;
-#endif
-    case AFMT_A_LAW : es = "codec=alaw";             break;
-    case AFMT_MU_LAW: es = "codec=mulaw";            break;
-#ifdef AFMT_VORBIS
-    case AFMT_VORBIS: es = "codec=ogg_vorbis";       break;
-#endif
-   }
-
-   if ( es != NULL ) {
-    ROAR_ERR("driver_oss_config_device(*): can not set requested codec, OSS retruned another codec than requested, to use this restart with -oO %s or set codec manuelly via -oO codec=somecodec", es);
-   } else {
-    ROAR_ERR("driver_oss_config_device(*): can not set requested codec, set codec manuelly via -oO codec=somecodec");
-   }
-   return -1;
-  }
- }
-
- tmp = info->rate;
-
- if ( ioctl(fh, SNDCTL_DSP_SPEED, &tmp) == -1 ) {
-  ROAR_ERR("driver_oss_config_device(*): can not set sample rate");
-  return -1;
- }
-
- if ( tmp != info->rate ) {
-  if ( autoconfig ) {
-   need_update_server = 1;
-   self->info.rate = tmp;
-  } else {
-   ROAR_WARN("driver_oss_config_device(*): Device does not support requested sample rate: req=%iHz, sug=%iHz",
-                     info->rate, tmp);
-
-   if ( tmp < info->rate * 0.98 || tmp > info->rate * 1.02 ) {
-    ROAR_ERR("driver_oss_config_device(*): sample rate out of acceptable accuracy");
-    return -1;
-   }
-  }
- }
-
- // latency things:
-#ifdef SNDCTL_DSP_SETFRAGMENT
-
- // defaults
- if ( self->blocksize < 1 )
-  self->blocksize = 2048;
- if ( self->blocks < 1 )
-  self->blocks    =    4;
-
- switch (self->blocksize) {
-  case 1<< 4: tmp =  4; break;
-  case 1<< 5: tmp =  5; break;
-  case 1<< 6: tmp =  6; break;
-  case 1<< 7: tmp =  7; break;
-  case 1<< 8: tmp =  8; break;
-  case 1<< 9: tmp =  9; break;
-  case 1<<10: tmp = 10; break;
-  case 1<<11: tmp = 11; break;
-  case 1<<12: tmp = 12; break;
-  case 1<<13: tmp = 13; break;
-  case 1<<14: tmp = 14; break;
-  case 1<<15: tmp = 15; break;
-  case 1<<16: tmp = 16; break;
-  default: tmp = 11;
-    ROAR_WARN("driver_oss_config_device(*): blocksize of %i byte is not a valid value. trying 2KB", self->blocksize);
-   break;
- }
-
- ROAR_DBG("driver_oss_config_device(*): blocksize=%i(N=%i), blocks=%i", self->blocksize, tmp, self->blocks);
-
- tmp |= self->blocks << 16;
- if ( ioctl(fh, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1 ) {
-  ROAR_WARN("driver_oss_ctl(*): Can not set fragment size, sorry :(");
- }
-#endif
-
- if ( need_update_server ) {
-  if ( self->stream == NULL ) {
-   streams_get(self->ssid, &(self->stream));
-  }
-
-  if ( self->stream == NULL ) {
-   ROAR_ERR("driver_oss_config_device(*): Auto config failed: can not set new values for stream: no stream object known");
-   return -1;
-  }
-
-  memcpy(&(ROAR_STREAM(self->stream)->info), info, sizeof(struct roar_audio_info));
- }
-
- ROAR_DBG("driver_oss_config_device(*): self->ssid=%i, fh=%i", self->ssid, fh);
- streams_set_fh(self->ssid, -2);
- self->need_config = 0;
-
- ROAR_DBG("driver_oss_config_device(*) = 0");
- return 0;
-}
-
-#define er() close(self->fh); if ( self->device ) roar_mm_free(self->device); roar_mm_free(self); return -1
-int driver_oss_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_oss * self = NULL;
-
- if ( (self = roar_mm_malloc(sizeof(struct driver_oss))) == NULL ) {
-  ROAR_ERR("driver_oss_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno));
-  return -1;
- }
-
- memset(self, 0, sizeof(struct driver_oss));
- memcpy(&(self->info), info, sizeof(struct roar_audio_info));
-
- self->ssid = -1;
- self->fh   = fh;
-
- if ( sstream != NULL )
-  self->ssid = ROAR_STREAM(sstream)->id;
-
- if ( fh != -1 ) {
-  self->fh_savemode = 1;
- } else {
-  self->fh_savemode = 0;
- }
-
- if ( device != NULL )
-  self->device = roar_mm_strdup(device);
-
- if ( driver_oss_init_vio(inst, self) == -1 ) {
-  ROAR_ERR("driver_oss_open(*): Can not init vio interface");
-  er();
- }
-
- if ( driver_oss_open_device(self) == -1 ) {
-  ROAR_ERR("driver_oss_open(*): Can not open audio device");
-  er();
- }
-
- ROAR_DBG("driver_oss_open(*): OSS devices opened :)");
-
- if ( sstream != NULL )
-  driver_oss_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
-
- return 0;
-}
-#undef er
-
-int     driver_oss_reopen_device(struct driver_oss * self) {
-
- // we need to reject in fh save mode.
- if ( self->fh_savemode )
-  return -1;
-
-#ifdef SNDCTL_DSP_SYNC
- ioctl(self->fh, SNDCTL_DSP_SYNC, NULL);
-#endif
-
- close(self->fh);
-
- if ( driver_oss_open_device(self) == -1 )
-  return -1;
-
- self->need_config = 1;
-
- return 0;
-}
-
-int driver_oss_close(DRIVER_USERDATA_T   inst) {
- return roar_vio_close((struct roar_vio_calls *)inst);
-}
-
-int     driver_oss_close_vio(struct roar_vio_calls * vio) {
- close(_get(vio,fh));
-
- if ( _get(vio,device) != NULL )
-  roar_mm_free(_get(vio,device));
-
- roar_mm_free(vio->inst);
- return 0;
-}
-
-int driver_oss_sync(struct roar_vio_calls * vio) {
-#ifdef SNDCTL_DSP_SYNC
- return ioctl(_get(vio,fh), SNDCTL_DSP_SYNC, NULL);
-#else
- return 0;
-#endif
-}
-
-int driver_oss_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_oss * self = vio->inst;
-#ifdef SNDCTL_DSP_GETODELAY
- int d;
-#endif
-
- ROAR_DBG("driver_oss_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data);
-
- if ( vio == NULL )
-  return -1;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_GET_DELAY:
-#ifdef SNDCTL_DSP_GETODELAY
-    if ( ioctl(_get(vio,fh), SNDCTL_DSP_GETODELAY, &d) == -1 )
-     return -1;
-
-    ROAR_DBG("driver_oss_ctl(*): delay=%i byte", d);
-
-    *(uint_least32_t *)data = d;
-#else
-    return -1;
-#endif
-   break;
-  case ROAR_VIO_CTL_SET_DBLOCKS:
-#ifdef SNDCTL_DSP_SETFRAGMENT
-    if ( !self->need_config ) {
-     ROAR_WARN("driver_oss_ctl(*): possible late ROAR_VIO_CTL_SET_DBLOCKS, setting anyway.");
-    }
-
-    self->blocks    = *(uint_least32_t *)data;
-#else
-    return -1;
-#endif
-   break;
-  case ROAR_VIO_CTL_SET_DBLKSIZE:
-#ifdef SNDCTL_DSP_SETFRAGMENT
-    if ( !self->need_config ) {
-     ROAR_WARN("driver_oss_ctl(*): possible late ROAR_VIO_CTL_SET_DBLKSIZE, setting anyway.");
-    }
-
-    self->blocksize = *(uint_least32_t *)data;
-#else
-    return -1;
-#endif
-   break;
-  case ROAR_VIO_CTL_GET_DBLKSIZE:
-    if ( !self->blocksize )
-     return -1;
-
-    *(uint_least32_t *)data = self->blocksize;
-   break;
-  case ROAR_VIO_CTL_SET_SSTREAMID:
-    self->ssid = *(int *)data;
-   break;
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    self->stream = data;
-   break;
-  case ROAR_VIO_CTL_GET_AUINFO:
-    memcpy(data, &(self->info), sizeof(struct roar_audio_info));
-   break;
-  case ROAR_VIO_CTL_SET_AUINFO:
-    memcpy(&(self->info), data, sizeof(struct roar_audio_info));
-    return driver_oss_reopen_device(self);
-   break;
-#ifdef SNDCTL_DSP_SETPLAYVOL
-  case ROAR_VIO_CTL_SET_VOLUME:
-    switch (self->info.channels) {
-     case 1:
-       d  = ROAR_MIXER(data)->mixer[0] * 100 / ROAR_MIXER(data)->scale;
-       d |= d << 8;
-      break;
-     case 2:
-       d  =  ROAR_MIXER(data)->mixer[0] * 100 / ROAR_MIXER(data)->scale;
-       d |= (ROAR_MIXER(data)->mixer[0] * 100 / ROAR_MIXER(data)->scale) << 8;
-      break;
-     default:
-      return -1;
-    }
-    return ioctl(_get(vio,fh), SNDCTL_DSP_SETPLAYVOL, &d);
-   break;
-#endif
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( roar_socket_nonblock(_get(vio,fh), *(int*)data) == -1 ) {
-     return -1;
-    }
-
-    if ( *(int*)data == ROAR_SOCKET_NONBLOCK ) {
-     return 0;
-    }
-
-    roar_vio_sync(vio);
-   break;
-  default:
-   return -1;
- }
-
- return 0;
-}
-
-ssize_t driver_oss_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- ROAR_DBG("driver_oss_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- if ( _get(vio,fh) == -1 )
-  return -1;
-
- if ( _get(vio,need_config) ) {
-  if ( driver_oss_config_device(vio->inst) == -1 ) {
-   return -1;
-  }
- }
-
- return write(_get(vio,fh), buf, count);
-}
-
-ssize_t driver_oss_read     (struct roar_vio_calls * vio, void *buf, size_t count) {
- ROAR_DBG("driver_oss_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- if ( _get(vio,fh) == -1 )
-  return -1;
-
- if ( _get(vio,need_config) ) {
-  if ( driver_oss_config_device(vio->inst) == -1 ) {
-   ROAR_DBG("driver_oss_read(vio=%p, buf=%p, count=%llu) = -1", vio, buf, (long long unsigned int)count);
-   return -1;
-  }
- }
-
- ROAR_DBG("driver_oss_read(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- return read(_get(vio,fh), buf, count);
-}
-
-#endif
-//ll
Index: roard/driver_portaudio.c
===================================================================
--- roard/driver_portaudio.c	(revision 6052)
+++ 	(revision )
@@ -1,302 +1,0 @@
-//driver_portaudio.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *      Copyright (C) Hans-Kristian 'maister' Arntzen - 2010-2011
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef _DRIVER_PORTAUDIO_CAN_OPERATE
-
-int driver_portaudio_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_portaudio * self;
- PaSampleFormat fmt;
-#ifdef ROAR_HAVE_LIBPABLIO
- long flags = PABLIO_WRITE;
-#elif defined(ROAR_HAVE_PA19_VERSION_19)
- PaStreamParameters params;
- const PaDeviceInfo * dev_info = NULL;
-#endif
- PaError err;
- int autoconfig = 0;
-
- if ( fh != -1 )
-  return -1;
-
- if ( sstream != NULL ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
- }
-
- switch (info->bits) {
-  case 8:
-    switch (info->codec) {
-     case ROAR_CODEC_PCM_S_LE:
-     case ROAR_CODEC_PCM_S_BE:
-     case ROAR_CODEC_PCM_S_PDP:
-       fmt = paInt8;
-      break;
-     case ROAR_CODEC_PCM_U_LE:
-     case ROAR_CODEC_PCM_U_BE:
-     case ROAR_CODEC_PCM_U_PDP:
-       fmt = paUInt8;
-      break;
-     default:
-       if ( autoconfig ) {
-        info->codec = ROAR_CODEC_DEFAULT;
-        fmt = paInt8;
-       } else {
-        return -1;
-       }
-      break;
-    }
-   break;
-  case 16:
-    if ( info->codec != ROAR_CODEC_DEFAULT ) {
-     if ( autoconfig ) {
-      info->codec = ROAR_CODEC_DEFAULT;
-     } else {
-      return -1;
-     }
-    }
-    fmt = paInt16;
-   break;
-#ifdef paPackedInt24
-  case 24:
-    if ( info->codec != ROAR_CODEC_DEFAULT ) {
-     if ( autoconfig ) {
-      info->codec = ROAR_CODEC_DEFAULT;
-     } else {
-      return -1;
-     }
-    }
-    fmt = paPackedInt24;
-   break;
-#endif
-  case 32:
-    if ( info->codec != ROAR_CODEC_DEFAULT ) {
-     if ( autoconfig ) {
-      info->codec = ROAR_CODEC_DEFAULT;
-     } else {
-      return -1;
-     }
-    }
-    fmt = paInt32;
-   break;
-  default:
-    if ( autoconfig ) {
-     info->codec = ROAR_CODEC_DEFAULT;
-     info->bits  = 16;
-     fmt = paInt16;
-    } else {
-     return -1;
-    }
-   break;
- }
-
- if ( (self = roar_mm_malloc(sizeof(struct driver_portaudio))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct driver_portaudio));
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags = ROAR_VIO_FLAGS_NONE;
- inst->refc  = 1;
-
- inst->inst  = self;
- inst->close = driver_portaudio_close;
- inst->write = driver_portaudio_write;
- inst->ctl   = driver_dummy_ctl;
-
- Pa_Initialize();
-
-#ifdef ROAR_HAVE_LIBPABLIO
- switch (info->channels) {
-  case 1: flags |= PABLIO_MONO;   break;
-  case 2: flags |= PABLIO_STEREO; break;
-  default:
-    if ( autoconfig ) {
-     info->channels = 2;
-     flags |= PABLIO_STEREO;
-    } else {
-     roar_mm_free(self);
-     Pa_Terminate();
-     return -1;
-    }
- }
-
- err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags);
-
- if ( err != paNoError && autoconfig ) {
-  if ( (flags & PABLIO_MONO) == PABLIO_MONO ) {
-   flags -= PABLIO_MONO;
-   flags |= PABLIO_STEREO;
-   info->channels = 2;
-  }
-  fmt         = paInt16;
-  info->codec = ROAR_CODEC_DEFAULT;
-  info->bits  = 16;
-
-  err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags);
- }
-
- if ( err != paNoError ) {
-  roar_mm_free(self);
-  Pa_Terminate();
-  return -1;
- }
-
- return 0;
-#elif defined(ROAR_HAVE_PA19_VERSION_19)
- err                              = paNoError;
-
- params.device                    = Pa_GetDefaultOutputDevice();
- params.channelCount              = info->channels;
- params.sampleFormat              = fmt;
-
- if ( params.device != paNoDevice )
-  dev_info = Pa_GetDeviceInfo(params.device);
-
- if ( dev_info != NULL ) {
-  params.suggestedLatency = dev_info->defaultLowOutputLatency;
- } else {
-  err = paNoDevice;
- }
-
- params.hostApiSpecificStreamInfo = NULL;
-
- // TODO: FIXME: use libroar for this.
- self->framesize = info->bits * info->channels / 8;
-
- // Sets up blocking I/O stream.
- if ( err == paNoError ) {
-  err = Pa_OpenStream(&(self->stream),
-                      NULL,
-                      &params,
-                      info->rate,
-                      128 /*FIXME:frames*/,
-                      paClipOff,
-                      NULL,
-                      NULL
-                     );
- }
-
- if ( err != paNoError && err != paNoDevice && autoconfig ) {
-  params.sampleFormat = paInt16;
-  params.channelCount = 2;
-  info->codec         = ROAR_CODEC_DEFAULT;
-  info->bits          = 16;
-  info->channels      = 2;
-
-  err = Pa_OpenStream(&(self->stream),
-                      NULL,
-                      &params,
-                      info->rate,
-                      128 /*FIXME:frames*/,
-                      paClipOff,
-                      NULL,
-                      NULL
-                     );
- }
-
- if ( err != paNoError ) {
-  ROAR_ERR("driver_portaudio_open(*): Could not open PortAudio device: \"%s\".", Pa_GetErrorText(err));
-  roar_mm_free(self);
-  return -1;
- }
-
- err = Pa_StartStream(self->stream);
-
- if ( err != paNoError ) {
-  ROAR_ERR("driver_portaudio_open(*): Could not start stream: \"%s\".", Pa_GetErrorText(err));
-  roar_mm_free(self);
-  return -1;
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int     driver_portaudio_close        (struct roar_vio_calls * vio) {
- struct driver_portaudio * self = vio->inst;
-
- // TODO: cleanup common code.
-
-#ifdef ROAR_HAVE_LIBPABLIO
- CloseAudioStream(self->ostream);
-
- Pa_Terminate();
-
- roar_mm_free(self);
-
- return 0;
-#elif defined(ROAR_HAVE_PA19_VERSION_19)
- if ( (self != NULL) && (self->stream != NULL) ) {
-  Pa_StopStream(self->stream);
-  Pa_CloseStream(self->stream);
- }
-
- roar_mm_free(self);
-
- Pa_Terminate();
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-ssize_t driver_portaudio_write        (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_portaudio * self = vio->inst;
-#ifdef ROAR_HAVE_PA19_VERSION_19
- size_t write_frames = count / self->framesize;
- PaError err;
-#endif
-
- ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
-#ifdef ROAR_HAVE_LIBPABLIO
- count /= self->ostream->bytesPerFrame; // TODO: FIXME: do not access private members
- ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, count=%llu) = ? // PABLIO mode", vio, buf, (long long unsigned int)count);
- return WriteAudioStream(self->ostream, buf, count) * self->ostream->bytesPerFrame;
-#elif defined(ROAR_HAVE_PA19_VERSION_19)
-
- ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, size=%llu) = ?", vio, buf, (long long unsigned int)size);
-
- // I'm not 100% sure if you could write arbitrary number of frames to Pa_WriteStream(), but it seems to be backend dependent.
- err = Pa_WriteStream(self->stream, buf, write_frames);
-
- if ( err < 0 && err != paOutputUnderflowed )
-  return -1;
-
- // PA always seems to write requested size, or it will error out.
- return count;
-#else
- return -1;
-#endif
-}
-
-#endif
-
-//ll
Index: roard/driver_pulsesimple.c
===================================================================
--- roard/driver_pulsesimple.c	(revision 6052)
+++ 	(revision )
@@ -1,185 +1,0 @@
-//driver_pulsesimple.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBPULSE
-
-int     driver_pulsesimple_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_pulsesimple * self;
- const char                * subdev = NULL;
- int                         pulseerror = -1;
- pa_stream_direction_t dir = PA_STREAM_PLAYBACK;
- pa_sample_spec        ss;
- int autoconfig = 0;
- int needauto   = 0;
-
-//    pa_sample_format_t format;     /**< The sample format */
-
- if ( fh != -1 )
-  return -1;
-
- if ( sstream != NULL ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_ALAW:
-    ss.format = PA_SAMPLE_ALAW;
-   break;
-  case ROAR_CODEC_MULAW:
-    ss.format = PA_SAMPLE_ULAW;
-   break;
-  case ROAR_CODEC_PCM_S_LE:
-    switch (info->bits) {
-     case 16:
-       ss.format = PA_SAMPLE_S16LE;
-      break;
-     default:
-       needauto = 1;
-      break;
-    }
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    switch (info->bits) {
-     case 16:
-       ss.format = PA_SAMPLE_S16BE;
-      break;
-     default:
-       needauto = 1;
-      break;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_LE:
-  case ROAR_CODEC_PCM_U_BE:
-  case ROAR_CODEC_PCM_U_PDP:
-    if ( info->bits == 8 ) {
-     ss.format = PA_SAMPLE_U8;
-    } else {
-     needauto = 1;
-    }
-   break;
-  default:
-    needauto = 1;
-   break;
- }
-
- if ( needauto ) {
-  if ( !autoconfig ) {
-   return -1;
-  }
-
-  info->bits = 16;
-  info->codec = ROAR_CODEC_DEFAULT;
-  ss.format = PA_SAMPLE_S16NE;
- }
-
- ss.rate     = info->rate;
- ss.channels = info->channels;
-
- if ( (self = roar_mm_malloc(sizeof(struct driver_pulsesimple))) == NULL )
-  return -1;
-
- self->handle = pa_simple_new(device, "roard", dir, subdev, "RoarAudio Sound Server", &ss, NULL, NULL, &pulseerror);
-
- if ( self->handle == NULL && autoconfig ) {
-  info->bits = 16;
-  info->codec = ROAR_CODEC_DEFAULT;
-  ss.format = PA_SAMPLE_S16NE;
-
-  self->handle = pa_simple_new(device, "roard", dir, subdev, "RoarAudio Sound Server", &ss, NULL, NULL, &pulseerror);
- }
-
- if ( self->handle == NULL ) {
-  ROAR_ERR("driver_pulsesimple_open(inst=%p, device='%s', info=%p, fh=%i, sstream=%p): can not open device: %s", inst, device, info, fh, sstream, pa_strerror(pulseerror));
-  roar_mm_free(self);
-  ROAR_DBG("driver_pulsesimple_open(inst=%p, device='%s', info=%p, fh=%i, sstream=%p) = -1", inst, device, info, fh, sstream);
-  return -1;
- }
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->inst     = self;
- inst->close    = driver_pulsesimple_close;
- inst->write    = driver_pulsesimple_write;
- inst->sync     = driver_pulsesimple_sync;
- inst->ctl      = driver_pulsesimple_ctl;
-
- return 0;
-}
-
-int     driver_pulsesimple_close        (struct roar_vio_calls * vio) {
- struct driver_pulsesimple * self = vio->inst;
-
- ROAR_DBG("driver_pulsesimple_close(vio=%p) = ?", vio);
-
- pa_simple_free(self->handle);
-
- roar_mm_free(self);
-
- return 0;
-}
-
-ssize_t driver_pulsesimple_write        (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_pulsesimple * self = vio->inst;
-
- ROAR_DBG("driver_pulsesimple_write(vio=%p, buf=%p, count=%llu) = ?", vio, buf, (long long unsigned int)count);
-
- return pa_simple_write(self->handle, buf, count, NULL) == 0 ? count : -1;
-}
-
-int     driver_pulsesimple_sync         (struct roar_vio_calls * vio) {
- struct driver_pulsesimple * self = vio->inst;
-
- ROAR_DBG("driver_pulsesimple_sync(vio=%p) = ?", vio);
-
- return pa_simple_drain(self->handle, NULL);
-}
-
-int     driver_pulsesimple_ctl          (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_pulsesimple * self = vio->inst;
-
- (void)self;
-
- ROAR_DBG("driver_pulsesimple_ctl(vio=%p) = ?", vio);
-
- switch (cmd) {
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( *(int*)data == ROAR_SOCKET_BLOCK )
-     return 0;
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
- }
-
- roar_err_set(ROAR_ERROR_NOSYS);
- return -1;
-}
-
-#endif
-
-//ll
Index: roard/driver_pwmled.c
===================================================================
--- roard/driver_pwmled.c	(revision 6052)
+++ 	(revision )
@@ -1,154 +1,0 @@
-//driver_pwmled.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#if !defined(ROAR_WITHOUT_DCOMP_PWMLED) && !defined(ROAR_WITHOUT_VIO_DSTR)
-
-int driver_pwmled_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct roar_vio_defaults def;
- struct driver_pwmled * self = roar_mm_malloc(sizeof(struct driver_pwmled));
-
- if ( self == NULL )
-  return -1;
-
- if ( fh == -1 ) {
-  if ( device == NULL )
-   device = "/dev/ttyS0";
-
-  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 ) {
-   roar_mm_free(self);
-   return -1;
-  }
-
-  if ( roar_vio_open_dstr(&(self->vio), device, &def, 1) == -1 ) {
-   roar_mm_free(self);
-   return -1;
-  }
-
-  inst->inst = self;
- } else {
-/*
-  if ( roar_vio_open_fh(inst, fh) == -1 )
-   return -1;
-*/
-  roar_mm_free(self);
-  return -1;
- }
-
- inst->read     = NULL;
- inst->write    = driver_pwmled_write;
- inst->lseek    = NULL;
- inst->sync     = NULL;
- inst->ctl      = driver_pwmled_ctl;
- inst->close    = driver_pwmled_close;
-
- info->codec = ROAR_CODEC_DMX512;
-
- if ( info->rate == g_sa->rate ) {
-  self->rate = 9600;
- } else {
-  self->rate = info->rate;
- }
-
- self->channel = 0;
-
- if ( roar_light_pwm_new(&(self->state), 16) == -1 ) {
-  roar_mm_free(self);
-  return -1;
- }
-
- if ( sstream != NULL )
-  driver_pwmled_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
-
- return 0;
-}
-
-int     driver_pwmled_close (struct roar_vio_calls * vio) {
- int ret = roar_vio_close(&(((struct driver_pwmled*)(vio->inst))->vio));
-
- if ( vio->inst != NULL )
-  roar_mm_free(vio->inst);
-
- return ret;
-}
-
-// TODO: this function should be optimized.
-ssize_t driver_pwmled_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
- struct driver_pwmled * self;
- int value;
-
- if ( vio == NULL || buf == NULL )
-  return -1;
-
- if ( count != 512 )
-  return -1;
-
- self = vio->inst;
-
- value = ((unsigned char*)buf)[self->channel] / 15;
-
- if ( roar_light_pwm_set(&(self->state), value) == -1 )
-  return -1;
-
-// ROAR_WARN("driver_pwmled_write(*): value=%i", value);
-
- if ( value ) {
-                                                                     // bit per word, bit per byte
-  return roar_light_pwm_send(&(self->state), &(self->vio), self->rate/11/8/100) == 0 ? count : -1;
- }
-
- return count;
-}
-
-int driver_pwmled_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_pwmled * self;
-
- if ( vio == NULL )
-  return -1;
-
- self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_SET_SSTREAM:
-    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
-    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
-   break;
-  case ROAR_VIO_CTL_SET_DMXSCHAN:
-    if ( *(uint16_t*)data > 511 )
-     return -1;
-
-    self->channel = *(uint16_t*)data;
-   break;
-  default:
-   return -1;
- }
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/driver_raw.c
===================================================================
--- roard/driver_raw.c	(revision 6052)
+++ 	(revision )
@@ -1,49 +1,0 @@
-//driver_raw.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_IO_POSIX
-int driver_raw_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
-
- ROAR_WARN("The raw driver is obsolete, use dstr driver!");
-
- if ( fh == -1 && device == NULL ) {
-  return -1;
- }
-
- if ( fh == -1 ) {
-  if ( roar_vio_open_file(inst, device, O_CREAT|O_TRUNC|O_WRONLY, 0644) == -1 )
-   return -1;
- } else {
-  if ( roar_vio_open_fh(inst, fh) == -1 )
-   return -1;
- }
-
- return 0;
-}
-#endif
-
-//ll
Index: roard/driver_roar.c
===================================================================
--- roard/driver_roar.c	(revision 6052)
+++ roard/driver_roar.c	(revision 0)
@@ -1,65 +1,49 @@
-//driver_roar.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
+//driver_esd.c:
 
 #include "roard.h"
 
-#define MIXER_ID -1
+int driver_roar_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) {
+/*
+ esd_format_t format = ESD_STREAM | ESD_PLAY;
+ char name[80] = "roard";
 
-int driver_roar_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- int dir = ROAR_DIR_PLAY;
+ format |= info->bits     == 16 ? ESD_BITS16 : ESD_BITS8;
+ format |= info->channels ==  2 ? ESD_STEREO : ESD_MONO;
 
- if ( fh != -1 ) { // this is a connection to a roard, no roar_simple_*() interface avalible for this case
+ *(int*)inst = esd_play_stream_fallback(format, info->rate, device, name);
+
+ if ( *(int*)inst == -1 )
   return -1;
- }
 
- if ( sstream != NULL ) {
-  switch (ROAR_STREAM(sstream)->dir) {
-   case ROAR_DIR_OUTPUT:      dir = ROAR_DIR_PLAY;       break;
-   case ROAR_DIR_MIDI_OUT:    dir = ROAR_DIR_MIDI_IN;    break;
-   case ROAR_DIR_LIGHT_OUT:   dir = ROAR_DIR_LIGHT_IN;   break;
-// TODO: we need to know a real pos id for raw streams...
-//   case ROAR_DIR_RAW_OUT:   dir = ROAR_DIR_RAW_IN;   break;
-   case ROAR_DIR_COMPLEX_OUT: dir = ROAR_DIR_COMPLEX_IN; break;
-   default:
-     return -1;
-  }
- }
+ return 0;
+*/
 
- if ( roar_vio_simple_stream(inst, info->rate, info->channels, info->bits, info->codec, device, dir, "roard", MIXER_ID) == -1 ) {
-  if ( streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF) ) {
-   if ( roar_profile2info(info, "default") == -1 )
-    return -1;
+ *(int*)inst =  roar_simple_play(info->rate, info->channels, info->bits, info->codec, device, "roard");
 
-   if ( roar_vio_simple_stream(inst, info->rate, info->channels, info->bits, info->codec, device, dir, "roard", MIXER_ID) == -1 ) {
-    return -1;
-   }
-  }
+ if ( *(int*)inst == -1 )
   return -1;
- }
 
  return 0;
 }
 
+int driver_roar_close(DRIVER_USERDATA_T   inst) {
+ return roar_simple_close((int)inst);
+}
+
+int driver_roar_pause(DRIVER_USERDATA_T   inst, int newstate) {
+ return -1;
+}
+
+int driver_roar_write(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ return write((int)inst, buf, len);
+}
+
+int driver_roar_read(DRIVER_USERDATA_T   inst, char * buf, int len) {
+ return read((int)inst, buf, len);
+}
+
+int driver_roar_flush(DRIVER_USERDATA_T   inst) {
+ return 0;
+}
+
 //ll
Index: roard/driver_rsound.c
===================================================================
--- roard/driver_rsound.c	(revision 6052)
+++ 	(revision )
@@ -1,205 +1,0 @@
-//driver_rsound.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#define _DRV_NEED_RSOUND_H
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBRSOUND
-
-int     driver_rsound_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- rsound_t * self = NULL;
- int autoconfig  = 0;
- int tmp, tmp2;
-
- if ( fh != -1 )
-  return -1;
-
- if ( ROAR_STREAM(sstream)->id != -1 ) {
-  autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF);
- }
-
- if ( rsd_init(&self) == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): rsd_init(&self) failed.");
-  return -1;
- }
-
- if ( device != NULL ) {
-  if ( rsd_set_param(self, RSD_HOST, device) == -1 ) {
-   ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_HOST, device) failed.");
-   rsd_free(self);
-   return -1;
-  }
- }
-
- tmp = info->channels;
- if ( rsd_set_param(self, RSD_CHANNELS, &tmp) == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_CHANNELS, &tmp) failed.");
-  rsd_free(self);
-  return -1;
- }
-
- if ( tmp != info->channels ) {
-  rsd_free(self);
-  return -1;
- }
-
- tmp = info->rate;
- if ( rsd_set_param(self, RSD_SAMPLERATE, &tmp) == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_SAMPLERATE, &tmp) failed.");
-  rsd_free(self);
-  return -1;
- }
-
- if ( tmp != info->rate ) {
-  rsd_free(self);
-  return -1;
- }
-
- tmp = -1; // unknown by RSound
-
- if ( info->bits > 16 && autoconfig ) {
-  info->bits = 32;
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-    switch (info->bits) {
-     case  8: tmp = RSD_S8;     break;
-     case 16: tmp = RSD_S16_LE; break;
-#ifdef RSD_S32_LE
-     case 32: tmp = RSD_S32_LE; break;
-#endif
-    }
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    switch (info->bits) {
-     case  8: tmp = RSD_S8;     break;
-     case 16: tmp = RSD_S16_BE; break;
-#ifdef RSD_S32_BE
-     case 32: tmp = RSD_S32_BE; break;
-#endif
-    }
-   break;
-  case ROAR_CODEC_PCM_S_PDP:
-    switch (info->bits) {
-     case  8: tmp = RSD_S8;     break;
-    }
-   break;
-  case ROAR_CODEC_PCM_U_LE:
-    switch (info->bits) {
-     case  8: tmp = RSD_U8;     break;
-     case 16: tmp = RSD_U16_LE; break;
-#ifdef RSD_U32_LE
-     case 32: tmp = RSD_U32_LE; break;
-#endif
-    }
-   break;
-  case ROAR_CODEC_PCM_U_BE:
-    switch (info->bits) {
-     case  8: tmp = RSD_U8;     break;
-     case 16: tmp = RSD_U16_BE; break;
-#ifdef RSD_U32_BE
-     case 32: tmp = RSD_U32_BE; break;
-#endif
-    }
-   break;
-  case ROAR_CODEC_PCM_U_PDP:
-    switch (info->bits) {
-     case  8: tmp = RSD_U8;     break;
-    }
-   break;
- }
-
-#ifdef RSD_S16_NE
- if ( tmp == -1 && autoconfig ) {
-  info->bits  = 16;
-  info->codec = ROAR_CODEC_DEFAULT;
-  tmp         = RSD_S16_NE;
- }
-#endif
-
- if ( tmp == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): Codec/Bits not supported by RSound");
-  rsd_free(self);
-  return -1;
- }
-
- tmp2 = tmp;
-
- if ( rsd_set_param(self, RSD_FORMAT, &tmp) == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_FORMAT, &tmp={0x%x->0x%x}) failed.", tmp2, tmp);
-  rsd_free(self);
-  return -1;
- }
-
- if ( tmp != tmp2 ) {
-  rsd_free(self);
-  return -1;
- }
-
- if ( rsd_start(self) == -1 ) {
-  ROAR_DBG("driver_rsound_open(*): rsd_start(self) failed.");
-  rsd_free(self);
-  return -1;
- }
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->inst     = self;
- inst->close    = driver_rsound_close;
- inst->write    = driver_rsound_write;
- inst->ctl      = driver_dummy_ctl;
-
- return 0;
-}
-
-int     driver_rsound_close        (struct roar_vio_calls * vio) {
- int r = 0;
-
- if ( rsd_stop(vio->inst) == -1 )
-  r = -1;
-
- if ( rsd_free(vio->inst) == -1 )
-  r = -1;
-
- return r;
-}
-
-ssize_t driver_rsound_write        (struct roar_vio_calls * vio, void *buf, size_t count) {
- size_t ret;
-
- ret = rsd_write(vio->inst, buf, count);
-
- if ( ret == 0 )
-  return -1;
-
- return ret;
-}
-
-#endif
-
-//ll
Index: roard/driver_shout.c
===================================================================
--- roard/driver_shout.c	(revision 6052)
+++ 	(revision )
@@ -1,267 +1,0 @@
-//driver_shout.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#ifdef ROAR_HAVE_LIBSHOUT
-
-struct driver_shout {
- shout_t * shout;
- int blocking;
-};
-
-static int _driver_shout_usage_counter = 0;
-
-int     driver_shout_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_shout * self = NULL;
- const char * s_server = NULL;
- const char * s_mount  = NULL;
- const char * s_user   = NULL;
- const char * s_pw     = NULL;
- int    s_port   = -1;
- const char * s_desc   = NULL;
- const char * s_genre  = NULL;
- const char * s_name   = NULL;
- const char * s_url    = NULL;
- int    s_public = 0;
- char * a;
- shout_t * shout;
-
- switch (info->codec) {
-  case ROAR_CODEC_DEFAULT:
-    info->codec = ROAR_CODEC_OGG_VORBIS;
-   break;
-  case ROAR_CODEC_OGG_VORBIS:
-  case ROAR_CODEC_OGG_SPEEX:
-  case ROAR_CODEC_OGG_FLAC:
-  case ROAR_CODEC_OGG_GENERAL:
-    // ok, no errors here
-   break;
-  default:
-    ROAR_ERR("This driver only supports Ogg/* (most common is Ogg/Vorbis), current codec is %s", roar_codec2str(info->codec));
-    return -1;
-   break;
- }
-
- if ( device != NULL ) {
-  // device sould be an URL in this form:
-  // [http[s]://][user[:pw]@]host[:port][/mp.ogg]
-
-  if ( (a = strstr(device, "://")) != NULL ) {
-   *a = 0;
-   if ( strcmp(device, "http") ) {
-    return -1;
-   }
-   device = a + 3;
-  }
-
-  // [user[:pw]@]host[:port][/mp.ogg]
-
-  if ( (a = strstr(device, "@")) != NULL ) {
-   *a = 0;
-   s_user = device;
-   device = a + 1;
-  }
-
-  if ( s_user != NULL ) {
-   if ( (a = strstr(s_user, ":")) != NULL ) {
-    *a = 0;
-    s_pw = a+1;
-   }
-  }
-
-  if ( s_user != NULL && ! *s_user )
-   s_user = NULL;
-
-  if ( s_pw != NULL && ! *s_pw )
-   s_pw = NULL;
-
-  // host[:port][/mp.ogg]
-
-  if ( (a = strstr(device, "/")) != NULL ) {
-   *a = 0;
-   s_server = device;
-   device = a + 1;
-  } else {
-   s_server  = device;
-   device   += strlen(device);
-  }
-
-  if ( (a = strstr(s_server, ":")) != NULL ) {
-   *a = 0;
-   s_port = atoi(a+1);
-  }
-
-  if ( ! *s_server )
-   s_server = NULL;
-
-  // [/mp.ogg]
-
-  if ( *device ) {
-   s_mount = device;
-  }
- }
-
- ROAR_DBG("driver_shout_open_vio(*): user='%s', pw='%s', server='%s', port=%i, mount='%s'",
-                   s_user, s_pw, s_server, s_port, s_mount);
-
- if ( s_server == NULL )
-  s_server = "localhost";
-
- if ( s_mount == NULL )
-  s_mount  = "/roar.ogg";
-
- if ( s_pw == NULL )
-  s_pw     = "hackme";
-
- if ( s_user == NULL )
-  s_user     = "source";
-
- if ( s_port == -1 )
-  s_port   = 8000;
-
- if ( _driver_shout_usage_counter++ == 0 )
-  shout_init();
-
- if (!(shout = shout_new())) {
-  ROAR_ERR("Can not clreate shout object");
-  return 1;
- }
-
- if (shout_set_host(shout, s_server) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting hostname: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting protocol: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_port(shout, s_port) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting port: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_password(shout, s_pw) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting password: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_mount(shout, s_mount) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting mount: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_user(shout, s_user) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting user: %s", shout_get_error(shout));
-  return 1;
- }
-
- if (shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Error setting format: %s", shout_get_error(shout));
-  return 1;
- }
-
- shout_set_public(shout, s_public);
-
- if (s_desc  != NULL)
-  shout_set_description(shout, s_desc);
-
- if (s_genre != NULL)
-  shout_set_genre(shout, s_genre);
-
- if (s_name  != NULL)
-  shout_set_name(shout, s_name);
-
- if (s_url   != NULL)
-  shout_set_url(shout, s_url);
-
- if (shout_open(shout) != SHOUTERR_SUCCESS) {
-  ROAR_ERR("Can not open connection via libshout!");
-  return -1;
- }
-
- self = roar_mm_malloc(sizeof(struct driver_shout));
- if ( self == NULL ) {
-  shout_close(shout);
-  return -1;
- }
-
- memset(self, 0, sizeof(struct driver_shout));
- self->shout = shout;
- self->blocking = ROAR_SOCKET_BLOCK;
-
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
- inst->inst     = (void*)self;
- inst->write    = driver_shout_write;
- inst->close    = driver_shout_close;
- inst->ctl      = driver_dummy_ctl;
-
- return 0;
-}
-
-int     driver_shout_close(struct roar_vio_calls * vio) {
- struct driver_shout * self = vio->inst;
-
- shout_close(self->shout);
- roar_mm_free(self);
-
- if ( _driver_shout_usage_counter-- == 1 )
-  shout_shutdown();
-
- return 0;
-}
-
-ssize_t driver_shout_write(struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_shout * self = vio->inst;
-
- if (shout_send(self->shout, (unsigned char*)buf, count) != SHOUTERR_SUCCESS)
-  return -1;
-
- if ( self->blocking == ROAR_SOCKET_BLOCK )
-  shout_sync(self->shout);
-
- return count;
-}
-
-int     driver_shout_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_shout * self = vio->inst;
-
- switch (cmd) {
-  case ROAR_VIO_CTL_NONBLOCK:
-    self->blocking = *(const int*)data;
-    return 0;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_BADRQC);
-    return -1;
-   break;
- }
-}
-
-#endif
-//ll
Index: roard/driver_sndio.c
===================================================================
--- roard/driver_sndio.c	(revision 6052)
+++ 	(revision )
@@ -1,284 +1,0 @@
-//driver_sndio.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-#ifdef ROAR_HAVE_LIBSNDIO
-
-int driver_sndio_init_vio(struct roar_vio_calls * vio, struct driver_sndio * inst) {
- if ( vio == NULL )
-  return -1;
-
- memset(vio, 0, sizeof(struct roar_vio_calls));
- vio->flags    = ROAR_VIO_FLAGS_NONE;
- vio->refc     = 1;
-
- vio->close    = driver_sndio_close_vio;
- vio->write    = driver_sndio_write;
- vio->sync     = driver_sndio_sync;
- vio->ctl      = driver_sndio_ctl;
-
- vio->inst     = (void*) inst;
-
- return 0;
-}
-
-#define _err() if ( self->shandle != NULL ) sio_close(self->shandle);   \
-               if ( self->mhandle != NULL ) mio_close(self->mhandle);   \
-               if ( self->device  != NULL ) roar_mm_free(self->device); \
-               roar_mm_free(self);                              \
-               return -1
-
-int driver_sndio_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_sndio * self = NULL;
-
- if ( (self = roar_mm_malloc(sizeof(struct driver_sndio))) == NULL ) {
-  ROAR_ERR("driver_sndio_open(*): Can not roar_mm_malloc() instance data: %s", strerror(errno));
-  return -1;
- }
-
- memset(self, 0, sizeof(struct driver_sndio));
- memcpy(&(self->info), info, sizeof(struct roar_audio_info));
-
- self->ssid = -1;
-
- if ( sstream == NULL ) {
-  self->stream = NULL;
-  self->dir    = ROAR_DIR_OUTPUT;
- } else {
-  self->stream = sstream;
-  self->dir    = ROAR_STREAM(sstream)->dir;
-
-  switch (self->dir) {
-   case ROAR_DIR_OUTPUT:
-   case ROAR_DIR_MONITOR:
-     self->dir = ROAR_DIR_OUTPUT;
-    break;
-   case ROAR_DIR_MIDI_OUT:
-     info->channels = 16;
-     info->codec    = ROAR_CODEC_MIDI;
-     info->bits     = 8;
-    break;
-   default:
-     _err();
-  }
- }
-
- if ( device != NULL )
-  self->device = roar_mm_strdup(device);
-
- if ( driver_sndio_init_vio(inst, self) == -1 ) {
-  ROAR_ERR("driver_sndio_open(*): Can not init vio interface");
-  _err();
- }
-
- if ( driver_sndio_open_device(self) == -1 ) {
-  ROAR_ERR("driver_sndio_open(*): Can not open audio device");
-  _err();
- }
-
- ROAR_DBG("driver_sndio_open(*): sndio devices opened :)");
-
- return 0;
-}
-#undef er
-
-int     driver_sndio_close_vio    (struct roar_vio_calls * vio) {
- struct driver_sndio * self = vio->inst;
-
- if ( self->shandle != NULL )
-  sio_close(self->shandle);
-
- if ( self->mhandle != NULL )
-  mio_close(self->mhandle);
-
- if ( self->device != NULL )
-  roar_mm_free(self->device);
-
- roar_mm_free(self);
-
- return 0;
-}
-
-int     driver_sndio_open_device  (struct driver_sndio * self) {
-
- ROAR_DBG("driver_sndio_open_device(*) = ?");
- switch (self->dir) {
-  case ROAR_DIR_OUTPUT:
-    if ( (self->shandle = sio_open(self->device, SIO_PLAY, 0)) == NULL ) {
-     ROAR_ERR("driver_sndio_open_device(*): Can not open sndio audio device");
-     return -1;
-    }
-   self->need_config = 1;
-   break;
-  case ROAR_DIR_MIDI_OUT:
-    if ( (self->mhandle = mio_open(self->device, MIO_OUT, 0)) == NULL ) {
-     ROAR_ERR("driver_sndio_open_device(*): Can not open sndio MIDI device");
-     return -1;
-    }
-   break;
-  default:
-    return -1;
- }
-
- ROAR_DBG("driver_sndio_open_device(*) = ?");
- return 0;
-}
-
-int     driver_sndio_config_device(struct driver_sndio * self) {
- struct sio_par par;
-
- sio_initpar(&par);
-
- par.bits  = self->info.bits;
- par.rate  = self->info.rate;
- par.pchan = self->info.channels;
-
- switch (self->info.codec) {
-  case ROAR_CODEC_PCM_S_LE:
-    par.le  = 1;
-    par.sig = 1;
-   break;
-  case ROAR_CODEC_PCM_S_BE:
-    par.le  = 0;
-    par.sig = 1;
-   break;
-  case ROAR_CODEC_PCM_U_LE:
-    par.le  = 1;
-    par.sig = 0;
-   break;
-  case ROAR_CODEC_PCM_U_BE:
-    par.le  = 0;
-    par.sig = 0;
-   break;
-  default:
-    return -1;
-   break;
- }
-
- if ( sio_setpar(self->shandle, &par) == 0 ) {
-  ROAR_ERR("driver_sndio_config_device(*): Can not set stream parameters");
-  return -1;
- }
-
- if ( sio_start(self->shandle) == 0 ) {
-  ROAR_ERR("driver_sndio_config_device(*): Can not start stream");
-  return -1;
- }
-
- self->need_config = 0;
-
- return 0;
-}
-
-int     driver_sndio_reopen_device(struct driver_sndio * self) {
- return -1;
-}
-
-ssize_t driver_sndio_write        (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_sndio * self = vio->inst;
-
- ROAR_DBG("driver_sndio_write(*) = ?");
-
- if ( self->need_config ) {
-  if ( driver_sndio_config_device(vio->inst) == -1 ) {
-   return -1;
-  }
- }
-
- ROAR_DBG("driver_sndio_write(*) = ?");
-
- switch (self->dir) {
-  case ROAR_DIR_OUTPUT:
-    return sio_write(self->shandle, buf, count);
-   break;
-  case ROAR_DIR_MIDI_OUT:
-    return mio_write(self->mhandle, buf, count);
-   break;
- }
-
- ROAR_WARN("driver_sndio_write(*): Driver changed direction to something not supported, this should not happen");
-
- return -1;
-}
-
-int     driver_sndio_sync         (struct roar_vio_calls * vio) {
- return -1;
-}
-
-#define data(x) x: if ( data == NULL ) return -1;
-#define no_data(x) x: if ( data != NULL ) return -1;
-
-int     driver_sndio_ctl          (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- struct driver_sndio * self = vio->inst;
- unsigned d;
-
- switch (cmd) {
-  case data(ROAR_VIO_CTL_SET_SSTREAMID)
-    self->ssid = *(int *)data;
-   break;
-  case data(ROAR_VIO_CTL_SET_SSTREAM)
-    // FIXME: we should do some better error handling here:
-    if ( ROAR_STREAM(data)->dir != self->dir ) return -1;
-    self->stream = data;
-   break;
-  case data(ROAR_VIO_CTL_GET_AUINFO)
-    memcpy(data, &(self->info), sizeof(struct roar_audio_info));
-   break;
-  case data(ROAR_VIO_CTL_SET_AUINFO)
-    memcpy(&(self->info), data, sizeof(struct roar_audio_info));
-    return driver_sndio_reopen_device(self);
-   break;
-  case ROAR_VIO_CTL_SET_VOLUME:
-    switch (self->info.channels) {
-     case 1:
-       d = ROAR_MIXER(data)->mixer[0] * SIO_MAXVOL / ROAR_MIXER(data)->scale;
-      break;
-     case 2:
-       if ( ROAR_MIXER(data)->mixer[0] != ROAR_MIXER(data)->mixer[1] )
-        return -1;
-       d = ROAR_MIXER(data)->mixer[0] * SIO_MAXVOL / ROAR_MIXER(data)->scale;
-      break;
-     default:
-      return -1;
-    }
-    return sio_setvol(self->shandle, d) == 0 ? -1 : 0;
-   break;
-  case ROAR_VIO_CTL_NONBLOCK:
-    if ( *(int*)data == ROAR_SOCKET_BLOCK )
-     return 0;
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return -1;
-   break;
-  default:
-    return -1;
-   break;
- }
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/driver_sysclock.c
===================================================================
--- roard/driver_sysclock.c	(revision 6052)
+++ 	(revision )
@@ -1,121 +1,0 @@
-//driver_sysclock.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_DRIVER_SYSCLOCK
-int driver_sysclock_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_sysclock * self = roar_mm_malloc(sizeof(struct driver_sysclock));
-
- if ( self == NULL )
-  return -1;
-
- if ( device != NULL ) {
-  return -1;
- }
-
- memset(self, 0, sizeof(struct driver_sysclock));
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
-
- inst->inst     = self;
- inst->close    = driver_sysclock_close;
- inst->write    = driver_sysclock_write;
- inst->ctl      = driver_dummy_ctl;
-
- self->bps      = roar_info2bitspersec(info)/8;
-
- if (!self->bps) {
-  roar_mm_free(self);
-  return -1;
- }
-
- switch (info->codec) {
-  case ROAR_CODEC_PCM_S_LE:
-  case ROAR_CODEC_PCM_S_BE:
-  case ROAR_CODEC_PCM_S_PDP:
-  case ROAR_CODEC_PCM_U_LE:
-  case ROAR_CODEC_PCM_U_BE:
-  case ROAR_CODEC_PCM_U_PDP:
-  case ROAR_CODEC_ALAW:
-  case ROAR_CODEC_MULAW:
-   break;
-  default:
-    roar_mm_free(self);
-    return -1;
-   break;
- }
-
- gettimeofday(&(self->lasttime), NULL);
-
- self->last_wanted = 0;
-
- return 0;
-}
-
-int     driver_sysclock_close   (struct roar_vio_calls * vio) {
- struct driver_sysclock * self = vio->inst;
-
- if ( self == NULL )
-  return -1;
-
- roar_mm_free(self);
-
- return 0;
-}
-
-ssize_t driver_sysclock_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_sysclock * self = vio->inst;
- struct timeval now;
- long long diff = (1000000LL * count / (long long)self->bps);
- long long ago;
-
- gettimeofday(&now, NULL);
-
- ago  = now.tv_usec - self->lasttime.tv_usec;
- ago += 1000000*(now.tv_sec - self->lasttime.tv_sec);
-
- ago -= self->last_wanted;
-
- memcpy(&(self->lasttime), &now, sizeof(now));
-
- ROAR_DBG("driver_sysclock_write(*): count=%u, bps=%u, diff=%llu, ago=%llu", count, self->bps, diff, ago);
-
- diff -= ago;
-
- self->last_wanted = diff;
-
- ROAR_DBG("driver_sysclock_write(*): diff=%lli", diff);
-
- if ( diff > 0 )
-  roar_usleep(diff);
-
- return count;
-}
-
-#endif
-
-//ll
Index: roard/driver_wmm.c
===================================================================
--- roard/driver_wmm.c	(revision 6052)
+++ 	(revision )
@@ -1,332 +1,0 @@
-//driver_wmm.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_HAVE_LIBWINMM
-
-static int _alloc_wave_headers(struct driver_wmm * self) {
-  int bytesPerBlock = self->wavefmt.nBlockAlign * self->splPerBlock;
-  /*   int bytes = internal->blocks * (sizeof(WAVEHDR) + bytesPerBlock); */
-  int bytes = self->blocks * (sizeof(*self->wh) + bytesPerBlock);
-  int res;
-  MMRESULT mmres;
-
-  self->bigbuffer = roar_mm_malloc(bytes);
-  if (self->bigbuffer != NULL) {
-    int i;
-    BYTE * b;
-
-    memset(self->bigbuffer,0,bytes);
-    self->wh = self->bigbuffer;
-    self->spl = (LPBYTE) (self->wh+self->blocks);
-    for (i=0, b=self->spl; i<self->blocks; ++i, b+=bytesPerBlock) {
-      self->wh[i].data = b;
-      self->wh[i].wh.lpData = self->wh[i].data;
-      self->wh[i].length = bytesPerBlock;
-      self->wh[i].wh.dwBufferLength = self->wh[i].length;
-      self->wh[i].wh.dwUser = (DWORD_PTR)self;
-      mmres = waveOutPrepareHeader(self->hwo,
-                                   &self->wh[i].wh,sizeof(WAVEHDR));
-      if (MMSYSERR_NOERROR != mmres) {
-        break;
-      }
-    }
-    if (i<self->blocks) {
-      while (--i >= 0) {
-        waveOutUnprepareHeader(self->hwo,
-                               &self->wh[i].wh,sizeof(WAVEHDR));
-      }
-      roar_mm_free(self->bigbuffer);
-      self->wh        = 0;
-      self->spl       = 0;
-      self->bigbuffer = 0;
-    } else {
-      /* all ok ! */
-    }
-  }
-
-  res = (self->bigbuffer != NULL);
-  return res;
-}
-
-static int _get_free_block(struct driver_wmm * self);
-static int _wait_wave_headers(struct driver_wmm * self, int wait_all) {
-  int res = 1;
-
-  while (self->sent_blocks > 0) {
-    int n;
-    _get_free_block(self);
-    n = self->sent_blocks;
-    if (n > 0) {
-      unsigned int ms = (self->msPerBlock>>1)+1;
-      if (wait_all) ms *= n;
-      Sleep(ms);
-    }
-  }
-
-  res &= !self->sent_blocks;
-  return res;
-}
-
-static int _get_free_block(struct driver_wmm * self) {
-  const int idx = self->widx;
-  int ridx = self->ridx;
-
-  while (self->wh[ridx].sent && !!(self->wh[ridx].wh.dwFlags & WHDR_DONE)) {
-    /* block successfully sent to hardware, release it */
-    /*debug("_ao_get_free_block: release block %d\n",ridx);*/
-    self->wh[ridx].sent = 0;
-    self->wh[ridx].wh.dwFlags &= ~WHDR_DONE;
-
-    --self->full_blocks;
-    if (self->full_blocks<0) {
-      self->full_blocks = 0;
-    }
-
-    --self->sent_blocks;
-    if (self->sent_blocks<0) {
-      self->sent_blocks = 0;
-    }
-    if (++ridx >= self->blocks) ridx = 0;
-  }
-  self->ridx = ridx;
-
-  return self->wh[idx].sent
-    ? -1
-    : idx;
-}
-
-static int _free_wave_headers(struct driver_wmm * self) {
-  MMRESULT mmres;
-  int res = 1;
-
-  if (self->wh) {
-    int i;
-
-    /* Reset so we dont need to wait ... Just a satefy net
-     * since _ao_wait_wave_headers() has been called once before.
-     */
-    mmres = waveOutReset(self->hwo);
-    /* Wait again to be sure reseted waveheaders has been released. */
-    _wait_wave_headers(self, 0);
-
-    for (i=self->blocks; --i>=0; ) {
-      mmres = waveOutUnprepareHeader(self->hwo,
-                                     &self->wh[i].wh,sizeof(WAVEHDR));
-
-      res &= mmres == MMSYSERR_NOERROR;
-    }
-    self->wh  = 0;
-    self->spl = 0;
-  }
-
-  return res;
-}
-
-/* Send a block to audio hardware */
-static int _send_block(struct driver_wmm * self, const int idx) {
-  MMRESULT mmres;
-
-  /* Satanity checks */
-  if (self->wh[idx].sent) {
-    return 0;
-  }
-  if (!!(self->wh[idx].wh.dwFlags & WHDR_DONE)) {
-    return 0;
-  }
-
-  /* count <= 0, just pretend it's been sent */
-  if (self->wh[idx].count <= 0) {
-    self->wh[idx].sent = 2; /* set with 2 so we can track these special cases */
-    self->wh[idx].wh.dwFlags |= WHDR_DONE;
-    ++self->sent_blocks;
-    return 1;
-  }
-
-  self->wh[idx].wh.dwBufferLength = self->wh[idx].count;
-  self->wh[idx].count = 0;
-  mmres = waveOutWrite(self->hwo,
-                       &self->wh[idx].wh, sizeof(WAVEHDR));
-  self->wh[idx].sent = (mmres == MMSYSERR_NOERROR);
-  /*&& !(internal->wh[idx].wh.dwFlags & WHDR_DONE);*/
-  self->sent_blocks += self->wh[idx].sent;
-  return mmres == MMSYSERR_NOERROR;
-}
-
-int     driver_wmm_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
- struct driver_wmm * self;
- MMRESULT mmres;
-
- if ( (self = roar_mm_malloc(sizeof(struct driver_wmm))) == NULL )
-  return -1;
-
- memset(self, 0, sizeof(struct driver_wmm));
-
- // VIO Setup:
- memset(inst, 0, sizeof(struct roar_vio_calls));
- inst->flags    = ROAR_VIO_FLAGS_NONE;
- inst->refc     = 1;
- inst->inst     = self;
- inst->close    = driver_wmm_close_vio;
- inst->write    = driver_wmm_write;
- inst->ctl      = driver_dummy_ctl;
-
- info->codec = ROAR_CODEC_PCM_S_LE;
-
- self->wavefmt.wFormatTag      = WAVE_FORMAT_PCM;
- self->wavefmt.nChannels       = info->channels;
- self->wavefmt.wBitsPerSample  = info->bits;
- self->wavefmt.nSamplesPerSec  = info->rate;
- self->wavefmt.nBlockAlign     = (self->wavefmt.wBitsPerSample>>3)*self->wavefmt.nChannels;
- self->wavefmt.nAvgBytesPerSec = self->wavefmt.nSamplesPerSec*self->wavefmt.nBlockAlign;
- self->wavefmt.cbSize          = 0;
-
- /* $$$ later this should be optionnal parms */
-  self->id          = WAVE_MAPPER;
-  self->blocks      = 64;
-  self->splPerBlock = 512;
-  self->msPerBlock  =
-    (self->splPerBlock * 1000 + info->rate - 1) / info->rate;
-
-  mmres =
-    waveOutOpen(&(self->hwo),
-                self->id,
-                &(self->wavefmt),
-                (DWORD_PTR)0/* waveOutProc */,
-                (DWORD_PTR)self,
-                CALLBACK_NULL/* |WAVE_FORMAT_DIRECT */|WAVE_ALLOWSYNC);
- if ( mmres != MMSYSERR_NOERROR ) {
-  driver_wmm_close_vio(inst);
-  return -1;
- }
-
- // FIXME: do error checking
- waveOutGetID(self->hwo, &(self->id));
-
- _alloc_wave_headers(self);
-
- self->opened = 1;
-
- ROAR_DBG("driver_wmm_open_vio(*) = 0");
-
- return 0;
-}
-
-int     driver_wmm_close_vio(struct roar_vio_calls * vio) {
- struct driver_wmm * self;
-
- if ( vio == NULL )
-  return -1;
-
- if ( (self = vio->inst) == NULL )
-  return -1;
-
- if ( self->opened ) {
-  _wait_wave_headers(self, 1);
-  _free_wave_headers(self);
-  waveOutClose(self->hwo);
- }
-
- roar_mm_free(self);
-
- ROAR_DBG("driver_wmm_close_vio(*) = 0");
-
- return 0;
-}
-
-ssize_t driver_wmm_write(struct roar_vio_calls * vio, void *buf, size_t count) {
- struct driver_wmm * self;
- ssize_t ret_ok = count;
- int ret = 1;
-
- ROAR_DBG("driver_wmm_write(vio=%p, buf=%p, count=%lu) = ?", vio, buf, (unsigned long)count);
-
- if ( vio == NULL )
-  return -1;
-
- if ( (self = vio->inst) == NULL )
-  return -1;
-
- if ( ! self->opened )
-  return -1;
-
-  while(ret && count > 0) {
-    int n;
-    const int idx = _get_free_block(self);
-
-    if (idx == -1) {
-      /* debug("sleep %dms, rem %d bytes\n",internal->msPerBlock,num_bytes); */
-      Sleep(self->msPerBlock);
-      continue;
-    }
-
-    /* Get free bytes in the block */
-    n = self->wh[idx].wh.dwBufferLength
-      - self->wh[idx].count;
-
-    /*     debug("free in block %d : %d/%d\n", */
-    /*    idx,n,internal->wh[idx].dwBufferLength); */
-
-    /* Get amount to copy */
-    if (n > (int)count) {
-      n = count;
-    }
-    /*     debug("copy = %d\n",n); */
-
-
-
-    /* Do copy */
-    CopyMemory((char*)self->wh[idx].wh.lpData
-               + self->wh[idx].count,
-               buf, n);
-
-    /* Updates pointers and counters */
-    buf += n;
-    count -= n;
-    /*     debug("rem = %d\n",num_bytes); */
-    self->wh[idx].count += n;
-
-    /* Is this block full ? */
-    if (self->wh[idx].count
-        == self->wh[idx].wh.dwBufferLength) {
-      ++self->full_blocks;
-      /*       debug("blocks %d full, total:%d\n",internal->widx,internal->full_blocks); */
-      if (++self->widx == self->blocks) {
-        self->widx = 0;
-      }
-      ret = _send_block(self, idx);
-    }
-  }
-
- ROAR_DBG("driver_wmm_write(vio=%p, buf=%p, count=%lu): ret=%i", vio, buf, (unsigned long)count, ret);
-
-  /*   debug("ao_wmm_play => %d rem => [%s]\n",num_bytes,ret?"success":"error"); */
-  return ret > -1 ? ret_ok : -1;
-}
-
-#endif
-
-//ll
Index: roard/empty.c
===================================================================
--- roard/empty.c	(revision 6052)
+++ roard/empty.c	(revision 0)
@@ -1,26 +1,3 @@
 //*.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2013-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
Index: roard/emul_rsound.c
===================================================================
--- roard/emul_rsound.c	(revision 6052)
+++ 	(revision )
@@ -1,335 +1,0 @@
-//emul_rsound.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-
-static int emul_rsound_lastcon = -1;
-
-int emul_rsound_new_client  (int client, int data);
-
-int emul_rsound_on_connect  (int fh, struct roard_listen * lsock) {
- int oldfh = emul_rsound_lastcon;
- int client;
- union {
-  int32_t i[4];
-  char c[16];
- } buf;
-
- (void)lsock;
-
- // TODO: add error handling
- roar_socket_nonblock(fh, ROAR_SOCKET_NONBLOCK);
-
- if ( emul_rsound_lastcon == -1 ) {
-  emul_rsound_lastcon = fh;
-  return -2;
- } else {
-  emul_rsound_lastcon = -1;
-
-  client = clients_new();
-
-  if ( client == -1 )
-   return -1;
-
-  if ( clients_set_fh(client, fh) == -1 ) {
-   ROAR_ERR("net_get_new_client(void): Can not set client's fh");
-
-   clients_delete(client);
-   close(oldfh);
-   close(fh);
-
-   ROAR_DBG("net_get_new_client(void) = -1");
-   return -1;
-  }
-
-  if ( emul_rsound_new_client(client, oldfh) == -1 ) {
-   clients_delete(client);
-   return -1;
-  }
-
-  // LATENCY:
-  // we currently don't know what we need to set here.
-  buf.i[0] = ROAR_HOST2NET32(0);
-
-  // block size used by roard.
-  buf.i[1] = ROAR_HOST2NET32(ROAR_OUTPUT_BUFFER_SAMPLES * roar_info2framesize(g_sa) / 8);
-
-  // Magic zeros to enable protocol handling.
-  // (RSD_CONN_PROTO)
-  buf.i[2] = ROAR_HOST2NET32(0);
-  buf.i[3] = ROAR_HOST2NET32(0);
-
-  if ( ROAR_NETWORK_WRITE(oldfh, buf.c, sizeof(buf.c)) != sizeof(buf.c) ) {
-   clients_delete(client);
-   return -1;
-  }
-
-  return client;
- }
-
- return -1;
-}
-
-int emul_rsound_new_client  (int client, int data) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- struct roar_client        *  c;
- int stream;
-
- if ( clients_get(client, &c) == -1 ) {
-  return -1;
- }
-
- if ((stream = streams_new()) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- if ( streams_get(stream, &ss) == -1 ) {
-  streams_delete(stream);
-  clients_delete(client);
-  return -1;
- }
-
- s = ROAR_STREAM(ss);
-
- if ( client_stream_add(client, stream) == -1 ) {
-  streams_delete(stream);
-  clients_delete(client);
-  return -1;
- }
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- ss->codec_orgi = s->info.codec = ROAR_CODEC_RIFF_WAVE;
-
- if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
-/*
- if ( client_stream_exec(client, stream) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-*/
-
- if ( client_stream_set_fh(client, stream, data) == -1 ) {
-  streams_delete(stream);
-  clients_delete(client);
-  return -1;
- }
-
- return 0;
-}
-
-int emul_rsound_vrecv_msg(struct emul_rsound_msg * msg, struct roar_vio_calls * vio) {
- struct roar_vio_select select;
- struct roar_vio_selecttv tv = {
-  .sec  = 0,
-  .nsec = 0
- };
- ssize_t ret;
- int     num;
-
- if ( msg == NULL || vio == NULL )
-  return -1;
-
- ROAR_VIO_SELECT_SETVIO(&select, vio, ROAR_VIO_SELECT_READ); 
- if ( roar_vio_select(&select, 1, &tv, NULL) == -1 )
-  return -1;
-
- if ( !(select.eventsa & ROAR_VIO_SELECT_READ) ) {
-  errno = EAGAIN;
-  return -1;
- }
-
- ret = roar_vio_read(vio, msg->header, EMUL_RSOUND_MSG_HEADER_LEN);
-
- if ( ret != EMUL_RSOUND_MSG_HEADER_LEN )
-  return -1;
-
- msg->header[ret] = 0;
-
- if ( msg->header[0] != 'R' || msg->header[1] != 'S' || msg->header[2] != 'D' )
-  return -1;
-
- if ( sscanf(&(msg->header[3]), "%5d", &num) != 1 )
-  return -1;
-
- if ( num > EMUL_RSOUND_MSG_DATA_LEN )
-  return -1;
-
- msg->datalen = num;
-
- ret = roar_vio_read(vio, msg->data, num);
-
- if ( ret != (ssize_t)num )
-  return -1;
-
- msg->data[num] = 0;
-
- msg->datasp   = msg->data;
- msg->dataslen = msg->datalen;
-
- for (num = 0; msg->data[num] == ' '; num++) {
-  msg->datasp++;
-  msg->dataslen--;
- }
-
- return 0;
-}
-
-int emul_rsound_vsend_msg(struct emul_rsound_msg * msg, struct roar_vio_calls * vio) {
- struct roar_vio_select select;
- struct roar_vio_selecttv tv = {
-  .sec = 0,
-  .nsec = 0
- };
- ssize_t ret;
-
- if ( msg == NULL || vio == NULL )
-  return -1;
-
- ROAR_VIO_SELECT_SETVIO(&select, vio, ROAR_VIO_SELECT_WRITE); 
- if ( roar_vio_select(&select, 1, &tv, NULL) == -1 )
-  return -1;
-
- if ( !(select.eventsa & ROAR_VIO_SELECT_WRITE) ) {
-  errno = EAGAIN;
-  return -1;
- }
-
- snprintf(msg->header, EMUL_RSOUND_MSG_HEADER_LEN+1, "RSD%5d", (int)msg->datalen);
-
- ret = roar_vio_write(vio, msg->header, EMUL_RSOUND_MSG_HEADER_LEN);
-
- if ( ret != EMUL_RSOUND_MSG_HEADER_LEN )
-  return -1;
-
- ret = roar_vio_write(vio, msg->data, msg->datalen);
-
- if ( ret != (ssize_t)msg->datalen )
-  return -1;
-
- return 0;
-}
-
-int emul_rsound_check_client(int client, struct roar_vio_calls * vio) {
- struct roar_vio_calls     rvio;
- struct emul_rsound_msg     msg;
- struct roar_client        *  c;
- struct roar_stream_server * ss;
- int                   streamid;
- int                          i;
- ssize_t                    ptr;
- size_t                 max_len;
-
- if ( vio == NULL ) {
-  vio = &rvio;
-  roar_vio_open_fh_socket(vio, clients_get_fh(client));
- }
-
- // we get called in a loop, in case this fails no problem, just
- // return -1, caller will delete us in case of real error.
- if ( emul_rsound_vrecv_msg(&msg, vio) == -1 )
-  return -1;
-
- if ( !strncmp(msg.datasp, "INFO", 4) ) {
-  if ( clients_get(client, &c) == -1 )
-   return clients_delete(client);
-
-  streamid = -1;
-  for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++)
-   if ( c->streams[i] > streamid )
-    streamid = c->streams[i];
-
-  if ( streamid == -1 )
-   return clients_delete(client);
-
-  if ( streams_get(streamid, &ss) == -1 )
-   return clients_delete(client);
-
-  ptr = roar_info2samplesize(&(ROAR_STREAM(ss)->info));
-
-  if ( ptr == -1 )
-   return clients_delete(client);
-
-  ptr *= ROAR_STREAM(ss)->pos;
-  ptr /= 8; // bits -> bytes
-
-  i = snprintf(msg.data+msg.datalen, EMUL_RSOUND_MSG_DATA_LEN - msg.datalen, " %" LIBROAR__ll "d", (LIBROAR__longlong int)ptr);
-
-  msg.datalen += i;
-
-  return emul_rsound_vsend_msg(&msg, vio);
- } else if ( !strncmp(msg.datasp, "NULL", 4) ) {
-  // NULL is simular to NOOP
- } else if ( !strncmp(msg.datasp, "STOP", 4) ) {
-  // This is quit.
-  return clients_delete(client);
- } else if ( !strncmp(msg.datasp, "IDENTITY ", 9) ) {
-  if ( msg.dataslen < (8+1+1) )
-   return clients_delete(client);
-
-  msg.datasp   += 9;
-  msg.dataslen -= 9;
-
-  if ( clients_get(client, &c) == -1 )
-   return clients_delete(client);
-
-  max_len = msg.dataslen < (ROAR_BUFFER_NAME-1) ? msg.dataslen : (ROAR_BUFFER_NAME-1);
-
-  strncpy(c->name, msg.datasp, max_len);
-  c->name[max_len] = 0;
- } else if ( !strncmp(msg.datasp, "CLOSECTL", 9) ) {
-  if ( clients_get(client, &c) == -1 )
-   return clients_delete(client);
-
-  strncpy(msg.data, " CLOSECTL OK", EMUL_RSOUND_MSG_DATA_LEN);
-  msg.datalen = 12; //strlen(" CLOSECTL OK");
-
-  if ( emul_rsound_vsend_msg(&msg, vio) == -1 )
-   return clients_delete(client);
-
-  streamid = c->streams[0];
-
-  if ( client_stream_exec(client, streamid) == -1 )
-   return clients_delete(client);
-
-  return 0;
- } else {
-  // Unknown command, kill the client.
-  return clients_delete(client);
- }
-
- return 0;
-}
-#endif
-
-//ll
Index: roard/emul_simple.c
===================================================================
--- roard/emul_simple.c	(revision 6052)
+++ 	(revision )
@@ -1,78 +1,0 @@
-//emul_simple.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-
-int emul_simple_on_connect  (int client, struct roard_listen * lsock) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- struct roar_client        *  c;
- int stream;
-
- if ( clients_get(client, &c) == -1 ) {
-  return -1;
- }
-
- if ((stream = streams_new()) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- if ( streams_get(stream, &ss) == -1 ) {
-  streams_delete(stream);
-  clients_delete(client);
-  return -1;
- }
-
- s = ROAR_STREAM(ss);
-
- if ( client_stream_add(client, stream) == -1 ) {
-  streams_delete(stream);
-  clients_delete(client);
-  return -1;
- }
-
- memcpy(&(s->info), &(lsock->inst.stpl.info), sizeof(struct roar_audio_info));
-
- ss->codec_orgi = s->info.codec;
-
- if ( streams_set_dir(stream, lsock->inst.stpl.dir, 1) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- if ( client_stream_exec(client, stream) == -1 ) {
-  clients_delete(client);
-  return -1;
- }
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/hwmixer.c
===================================================================
--- roard/hwmixer.c	(revision 6052)
+++ 	(revision )
@@ -1,302 +1,0 @@
-//hwmixer.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-
-#define FLAG_NONE     0x0000
-#define FLAG_FHSEC    0x0001
-
-struct hwmixer {
- const char * name;
- const char * desc;
- const char * devs;
- int flags;
- int (*open)(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen);
- int (*close)(struct hwmixer_stream * stream);
- int (*set_vol)(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings);
- int (*get_vol)(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings);
-};
-
-static int __true (void) { return 0; }
-
-struct hwmixer g_hwmixers[] = {
-#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS)
- {"oss",  "OSS Mixer",     "/dev/mixer*", FLAG_FHSEC, hwmixer_oss_open, hwmixer_oss_close, hwmixer_oss_set_vol, hwmixer_oss_get_vol},
-#endif
- {"dstr", "Write to DSTR", "/some/file",  FLAG_FHSEC,  hwmixer_dstr_open, hwmixer_dstr_close, hwmixer_dstr_set_vol, NULL},
- {"null", "Null Mixer",    NULL,          FLAG_NONE,  (int (*)(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen))__true, (int (*)(struct hwmixer_stream * stream))__true, (int (*)(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings))__true, (int (*)(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings))__true},
- {NULL,   NULL, NULL, FLAG_NONE, NULL, NULL, NULL, NULL}
-};
-
-void print_hwmixerlist (void) {
- struct hwmixer * mixer;
- int i;
-
- printf("  Source   Flag Subsys - Description (devices)\n");
- printf("------------------------------------------------------\n");
-
- for (i = 0; (mixer = &(g_hwmixers[i]))->name != NULL; i++) {
-  printf("  %-9s %c   Mixer  - %s (devices: %s)\n",
-         mixer->name,
-         mixer->flags & FLAG_FHSEC ? 's' : ' ',
-         mixer->desc,
-         mixer->devs == NULL ? "(none)" : mixer->devs
-        );
- }
-}
-
-void hwmixer_setup_info(struct hwmixer_stream * mstream) {
- struct roar_stream_server * ss;
-
- streams_get(mstream->stream, &ss);
-
- memset(&(ROAR_STREAM(ss)->info), 0, sizeof(ROAR_STREAM(ss)->info));
-
- streams_set_dir(mstream->stream, ROAR_DIR_MIXING, 1);
-
- streams_set_flag(mstream->stream, ROAR_FLAG_HWMIXER);
-}
-
-int hwmixer_open(int basestream, char * drv, char * dev, int fh, char * basename, char * subnames) {
- struct roar_stream_server * ss;
- struct roar_keyval * subnamekv = NULL;
- struct hwmixer * mixer = NULL;
- struct hwmixer_stream * stream;
- ssize_t subnamekvlen = 0;
- int i;
- int ret;
-
- for (i = 0; g_hwmixers[i].name != NULL; i++) {
-  if ( !strcmp(g_hwmixers[i].name, drv) ) {
-   mixer = &(g_hwmixers[i]);
-   break;
-  }
- }
-
- if ( mixer == NULL ) {
-  ROAR_WARN("hwmixer_open(basestream=%i, drv='%s', dev='%s', fh=%i, basename='%s', subnames='%s'): Driver not found.", basestream, drv, dev, fh, basename, subnames);
-  return -1;
- }
-
- if ( mixer->open == NULL ) {
-  return -1;
- }
-
- if ( fh != -1 && !(mixer->flags & FLAG_FHSEC) ) {
-  return -1;
- }
-
- stream = roar_mm_malloc(sizeof(struct hwmixer_stream));
- if ( stream == NULL )
-  return -1;
-
- memset(stream, 0, sizeof(struct hwmixer_stream));
-
- stream->hwmixer    = mixer;
- stream->basestream = basestream;
- stream->stream     = basestream;
- stream->baseud     = NULL;
- stream->ud         = NULL;
-
- if ( basename == NULL ) {
-  streams_set_name(basestream, "Hardware Mixer");
- } else {
-  streams_set_name(basestream, basename);
- }
-
- hwmixer_setup_info(stream);
-
- if ( subnames != NULL ) {
-  subnamekvlen = roar_keyval_split(&subnamekv, subnames, ",;", NULL, 1);
- }
-
- ret = mixer->open(stream, drv, dev, fh, basename, subnamekv, subnamekvlen);
-
- if ( subnamekv != NULL )
-  roar_mm_free(subnamekv);
-
- if ( ret == -1 ) {
-  roar_mm_free(stream);
-  return -1;
- }
-
- streams_set_mixerstream(basestream, stream);
-
- // try to get in sync with HW mixer.
- // if possible read hw mixer state.
- // if not possible write to force a sync value.
- if ( streams_get(basestream, &ss) == 0 ) {
-  if ( mixer->get_vol != NULL ) {
-   hwmixer_get_volume(basestream, ss, stream, &(ss->mixer));
-  } else {
-   hwmixer_set_volume(basestream, ss, stream, &(ss->mixer));
-  }
- }
-
- return 0;
-}
-
-int hwmixer_close(int stream) {
- struct hwmixer_stream * mstream = streams_get_mixerstream(stream);
-
- if ( mstream == NULL )
-  return 0;
-
- if ( mstream->hwmixer->close != NULL )
-  mstream->hwmixer->close(mstream);
-
- roar_mm_free(mstream);
-
- return 0;
-}
-
-int hwmixer_set_volume(int id, struct roar_stream_server * ss, struct hwmixer_stream * mstream, struct roar_mixer_settings *
-settings) {
- if ( mstream->hwmixer->set_vol != NULL )
-  return mstream->hwmixer->set_vol(mstream, ROAR_STREAM(ss)->info.channels, HWMIXER_MODE_SET, settings);
-
- return 0;
-}
-
-int hwmixer_get_volume(int id, struct roar_stream_server * ss, struct hwmixer_stream * mstream, struct roar_mixer_settings *
-settings) {
- if ( mstream->hwmixer->get_vol != NULL )
-  return mstream->hwmixer->get_vol(mstream, ROAR_STREAM(ss)->info.channels, HWMIXER_MODE_ASK, settings);
-
- return 0;
-}
-
-struct hwmixer_stream * hwmixer_substream_new(struct hwmixer_stream * parent) {
- struct roar_stream_server * ss;
- struct hwmixer_stream * stream;
- int id;
-
- ROAR_DBG("hwmixer_substream_new(parent=%p) = ?", parent);
-
- if ( parent == NULL )
-  return NULL;
-
- ROAR_DBG("hwmixer_substream_new(parent=%p) = ?", parent);
-
- stream = roar_mm_malloc(sizeof(struct hwmixer_stream));
- if ( stream == NULL )
-  return NULL;
-
- ROAR_DBG("hwmixer_substream_new(parent=%p) = ?", parent);
-
- if ( (id = streams_new_virtual(parent->basestream, &ss)) == -1 ) {
-  roar_mm_free(stream);
-  return NULL;
- }
-
- memset(stream, 0, sizeof(struct hwmixer_stream));
-
- stream->hwmixer    = parent->hwmixer;
- stream->basestream = parent->basestream;
- stream->stream     = id;
- stream->baseud     = parent->baseud;
- stream->ud         = NULL;
-
- hwmixer_setup_info(stream);
-
- streams_set_mixerstream(id, stream);
-
- ROAR_DBG("hwmixer_substream_new(parent=%p) = %p", parent, stream);
-
- return stream;
-}
-
-int hwmixer_add (char * drv, char * dev, char * opts, int prim, int count) {
- char * basename = NULL;
- char * subnames = NULL;
- char * k, * v;
- int basestream = streams_new();
- int ret;
- int error = 0;
- char * strtok_store;
-//int hwmixer_open(int basestream, char * drv, char * dev, int fh, char * basename, char * subnames) {
-
- if ( basestream == -1 )
-  return -1;
-
- client_stream_add(g_self_client, basestream);
-
- if ( opts == NULL ) {
-  k = NULL;
- } else {
-  k = roar_mm_strtok_r(opts, ",", &strtok_store);
- }
-
- while (k != NULL) {
-//  ROAR_WARN("add_output(*): opts: %s", k);
-
-  if ( (v = strstr(k, "=")) != NULL ) {
-   *v++ = 0;
-  }
-
-  if ( strcmp(k, "primary") == 0 ) {
-   prim = 1;
-
-  } else if ( strcmp(k, "name") == 0 ) {
-   basename = v;
-  } else if ( strcmp(k, "subs") == 0 ) {
-   subnames = v;
-
-  } else if ( strcmp(k, "autoconf") == 0 ) {
-   streams_set_flag(basestream, ROAR_FLAG_AUTOCONF);
-  } else if ( strcmp(k, "passmixer") == 0 ) {
-   streams_set_flag(basestream, ROAR_FLAG_PASSMIXER);
-  } else {
-   ROAR_ERR("add_hwmixer(*): unknown option '%s'", k);
-   error++;
-  }
-
-  if ( error ) {
-   streams_delete(basestream);
-   if ( prim ) alive = 0;
-   return -1;
-  }
-
-  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
- }
-
- if ( prim ) {
-  streams_mark_primary(basestream);
- }
-
- ret = hwmixer_open(basestream, drv, dev, -1, basename, subnames);
-
- if ( ret == -1 ) {
-  streams_delete(basestream);
- }
-
- return ret == -1 ? -1 : 0;
-}
-
-#endif
-
-//ll
Index: roard/hwmixer_dstr.c
===================================================================
--- roard/hwmixer_dstr.c	(revision 6052)
+++ 	(revision )
@@ -1,129 +1,0 @@
-//hwmixer_dstr.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-
-/*
- * This driver ignores errors on seeks:
- * The writes ensure that if the seek back to begin of file
- * does not work the records keep seperate and parsable.
- * So it basically enters some kind of streaming mode.
- */
-
-//#define TEST_HWMIXER_SUBSTREAMS
-
-int hwmixer_dstr_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) {
- struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
- struct roar_vio_defaults def;
- struct roar_stream_server * ss;
-
- if ( vio == NULL )
-  return -1;
-
- if ( fh == -1 ) {
-  if ( dev == NULL ) {
-   roar_mm_free(vio);
-   return -1;
-  }
-
-  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY|O_CREAT|O_TRUNC, 0644) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
-
-  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
- } else {
-  if ( roar_vio_open_fh(vio, fh) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
- }
-
- stream->baseud = vio;
-
- roar_vio_printf(vio, "No data yet.\n");
- _LIBROAR_IGNORE_RET(roar_vio_lseek(vio, 0, SEEK_SET));
- roar_vio_sync(vio);
-
- if (streams_get(stream->basestream, &ss) != -1) {
-  ROAR_STREAM(ss)->info.channels = 2;
- } else {
-  ROAR_WARN("hwmixer_dstr_open(*): can not get object for basestream %i", stream->basestream);
- }
-
-#ifdef TEST_HWMIXER_SUBSTREAMS
- stream = hwmixer_substream_new(stream);
- if ( stream == NULL ) {
-  ROAR_WARN("hwmixer_dstr_open(*): can not create substream");
- } else {
-  if (streams_get(stream->stream, &ss) != -1) {
-   ROAR_STREAM(ss)->info.channels = 2;
-  } else {
-   ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream);
-  }
- }
-#endif
-
- return 0;
-}
-
-int hwmixer_dstr_close(struct hwmixer_stream * stream) {
- // are we a substream? if yes we do not clean up anything.
- // streams_delete() will do all our work.
- if ( stream->stream != stream->basestream )
-  return 0;
-
- roar_vio_close(stream->baseud);
- roar_mm_free(stream->baseud);
- return 0;
-}
-
-int hwmixer_dstr_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings) {
- struct roar_vio_calls * vio = stream->baseud;
- int i;
-
- roar_vio_printf(vio, "[Stream %2i of basestream %2i]\n", stream->stream, stream->basestream);
- roar_vio_printf(vio, "Channels: %2i\n", channels);
- roar_vio_printf(vio, "Mode: %1i\n", mode);
- roar_vio_printf(vio, "Scale: %5i\n", (int)settings->scale);
- roar_vio_printf(vio, "RPG: %5i/%5i\n", (int)settings->rpg_mul, (int)settings->rpg_div);
-
- for (i = 0; i < channels; i++) {
-  roar_vio_printf(vio, "Channel[%2i]: %5i\n", i, (int)settings->mixer[i]);
- }
-
- _LIBROAR_IGNORE_RET(roar_vio_lseek(vio, 0, SEEK_SET));
- roar_vio_sync(vio);
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/hwmixer_oss.c
===================================================================
--- roard/hwmixer_oss.c	(revision 6052)
+++ 	(revision )
@@ -1,323 +1,0 @@
-//hwmixer_oss.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-
-#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS)
-
-#define OSS_VOLUME_SCALE 100
-
-struct subdev {
- int bit;
- int channels;
- long long int cmd_read, cmd_write;
-};
-
-static struct subdev_map {
- const char * name;
- struct subdev subdev;
-} g_subdevs[] = {
- {"Volume",  {.bit = SOUND_MASK_VOLUME,  .cmd_read = SOUND_MIXER_READ_VOLUME,  .cmd_write = SOUND_MIXER_WRITE_VOLUME  }},
- {"Bass",    {.bit = SOUND_MASK_BASS,    .cmd_read = SOUND_MIXER_READ_BASS,    .cmd_write = SOUND_MIXER_WRITE_BASS    }},
- {"Treble",  {.bit = SOUND_MASK_TREBLE,  .cmd_read = SOUND_MIXER_READ_TREBLE,  .cmd_write = SOUND_MIXER_WRITE_TREBLE  }},
- {"Synth",   {.bit = SOUND_MASK_SYNTH,   .cmd_read = SOUND_MIXER_READ_SYNTH,   .cmd_write = SOUND_MIXER_WRITE_SYNTH   }},
- {"PCM",     {.bit = SOUND_MASK_PCM,     .cmd_read = SOUND_MIXER_READ_PCM,     .cmd_write = SOUND_MIXER_WRITE_PCM     }},
- {"Speaker", {.bit = SOUND_MASK_SPEAKER, .cmd_read = SOUND_MIXER_READ_SPEAKER, .cmd_write = SOUND_MIXER_WRITE_SPEAKER }},
- {"Line",    {.bit = SOUND_MASK_LINE,    .cmd_read = SOUND_MIXER_READ_LINE,    .cmd_write = SOUND_MIXER_WRITE_LINE    }},
- {"Mic",     {.bit = SOUND_MASK_MIC,     .cmd_read = SOUND_MIXER_READ_MIC,     .cmd_write = SOUND_MIXER_WRITE_MIC     }},
- {"CD",      {.bit = SOUND_MASK_CD,      .cmd_read = SOUND_MIXER_READ_CD,      .cmd_write = SOUND_MIXER_WRITE_CD      }},
- {"Imix",    {.bit = SOUND_MASK_IMIX,    .cmd_read = SOUND_MIXER_READ_IMIX,    .cmd_write = SOUND_MIXER_WRITE_IMIX    }},
- {"AltPCM",  {.bit = SOUND_MASK_ALTPCM,  .cmd_read = SOUND_MIXER_READ_ALTPCM,  .cmd_write = SOUND_MIXER_WRITE_ALTPCM  }},
- {"Reclev",  {.bit = SOUND_MASK_RECLEV,  .cmd_read = SOUND_MIXER_READ_RECLEV,  .cmd_write = SOUND_MIXER_WRITE_RECLEV  }},
- {"IGain",   {.bit = SOUND_MASK_IGAIN,   .cmd_read = SOUND_MIXER_READ_IGAIN,   .cmd_write = SOUND_MIXER_WRITE_IGAIN   }},
- {"OGain",   {.bit = SOUND_MASK_OGAIN,   .cmd_read = SOUND_MIXER_READ_OGAIN,   .cmd_write = SOUND_MIXER_WRITE_OGAIN   }},
- {"Line1",   {.bit = SOUND_MASK_LINE1,   .cmd_read = SOUND_MIXER_READ_LINE1,   .cmd_write = SOUND_MIXER_WRITE_LINE1   }},
- {"Line2",   {.bit = SOUND_MASK_LINE2,   .cmd_read = SOUND_MIXER_READ_LINE2,   .cmd_write = SOUND_MIXER_WRITE_LINE2   }},
- {"Line3",   {.bit = SOUND_MASK_LINE3,   .cmd_read = SOUND_MIXER_READ_LINE3,   .cmd_write = SOUND_MIXER_WRITE_LINE3   }},
-/*
- {"Digital1", {.bit = SOUND_MASK_DIGITAL1, .cmd_read = SOUND_MIXER_READ_DIGITAL1, .cmd_write = SOUND_MIXER_WRITE_DIGITAL1}},
- {"Digital2", {.bit = SOUND_MASK_DIGITAL2, .cmd_read = SOUND_MIXER_READ_DIGITAL2, .cmd_write = SOUND_MIXER_WRITE_DIGITAL2}},
- {"Digital3", {.bit = SOUND_MASK_DIGITAL3, .cmd_read = SOUND_MIXER_READ_DIGITAL3, .cmd_write = SOUND_MIXER_WRITE_DIGITAL3}},
- {"PhoneIn", {.bit = SOUND_MASK_PHONEIN, .cmd_read = SOUND_MIXER_READ_PHONEIN, .cmd_write = SOUND_MIXER_WRITE_PHONEIN }},
- {"PhoneOut", {.bit = SOUND_MASK_PHONEOUT, .cmd_read = SOUND_MIXER_READ_PHONEOUT, .cmd_write = SOUND_MIXER_WRITE_PHONEOUT}},
- {"Radio",   {.bit = SOUND_MASK_RADIO,   .cmd_read = SOUND_MIXER_READ_RADIO,   .cmd_write = SOUND_MIXER_WRITE_RADIO   }},
- {"Video",   {.bit = SOUND_MASK_VIDEO,   .cmd_read = SOUND_MIXER_READ_VIDEO,   .cmd_write = SOUND_MIXER_WRITE_VIDEO   }},
- {"Monitor", {.bit = SOUND_MASK_MONITOR, .cmd_read = SOUND_MIXER_READ_MONITOR, .cmd_write = SOUND_MIXER_WRITE_MONITOR }},
-*/
- // Alias with better name:
- {"Master",  {.bit = SOUND_MASK_VOLUME,  .cmd_read = SOUND_MIXER_READ_VOLUME,  .cmd_write = SOUND_MIXER_WRITE_VOLUME  }},
- {"PCM2",    {.bit = SOUND_MASK_ALTPCM,  .cmd_read = SOUND_MIXER_READ_ALTPCM,  .cmd_write = SOUND_MIXER_WRITE_ALTPCM  }},
- {NULL}
-};
-
-static int hwmixer_oss_open_stream(struct hwmixer_stream * stream, int devmask, int sdevmask, char * basename, struct roar_keyval * subname) {
- struct subdev * subdev;
- struct subdev * source_subdev = NULL;
- struct roar_stream_server * ss;
- const char * reqname = subname->value;
- int i;
- char name[80];
-
- for (i = 0; g_subdevs[i].name != NULL; i++) {
-  if ( !strcasecmp(subname->key, g_subdevs[i].name) ) {
-   source_subdev = &(g_subdevs[i].subdev);
-   if ( reqname == NULL )
-    reqname = g_subdevs[i].name;
-   break;
-  }
- }
-
- if ( source_subdev == NULL )
-  return -1;
-
- if ( !(devmask & source_subdev->bit) )
-  return -1;
-
- subdev = roar_mm_malloc(sizeof(struct subdev));
-
- if ( subdev == NULL )
-  return -1;
-
- memcpy(subdev, source_subdev, sizeof(struct subdev));
-
- subdev->channels = sdevmask & subdev->bit ? 2 : 1;
-
- stream->ud     = subdev;
-
- if ( basename == NULL ) {
-  streams_set_name(stream->stream, (char*)reqname);
- } else {
-  snprintf(name, sizeof(name)-1, "%s/%s", basename, reqname);
-  name[sizeof(name)-1] = 0;
-  streams_set_name(stream->stream, name);
- }
-
- if (streams_get(stream->stream, &ss) != -1) {
-  ROAR_STREAM(ss)->info.channels = subdev->channels;
- } else {
-  ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream);
- }
-
- return 0;
-}
-
-int hwmixer_oss_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) {
- struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
- struct roar_vio_defaults def;
- struct roar_vio_sysio_ioctl ctl;
- struct roar_keyval kv;
- struct hwmixer_stream * cstream;
- int devmask, sdevmask;
- mixer_info info;
- size_t i;
-
- if ( vio == NULL ) {
-  return -1;
- }
-
- if ( fh == -1 ) {
-#ifdef ROAR_DEFAULT_OSS_MIX_DEV
-  if ( dev == NULL ) {
-   dev = ROAR_DEFAULT_OSS_MIX_DEV;
-  }
-#endif
-
-  if ( dev == NULL ) {
-   roar_mm_free(vio);
-   return -1;
-  }
-
-  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_FILE, O_RDWR, 0644) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
-
-  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
- } else {
-  if ( roar_vio_open_fh(vio, fh) == -1 ) {
-   roar_mm_free(vio);
-   return -1;
-  }
- }
-
- stream->baseud = vio;
-
- ctl.cmd  = SOUND_MIXER_READ_DEVMASK;
- ctl.argp = &devmask;
-
- if ( roar_vio_ctl(vio, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == -1 ) {
-  roar_vio_close(vio);
-  roar_mm_free(vio);
-  return -1;
- }
-
- ctl.cmd  = SOUND_MIXER_READ_STEREODEVS;
- ctl.argp = &sdevmask;
-
- if ( roar_vio_ctl(vio, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == -1 ) {
-  sdevmask = 0;
- }
-
- if ( basename == NULL ) {
-  ctl.cmd  = SOUND_MIXER_INFO;
-  ctl.argp = &info;
-
-  if ( roar_vio_ctl(vio, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == 0 ) {
-   basename = info.name;
-  }
- }
-
- if ( subnamelen == 0 ) {
-  kv.key   = "Master";
-  kv.value = NULL;
-
-  if ( hwmixer_oss_open_stream(stream, devmask, sdevmask, basename, &kv) == -1 ) {
-   roar_vio_close(vio);
-   roar_mm_free(vio);
-   return -1;
-  }
- } else {
-  if ( hwmixer_oss_open_stream(stream, devmask, sdevmask, basename, subnames) == -1 ) {
-   roar_vio_close(vio);
-   roar_mm_free(vio);
-   return -1;
-  }
-
-  for (i = 1; i < subnamelen; i++) {
-   cstream = hwmixer_substream_new(stream);
-   if ( hwmixer_oss_open_stream(cstream, devmask, sdevmask, basename, &(subnames[i])) == -1 ) {
-    roar_vio_close(vio);
-    roar_mm_free(vio);
-    return -1;
-   }
-  }
- }
-
-
-#ifdef TEST_HWMIXER_SUBSTREAMS
- stream = hwmixer_substream_new(stream);
- if ( stream == NULL ) {
-  ROAR_WARN("hwmixer_dstr_open(*): can not create substream");
- } else {
-  if (streams_get(stream->stream, &ss) != -1) {
-   ROAR_STREAM(ss)->info.channels = 2;
-  } else {
-   ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream);
-  }
- }
-#endif
-
- return 0;
-}
-
-int hwmixer_oss_close(struct hwmixer_stream * stream) {
- // are we a substream? if yes we do not clean up anything.
- // streams_delete() will do all our work.
-
- roar_mm_free(stream->ud);
-
- if ( stream->stream != stream->basestream )
-  return 0;
-
- roar_vio_close(stream->baseud);
- roar_mm_free(stream->baseud);
- return 0;
-}
-
-int hwmixer_oss_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings) {
- struct roar_vio_calls * vio = stream->baseud;
- struct roar_vio_sysio_ioctl ctl;
- struct subdev         * subdev = stream->ud;
- int i;
- int l, r;
-
- if ( channels == 0 )
-  return 0;
-
- if ( channels == 1 ) {
-  l = r = settings->mixer[0];
- } else {
-  l = settings->mixer[0];
-  r = settings->mixer[1];
- }
-
- if ( subdev->channels == 1 ) {
-  l = r = (l + r) / 2;
- }
-
- l = (l * OSS_VOLUME_SCALE) / settings->scale;
- r = (r * OSS_VOLUME_SCALE) / settings->scale;
-
- i = (l & 0xFF) | ((r & 0xFF) << 8); 
-
- ctl.cmd = subdev->cmd_write;
- ctl.argp = &i;
-
- return roar_vio_ctl(vio, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl);
-}
-
-int hwmixer_oss_get_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings) {
- struct roar_vio_calls * vio = stream->baseud;
- struct roar_vio_sysio_ioctl ctl;
- struct subdev         * subdev = stream->ud;
- int i;
- int l, r;
-
- ctl.cmd = subdev->cmd_read;
- ctl.argp = &i;
-
- if ( roar_vio_ctl(vio, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == -1 )
-  return -1;
-
- l =  i       & 0xFF;
- r = (i >> 8) & 0xFF;
-
- if ( subdev->channels == 1 )
-  r = l;
-
- settings->scale    = OSS_VOLUME_SCALE;
-
- if ( channels == 1 ) {
-  settings->mixer[0] = (l + r) / 2;
- } else if ( channels == 2 ) {
-  settings->mixer[0] = l;
-  settings->mixer[1] = r;
- } else {
-  return -1;
- }
-
- return 0;
-}
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/.cvsignore
===================================================================
--- roard/include/.cvsignore	(revision 1952)
+++ 	(revision )
@@ -1,1 +1,0 @@
-driver_ftd2.h
Index: roard/include/.release-helper
===================================================================
--- roard/include/.release-helper	(revision 5244)
+++ 	(revision )
@@ -1,3 +1,0 @@
-#!RELEASE-HELPER:0.0beta0
-@RM driver_raw.h
-#!END
Index: roard/include/auth.h
===================================================================
--- roard/include/auth.h	(revision 6052)
+++ 	(revision )
@@ -1,83 +1,0 @@
-//auth.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _AUTH_H_
-#define _AUTH_H_
-
-#include <roaraudio.h>
-
-#define AT_TRUST_MAX_ENTRYS 8
-#define AUTH_KEYRING_LEN    8
-
-struct at_none {
- char dummy;
-};
-
-struct at_cookie {
- char * cookie;
- size_t len;
-};
-
-struct at_trust {
- pid_t pids[AT_TRUST_MAX_ENTRYS];
- uid_t uids[AT_TRUST_MAX_ENTRYS];
- gid_t gids[AT_TRUST_MAX_ENTRYS];
- size_t pids_len, uids_len, gids_len;
-};
-
-struct at_password {
- const char * password;
-};
-
-union auth_typeunion {
- struct at_none     none;
- struct at_cookie   cookie;
- struct at_trust    trust;
- struct at_password password;
-};
-
-struct auth_key {
- int type;
- enum roard_client_acclev acclev;
- union auth_typeunion at_data;
-};
-
-extern struct auth_key g_auth_keyring[AUTH_KEYRING_LEN];
-
-int auth_init (void);
-int auth_free (void);
-
-union auth_typeunion * auth_regkey_simple(int type, enum roard_client_acclev acclev);
-
-int auth_client_ckeck(struct roar_client_server * cs, struct roar_auth_message * authmes, int * next);
-
-int auth_addkey_anonymous(enum roard_client_acclev acclev);
-int auth_addkey_password(enum roard_client_acclev acclev, const char * password);
-int auth_addkey_cookie(enum roard_client_acclev acclev, const void * cookie, const size_t len);
-int auth_addkey_trust(enum roard_client_acclev acclev, ...);
-
-#endif
-
-//ll
Index: roard/include/beep.h
===================================================================
--- roard/include/beep.h	(revision 6052)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//beep.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _BEEP_H_
-#define _BEEP_H_
-
-#include <roaraudio.h>
-
-int beep_start (int client, struct roar_beep * beep);
-
-#endif
-
-//ll
Index: roard/include/caps.h
===================================================================
--- roard/include/caps.h	(revision 6052)
+++ 	(revision )
@@ -1,37 +1,0 @@
-//caps.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CAPS_H_
-#define _CAPS_H_
-
-#include <roaraudio.h>
-
-extern struct roar_stds g_caps_stds;
-
-char * stds_string (void);
-
-#endif
-
-//ll
Index: roard/include/client.h
===================================================================
--- roard/include/client.h	(revision 6052)
+++ roard/include/client.h	(revision 0)
@@ -1,26 +1,3 @@
 //client.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _CLIENT_H_
@@ -47,115 +24,30 @@
 */
 
-// access level:
-enum roard_client_acclev {
- ACCLEV_ERROR    = -1, // used as erorr return value.
- ACCLEV_NONE     =  0, // only very basic commands like NOOP and IDENTIFY
- ACCLEV_IDENTED,       // same as NONE but INDENTIFY worked.
- ACCLEV_CONCTL,        // only allowed to do basic connection things.
- ACCLEV_GUEST,         // guest connection (read only)
- ACCLEV_USER,          // normal user connect (read write)
- ACCLEV_PWRUSER,       // power user, may access other user's clients
- ACCLEV_ALL            // full (admin) access (read write ctl)
-};
+struct roar_client * g_clients[ROAR_CLIENTS_MAX];
 
-struct roar_client_nsubscribe {
- struct roar_subscriber * sub;
-};
-
-extern struct roar_client_server {
- struct roar_client _client;
- size_t blockc;
- struct roar_subscriber ** waits;
- enum roard_client_acclev acclev;
- // may be used by protocols working directly on big data blocks to buffer a bit:
- struct roar_buffer * inbuf, * outbuf;
- void * protoinst;
-} * g_clients[ROAR_CLIENTS_MAX];
-
-struct roard_listen;
-
-struct roard_proto {
- int proto;
- int subsystems;
- const char * description;
- struct roar_dl_lhandle * lhandle;
- int (*new_client)(int client, struct roar_vio_calls * vio, struct roard_listen * lsock);
- int (*delete_client)(int client);
- int (*check_client)(int client, struct roar_vio_calls * vio);
- int (*flush_client)(int client, struct roar_vio_calls * vio);
- int (*flushed_client)(int client, struct roar_vio_calls * vio);
-};
-
-enum roard_proto_type {
- ROARD_PROTO_TYPE_BUILDIN = 0,
-// ROARD_PROTO_TYPE_ROARDPROTO = 1, // old. Removed in 1.0beta6.
- ROARD_PROTO_TYPE_COMMON = 2
-};
-
-struct roard_proto_handle {
- int proto;
- struct roar_dl_lhandle * lhandle;
- enum roard_proto_type type;
- const struct roar_keyval * para;
- ssize_t paralen;
- union {
-  int buildin; // dummy
-  const struct roar_dl_proto * common;
- } impl;
-};
-
-#define MAX_PROTOS 16
 
 // basic functions
-int clients_init       (void);
-int clients_free       (void);
-int clients_new        (void);
-int clients_new_from_fh(int fh, int proto, int byteorder, int update_nnode);
-int clients_new_from_fh2(int fh, int proto, int byteorder,
-                         int update_nnode,
-                         struct roard_listen * lsock, struct sockaddr * sockaddr, socklen_t addrlen);
-int clients_delete     (int id);
-int clients_close      (int id, int nocheck_exec);
-int clients_set_fh     (int id, int    fh);
-int clients_set_pid    (int id, int    pid);
-int clients_set_uid    (int id, int    uid);
-int clients_set_gid    (int id, int    gid);
-int clients_set_name   (int id, const char * name);
-int clients_set_proto  (int id, int    proto);
-int clients_get        (int id, struct roar_client ** client);
-int clients_get_server (int id, struct roar_client_server ** client);
-int clients_get_fh     (int id);
 
-int clients_block      (int id, int unblock);
+int clients_init      (void);
+int clients_free      (void);
+int clients_new       (void);
+int clients_delete    (int id);
+int clients_set_fh    (int id, int    fh);
+int clients_set_pid   (int id, int    pid);
+int clients_set_name  (int id, char * name);
+int clients_get       (int id, struct roar_client ** client);
 
 // network functions
 int clients_check_all  (void);
 int clients_check      (int id);
-int clients_flush      (int id);
-int clients_send_mon   (struct roar_audio_info * sa);
-int clients_send_filter(struct roar_audio_info * sa);
-
-int clients_add_output (int id, struct roar_buffer ** buf);
-
-// proto support
-const struct roard_proto_handle * clients_get_protohandle(const int proto);
-int clients_register_proto_common(const struct roar_dl_proto * proto, struct roar_dl_lhandle * lhandle);
-int clients_unregister_proto(int proto);
-void print_protolist        (enum output_format format);
+int clients_send_mon   (struct roar_audio_info * sa, uint32_t pos);
+int clients_send_filter(struct roar_audio_info * sa, uint32_t pos);
 
 // stream functions
+
+
 int client_stream_exec   (int client, int stream);
-int client_stream_set_fh (int client, int stream, int fh);
 int client_stream_add    (int client, int stream);
 int client_stream_delete (int client, int stream);
-int client_stream_move   (int client, int stream);
-
-// notify thingys
-int  clients_wait    (int client, struct roar_event * events, size_t num);
-void clients_ncb_wait(struct roar_notify_core * core, struct roar_event * event, void * userdata);
-
-// acclev:
-enum roard_client_acclev clients_str2acclev(const char * acclev);
-const char * clients_acclev2str(const enum roard_client_acclev acclev);
 
 #endif
Index: roard/include/codecfilter.h
===================================================================
--- roard/include/codecfilter.h	(revision 6052)
+++ 	(revision )
@@ -1,166 +1,0 @@
-//codecfilter.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_H_
-#define _CODECFILTER_H_
-
-#include <roaraudio.h>
-
-#define CODECFILTER_USERDATA_T void *
-
-struct roar_stream_server;
-
-#define ROAR_CODECFILTER_NONE        0x00
-#define ROAR_CODECFILTER_READ        0x01
-#define ROAR_CODECFILTER_WRITE       0x02
-#define ROAR_CODECFILTER_PRETHRU     0x04 /* we have support for prethru */
-#define ROAR_CODECFILTER_PRETHRU_NN  0x08 /* prethru Not Needed          */
-
-
-#define ROAR_CODECFILTER_CTL_NOOP            ROAR_STREAM_CTL_COMP_CF|0x0000 /* noop... */
-#define ROAR_CODECFILTER_CTL_BASE            ROAR_STREAM_CTL_COMP_CF|0x0000 /* Base ops... */
-#define ROAR_CODECFILTER_CTL_META            ROAR_STREAM_CTL_COMP_CF|0x1000 /* Meta data things... */
-#define ROAR_CODECFILTER_CTL_VIRTUAL         ROAR_STREAM_CTL_COMP_CF|0x2000 /* container/virtual stream things... */
-
-#define ROAR_CODECFILTER_CTL_SET             0x0002
-#define ROAR_CODECFILTER_CTL_GET             0x0003
-
-#define ROAR_CODECFILTER_CTL_UPDATE          0x0001
-#define ROAR_CODECFILTER_CTL_DELETE          0x0004
-#define ROAR_CODECFILTER_CTL_NEW             0x0005
-
-#define ROAR_CODECFILTER_CTL_Q               0x0010
-#define ROAR_CODECFILTER_CTL_SET_Q           ROAR_CODECFILTER_CTL_BASE|ROAR_CODECFILTER_CTL_Q|ROAR_CODECFILTER_CTL_SET
-#define ROAR_CODECFILTER_CTL_GET_Q           ROAR_CODECFILTER_CTL_BASE|ROAR_CODECFILTER_CTL_Q|ROAR_CODECFILTER_CTL_GET
-
-#define ROAR_CODECFILTER_CTL_META_UPDATE     ROAR_CODECFILTER_CTL_META|ROAR_CODECFILTER_CTL_UPDATE
-
-#define ROAR_CODECFILTER_CTL_VIRTUAL_DELETE  ROAR_CODECFILTER_CTL_VIRTUAL|ROAR_CODECFILTER_CTL_DELETE
-#define ROAR_CODECFILTER_CTL_VIRTUAL_NEW     ROAR_CODECFILTER_CTL_VIRTUAL|ROAR_CODECFILTER_CTL_NEW
-
-
-#define ROAR_CODECFILTER_CTL2CMD(x)          ((x) & (~ROAR_STREAM_CTL_COMP_CF))
-
-struct roar_codecfilter {
- int    codec;
- char * name;
- char * desc;
- char * options;
- void * setup;
- int    flags;
- unsigned int subsystems;
- int (*open )(CODECFILTER_USERDATA_T * inst, int codec,
-                                             struct roar_stream_server * info,
-                                             struct roar_codecfilter   * filter);
- int (*close)(CODECFILTER_USERDATA_T   inst);
- int (*pause)(CODECFILTER_USERDATA_T   inst, int newstate);
- int (*write)(CODECFILTER_USERDATA_T   inst, char * buf, int len);
- int (*read )(CODECFILTER_USERDATA_T   inst, char * buf, int len);
- int (*flush)(CODECFILTER_USERDATA_T   inst);
- int (*delay)(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
- int (*ctl  )(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-};
-
-
-#include "codecfilter_cmd.h"
-#include "codecfilter_wave.h"
-#include "codecfilter_au.h"
-
-
-#ifdef ROAR_HAVE_LIBVORBISFILE
-#include "codecfilter_vorbis.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBCELT
-#include "codecfilter_celt.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBSPEEX
-#include "codecfilter_speex.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBSNDFILE
-#include "codecfilter_sndfile.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBFISHSOUND
-#include "codecfilter_fishsound.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBFLAC
-#include "codecfilter_flac.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBUNIRAUM
-#include "codecfilter_uniraum.h"
-#endif
-
-#include "container_framework.h"
-
-//cf alaw/mulaw:
-#include <libroardsp/libroardsp.h>
-
-void print_codecfilterlist (void);
-
-int codecfilter_open (CODECFILTER_USERDATA_T * inst,
-                 int * codecfilter_id, char * codecfilter /* NOTE: this is not part of struct roar_codecfilter's def! */,
-                 int codec, struct roar_stream_server * info);
-int codecfilter_close(CODECFILTER_USERDATA_T   inst, int codecfilter);
-int codecfilter_pause(CODECFILTER_USERDATA_T   inst, int codecfilter, int newstate);
-int codecfilter_write(CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len);
-int codecfilter_read (CODECFILTER_USERDATA_T   inst, int codecfilter, char * buf, int len);
-int codecfilter_flush(CODECFILTER_USERDATA_T   inst, int codecfilter);
-int codecfilter_delay(CODECFILTER_USERDATA_T   inst, int codecfilter, uint_least32_t * delay);
-int codecfilter_ctl  (CODECFILTER_USERDATA_T   inst, int codecfilter, int_least32_t cmd, void * data);
-
-int codecfilter_delay_fulldyn(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-int codecfilter_delay_zero(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-
-
-// codecfilter without a own .h:
-int cf_alaw_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_alaw_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_alaw_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_alaw_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_mulaw_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_mulaw_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_mulaw_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_mulaw_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-// cf_mulaw_delay() would be exactly the same as cf_alaw_delay() so it is just used by mulaw, too.
-
-CONT_FW_SETUP_TYPE(cf_raum_setup);
-
-#endif
-
-//ll
Index: roard/include/codecfilter_au.h
===================================================================
--- roard/include/codecfilter_au.h	(revision 6052)
+++ 	(revision )
@@ -1,69 +1,0 @@
-//codecfilter_au.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_AU_H_
-#define _CODECFILTER_AU_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_CF_AU
-
-#define ROAR_AU_MIN_HEADER_LEN        (6*4)
-#define ROAR_AU_MAGIC                 0x2e736e64
-
-#define ROAR_AU_DATASIZE              0xffffffff
-
-// most important codec IDs:
-#define ROAR_AU_CID_MULAW             0x00000001
-#define ROAR_AU_CID_PCM_S_8           0x00000002
-#define ROAR_AU_CID_PCM_S_16          0x00000003
-#define ROAR_AU_CID_PCM_S_24          0x00000004
-#define ROAR_AU_CID_PCM_S_32          0x00000005
-#define ROAR_AU_CID_ALAW              0x00000033
-
-
-struct codecfilter_au_inst {
- struct roar_stream_server *  stream;
- struct roar_stream_server * vstream;
- int opened;
-};
-
-
-int cf_au_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_au_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_au_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_au_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_au_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/codecfilter_celt.h
===================================================================
--- roard/include/codecfilter_celt.h	(revision 6052)
+++ 	(revision )
@@ -1,70 +1,0 @@
-//codecfilter_celt.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_CELT_H_
-#define _CODECFILTER_CELT_H_
-
-#include <roaraudio.h>
-
-#ifdef ROAR_HAVE_LIBCELT
-
-#include <celt/celt.h>
-#include <celt/celt_header.h>
-
-struct codecfilter_celt_inst {
- struct roar_stream_server * stream;
- CELTMode * mode;
- CELTEncoder * encoder;
- CELTDecoder * decoder;
- int frame_size;
- int lookahead;
- int out_size;
- char * ibuf;
- char * obuf;
- char * i_rest;
- char * o_rest;
- int s_buf;
- int fi_rest; /* how much is in rest? */
- int fo_rest; /* how much is in rest? */
- int opened_encoder;
- int opened_decoder;
-};
-
-int cf_celt_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_celt_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_celt_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_celt_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_celt_delay(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/codecfilter_cmd.h
===================================================================
--- roard/include/codecfilter_cmd.h	(revision 6052)
+++ 	(revision )
@@ -1,37 +1,0 @@
-//codecfilter_cmd.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_CMD_H_
-#define _CODECFILTER_CMD_H_
-
-#include <roaraudio.h>
-
-int cf_cmd_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                             struct roar_stream_server * info,
-                                             struct roar_codecfilter   * filter);
-
-#endif
-
-//ll
Index: roard/include/codecfilter_fishsound.h
===================================================================
--- roard/include/codecfilter_fishsound.h	(revision 6052)
+++ 	(revision )
@@ -1,55 +1,0 @@
-//codecfilter_fishsound.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_FISHSOUND_H_
-#define _CODECFILTER_FISHSOUND_H_
-
-#include <roaraudio.h>
-
-#include <oggz/oggz.h>
-#include <fishsound/fishsound.h>
-
-
-struct codecfilter_fishsound_inst {
- struct roar_stream_server * stream;
- int opened;
- FishSoundInfo fsinfo;
- FishSound * fsound;
- OGGZ * oggz;
- struct roar_buffer * buffer;
-};
-
-
-int cf_fishsound_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_fishsound_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_fishsound_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-#endif
-
-//ll
Index: roard/include/codecfilter_flac.h
===================================================================
--- roard/include/codecfilter_flac.h	(revision 6052)
+++ 	(revision )
@@ -1,65 +1,0 @@
-//codecfilter_flac.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_FLAC_H_
-#define _CODECFILTER_FLAC_H_
-
-#include <roaraudio.h>
-
-#if defined(ROAR_HAVE_LIBFLAC)
-
-#include <FLAC/all.h>
-
-struct codecfilter_flac_inst {
- struct roar_stream_server * ss;
- struct {
-  FLAC__StreamDecoder * decoder;
-  struct roar_buffer * written;
-  ssize_t readret;
-  size_t readc;
- } decoder;
-};
-
-FLAC__StreamDecoderReadStatus cf_flac_cb_read(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
-FLAC__StreamDecoderWriteStatus cf_flac_cb_write(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-void cf_flac_cb_metadata(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-void cf_flac_cb_error(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-
-int cf_flac_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_flac_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_flac_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_flac_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_flac_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/codecfilter_sndfile.h
===================================================================
--- roard/include/codecfilter_sndfile.h	(revision 6052)
+++ 	(revision )
@@ -1,57 +1,0 @@
-//codecfilter_sndfile.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_SNDFILE_H_
-#define _CODECFILTER_SNDFILE_H_
-
-#include <roaraudio.h>
-
-#ifdef ROAR_HAVE_LIBSNDFILE
-
-#include <sndfile.h>
-
-struct codecfilter_sndfile_inst {
- struct roar_stream_server * stream;
- int opened;
- int bytes;
- SNDFILE * state;
- SF_INFO   info;
-};
-
-
-int cf_sndfile_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_sndfile_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_sndfile_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_sndfile_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/codecfilter_speex.h
===================================================================
--- roard/include/codecfilter_speex.h	(revision 6052)
+++ 	(revision )
@@ -1,72 +1,0 @@
-//codecfilter_speex.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_SPEEX_H_
-#define _CODECFILTER_SPEEX_H_
-
-#include <roaraudio.h>
-#include <speex/speex.h>
-#include <speex/speex_stereo.h>
-#include <speex/speex_callbacks.h>
-
-struct codecfilter_speex_inst {
- void * encoder;
- void * decoder;
- SpeexBits bits;
- SpeexStereoState stereo_state;
- SpeexCallback    stereo_callback;
- int              stereo;
- struct roar_stream_server * stream;
- int frame_size;
- void     * cd; /* current data */
- char       cc[ROAR_SPEEX_MAX_CC]; /* buffer for read() and write() */
- void     * i_rest; /* rest... */
- int fi_rest;
- char * o_rest;
- int fo_rest; /* how much is in rest? */
-
-/*
- char * ibuf;
- char * obuf;
- int out_size;
- char * i_rest;
- int s_buf;
- int fi_rest; /-* how much is in rest? *-/
-*/
- struct roar_libroar_config_codec * codec_config;
-};
-
-int cf_speex_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_speex_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_speex_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_speex_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-#endif
-
-//ll
Index: roard/include/codecfilter_uniraum.h
===================================================================
--- roard/include/codecfilter_uniraum.h	(revision 6052)
+++ 	(revision )
@@ -1,47 +1,0 @@
-//codecfilter_uniraum.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_UNIRAUM_H_
-#define _CODECFILTER_UNIRAUM_H_
-
-#include <roaraudio.h>
-
-#ifdef ROAR_HAVE_LIBUNIRAUM
-
-int cf_uniraum_open (CODECFILTER_USERDATA_T * inst, int codec,
-                     struct roar_stream_server * info,
-                     struct roar_codecfilter   * filter);
-int cf_uniraum_close(CODECFILTER_USERDATA_T   inst);
-//int cf_uniraum_pause(CODECFILTER_USERDATA_T   inst, int newstate);
-int cf_uniraum_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_uniraum_read (CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_uniraum_flush(CODECFILTER_USERDATA_T   inst);
-//int cf_uniraum_delay(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-int cf_uniraum_ctl  (CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-#endif
-
-//ll
Index: roard/include/codecfilter_vorbis.h
===================================================================
--- roard/include/codecfilter_vorbis.h	(revision 6052)
+++ 	(revision )
@@ -1,88 +1,0 @@
-//codecfilter_vorbis.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_VORBIS_H_
-#define _CODECFILTER_VORBIS_H_
-
-#include <roaraudio.h>
-
-#if defined(ROAR_HAVE_LIBVORBISFILE) && defined(ROAR_REQUIRE_LIBVORBISFILE)
-
-#include <vorbis/codec.h>
-#include <vorbis/vorbisfile.h>
-#include <math.h>
-
-#ifdef ROAR_HAVE_LIBVORBISENC
-#include <vorbis/vorbisenc.h>
-#endif
-
-struct codecfilter_vorbis_inst {
- int current_section;
- int last_section;
- int opened;
- struct roar_stream_server * stream;
- OggVorbis_File vf;
- int got_it_running;
- int bigendianp;
-#ifdef ROAR_HAVE_LIBVORBISENC
- int encoding;
- struct {
-  int srn;
-  float v_base_quality;
-  ogg_stream_state os;
-  ogg_page         og;
-  ogg_packet       op;
-
-  vorbis_dsp_state vd;
-  vorbis_block     vb;
-  vorbis_info      vi;
-  vorbis_comment   vc;
- } encoder;
-#endif
-};
-
-size_t cf_vorbis_vfvio_read (void *ptr, size_t size, size_t nmemb, void *datasource);
-
-int cf_vorbis_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_vorbis_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_vorbis_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_vorbis_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_vorbis_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-int cf_vorbis_update_stream  (struct codecfilter_vorbis_inst * self);
-int cf_vorbis_encode_start   (struct codecfilter_vorbis_inst * self);
-int cf_vorbis_encode_end     (struct codecfilter_vorbis_inst * self);
-int cf_vorbis_encode_flushout(struct codecfilter_vorbis_inst * self);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/codecfilter_wave.h
===================================================================
--- roard/include/codecfilter_wave.h	(revision 6052)
+++ 	(revision )
@@ -1,73 +1,0 @@
-//codecfilter_wave.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CODECFILTER_WAVE_H_
-#define _CODECFILTER_WAVE_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_CF_WAVE
-
-// most important codec IDs:
-#define ROAR_RIFF_WAVE_CID_PCM        0x0001
-#define ROAR_RIFF_WAVE_CID_IEEE_FLOAT 0x0003
-#define ROAR_RIFF_WAVE_CID_ALAW       0x0006
-#define ROAR_RIFF_WAVE_CID_MULAW      0x0007
-
-// Invalid but used by RSound:
-#define ROAR_RIFF_WAVE_CID_RSOUND     0x0000
-
-// Type is encoded in length by RSound using the following values:
-#define ROAR_RIFF_WAVE_RSID_S16_LE    0x0001
-#define ROAR_RIFF_WAVE_RSID_S16_BE    0x0002
-#define ROAR_RIFF_WAVE_RSID_U16_LE    0x0004
-#define ROAR_RIFF_WAVE_RSID_U16_BE    0x0008
-#define ROAR_RIFF_WAVE_RSID_U8        0x0010
-#define ROAR_RIFF_WAVE_RSID_S8        0x0020
-
-
-struct codecfilter_wave_inst {
- struct roar_stream_server *  stream;
- struct roar_stream_server * vstream;
- int opened;
-};
-
-
-int cf_wave_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                            struct roar_stream_server * info,
-                                            struct roar_codecfilter   * filter);
-
-int cf_wave_close(CODECFILTER_USERDATA_T   inst);
-
-int cf_wave_read(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cf_wave_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-
-int cf_wave_ctl(CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/commands.h
===================================================================
--- roard/include/commands.h	(revision 6052)
+++ roard/include/commands.h	(revision 0)
@@ -1,26 +1,3 @@
 //commands.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- nd_exec*
- */
 
 #ifndef _COMMANDS_H_
@@ -30,26 +7,15 @@
 
 #define COMMAND_MAX_NAMELEN  80
-#define COMMAND_MAX_COMMANDS 48
-
-#define COMMAND_FLAG_NONE          0x00000000
-#define COMMAND_FLAG_OUT_CLOSECON  0x00000001
-#define COMMAND_FLAG_OUT_LONGDATA  0x00000002
-#define COMMAND_FLAG_OUT_NOSEND    0x00000004
-#define COMMAND_FLAG_OUT_DELETE    0x00000008 /* delete the client */
+#define COMMAND_MAX_COMMANDS 32
 
 struct roar_command {
  int cmd;
-#if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_MINIMAL)
- const char name[COMMAND_MAX_NAMELEN];
-#else
- const char * name;
-#endif
- int (*handler)(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
- enum roard_client_acclev minacclev;
+ char name[COMMAND_MAX_NAMELEN];
+ int (*handler)(int client, struct roar_message * mes, char * data);
 };
 
 int command_get_id_by_cmd (int command);
-int command_exec (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int command_get_name (int command, const char ** name);
+int command_exec (int client, struct roar_message * mes, char * data);
+int command_get_name (int command, char ** name);
 
 #endif
Index: roard/include/container_framework.h
===================================================================
--- roard/include/container_framework.h	(revision 6052)
+++ 	(revision )
@@ -1,112 +1,0 @@
-//container_framework.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _CONTAINER_FRAMEWORK_H_
-#define _CONTAINER_FRAMEWORK_H_
-
-#include <roaraudio.h>
-
-#define CONT_FW_MAX_CHILDS 8
-
-#define CONT_FW_SETUP_TYPE(f) int (f)(struct cont_fw_parent_inst * self, int codec, struct roar_codecfilter    * filter)
-
-struct cont_fw_parent_inst;
-
-struct cont_fw_child_vio_inst {
- int child;
- void * u_inst;
- struct cont_fw_parent_inst * parent;
-};
-
-struct cont_fw_parent_inst {
- struct cont_fw_child_vio_inst * child[CONT_FW_MAX_CHILDS];
- void * u_inst;
- int state;
- struct roar_vio_calls vio;
- struct {
-  int id;
-  int codec;
-  struct roar_stream_server  * stream;
-  struct roar_codecfilter    * filter;
- } stream;
- struct {
-  ssize_t (*read) (struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len);
-  ssize_t (*write)(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len);
-  int     (*flush)(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child);
-  int     (*close)(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child);
- } ccb;
- struct {
-  int     (*open     )(struct cont_fw_parent_inst * self,
-                       int                          codec,
-                       struct roar_stream_server  * stream,
-                       struct roar_codecfilter    * filter);
-  int     (*close    )(struct cont_fw_parent_inst * self);
-  int     (*flush    )(struct cont_fw_parent_inst * self);
-  int     (*new_child)(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child);
- } pcb;
-};
-
-// Parent:
-int     cont_fw_new      (struct cont_fw_parent_inst ** inst);
-int     cont_fw_delete   (struct cont_fw_parent_inst  * inst);
-int     cont_fw_set_uinst(struct cont_fw_parent_inst  * inst, void  * u_inst);
-int     cont_fw_get_uinst(struct cont_fw_parent_inst  * inst, void ** u_inst);
-
-// Child:
-int     cont_fw_new_child(struct cont_fw_parent_inst  * inst, int id);
-int     cont_fw_init_vio(struct roar_vio_calls * vio, void * inst);
-
-// VIO Childs:
-ssize_t cont_fw_read    (struct roar_vio_calls * vio, void *buf, size_t count);
-ssize_t cont_fw_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-roar_off_t   cont_fw_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence);
-int     cont_fw_sync    (struct roar_vio_calls * vio);
-int     cont_fw_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-int     cont_fw_close   (struct roar_vio_calls * vio);
-
-// VIO Parent:
-int     cont_pvio_open    (struct roar_vio_calls * vio, void * inst);
-ssize_t cont_pvio_read    (struct roar_vio_calls * vio, void *buf, size_t count);
-ssize_t cont_pvio_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-roar_off_t   cont_pvio_lseek   (struct roar_vio_calls * vio, roar_off_t offset, int whence);
-int     cont_pvio_sync    (struct roar_vio_calls * vio);
-int     cont_pvio_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-int     cont_pvio_close   (struct roar_vio_calls * vio);
-
-// CF:
-int cont_fw_cf_open(CODECFILTER_USERDATA_T * inst, int codec,
-                                             struct roar_stream_server * info,
-                                             struct roar_codecfilter   * filter);
-int cont_fw_cf_close(CODECFILTER_USERDATA_T   inst);
-int cont_fw_cf_pause(CODECFILTER_USERDATA_T   inst, int newstate);
-int cont_fw_cf_write(CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cont_fw_cf_read (CODECFILTER_USERDATA_T   inst, char * buf, int len);
-int cont_fw_cf_flush(CODECFILTER_USERDATA_T   inst);
-int cont_fw_cf_delay(CODECFILTER_USERDATA_T   inst, uint_least32_t * delay);
-int cont_fw_cf_ctl  (CODECFILTER_USERDATA_T   inst, int cmd, void * data);
-
-#endif
-
-//ll
Index: roard/include/driver.h
===================================================================
--- roard/include/driver.h	(revision 6052)
+++ roard/include/driver.h	(revision 0)
@@ -1,26 +1,3 @@
 //driver.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _DRIVER_H_
@@ -32,4 +9,10 @@
 
 #ifdef ROAR_HAVE_ESD
+#define ROAR_DRIVER_DEFAULT "esd"
+#else
+#define ROAR_DRIVER_DEFAULT "null"
+#endif
+
+#ifdef ROAR_HAVE_ESD
 #include <esd.h>
 #include "driver_esd.h"
@@ -37,12 +20,4 @@
 
 #include "driver_roar.h"
-#include "driver_dstr.h"
-#include "driver_dmx.h"
-#include "driver_pwmled.h"
-
-#if defined(ROAR_HAVE_GETTIMEOFDAY) && defined(ROAR_HAVE_USLEEP)
-#define ROAR_HAVE_DRIVER_SYSCLOCK
-#include "driver_sysclock.h"
-#endif
 
 #ifdef ROAR_HAVE_LIBAO
@@ -51,118 +26,26 @@
 #endif
 
-#ifdef ROAR_HAVE_LIBSHOUT
-#include <shout/shout.h>
-#include "driver_shout.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBSNDIO
-#include <sndio.h>
-#include "driver_sndio.h"
-#endif
-
-#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS)
-#if defined(__OpenBSD__) || defined(__NetBSD__)
-#include <soundcard.h>
-#else
-#include <sys/soundcard.h>
-#endif
-#include <sys/ioctl.h>
-
-#include "driver_oss.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBRSOUND
-#ifdef _DRV_NEED_RSOUND_H
-#include <rsound.h>
-#endif
-#include "driver_rsound.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBPORTAUDIO
-#include <portaudio.h>
-#ifdef ROAR_HAVE_LIBPABLIO
-#include <pablio/pablio.h>
-#endif
-#include "driver_portaudio.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBASOUND
-#include <alsa/asoundlib.h>
-#include "driver_alsa.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBWINMM
-#include <windows.h>
-#include <mmsystem.h>
-#include "driver_wmm.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBPULSE
-#include <pulse/simple.h>
-#include <pulse/error.h>
-#include "driver_pulsesimple.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBJACK
-#include <jack/jack.h>
-#include <jack/transport.h>
-#include "driver_jack.h"
-#endif
-
-#ifdef ROAR_HAVE_LIBARTSC
-#include <kde/artsc/artsc.h>
-#include "driver_artsc.h"
-#endif
-
-#if !defined(ROAR_WITHOUT_VIO_DSTR) && !defined(ROAR_WITHOUT_DCOMP_DMX) && defined(ROAR_HAVE_H_LINUX_I2C) && defined(ROAR_HAVE_H_LINUX_I2C_DEV) && defined(ROAR_HAVE_CONST_I2C_SMBUS_I2C_BLOCK_BROKEN)
-#define ROAR_HAVE_DRIVER_I2CDMX
-int driver_i2cdmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-#endif
-
-#define DRV_FLAG_NONE           0x00
-#define DRV_FLAG_FHSEC          0x01
-
-#define ROAR_DRIVER_CTL_NOOP            ROAR_STREAM_CTL_COMP_DRV|0x0000 /* noop... */
-#define ROAR_DRIVER_CTL_BASE            ROAR_STREAM_CTL_COMP_DRV|0x0000 /* Base ops... */
-
-#define ROAR_DRIVER_CTL_SET             0x0002
-#define ROAR_DRIVER_CTL_GET             0x0003
-
-#define ROAR_DRIVER_CTL_RECORD          0x0010
-#define ROAR_DRIVER_CTL_SET_RECORD      ROAR_DRIVER_CTL_BASE|ROAR_DRIVER_CTL_RECORD|ROAR_DRIVER_CTL_SET
-
-
-#define ROAR_DRIVER_CTL2CMD(x)          ((x) & (~ROAR_STREAM_CTL_COMP_DRV))
-
-
-
 struct roar_driver {
  char * name;
  char * desc;
  char * devices;
- unsigned int mode;
- unsigned int flags;
- unsigned int subsystems;
  int (*open )(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info);
  int (*close)(DRIVER_USERDATA_T   inst);
- int (*vio_init)(struct roar_vio_calls * calls, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
+ int (*pause)(DRIVER_USERDATA_T   inst, int newstate);
+ int (*write)(DRIVER_USERDATA_T   inst, char * buf, int len);
+ int (*read )(DRIVER_USERDATA_T   inst, char * buf, int len);
+ int (*flush)(DRIVER_USERDATA_T   inst);
 };
 
-void print_driverlist (enum output_format format);
+void print_driverlist (void);
 
-int driver_openvio(struct roar_vio_calls * calls,
+int driver_open (DRIVER_USERDATA_T * inst,
                  int * driver_id, char * driver /* NOTE: this is not part of struct roar_driver's def! */,
-                 char * device, struct roar_audio_info * info, int fh,
-                 struct roar_stream_server * sstream);
-
-int driver_closevio(struct roar_vio_calls * calls, int driver);
-int driver_set_volume(int stream, struct roar_mixer_settings * mixer);
-
-// opening a cdriver
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
-int driver_cdriver_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-#endif
-
-int  driver_dummy_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
+                 char * device, struct roar_audio_info * info);
+int driver_close(DRIVER_USERDATA_T   inst, int driver);
+int driver_pause(DRIVER_USERDATA_T   inst, int driver, int newstate);
+int driver_write(DRIVER_USERDATA_T   inst, int driver, char * buf, int len);
+int driver_read (DRIVER_USERDATA_T   inst, int driver, char * buf, int len);
+int driver_flush(DRIVER_USERDATA_T   inst, int driver);
 
 #endif
Index: roard/include/driver_alsa.h
===================================================================
--- roard/include/driver_alsa.h	(revision 6052)
+++ 	(revision )
@@ -1,47 +1,0 @@
-//driver_alsa.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *      Copyright (C) Hans-Kristian 'maister' Arntzen - 2010
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_ALSA_H_
-#define _DRIVER_ALSA_H_
-
-typedef struct roar_alsa {
- snd_pcm_t * handle;
- snd_pcm_hw_params_t * params;
- snd_pcm_format_t format;
- struct roar_audio_info info;
- struct roar_stream_server * sstream;
- int ssid;
-} roar_alsa_t;
-
-int     driver_alsa_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_alsa_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_alsa_close   (struct roar_vio_calls * vio);
-int     driver_alsa_sync    (struct roar_vio_calls * vio);
-int     driver_alsa_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-#endif
-
-//ll
Index: roard/include/driver_ao.h
===================================================================
--- roard/include/driver_ao.h	(revision 6052)
+++ roard/include/driver_ao.h	(revision 0)
@@ -1,33 +1,13 @@
 //driver_ao.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _DRIVER_AO_H_
 #define _DRIVER_AO_H_
 
-int driver_ao_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_ao_write(struct roar_vio_calls * vio, void *buf, size_t count);
-int driver_ao_close(struct roar_vio_calls * vio);
+int driver_ao_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info);
+int driver_ao_close(DRIVER_USERDATA_T   inst);
+int driver_ao_pause(DRIVER_USERDATA_T   inst, int newstate);
+int driver_ao_write(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_ao_read(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_ao_flush(DRIVER_USERDATA_T   inst);
 
 #endif
Index: roard/include/driver_artsc.h
===================================================================
--- roard/include/driver_artsc.h	(revision 6052)
+++ 	(revision )
@@ -1,41 +1,0 @@
-//driver_artsc.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_ARTSC_H_
-#define _DRIVER_ARTSC_H_
-
-struct roar_artsc {
- arts_stream_t stream;
- struct roar_audio_info * info;
-};
-
-int     driver_artsc_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_artsc_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_artsc_close   (struct roar_vio_calls * vio);
-int     driver_artsc_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-#endif
-
-//ll
Index: roard/include/driver_dmx.h
===================================================================
--- roard/include/driver_dmx.h	(revision 6052)
+++ 	(revision )
@@ -1,43 +1,0 @@
-//driver_dmx.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_DMX_H_
-#define _DRIVER_DMX_H_
-
-#if defined(ROAR_WITHOUT_DCOMP_LIGHT) && !defined(ROAR_WITHOUT_DCOMP_DMX)
-#define ROAR_WITHOUT_DCOMP_DMX
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_DMX
-
-int driver_dmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count);
-int     driver_dmx_ctl   (struct roar_vio_calls * vio,  roar_vio_ctl_t cmd, void * data);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/driver_dstr.h
===================================================================
--- roard/include/driver_dstr.h	(revision 6052)
+++ 	(revision )
@@ -1,33 +1,0 @@
-//driver_dstr.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_DSTR_H_
-#define _DRIVER_DSTR_H_
-
-int driver_dstr_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-
-#endif
-
-//ll
Index: roard/include/driver_esd.h
===================================================================
--- roard/include/driver_esd.h	(revision 6052)
+++ roard/include/driver_esd.h	(revision 0)
@@ -1,31 +1,13 @@
 //driver_esd.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _DRIVER_ESD_H_
 #define _DRIVER_ESD_H_
 
-int driver_esd_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
+int driver_esd_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info);
+int driver_esd_close(DRIVER_USERDATA_T   inst);
+int driver_esd_pause(DRIVER_USERDATA_T   inst, int newstate);
+int driver_esd_write(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_esd_read(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_esd_flush(DRIVER_USERDATA_T   inst);
 
 #endif
Index: roard/include/driver_jack.h
===================================================================
--- roard/include/driver_jack.h	(revision 6052)
+++ 	(revision )
@@ -1,46 +1,0 @@
-//driver_jack.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_JACK_H_
-#define _DRIVER_JACK_H_
-
-struct driver_jack {
- jack_client_t * client;
- unsigned int channels;
- jack_port_t  ** ports_in;
- jack_port_t  ** ports_out;
-};
-
-int driver_jack_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-
-ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count);
-ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_jack_sync    (struct roar_vio_calls * vio);
-int     driver_jack_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-int     driver_jack_close   (struct roar_vio_calls * vio);
-
-#endif
-
-//ll
Index: roard/include/driver_oss.h
===================================================================
--- roard/include/driver_oss.h	(revision 6052)
+++ 	(revision )
@@ -1,53 +1,0 @@
-//driver_oss.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_OSS_H_
-#define _DRIVER_OSS_H_
-
-struct driver_oss {
- char * device;
- int fh;
- int blocks;
- int blocksize;
- struct roar_audio_info info;
- int need_config;
- struct roar_stream_server * stream;
- int ssid;
- int fh_savemode;
-};
-
-int driver_oss_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int driver_oss_close(DRIVER_USERDATA_T   inst);
-int driver_oss_sync(struct roar_vio_calls * vio);
-int driver_oss_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-ssize_t driver_oss_write    (struct roar_vio_calls * vio, void *buf, size_t count);
-ssize_t driver_oss_read     (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_oss_close_vio(struct roar_vio_calls * vio);
-int     driver_oss_reopen_device(struct driver_oss * self);
-
-#endif
-
-//ll
Index: roard/include/driver_portaudio.h
===================================================================
--- roard/include/driver_portaudio.h	(revision 6052)
+++ 	(revision )
@@ -1,56 +1,0 @@
-//driver_portaudio.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_PORTAUDIO_H_
-#define _DRIVER_PORTAUDIO_H_
-
-#ifdef ROAR_HAVE_LIBPORTAUDIO
-#if defined(ROAR_HAVE_LIBPABLIO) || defined(ROAR_HAVE_PA19_VERSION_19)
-#define _DRIVER_PORTAUDIO_CAN_OPERATE
-#endif
-#endif
-
-#ifdef _DRIVER_PORTAUDIO_CAN_OPERATE
-
-struct driver_portaudio {
-#ifdef ROAR_HAVE_LIBPABLIO
- PABLIO_Stream * ostream;
-#elif defined(ROAR_HAVE_PA19_VERSION_19)
- PaStream *stream;
- int framesize;
-#endif
-};
-
-int driver_portaudio_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-
-int     driver_portaudio_close        (struct roar_vio_calls * vio);
-ssize_t driver_portaudio_write        (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_portaudio_sync         (struct roar_vio_calls * vio);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/driver_pulsesimple.h
===================================================================
--- roard/include/driver_pulsesimple.h	(revision 6052)
+++ 	(revision )
@@ -1,48 +1,0 @@
-//driver_pulsesimple.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_PULSESIMPLE_H_
-#define _DRIVER_PULSESIMPLE_H_
-
-struct driver_pulsesimple {
- pa_simple * handle;
-/*
- int    dir;
- char * device;
- struct roar_stream_server * stream;
- int ssid;
-*/
-};
-
-int     driver_pulsesimple_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int     driver_pulsesimple_close        (struct roar_vio_calls * vio);
-ssize_t driver_pulsesimple_write        (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_pulsesimple_sync         (struct roar_vio_calls * vio);
-int     driver_pulsesimple_ctl          (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-
-#endif
-
-//ll
Index: roard/include/driver_pwmled.h
===================================================================
--- roard/include/driver_pwmled.h	(revision 6052)
+++ 	(revision )
@@ -1,51 +1,0 @@
-//driver_pwmled.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_PWMLED_H_
-#define _DRIVER_PWMLED_H_
-
-#if defined(ROAR_WITHOUT_DCOMP_LIGHT) && !defined(ROAR_WITHOUT_DCOMP_PWMLED)
-#define ROAR_WITHOUT_DCOMP_PWMLED
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_PWMLED
-
-struct driver_pwmled {
- struct roar_vio_calls  vio;
- struct roar_lpwm_state state;
- unsigned int           rate;    // bit/s
- uint16_t               channel; // DMX Channel
-};
-
-int driver_pwmled_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_pwmled_write (struct roar_vio_calls * vio,  void *buf, size_t count);
-int     driver_pwmled_ctl   (struct roar_vio_calls * vio,  roar_vio_ctl_t cmd, void * data);
-int     driver_pwmled_close (struct roar_vio_calls * vio);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/driver_raw.h
===================================================================
--- roard/include/driver_raw.h	(revision 6052)
+++ 	(revision )
@@ -1,36 +1,0 @@
-//driver_raw.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_RAW_H_
-#define _DRIVER_RAW_H_
-
-int driver_raw_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int driver_raw_close(DRIVER_USERDATA_T   inst);
-int driver_raw_pause(DRIVER_USERDATA_T   inst, int newstate);
-int driver_raw_flush(DRIVER_USERDATA_T   inst);
-
-#endif
-
-//ll
Index: roard/include/driver_roar.h
===================================================================
--- roard/include/driver_roar.h	(revision 6052)
+++ roard/include/driver_roar.h	(revision 0)
@@ -1,31 +1,13 @@
-//driver_roar.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
+//driver_esd.h:
 
 #ifndef _DRIVER_ROAR_H_
 #define _DRIVER_ROAR_H_
 
-int driver_roar_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
+int driver_roar_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info);
+int driver_roar_close(DRIVER_USERDATA_T   inst);
+int driver_roar_pause(DRIVER_USERDATA_T   inst, int newstate);
+int driver_roar_write(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_roar_read(DRIVER_USERDATA_T   inst, char * buf, int len);
+int driver_roar_flush(DRIVER_USERDATA_T   inst);
 
 #endif
Index: roard/include/driver_rsound.h
===================================================================
--- roard/include/driver_rsound.h	(revision 6052)
+++ 	(revision )
@@ -1,36 +1,0 @@
-//driver_rsound.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_RSOUND_H_
-#define _DRIVER_RSOUND_H_
-
-int     driver_rsound_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int     driver_rsound_close        (struct roar_vio_calls * vio);
-ssize_t driver_rsound_write        (struct roar_vio_calls * vio, void *buf, size_t count);
-
-
-#endif
-
-//ll
Index: roard/include/driver_shout.h
===================================================================
--- roard/include/driver_shout.h	(revision 6052)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//driver_shout.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_SHOUT_H_
-#define _DRIVER_SHOUT_H_
-
-int     driver_shout_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-ssize_t driver_shout_write(struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_shout_close(struct roar_vio_calls * vio);
-
-#endif
-
-//ll
Index: roard/include/driver_sndio.h
===================================================================
--- roard/include/driver_sndio.h	(revision 6052)
+++ 	(revision )
@@ -1,53 +1,0 @@
-//driver_sndio.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_SNDIO_H_
-#define _DRIVER_SNDIO_H_
-
-struct driver_sndio {
- int    dir;
- char * device;
- struct sio_hdl * shandle;
- struct mio_hdl * mhandle;
- struct roar_audio_info info;
- int need_reopen;
- int need_config;
- struct roar_stream_server * stream;
- int ssid;
-};
-
-int     driver_sndio_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int     driver_sndio_close_vio    (struct roar_vio_calls * vio);
-int     driver_sndio_open_device  (struct driver_sndio * self);
-int     driver_sndio_config_device(struct driver_sndio * self);
-int     driver_sndio_reopen_device(struct driver_sndio * self);
-ssize_t driver_sndio_write        (struct roar_vio_calls * vio, void *buf, size_t count);
-int     driver_sndio_sync         (struct roar_vio_calls * vio);
-int     driver_sndio_ctl          (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data);
-
-
-#endif
-
-//ll
Index: roard/include/driver_sysclock.h
===================================================================
--- roard/include/driver_sysclock.h	(revision 6052)
+++ 	(revision )
@@ -1,41 +1,0 @@
-//driver_sysclock.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_SYSCLOCK_H_
-#define _DRIVER_SYSCLOCK_H_
-
-struct driver_sysclock {
- int bps;
- struct timeval lasttime;
- long int last_wanted;
-};
-
-int     driver_sysclock_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int     driver_sysclock_close   (struct roar_vio_calls * vio);
-ssize_t driver_sysclock_write   (struct roar_vio_calls * vio, void *buf, size_t count);
-
-#endif
-
-//ll
Index: roard/include/driver_wmm.h
===================================================================
--- roard/include/driver_wmm.h	(revision 6052)
+++ 	(revision )
@@ -1,70 +1,0 @@
-//driver_wmm.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _DRIVER_WMM_H_
-#define _DRIVER_WMM_H_
-
-#include <roaraudio.h>
-
-#ifdef ROAR_HAVE_LIBWINMM
-
-struct driver_wmm {
-  UINT  id;             /* device id                       */
-  HWAVEOUT hwo;         /* waveout handler                 */
-  WAVEOUTCAPS caps;     /* device caps                     */
-  WAVEFORMATEX wavefmt; /* sample format                   */
-
-  int opened;           /* device has been opened          */
-  int prepared;         /* waveheaders have been prepared  */
-  int blocks;           /* number of blocks (wave headers) */
-  int splPerBlock;      /* sample per blocks.              */
-  int msPerBlock;       /* millisecond per block (approx.) */
-
-  void * bigbuffer;     /* Allocated buffer for waveheaders and sound data */
-  struct {
-   WAVEHDR wh;          /* waveheader                        */
-   char *  data;        /* sample data ptr                   */
-   int     idx;         /* index of this header              */
-   int     count;       /* current byte count                */
-   int     length;      /* size of data                      */
-   int     sent;        /* set when header is sent to device */
-  } * wh;          /* Pointer to waveheaders in bigbuffer             */
-  BYTE * spl;           /* Pointer to sound data in bigbuffer              */
-
-  int sent_blocks;      /* Number of waveheader sent (not ack).        */
-  int full_blocks;      /* Number of waveheader full (ready to send).  */
-  int widx;             /* Index to the block being currently filled.  */
-  int ridx;             /* Index to the block being sent.              */
-};
-
-int     driver_wmm_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
-int     driver_wmm_close_vio(struct roar_vio_calls * vio);
-ssize_t driver_wmm_write(struct roar_vio_calls * vio, void *buf, size_t count);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/empty.h
===================================================================
--- roard/include/empty.h	(revision 6052)
+++ 	(revision )
@@ -1,33 +1,0 @@
-//*.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2013-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _*_H_
-#define _*_H_
-
-#include <roaraudio.h>
-
-#endif
-
-//ll
Index: roard/include/emul_esd.h.OLD
===================================================================
--- roard/include/emul_esd.h.OLD	(revision 5739)
+++ 	(revision )
@@ -1,41 +1,0 @@
-//emul_esd.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _EMUL_ESD_H_
-#define _EMUL_ESD_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD
-#ifdef ROAR_HAVE_H_ESD
-
-extern struct roar_dl_proto __proto_common_esd;
-
-#endif
-#endif
-
-#endif
-
-//ll
Index: roard/include/emul_gopher.h.OLD
===================================================================
--- roard/include/emul_gopher.h.OLD	(revision 5739)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//emul_gopher.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2012
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _EMUL_GOPHER_H_
-#define _EMUL_GOPHER_H_
-
-#include <roaraudio.h>
-
-extern struct roar_dl_proto __proto_common_gopher;
-
-#endif
-
-//ll
Index: roard/include/emul_rplay.h.OLD
===================================================================
--- roard/include/emul_rplay.h.OLD	(revision 5739)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//emul_rplay.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _EMUL_RPLAY_H_
-#define _EMUL_RPLAY_H_
-
-#include <roaraudio.h>
-
-extern struct roar_dl_proto __proto_common_rplay;
-
-#endif
-
-//ll
Index: roard/include/emul_rsound.h
===================================================================
--- roard/include/emul_rsound.h	(revision 6052)
+++ 	(revision )
@@ -1,54 +1,0 @@
-//emul_rsound.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _EMUL_RSOUND_H_
-#define _EMUL_RSOUND_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-
-#define EMUL_RSOUND_MSG_HEADER_LEN (3+5)
-#define EMUL_RSOUND_MSG_DATA_LEN   (64)
-
-struct emul_rsound_msg {
- char header[EMUL_RSOUND_MSG_HEADER_LEN+1];
- size_t datalen;
- char data[EMUL_RSOUND_MSG_DATA_LEN+1];
- char * datasp;
- size_t dataslen;
-};
-
-int emul_rsound_vrecv_msg(struct emul_rsound_msg * msg, struct roar_vio_calls * vio);
-int emul_rsound_vsend_msg(struct emul_rsound_msg * msg, struct roar_vio_calls * vio);
-
-int emul_rsound_on_connect  (int fh, struct roard_listen * lsock);
-int emul_rsound_check_client(int client, struct roar_vio_calls * vio);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/emul_simple.h
===================================================================
--- roard/include/emul_simple.h	(revision 6052)
+++ 	(revision )
@@ -1,39 +1,0 @@
-//emul_simple.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _EMUL_SIMPLE_H_
-#define _EMUL_SIMPLE_H_
-
-#include <roaraudio.h>
-
-#if 1
-
-int emul_simple_on_connect  (int client, struct roard_listen * lsock);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/hwmixer.h
===================================================================
--- roard/include/hwmixer.h	(revision 6052)
+++ 	(revision )
@@ -1,71 +1,0 @@
-//hwmixer.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _HWMIXER_H_
-#define _HWMIXER_H_
-
-#include <roaraudio.h>
-
-#define HWMIXER_MODE_ASK        0
-#define HWMIXER_MODE_SET        1
-
-struct hwmixer;
-
-struct hwmixer_stream {
- struct hwmixer * hwmixer;
- int basestream;
- int stream;
- void * baseud;
- void * ud;
-};
-
-void print_hwmixerlist (void);
-int hwmixer_open(int basestream, char * drv, char * dev, int fh, char * basename, char * subnames);
-int hwmixer_close(int stream);
-
-int hwmixer_set_volume(int id, struct roar_stream_server * ss, struct hwmixer_stream * mstream, struct roar_mixer_settings * settings);
-int hwmixer_get_volume(int id, struct roar_stream_server * ss, struct hwmixer_stream * mstream, struct roar_mixer_settings * settings);
-
-struct hwmixer_stream * hwmixer_substream_new(struct hwmixer_stream * parent);
-
-int hwmixer_add (char * drv, char * dev, char * opts, int prim, int count);
-
-
-// Mixers:
-
-// dstr
-int hwmixer_dstr_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen);
-int hwmixer_dstr_close(struct hwmixer_stream * stream);
-int hwmixer_dstr_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings);
-
-// OSS
-int hwmixer_oss_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen);
-int hwmixer_oss_close(struct hwmixer_stream * stream);
-int hwmixer_oss_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings);
-int hwmixer_oss_get_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings);
-
-#endif
-
-//ll
Index: roard/include/lib.h
===================================================================
--- roard/include/lib.h	(revision 6052)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//lib.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _LIB_H_
-#define _LIB_H_
-
-#include <roaraudio.h>
-
-int lib_run_bg(const char * cmd, const int infh, const int outfh, const int errfh, int * closefh, const size_t lenclose);
-
-#endif
-
-//ll
Index: roard/include/light.h
===================================================================
--- roard/include/light.h	(revision 6052)
+++ 	(revision )
@@ -1,81 +1,0 @@
-//light.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _LIGHT_H_
-#define _LIGHT_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-
-#define LIGHT_CHANNELS_DEFAULT 512 /* one DMX Universe */
-#define MAX_EVENTS_PER_CYCLE   16  /* this*cfreq is event thruput (16*100Hz = 1.6kEvents/s) */
-
-extern struct light_state {
- unsigned int    channels;
- uint8_t events[MAX_EVENTS_PER_CYCLE];
- size_t eventsqueuelen;
- uint8_t * state;
- uint8_t * changes;
- uint8_t * output;
- uint8_t * outputchanges;
- struct roar_slfi_inst * filter;
-} g_light_state;
-
-extern struct light_mixer {
- int stream;
-} g_light_mixer;
-
-int light_init  (uint32_t channels);
-int light_free  (void);
-
-int light_update(void);
-int light_reset (void);
-int light_reinit(void);
-
-int light_check_stream  (int id);
-int light_send_stream   (int id);
-
-int light_filter_load(int primary, const char * name, int autoload, const struct roar_keyval * para, ssize_t paralen);
-
-// for plugins:
-// Those functions should be avoided. Please write SLFI filters instead!
-int     light_dmxchannel_get(size_t index); // get channel value from output state.
-int     light_dmxchannel_set(size_t index, uint8_t val); // set channel in input state.
-ssize_t light_dmxchannel_num(void); // returns number of channels.
-
-int light_dmxevent_add(const uint8_t * events, size_t len);
-int light_dmxevent_read(const uint8_t ** events, size_t * len);
-#define light_dmxevent_addone(event) light_dmxevent_add(&(uint8_t){(event)}, 1)
-
-// codec filters:
-int cf_light_roardmx_read(int id, struct roar_stream_server * ss);
-int cf_light_roardmx_write(int id, struct roar_stream_server * ss);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/memlock.h
===================================================================
--- roard/include/memlock.h	(revision 6052)
+++ 	(revision )
@@ -1,48 +1,0 @@
-//memlock.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _MEMLOCK_H_
-#define _MEMLOCK_H_
-
-#include <roaraudio.h>
-
-#define MEMLOCK_NONE         0
-#define MEMLOCK_LOW          1
-#define MEMLOCK_MEDIUM       2
-#define MEMLOCK_HIGH         3
-#define MEMLOCK_NEARLYALL    124
-#define MEMLOCK_NEARLYALLSYS 125 /* include stack and heap if possible */
-#define MEMLOCK_ALLCUR       126 /* specal as it uses roar_mm_mlockall() excluding future pages */
-#define MEMLOCK_ALL          127 /* specal as it uses roar_mm_mlockall() including future pages */
-
-#define MEMLOCK_DEFAULT      MEMLOCK_MEDIUM
-
-int memlock_str2level(const char * str);
-int memlock_set_level(int level);
-int memlock_register(int level, void * addr, size_t len);
-
-#endif
-
-//ll
Index: roard/include/meta.h
===================================================================
--- roard/include/meta.h	(revision 6052)
+++ 	(revision )
@@ -1,42 +1,0 @@
-//meta.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _META_H_
-#define _META_H_
-
-#include <roaraudio.h>
-
-#ifdef ROAR_SUPPORT_META
-int stream_meta_set     (int id, int type, const char * name, const char * val);
-int stream_meta_add     (int id, int type, const char * name, const char * val);
-int stream_meta_get     (int id, int type, const char * name, char * val, size_t len);
-int stream_meta_list    (int id, int * types, size_t len);
-int stream_meta_clear   (int id);
-int stream_meta_finalize(int id);
-#endif
-
-#endif
-
-//ll
Index: roard/include/midi.h
===================================================================
--- roard/include/midi.h	(revision 6052)
+++ 	(revision )
@@ -1,181 +1,0 @@
-//midi.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _MIDI_H_
-#define _MIDI_H_
-
-#include <roaraudio.h>
-
-// CB has MIDI as dep
-#if defined(ROAR_WITHOUT_DCOMP_MIDI) && !defined(ROAR_WITHOUT_DCOMP_CB)
-#define ROAR_WITHOUT_DCOMP_CB
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
-#ifdef __linux__
-#include <sys/ioctl.h>
-#include <linux/kd.h>
-#endif
-
-#define MIDI_CB_NOOVERRIDE 0
-#define MIDI_CB_OVERRIDE   1
-#endif
-
-#define MIDI_RATE    31250
-
-// standard MIDI commands:
-#define MIDI_TYPE_NOTE_OFF      0x80
-#define MIDI_TYPE_NOTE_ON       0x90
-#define MIDI_TYPE_PA            0xA0
-#define MIDI_TYPE_CONTROLER     0xB0
-#define MIDI_TYPE_PROGRAM       0xC0
-#define MIDI_TYPE_MA            0xD0
-#define MIDI_TYPE_PB            0xE0
-#define MIDI_TYPE_SYSEX         0xF0
-#define MIDI_TYPE_CLOCK_TICK    0xF8
-#define MIDI_TYPE_CLOCK_START   0xFA
-#define MIDI_TYPE_CLOCK_STOP    0xFC
-
-// RoarAudio MIDI Commands:
-#define MIDI_TYPE_NONE          0x00
-#define MIDI_TYPE_RAW_PASS      0x10
-#define MIDI_TYPE_RAW_NOPASS    0x20
-
-// controller events:
-#define MIDI_CCE_MAIN_VOL        7
-#define MIDI_CCE_BALANCE         8
-#define MIDI_CCE_PANORAMA       10
-#define MIDI_CCE_LOCAL_CONTR   122
-#define MIDI_CCE_ALL_NOTE_OFF  123
-
-
-#define MIDI_MES_BUFSIZE        4
-#define MIDI_READ_SIZE          256 /* this should be big enoth in both cfreq=20..100Hz mode */
-
-#define MIDI_MFLAG_FREE_DP     (1<<0)
-
-#define MIDI_INITED_MAIN        0x01
-#define MIDI_INITED_CB          0x02
-#define MIDI_INITED_CLOCK       0x04
-
-extern struct midi_config {
- int init;
- int inited;
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
- int init_cb;
- char * console_dev;
-#endif
-} midi_config;
-
-struct midi_message {
- unsigned char   type;
- unsigned char   channel;
- unsigned char   flags;
- unsigned char   kk;
- unsigned char   vv;
- size_t          datalen;
- unsigned char * dataptr;
- union {
-  unsigned char           ldata[MIDI_MES_BUFSIZE];
-  struct roar_note_octave note;
- }               d;
-};
-
-extern struct midi_state_mess {
- struct roar_buffer * buf;
-} g_midi_mess;
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
-extern struct midi_state_cb {
- int      console;
- int      stream;
- uint32_t stoptime;
- int      playing;
-} g_midi_cb;
-#endif
-
-extern struct midi_clock {
- int stream;
- uint_least32_t bph; // beats per hour
- uint_least32_t spt; // samples per tick
- uint32_t       nt;  // time of next tick
-} g_midi_clock;
-
-extern struct midi_mixer {
- int stream;
-} g_midi_mixer;
-
-
-// general midi interface:
-int midi_init_config(void);
-
-int midi_init (void);
-int midi_free (void);
-
-int midi_update(void);
-int midi_reinit(void);
-
-// streams:
-int midi_check_stream  (int id);
-int midi_send_stream   (int id);
-
-int midi_conv_midi2mes (int id);
-int midi_conv_mes2midi (int id);
-
-int midi_conv_mes2ssynth(void);
-
-int midi_new_bufmes    (struct roar_buffer ** buf, struct midi_message ** mes);
-int midi_add_buf       (int id, struct roar_buffer ** buf);
-
-// bridges:
-int midi_check_bridge  (int id);
-
-// clock:
-int midi_clock_init (void);
-int midi_clock_set_bph (uint_least32_t bph);
-int midi_clock_tick (void);
-
-// cb = console beep
-#ifndef ROAR_WITHOUT_DCOMP_CB
-int midi_cb_init(void);
-int midi_cb_free(void);
-int midi_cb_play(float t, float freq, int override);
-int midi_cb_update (void);
-int midi_cb_start(float freq);
-int midi_cb_stop (void);
-int midi_cb_readbuf(void);
-#endif
-
-// dummys:
-int     midi_vio_set_dummy(int stream);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/mixer.h
===================================================================
--- roard/include/mixer.h	(revision 6052)
+++ roard/include/mixer.h	(revision 0)
@@ -1,26 +1,3 @@
-//mixer.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
+//output.h:
 
 #ifndef _MIXER_H_
@@ -29,11 +6,9 @@
 #include <roaraudio.h>
 
-#define _MIXER_NAME_PREFIX ""
-#define _MIXER_NAME_SUFFIX " Mixer"
-#define _MIXER_NAME(x)     (_MIXER_NAME_PREFIX x _MIXER_NAME_SUFFIX)
-
-int need_vol_change  (int channels, struct roar_mixer_settings * set);
-
-int add_mixer (int subsys, char * name, struct roar_stream_server ** ss_ptr);
+int mix_clients       (void * output, int bits, void ** input, int samples);
+int mix_clients_8bit  (void * output, void ** input, int samples);
+int mix_clients_16bit (void * output, void ** input, int samples);
+int mix_clients_24bit (void * output, void ** input, int samples);
+int mix_clients_32bit (void * output, void ** input, int samples);
 
 #endif
Index: roard/include/network.h
===================================================================
--- roard/include/network.h	(revision 6052)
+++ roard/include/network.h	(revision 0)
@@ -1,26 +1,3 @@
 //network.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _NETWORK_H_
@@ -31,7 +8,5 @@
 int net_check_listen  (void);
 
-struct roard_listen;
-
-int net_get_new_client (struct roard_listen * lsock);
+int net_get_new_client (void);
 
 #endif
Index: roard/include/output.h
===================================================================
--- roard/include/output.h	(revision 6052)
+++ roard/include/output.h	(revision 0)
@@ -1,26 +1,3 @@
 //output.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _OUTPUT_H_
@@ -29,47 +6,13 @@
 #include <roaraudio.h>
 
-// NOTE: we do not set ROAR_OUTPUT_BUFFER_SAMPLES depending on DEBUG anymore
-//       as it caused a lot problems with partly enabled debugging
-
-#ifdef ROAR_OUTPUT_CFREQ
-#define ROAR_OUTPUT_BUFFER_SAMPLES (ROAR_RATE_DEFAULT/ROAR_OUTPUT_CFREQ)
-#else
-// in normal case we use 100 cycles per sec, as we do not know the sample
-// rate at compile time we guess it's normaly the default rate.
-// on OpenBSD we need to set a lower freq, use 20 cycles per sec here as
-// it seems to work.
-// FIXME: find out what the problem is and how to fix
-#ifdef ROAR_OS_OPENBSD
-#define ROAR_OUTPUT_BUFFER_SAMPLES (ROAR_RATE_DEFAULT/20)
-#define ROAR_OUTPUT_CFREQ          20
-#else
-#define ROAR_OUTPUT_BUFFER_SAMPLES (ROAR_RATE_DEFAULT/100)
-#define ROAR_OUTPUT_CFREQ          100
-#endif
-
-#endif
-
+//#define ROAR_OUTPUT_BUFFER_SAMPLES 1024
+//#define ROAR_OUTPUT_BUFFER_SAMPLES 1024
+#define ROAR_OUTPUT_BUFFER_SAMPLES 441
 #define ROAR_OUTPUT_WRITE_SIZE     1024
 
-//#define ROAR_OUTPUT_CALC_OUTBUFSIZE(x)   (ROAR_OUTPUT_BUFFER_SAMPLES * (x)->channels * ((x)->bits / 8) * ((float)(x)->rate/g_sa->rate))
-// First rounds the samples count, and makes sure that the outbuffer size is divisible by the framesize (channels * bits/8)
-#define ROAR_OUTPUT_CALC_OUTBUFSIZE(x)   ( \
-                                          ( \
-                                           (int)(ROAR_OUTPUT_BUFFER_SAMPLES * ((float)(x)->rate/g_sa->rate) + 0.5) \
-                                          ) * \
-                                          (x)->channels * ((x)->bits / 8) \
-                                         )
+#define ROAR_OUTPUT_CALC_OUTBUFSIZE(x) (ROAR_OUTPUT_BUFFER_SAMPLES * (x)->channels * ((x)->bits / 8))
 
-#define ROAR_OUTPUT_CALC_OUTBUFSAMP(x,y) ((y) / ((x)->channels * ((x)->bits / 8)*((float)(x)->rate/g_sa->rate)))
-#define ROAR_OUTPUT_CALC_OUTBUFSIZE_MAX(x0,x1)  (ROAR_OUTPUT_BUFFER_SAMPLES                                  * \
-                                                  ROAR_MAX((x0)->channels,(x1)->channels)                    * \
-                                                 (ROAR_MAX((x0)->bits,    (x1)->bits    ) / 8)               * \
-                                                 (ROAR_MAX((float)(x0)->rate,(float)(x1)->rate)/g_sa->rate)    \
-                                                )
-
-extern void         * g_output_buffer;
-extern void         * g_input_buffer;
-extern size_t         g_output_buffer_len;
-#define        g_input_buffer_len g_output_buffer_len
+void         * g_output_buffer;
+unsigned int   g_output_buffer_len;
 
 int output_buffer_init   (struct roar_audio_info * info);
@@ -77,6 +20,5 @@
 int output_buffer_free   (void);
 
-int output_add         (char * drv, char * dev, char * opts, int prim, int count);
-int output_add_default (char * drv, char * dev, char * opts, int prim, int count);
+int output_buffer_flush  (DRIVER_USERDATA_T inst, int driver);
 
 #endif
Index: roard/include/plugins.h
===================================================================
--- roard/include/plugins.h	(revision 6052)
+++ 	(revision )
@@ -1,48 +1,0 @@
-//plugins.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _PLUGINS_H_
-#define _PLUGINS_H_
-
-#include <roaraudio.h>
-
-#define ROARD_DL_APPNAME    "roard " ROAR_VSTR_ROARAUDIO
-#define ROARD_DL_ABIVERSION "1.0beta12"
-
-int plugins_preinit  (void);
-int plugins_init     (void);
-int plugins_free     (void);
-int plugins_update   (void);
-
-int plugins_load     (const char * filename, const char * args);
-
-void print_pluginlist(enum output_format format);
-
-// Check version:
-#define ROARD_DL_CHECK_VERSIONS() ROAR_DL_PLUGIN_CHECK_VERSIONS(ROARD_DL_APPNAME, ROARD_DL_ABIVERSION)
-
-#endif
-
-//ll
Index: roard/include/raw.h
===================================================================
--- roard/include/raw.h	(revision 6052)
+++ 	(revision )
@@ -1,41 +1,0 @@
-//raw.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _RAW_H_
-#define _RAW_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-
-#define RAW_READ_LEN  1024
-
-int raw_check_stream  (int id);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/rdtcs.h
===================================================================
--- roard/include/rdtcs.h	(revision 6052)
+++ 	(revision )
@@ -1,81 +1,0 @@
-//rdtcs.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _RDTCS_H_
-#define _RDTCS_H_
-
-#include <roaraudio.h>
-
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-
-#define RDTCS_RDS_PS_LEN      8
-#define RDTCS_RDS_PS_DEFAULT  "ROARING"
-#define RDTCS_RDS_PTY_DEFAULT 0
-#define RDTCS_RDS_PI_DEFAULT  0x0000
-
-#define RDTCS_RDS_BLOCK_A     1
-#define RDTCS_RDS_BLOCK_B     2
-#define RDTCS_RDS_BLOCK_C0    3
-#define RDTCS_RDS_BLOCK_C1    4
-#define RDTCS_RDS_BLOCK_D     5
-
-#define RDTCS_RDS_GROUP_LEN   ((4*(16+10))/8)
-
-#define RDTCS_RDS_FLAG_NONE   0x0000
-#define RDTCS_RDS_FLAG_TP     0x0001
-#define RDTCS_RDS_FLAG_CT     0x0002
-
-extern struct rdtcs_state {
- int inited;
- struct {
-  char          ps[RDTCS_RDS_PS_LEN+1];
-  unsigned char pty;
-  uint16_t      pi;
-  unsigned int  flags;
- } rds;
-} g_rdtcs;
-
-int rdtcs_init  (void);
-int rdtcs_free  (void);
-
-int rdtcs_init_config  (void);
-
-int rdtcs_rds_set_ps  (char * ps);
-int rdtcs_rds_set_pty (char * pty);
-int rdtcs_rds_set_flag(unsigned int flag, int reset);
-
-int rdtcs_check_stream  (int id);
-int rdtcs_send_stream   (int id);
-
-int rdtcs_send_stream_rds        (int id, struct roar_stream_server *  ss);
-int rdtcs_send_stream_rds_group  (int id, struct roar_stream_server *  ss);
-
-uint16_t rdtcs_rds_crc_calc      (uint16_t data, int block);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/req.h
===================================================================
--- roard/include/req.h	(revision 6052)
+++ roard/include/req.h	(revision 0)
@@ -1,26 +1,3 @@
 //req.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _REQ_H_
@@ -29,57 +6,33 @@
 #include <roaraudio.h>
 
-int req_on_noop        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_quit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_noop        (int client, struct roar_message * mes, char * data);
 
-int req_on_identify    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_auth        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_identify    (int client, struct roar_message * mes, char * data);
+int req_on_auth        (int client, struct roar_message * mes, char * data);
 
-int req_on_whoami      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_new_stream  (int client, struct roar_message * mes, char * data);
+int req_on_exec_stream (int client, struct roar_message * mes, char * data);
 
-int req_on_new_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_exec_stream (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_con_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_passfh      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_set_meta    (int client, struct roar_message * mes, char * data);
 
-#ifdef ROAR_SUPPORT_META
-int req_on_set_meta    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_get_meta    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_list_meta   (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-#endif
+int req_on_get_standby (int client, struct roar_message * mes, char * data);
+int req_on_set_standby (int client, struct roar_message * mes, char * data);
 
-int req_on_get_standby (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_set_standby (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_exit        (int client, struct roar_message * mes, char * data);
 
-int req_on_exit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_server_oinfo(int client, struct roar_message * mes, char * data);
 
-int req_on_gettimeofday(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_server_info (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_list_clients(int client, struct roar_message * mes, char * data);
+int req_on_list_streams(int client, struct roar_message * mes, char * data);
 
-int req_on_server_oinfo(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_get_client  (int client, struct roar_message * mes, char * data);
+int req_on_get_stream  (int client, struct roar_message * mes, char * data);
 
-int req_on_caps        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_kick        (int client, struct roar_message * mes, char * data);
 
-int req_on_list_clients(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_list_streams(int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+int req_on_add_data    (int client, struct roar_message * mes, char * data);
 
-int req_on_get_client  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_get_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
 
-int req_on_get_stream_para (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_set_stream_para (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-int req_on_kick        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_attach      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-int req_on_set_vol     (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-int req_on_get_vol     (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-int req_on_add_data    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-int req_on_beep        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-int req_on_wait        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
-
-//int req_on_ (int client, struct roar_message * mes, char ** data, uint32_t flags[2]);
+//int req_on_ (int client, struct roar_message * mes, char * data);
 
 #endif
Index: roard/include/roard.h
===================================================================
--- roard/include/roard.h	(revision 6052)
+++ roard/include/roard.h	(revision 0)
@@ -1,117 +1,13 @@
 //roard.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _ROARD_H_
 #define _ROARD_H_
 
-// configure ROAR_INFO()
-extern int g_verbose;
-#define ROAR_DBG_INFOVAR g_verbose
-
-// configure ROAR_*()
-#define ROAR_DBG_PREFIX "roard"
-
-// need to include this first as we need the config
+#include <signal.h>
+#include <sys/select.h>
 #include <roaraudio.h>
-#include <roaraudio/units.h>
-#include <libroarlight/libroarlight.h>
-#include <libroareio/libroareio.h>
-
-#include <ctype.h>
-
-#ifdef ROAR_HAVE_H_SIGNAL
-#include <signal.h>
-#endif
-
-#if defined(ROAR_HAVE_SELECT) && defined(ROAR_HAVE_H_SYS_SELECT)
-#include <sys/select.h>
-#endif
-
-#ifdef ROAR_HAVE_WAIT
-#include <sys/wait.h>
-#endif
-
-#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
-#include <grp.h>
-#include <pwd.h>
-#endif
-
-#ifdef ROAR_HAVE_H_SYS_TIME
-#include <sys/time.h>
-#endif
-#ifdef ROAR_HAVE_H_TIME
-#include <time.h>
-#endif
-
-#ifdef ROAR_HAVE_LIBSLP
-#include <slp.h>
-#endif
-
-/*
-#ifdef __linux__
-#include <linux/unistd.h>
-#include <linux/ioprio.h>
-#endif
-*/
-
-#define ROAR_SUBSYS_NONE          0x00
-#define ROAR_SUBSYS_WAVEFORM      0x01
-#define ROAR_SUBSYS_MIDI          0x02
-#define ROAR_SUBSYS_CB            0x04
-#define ROAR_SUBSYS_LIGHT         0x08
-#define ROAR_SUBSYS_RAW           0x10
-#define ROAR_SUBSYS_COMPLEX       0x20
-#define ROAR_SUBSYS_RDTCS         0x40
-
-// listeing code:
-#define ROAR_MAX_LISTEN_SOCKETS   16
-
-union uniinst {
- void * vp;
- int    si;
-};
-
-enum output_format {
- FORMAT_NATIVE = 1,
- FORMAT_WIKI,
- FORMAT_CSV,
-
- FORMAT_DEFAULT = FORMAT_NATIVE
-};
-
-
-// MFOI = Marked For Optional Include
-
 //#include "buffer.h"
-#include "caps.h"
-#include "memlock.h"
-#include "codecfilter.h" /* MFOI */
-#include "container_framework.h" /* MFOI */
-#include "rolestack.h"
 #include "client.h"
-#include "auth.h"
-#include "driver.h" /* MFOI */
+#include "driver.h"
 #include "output.h"
 #include "mixer.h"
@@ -121,117 +17,19 @@
 #include "commands.h"
 #include "req.h"
-#include "emul_simple.h" /* MFOI */
-#include "emul_rsound.h" /* MFOI */
 #include "sources.h"
-#include "sample.h"
-#include "hwmixer.h"
-#include "meta.h"
-#include "midi.h"
-#include "ssynth.h"
-#include "light.h"
-#include "raw.h"
-#include "rdtcs.h"
-#include "waveform.h"
-#include "beep.h"
-#include "lib.h"
-#include "plugins.h"
 
+int alive;
 
-extern int alive;
-#ifdef ROAR_SUPPORT_LISTEN
-extern int g_no_listen;
-#endif
+int g_standby;
 
-extern uint32_t g_pos; // current position in output stream
-
-extern int g_standby;
-extern int g_autostandby;
-
-#ifdef ROAR_SUPPORT_LISTEN
-struct roard_listen;
-#endif
-
-int main_loop (struct roar_audio_info * sa, int sysclocksync);
-void cleanup_listen_socket (int terminate);
+int main_loop (int driver, DRIVER_USERDATA_T driver_inst, struct roar_audio_info * sa);
 void clean_quit (void);
 void clean_quit_prep (void);
 
-void on_sig_int  (int signum);
-void on_sig_term (int signum);
-void on_sig_chld (int signum);
-void on_sig_usr1 (int signum);
+void on_sig_int (int signum);
 
-#ifdef ROAR_SUPPORT_LISTEN
-int get_listen(struct roard_listen ** sock, const char *** sockname);
-int add_listen (const char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info);
-#endif
+int g_listen_socket;
 
-#ifdef ROAR_SUPPORT_LISTEN
-extern struct roard_listen {
- int used;
- struct roar_vio_calls sock;
- int proto;
- union {
-  void * vp;
-  int    si;
-  struct {
-   int                    dir;
-   struct roar_audio_info info;
-  } stpl;
- } inst;
-} g_listen[ROAR_MAX_LISTEN_SOCKETS];
-#endif
-
-extern int g_self_client;
-
-extern int g_terminate;
-
-extern struct roar_audio_info * g_sa, * g_max_sa;
-
-#define CONF_DEF_STRING "***default***"
-
-extern struct roard_config {
- uint32_t flags;
- struct {
-  uint32_t                   flags;
-  struct roar_mixer_settings mixer;
-  int                        mixer_channels;
-  int                        rpgmode;
- } streams[ROAR_DIR_DIRIDS];
- char * location;
- char * description;
- char * contact;
- char * serial;
- char * uiurl;
- size_t jumbo_mtu;
- int memlock_level;
-#ifdef ROAR_HAVE_SYSTEM
- struct {
-  const char * post_shutdown;
- } scripts;
-#endif
-} * g_config;
-
-struct _counters {
- size_t clients, streams,
-        samples,
-        sources, outputs,
-        mixers, bridges,
-        listens;
-};
-
-extern struct counters {
- struct _counters cur, sum;
-} g_counters;
-
-
-#define counters_init() memset(counters_getptr(), 0, sizeof(struct counters))
-//#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)
-#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)
-
-#define counters_get(g,c) ((counters_getptr()->g.c))
-
-struct counters * counters_getptr(void);
-void counters_print(int type, int force);
+struct roar_audio_info * g_sa;
 
 #endif
Index: roard/include/rolestack.h
===================================================================
--- roard/include/rolestack.h	(revision 6052)
+++ 	(revision )
@@ -1,58 +1,0 @@
-//rolestack.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _ROLESTACK_H_
-#define _ROLESTACK_H_
-
-#include <roaraudio.h>
-
-enum rs_action {
- RS_ERROR = -1,
- RS_MIX = 0,
- RS_KICK,
- RS_MUTE,
- RS_PAUSE
-};
-
-struct rolestack {
- int index;
- int role;
- enum rs_action action;
-};
-
-void rolestack_init(void);
-void print_rolestack(void);
-
-const struct rolestack * rolestack_get_role(int role);
-int rolestack_push(const struct rolestack * role);
-
-enum rs_action rolestack_str2action(const char * str);
-const char * rolestack_action2str(enum rs_action action);
-
-const struct rolestack * rolestack_parse(const char * str);
-
-#endif
-
-//ll
Index: roard/include/sample.h
===================================================================
--- roard/include/sample.h	(revision 6052)
+++ 	(revision )
@@ -1,44 +1,0 @@
-//sample.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _SAMPLE_H_
-#define _SAMPLE_H_
-
-#include <roaraudio.h>
-
-#define ROAR_SAMPLES_MAX  32
-
-extern struct roar_sample * g_samples[ROAR_SAMPLES_MAX];
-
-int samples_init      (void);
-int samples_free      (void);
-int samples_new       (void);
-int samples_delete    (int id);
-int samples_set_name  (int id, char * name);
-int samples_add_data  (int id, void * data, size_t len);
-
-#endif
-
-//ll
Index: roard/include/sources.h
===================================================================
--- roard/include/sources.h	(revision 6052)
+++ roard/include/sources.h	(revision 0)
@@ -1,26 +1,3 @@
 //sources.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _SOURCES_H_
@@ -29,41 +6,10 @@
 #include <roaraudio.h>
 
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-#define SRC_FLAG_NONE           0x00
-#define SRC_FLAG_FHSEC          0x01
-
-struct roar_source {
- char * name;
- char * desc;
- char * devices;
- unsigned int flags;
- unsigned int subsystems;
- int (*old_open)(const char * driver, const char * device, const char * container, const char * options, int primary);
- int (*new_open)(int stream   , const char * device, int fh, const char * driver);
-};
+int g_source_client;
 
 int sources_init (void);
 int sources_free (void);
 
-int sources_set_client (int client);
-
-void print_sourcelist (void);
-
-int sources_add (char * driver, char * device, char * container, char * options, int primary);
-
-int sources_add_new (struct roar_source * source,
-                     char * driver, char * device,
-                     char * options, int primary);
-
-int sources_add_dstr (int stream   , const char * device, int fh, const char * driver);
-int sources_add_cf   (const char * driver, const char * device, const char * container, const char * options, int primary);
-
-int sources_add_roar (int stream, const char * device, int fh, const char * driver);
-int sources_add_radionoise (int stream, const char * device, int fh, const char * driver);
-
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
-int sources_add_cdriver (int stream   , const char * device, int fh, const char * driver);
-#endif
-#endif
+int sources_add (char * driver, char * device, char * containe, char * options, int primary);
 
 #endif
Index: roard/include/ssynth.h
===================================================================
--- roard/include/ssynth.h	(revision 6052)
+++ 	(revision )
@@ -1,80 +1,0 @@
-//ssynth.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _SSYNTH_H_
-#define _SSYNTH_H_
-
-#include <roaraudio.h>
-
-// we relay on the MIDI subsystem
-#if defined(ROAR_WITHOUT_DCOMP_MIDI) && !defined(ROAR_WITHOUT_DCOMP_SSYNTH)
-#define ROAR_WITHOUT_DCOMP_SSYNTH
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-
-#define SSYNTH_NOTES_MAX            16
-
-#define SSYNTH_STAGE_NONE            0
-#define SSYNTH_STAGE_UNUSED          SSYNTH_STAGE_NONE
-#define SSYNTH_STAGE_KEYSTROKE       1
-#define SSYNTH_STAGE_MIDSECTION      2
-#define SSYNTH_STAGE_KEYRELEASE      3
-
-#define SSYNTH_POLY_KEYDOWN          0
-#define SSYNTH_POLY_KEYUP            1
-#define SSYNTH_POLY_POLYMAX          2
-
-#define SSYNTH_POLY_COEFF            4
-
-extern struct ssynth_conf {
- int enable;
-} ssynth_conf;
-
-int ssynth_init_config(void);
-
-int ssynth_init (void);
-int ssynth_free (void);
-
-int ssynth_update (void);
-
-int ssynth_note_new(struct roar_note_octave * note, char vv);
-int ssynth_note_free(int id);
-int ssynth_note_find(struct roar_note_octave * note);
-
-int ssynth_note_set_stage(int id, int stage);
-
-int ssynth_note_render   (int id, void * data);
-
-int ssynth_note_on       (struct roar_note_octave * note, char vv);
-int ssynth_note_off      (struct roar_note_octave * note, char vv);
-
-int ssynth_eval_message (struct midi_message * mes);
-
-#endif
-
-#endif
-
-//ll
Index: roard/include/streams.h
===================================================================
--- roard/include/streams.h	(revision 6052)
+++ roard/include/streams.h	(revision 0)
@@ -1,26 +1,3 @@
 //streams.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #ifndef _STREAMS_H_
@@ -35,44 +12,7 @@
 */
 
-//#define ROAR_STREAM(x)        ((struct roar_stream*)(x))
 #define ROAR_STREAM_SERVER(x) ((struct roar_stream_server*)(x))
 
-// stream ctls...:
-
-#define ROAR_STREAM_CTL_COMPMASK  0xFF000000
-#define ROAR_STREAM_CTL_TYPEMASK  0x00FF0000
-#define ROAR_STREAM_CTL_CMDMASK   0x0000FFFF
-
-#define ROAR_STREAM_CTL_COMP_BASE 0x00000000
-#define ROAR_STREAM_CTL_COMP_CF   0x01000000
-#define ROAR_STREAM_CTL_COMP_DRV  0x02000000
-
-#define ROAR_STREAM_CTL_TYPE_VOID   0x00000000
-#define ROAR_STREAM_CTL_TYPE_INT    0x00010000
-#define ROAR_STREAM_CTL_TYPE_FLOAT  0x00020000
-#define ROAR_STREAM_CTL_TYPE_FPI100 0x00030000 /* fix point integter int/100 */
-
-#define STREAM_DIR_NONE             0x00
-#define STREAM_DIR_IN               0x01
-#define STREAM_DIR_OUT              0x02
-#define STREAM_DIR_BIDIR            (STREAM_DIR_IN|STREAM_DIR_OUT)
-
-#define MAX_LTM_WINDOWS_PER_STREAM  1
-
-struct roar_ltm_vals {
- int64_t rms;
-};
-
-struct roar_stream_ltm {
- int window;
- int parent_window;
- int mt;
- size_t refc;
- size_t channels;
- struct roar_ltm_vals *  cur;
- struct roar_ltm_vals ** history;
-};
-
-extern struct roar_stream_server {
+struct roar_stream_server {
  struct roar_stream _stream;
  unsigned int pos_abs;
@@ -81,45 +21,5 @@
  size_t need_extra;
  void  * output;
- struct roar_mixer_settings mixer;
-#ifdef ROAR_SUPPORT_META
- struct roar_meta meta[ROAR_META_MAX_PER_STREAM];
-#endif
- int is_new;
- int codecfilter;
- ROAR_AUDIO_INFO_TYPE codec_orgi;
- CODECFILTER_USERDATA_T codecfilter_inst;
- int socktype;
- int pre_underruns;
- int post_underruns;
- struct roar_vio_calls vio;
- int primary;
- int driver_id;
-// struct roardsp_filterchain fc;
- uint32_t flags;
- uint32_t flags_protection;
- uint_least32_t delay;
- char * name;
- int ready;
- struct roar_buffer * outputbuffer;
- int state;
- struct roar_buffer * prethru;
- struct roar_vio_calls jumbo;
- struct roar_vio_calls * viop;
- int mixer_stream;
- struct roardsp_chanmap chanmap;
- int role;
- int parent_stream;
- struct roar_stream_ltm ltm[MAX_LTM_WINDOWS_PER_STREAM];
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- struct hwmixer_stream * mixerstream;
-#endif
- size_t single_sink_c;
- size_t single_sink_self_c;
- int rpgmode;
 } * g_streams[ROAR_STREAMS_MAX];
-
-extern int streams_recsource_id;
-
-void streams_change_sync_num(int id, int diff);
 
 int streams_init   (void);
@@ -130,79 +30,15 @@
 
 int streams_set_client (int id, int client);
-int streams_get_client (int id);
-
-int streams_set_dir    (int id, int dir, int defaults);
-int streams_get_dir    (int id);
-
-int streams_set_mixer_stream(int id, int mixer);
-int streams_get_mixer_stream(int id);
-
-int streams_set_role   (int id, int role);
-
-int streams_dir2subsys (int dir);
-int streams_get_subsys (int id);
-int streams_get_ssdir  (int id);
-
-int streams_new_virtual (int parent, struct roar_stream_server ** stream);
 
 int streams_set_fh     (int id, int fh);
-int streams_get_fh     (int id);
-int streams_set_null_io(int id);
 int streams_get        (int id, struct roar_stream_server ** stream);
-int streams_get_clientobj (int id, struct roar_stream        ** stream);
 
-int streams_set_socktype (int id, int socktype);
-int streams_get_socktype (int id);
-
-int streams_is_ready     (int id);
-int streams_is_new       (int id);
-
-int streams_set_primary  (int id, int prim);
-int streams_mark_primary (int id);
-int streams_set_sync     (int id, int sync);
-int streams_set_mmap     (int id, int reset);
-int streams_set_single_sink(int id, int reset);
-int streams_set_flag     (int id, uint32_t flag);
-int streams_set_rawflag  (int id, uint32_t flag);
-int streams_reset_flag   (int id, uint32_t flag);
-int streams_get_flag     (int id, uint32_t flag);
-
-int streams_protect_flag (int id, uint32_t flag);
-
-int streams_set_name     (int id, char * name);
-char * streams_get_name  (int id);
-
-int streams_calc_delay   (int id);
-int streams_set_mixer    (int id);
-
-int streams_set_map      (int id, char * map, size_t len);
-
-int streams_get_rpg      (int id, struct roar_stream_rpg * rpg);
-int streams_set_rpg      (int id, const struct roar_stream_rpg * rpg);
-
-int streams_ltm_ctl      (int id, int mt, int window, int cmd);
-int streams_ltm_calc     (int id, struct roar_audio_info * info, void * data, size_t len);
-struct roar_stream_ltm * streams_ltm_get(int id, int mt, int window);
-
-struct hwmixer_stream * streams_get_mixerstream(int id);
-int streams_set_mixerstream(int id, struct hwmixer_stream * mstream);
-int streams_read_mixervalues(int id);
-
-int streams_ctl          (int id, int_least32_t cmd, void * data);
-
-int stream_add_buffer     (int id, struct roar_buffer **  buf);
-int stream_shift_out_buffer   (int id, void * data, size_t * len);
-
-int stream_outputbuffer_request(int id, struct roar_buffer ** buf, size_t len);
-int stream_outputbuffer_destroy(int id);
-
-int stream_prethru_add(int id, struct roar_buffer ** buf);
-int stream_prethru_add_data(int id, void ** buf, size_t len);
-int stream_prethru_destroy(int id);
-int stream_prethru_send(int dst, int src);
+int stream_add_buffer     (int id, struct roar_buffer *  buf);
+//int stream_get_buffer     (int id, struct roar_buffer ** buf);
+int stream_shift_buffer   (int id, struct roar_buffer ** buf);
+int stream_unshift_buffer (int id, struct roar_buffer *  buf);
 
 int streams_check      (int id);
 int streams_send_mon   (int id);
-int streams_send_filter_all(void);
 int streams_send_filter(int id);
 
@@ -210,12 +46,5 @@
 int streams_get_outputbuffer (int id, void ** buffer, size_t size);
 int streams_fill_mixbuffer   (int id, struct roar_audio_info * info);
-int streams_fill_mixbuffer2  (int id, struct roar_audio_info * info);
 
-ssize_t stream_vio_read (int stream, void         * buf, size_t count);
-ssize_t stream_vio_write(int stream, void         * buf, size_t count);
-int     stream_vio_ctl  (int stream, roar_vio_ctl_t cmd, void * data);
-ssize_t stream_vio_s_read (struct roar_stream_server * stream, void         * buf, size_t count);
-ssize_t stream_vio_s_write(struct roar_stream_server * stream, void         * buf, size_t count);
-int     stream_vio_s_ctl  (struct roar_stream_server * stream, roar_vio_ctl_t cmd, void * data);
 
 #endif
Index: roard/include/waveform.h
===================================================================
--- roard/include/waveform.h	(revision 6052)
+++ 	(revision )
@@ -1,46 +1,0 @@
-//waveform.h:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _WAVEFORM_H_
-#define _WAVEFORM_H_
-
-#include <roaraudio.h>
-
-struct waveform_stream {
- int stream;
- struct roar_stream_server * ss;
-};
-
-extern struct waveform_stream g_waveform_mixer, g_waveform_recbridge;
-
-int waveform_init  (void);
-int waveform_free  (void);
-
-int waveform_update_inputs (void);
-int waveform_update_mixer  (void);
-
-#endif
-
-//ll
Index: roard/lib.c
===================================================================
--- roard/lib.c	(revision 6052)
+++ 	(revision )
@@ -1,109 +1,0 @@
-//lib.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-int lib_run_bg(const char * cmd, const int infh, const int outfh, const int errfh, int * closefh, const size_t lenclose) {
-#ifdef ROAR_HAVE_FORK
- pid_t child;
- int fh[3] = {-1, -1, -1};
- size_t i;
-
- ROAR_WARN("lib_run_bg(cmd='%s', ...): This function should never be called. Contact devels.", cmd);
-
- child = roar_fork(NULL);
-
- if ( child == -1 ) {
-  ROAR_ERR("lib_run_bg(*): Can not fork: %s", strerror(errno));
-  return -1;
- }
-
- if ( child ) {
-  // we are the parent!
-  return child;
- }
-
- // we are the child.
-
- // first stop the watchdog.
- roar_watchdog_stop();
-
- // then we need to close a lot of open files!
-
- // before we do this we need to keep backups of our handles:
- fh[0] = dup(infh);
- fh[1] = dup(outfh);
- fh[2] = dup(errfh);
-
- // TODO: test for errors here.
-
-#ifdef ROAR_SUPPORT_LISTEN
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++)
-  if ( g_listen[i].used )
-   roar_vio_close(&(g_listen[i].sock)); // listen socket.
-#endif
-
-// this breaks the new driver interface
-// clients_free(); // delete all clients!, this allso delets all streams
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- midi_free(); // close midi devices
-#endif
-
- // close fh's we got ask to close:
-#ifdef ROAR_HAVE_IO_POSIX
- for (i = 0; i < lenclose; i++)
-  close(closefh[i]);
-#else
- if ( lenclose ) {
-  ROAR_WARN("lib_run_bg(*): lenclose > 0 and no way known to close fds");
- }
-#endif
-
- // next we need to remap our stdio:
- // stdio: fh 0..2
-
- for (i = 0; i < 3; i++) {
-#ifdef ROAR_HAVE_IO_POSIX
-  close(i);
-#endif
-  dup2(fh[i], i); // todo test if this is ok.
-  close(fh[i]);
- }
-
- // OK, now we should have set up all our fh properbly, exec our command:
-
- execl("/bin/sh", "sh", "-c", cmd, (char*)NULL);
-
- // still alive? BAD!
- ROAR_ERR("lib_run_bg(*): We are still alive! BAD!");
- ROAR_U_EXIT(3);
- return -1;
-#else
- return -1;
-#endif
-}
-
-//ll
Index: roard/light.c
===================================================================
--- roard/light.c	(revision 6052)
+++ 	(revision )
@@ -1,397 +1,0 @@
-//light.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-
-static uint8_t nextcycle_events[MAX_EVENTS_PER_CYCLE];
-static size_t nextcycle_eventsqueuelen;
-static int __cb_event_add(struct roar_slfi_inst * inst, void * userdata, uint8_t event);
-
-// declared 'extern'
-struct light_state g_light_state;
-struct light_mixer g_light_mixer;
-// //
-
-static inline void __set_channel(size_t index, uint8_t val) {
- g_light_state.changes[index] |= g_light_state.state[index] ^ val;
- g_light_state.state[index]    =                              val;
-}
-
-int light_init  (uint32_t channels) {
- struct roar_stream_server * ss;
- int i;
-
- g_light_state.channels = 0;
-
- if ( channels == 0 || channels > ((uint32_t)512UL*(uint32_t)512UL) ) /* unrealstic values */
-  return -1;
-
- if ( (g_light_state.state = roar_mm_malloc(channels)) == NULL ) {
-  return -1;
- }
-
- if ( (g_light_state.changes = roar_mm_malloc(channels)) == NULL ) {
-  roar_mm_free(g_light_state.state);
-  return -1;
- }
-
- if ( (g_light_state.output = roar_mm_malloc(channels)) == NULL ) {
-  roar_mm_free(g_light_state.state);
-  roar_mm_free(g_light_state.changes);
-  return -1;
- }
-
- if ( (g_light_state.outputchanges = roar_mm_malloc(channels)) == NULL ) {
-  roar_mm_free(g_light_state.state);
-  roar_mm_free(g_light_state.changes);
-  roar_mm_free(g_light_state.output);
-  return -1;
- }
-
- g_light_state.channels = channels;
- g_light_state.filter   = NULL;
-
- if ( (g_light_mixer.stream = add_mixer(ROAR_SUBSYS_LIGHT, _MIXER_NAME("Light Control"), &ss)) == -1 ) {
-  roar_mm_free(g_light_state.state);
-  return -1;
- }
-
- ROAR_STREAM(ss)->info.codec = ROAR_CODEC_DMX512;
- ROAR_STREAM(ss)->info.bits  = ROAR_LIGHT_BITS;
- ROAR_STREAM(ss)->info.rate  = ROAR_OUTPUT_CFREQ;
-
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( g_streams[i] != NULL ) {
-   if ( streams_get_subsys(i) == ROAR_SUBSYS_LIGHT ) {
-    streams_set_mixer_stream(i, g_light_mixer.stream);
-   }
-  }
- }
-
- return light_reset();
-}
-
-int light_free  (void) {
- if ( g_light_state.filter != NULL ) {
-  roar_slfi_unref(g_light_state.filter);
- }
-
- if ( g_light_state.state != NULL ) {
-  roar_mm_free(g_light_state.state);
- }
-
- if ( g_light_state.changes != NULL ) {
-  roar_mm_free(g_light_state.changes);
- }
-
- if ( g_light_state.output != NULL ) {
-  roar_mm_free(g_light_state.output);
- }
-
- if ( g_light_state.outputchanges != NULL ) {
-  roar_mm_free(g_light_state.outputchanges);
- }
-
- g_light_state.channels = 0;
-
- return 0;
-}
-
-int light_reset (void) {
- if ( g_light_state.channels == 0 )
-  return 0;
-
- if ( g_light_state.state == NULL )
-  return -1;
-
- if ( g_light_state.changes == NULL )
-  return -1;
-
- memset(g_light_state.state,         0, g_light_state.channels);
- memset(g_light_state.changes,       0, g_light_state.channels);
- memset(g_light_state.output,        0, g_light_state.channels);
- memset(g_light_state.outputchanges, 0, g_light_state.channels);
- memset(g_light_state.events,        0, sizeof(g_light_state.events));
-
- g_light_state.eventsqueuelen = 0;
-
- return 0;
-}
-
-// called at end of mainloop.
-int light_reinit(void) {
- if ( g_light_state.changes == NULL )
-  return -1;
-
- memset(g_light_state.changes, 0, g_light_state.channels);
- memset(g_light_state.events,  0, sizeof(g_light_state.events));
-
- g_light_state.eventsqueuelen = 0;
-
- if ( nextcycle_eventsqueuelen ) {
-  light_dmxevent_add(nextcycle_events, nextcycle_eventsqueuelen);
-  nextcycle_eventsqueuelen = 0;
- }
-
- return 0;
-}
-
-// called at mid of mainloop.
-int light_update(void) {
- uint8_t * tmp;
- unsigned int c;
-
- // swap buffers:
- // after that step we have the old values in outputchanges and output is a fresh buffer.
- tmp = g_light_state.outputchanges;
- g_light_state.outputchanges = g_light_state.output;
- g_light_state.output = tmp;
-
- // copy data for filters:
- memcpy(g_light_state.output, g_light_state.state, g_light_state.channels);
-
- // TODO: next run filters
- if ( g_light_state.filter != NULL ) {
-  if ( roar_slfi_update(g_light_state.filter,
-                        g_light_state.output, g_light_state.channels,
-                        ((int32_t)1000000LU)/(int32_t)ROAR_OUTPUT_CFREQ,
-                        g_light_state.events, g_light_state.eventsqueuelen) == -1 ) {
-   ROAR_WARN("light_update(void): Can not run SLFI filter: %s", roar_errorstring);
-  }
- }
-
- // calculate diffrence:
- // after this step we have only teh changes in the outputchanges array.
- for (c = 0; c < g_light_state.channels; c++)
-  g_light_state.outputchanges[c] ^= g_light_state.output[c];
-
- return 0;
-}
-
-int light_check_stream  (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
- char buf[512];
- int i;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("light_check_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- switch (s->info.codec) {
-  case ROAR_CODEC_DMX512:
-    if ( stream_vio_s_read(ss, buf, 512) != 512 ) {
-     streams_delete(id);
-     return -1;
-    }
-
-    for (i = 0; i < (g_light_state.channels < 512 ? g_light_state.channels : 512); i++) {
-     __set_channel(i, buf[i]);
-    }
-//    memcpy(g_light_state.state, buf, g_light_state.channels < 512 ? g_light_state.channels : 512);
-
-    s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1);
-
-    return 0;
-   break;
-  case ROAR_CODEC_ROARDMX:
-    ROAR_DBG("light_check_stream(id=%i): Codec: RoarDMX", id);
-    if ( cf_light_roardmx_read(id, ss) == -1 ) {
-     streams_delete(id); // simply drop the client on error.
-     return -1;
-    }
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- return 0;
-}
-
-static inline int light_send_stream_dmx512  (int id, struct roar_stream * s, struct roar_stream_server * ss) {
- size_t chans = g_light_state.channels;
- uint8_t buf[512];
- register uint8_t * bufptr;
-
- if ( chans > 512 )
-  chans = 512;
-
- if ( chans == 512 ) {
-  bufptr = g_light_state.output;
- } else {
-  memset(buf, 0, 512);
-  memcpy(buf, g_light_state.output, chans);
-  bufptr = buf;
- }
-
- if ( stream_vio_s_write(ss, bufptr, 512) != 512 ) {
-  streams_delete(id);
-  return -1;
- }
-
- s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1);
-
- return 0;
-}
-
-int light_send_stream   (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("light_send_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- switch (s->info.codec) {
-  case ROAR_CODEC_DMX512:
-    return light_send_stream_dmx512(id, s, ss);
-   break;
-  case ROAR_CODEC_ROARDMX:
-    return cf_light_roardmx_write(id, ss);
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- return 0;
-}
-
-int light_filter_load(int primary, const char * name, int autoload, const struct roar_keyval * para, ssize_t paralen) {
- struct roar_slfi_inst * filter;
- int ret;
- int err;
-
- if ( primary && g_light_state.filter != NULL ) {
-  roar_err_set(ROAR_ERROR_ALREADY);
-  return -1;
- } else if ( !primary && g_light_state.filter == NULL ) {
-  roar_err_set(ROAR_ERROR_BADSTATE);
-  return -1;
- }
-
- filter = roar_slfi_new(name, autoload, para, paralen);
- if ( filter == NULL )
-  return -1;
-
- if ( primary ) {
-  roar_slfi_cb_set_event_add(filter, __cb_event_add, NULL);
-  g_light_state.filter = filter;
-  return 0;
- }
-
- ret = roar_slfi_ctl(g_light_state.filter, ROAR_SLFI_CMD_PUSH, filter);
- err = roar_error;
-
- roar_slfi_unref(filter);
-
- roar_err_set(err);
- return ret;
-}
-
-int light_dmxchannel_get(size_t index) {
- if ( (size_t)g_light_state.channels <= index ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- return (int)(unsigned int)(uint8_t)g_light_state.output[index];
-}
-
-int light_dmxchannel_set(size_t index, uint8_t val) {
- if ( (size_t)g_light_state.channels <= index ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- __set_channel(index, val);
- return 0;
-}
-
-ssize_t light_dmxchannel_num(void) {
- if ( g_light_state.state == NULL ) {
-  roar_err_set(ROAR_ERROR_BADSTATE);
-  return -1;
- }
-
- return g_light_state.channels;
-}
-
-int light_dmxevent_add(const uint8_t * events, size_t len) {
- size_t i;
-
- if ( events == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( len > (sizeof(g_light_state.events) - g_light_state.eventsqueuelen) ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- for (i = 0; i < len; i++) {
-  g_light_state.events[g_light_state.eventsqueuelen++] = events[i];
-  roar_notify_core_emit_simple(ROAR_DATA_DMX512_EVENT, -1, g_light_mixer.stream, ROAR_OT_STREAM, events[i], -1, NULL, -1);
- }
-
- return 0;
-}
-
-int light_dmxevent_read(const uint8_t ** events, size_t * len) {
- if ( events == NULL || len == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- *events = g_light_state.events;
- *len    = g_light_state.eventsqueuelen;
-
- return 0;
-}
-
-static int __cb_event_add(struct roar_slfi_inst * inst, void * userdata, uint8_t event) {
- if ( nextcycle_eventsqueuelen == MAX_EVENTS_PER_CYCLE ) {
-  roar_err_set(ROAR_ERROR_NOSPC);
-  return -1;
- }
-
- nextcycle_events[nextcycle_eventsqueuelen++] = event;
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/loop.c
===================================================================
--- roard/loop.c	(revision 6052)
+++ roard/loop.c	(revision 0)
@@ -1,118 +1,31 @@
 //loop.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-int main_loop (struct roar_audio_info * sa, int sysclocksync) {
+int main_loop (int driver, DRIVER_USERDATA_T driver_inst, struct roar_audio_info * sa) {
  void ** streams_input = NULL;
- int     term = 0;
- int     streams;
-#ifdef ROAR_HAVE_GETTIMEOFDAY
- long int loopc = 0;
- struct timeval         try, ans;
- float  freq;
-#endif
-#ifdef ROAR_SUPPORT_LISTEN
- int i;
- int have_listen;
-#endif
-#ifdef MONITOR_LATENCY
- long int ans_1last = 0, ans_2last = 0, ans_3last = 0;
-
- printf("\n\e[s");
- fflush(stdout);
-#endif
+ uint32_t pos = 0;
 
  ROAR_DBG("main_loop(*) = ?");
-// alive = 1;
- g_pos = 0;
-
-#ifdef ROAR_HAVE_GETTIMEOFDAY
- if ( sysclocksync ) {
-  gettimeofday(&try, NULL);
- }
-#endif
+ alive = 1;
 
  while (alive) {
-#if defined(MONITOR_LATENCY) && defined(ROAR_HAVE_GETTIMEOFDAY)
-  gettimeofday(&try, NULL);
-#endif
-
   ROAR_DBG("main_loop(*): looping...");
 
-  roar_watchdog_trigger();
-
-#ifdef ROAR_SUPPORT_LISTEN
-  have_listen = 0;
-  for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-   if ( g_listen[i].used ) {
-    have_listen = 1;
-    break;
-   }
-  }
-
-  if ( have_listen ) {
-   ROAR_DBG("main_loop(*): check for new clients...");
-   net_check_listen();
-  }
-#endif
+  ROAR_DBG("main_loop(*): check for new clients...");
+  net_check_listen();
 
   ROAR_DBG("main_loop(*): check for new data...");
-#ifdef ROAR_SUPPORT_LISTEN
-  if ( clients_check_all() == 0 && g_terminate && !have_listen ) {
-#else
-  if ( clients_check_all() == 0 && g_terminate ) {
-#endif
-   term  = 1;
-  }
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-  ROAR_DBG("main_loop(*): updating midi subsystem...");
-  midi_update();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-  light_update();
-#endif
-
-  if ( waveform_update_inputs() == -1 )
-   alive = 0;
+  clients_check_all();
 
   ROAR_DBG("main_loop(*): mixing clients...");
   if ( g_standby ) {
    // while in standby we still neet to get the buffers to free input buffer space.
-   streams = streams_get_mixbuffers(&streams_input, sa, g_pos);
+   streams_get_mixbuffers(&streams_input, sa, pos);
   } else {
-   if ( ( streams = streams_get_mixbuffers(&streams_input, sa, g_pos)) != -1 ) {
-    roar_mix_pcm(g_output_buffer, sa->bits, streams_input, ROAR_OUTPUT_BUFFER_SAMPLES * sa->channels);
+   if ( streams_get_mixbuffers(&streams_input, sa, pos) == 0 ) {
+    mix_clients(g_output_buffer, sa->bits, streams_input, ROAR_OUTPUT_BUFFER_SAMPLES * sa->channels);
    }
   }
-
-  if ( term && streams < 1 )
-   alive = 0;
-
-  if ( waveform_update_mixer() == -1 )
-   alive = 0;
 
 /*
@@ -121,77 +34,15 @@
 */
 
-  if ( plugins_update() == -1 )
-   alive = 0;
-
-  ROAR_DBG("main_loop(*): sending output data...");
-
-#ifdef ROAR_HAVE_USLEEP
-  if ( g_standby || (streams < 1 && g_autostandby) ) {
-   roar_usleep(((uint_least32_t)1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate);
-   ROAR_DBG("usleep(%u) = ?\n", (1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate);
+  if ( g_standby ) {
+   usleep((1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate);
   } else {
-#endif
-   clients_send_filter(sa);
-//   streams_send_filter_all(); // this currently results in deadlocks.
-   clients_send_mon(sa);
-#ifdef ROAR_HAVE_USLEEP
+   clients_send_filter(sa, pos);
+   output_buffer_flush(driver_inst, driver);
+   clients_send_mon(sa, pos);
   }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-  midi_reinit();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-  ssynth_update();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-  light_reinit();
-#endif
-
 //  output_buffer_reinit();
 
-  g_pos = ROAR_MATH_OVERFLOW_ADD(g_pos, ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels);
-  ROAR_DBG("main_loop(*): current pos: %u", g_pos);
-#if defined(MONITOR_LATENCY) && defined(ROAR_HAVE_GETTIMEOFDAY)
-  gettimeofday(&ans, NULL);
-
-  while (ans.tv_sec > try.tv_sec) {
-   ans.tv_sec--;
-   ans.tv_usec += 1000000;
-  }
-  ans.tv_usec -= try.tv_usec;
-
-  if ( loopc % 128 ) {
-   printf("\e[ucurrent latency: %.3fms  average: %.3fms   ",  ans.tv_usec                               / (double)1000,
-                                                             (ans.tv_usec+ans_3last+ans_2last+ans_1last)/ (double)4000);
-   fflush(stdout);
-  }
-
-  ans_3last = ans_2last;
-  ans_2last = ans_1last;
-  ans_1last = ans.tv_usec;
-#endif
-
-#ifdef ROAR_HAVE_GETTIMEOFDAY
-  if ( sysclocksync && !(loopc % sysclocksync) ) {
-   gettimeofday(&ans, NULL);
-
-   while (ans.tv_sec > try.tv_sec) {
-    ans.tv_sec--;
-    ans.tv_usec += 1000000;
-   }
-   ans.tv_usec -= try.tv_usec;
-
-
-   freq = (sysclocksync * ROAR_OUTPUT_BUFFER_SAMPLES) / (ans.tv_usec / 1e6);
-   printf("SYNC: f_conf=%iHz, f_real=%.2fHz diff=%+.3f%%\n", sa->rate, freq, 100*(freq/sa->rate - 1));
-
-//   memcpy(&try, &ans, sizeof(try));
-   gettimeofday(&try, NULL);
-  }
-
-  if ( sysclocksync )
-   loopc++;
-#endif
+  pos = ROAR_MATH_OVERFLOW_ADD(pos, ROAR_OUTPUT_BUFFER_SAMPLES);
+  ROAR_DBG("main_loop(*): current pos: %u", pos);
  }
 
Index: roard/memlock.c
===================================================================
--- roard/memlock.c	(revision 6052)
+++ 	(revision )
@@ -1,171 +1,0 @@
-//memlock.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#define MAX_SEGMENTS 16
-
-struct memlock {
- int level;
- void * addr;
- size_t len;
-};
-
-static struct memlock memlock_table[MAX_SEGMENTS];
-
-static volatile int memlock_table_inited = 0;
-
-static void memlock_table_init (void) {
- if ( memlock_table_inited )
-  return;
-
- memset(memlock_table, 0, sizeof(memlock_table));
-
- memlock_table_inited = 1;
-
- memlock_register(MEMLOCK_MEDIUM, memlock_table, sizeof(memlock_table));
-
- memlock_register(MEMLOCK_MEDIUM, g_clients, sizeof(g_clients));
- memlock_register(MEMLOCK_MEDIUM, g_streams, sizeof(g_streams));
-
- memlock_register(MEMLOCK_HIGH, g_listen, sizeof(g_listen));
- memlock_register(MEMLOCK_HIGH, &g_counters, sizeof(g_counters));
-}
-
-int memlock_register(int level, void * addr, size_t len) {
- int i;
-
- if ( !memlock_table_inited )
-  memlock_table_init();
-
- for (i = 0; i < MAX_SEGMENTS; i++) {
-  if ( memlock_table[i].addr == NULL ) {
-   memlock_table[i].level = level;
-   memlock_table[i].addr  = addr;
-   memlock_table[i].len   = len;
-   return 0;
-  }
- }
-
- return -1;
-}
-
-static inline int memlock_lock(struct memlock * seg) {
- return roar_mm_mlock(seg->addr, seg->len);
-}
-
-static inline int memlock_unlock(struct memlock * seg) {
- return roar_mm_munlock(seg->addr, seg->len);
-}
-
-int memlock_str2level(const char * str) {
- if ( str == NULL )
-  return -1;
-
- if ( !strcasecmp(str, "none") ) {
-  return MEMLOCK_NONE;
- } else if ( !strcasecmp(str, "low") ) {
-  return MEMLOCK_LOW;
- } else if ( !strcasecmp(str, "medium") ) {
-  return MEMLOCK_MEDIUM;
- } else if ( !strcasecmp(str, "high") ) {
-  return MEMLOCK_HIGH;
- } else if ( !strcasecmp(str, "nearlyall") ) {
-  return MEMLOCK_NEARLYALL;
- } else if ( !strcasecmp(str, "nearlyallsys") ) {
-  return MEMLOCK_NEARLYALLSYS;
- } else if ( !strcasecmp(str, "allcur") ) {
-  return MEMLOCK_ALLCUR;
- } else if ( !strcasecmp(str, "all") ) {
-  return MEMLOCK_ALL;
- } else if ( !strcasecmp(str, "default") ) {
-  return MEMLOCK_DEFAULT;
- } else {
-  return -1;
- }
-}
-
-int memlock_set_level(int level) {
- static int old_level = MEMLOCK_NONE;
- int i;
- int ret = 0;
-
- ROAR_DBG("memlock_set_level(level=%i) = ?", level);
-
- ROAR_DBG("memlock_set_level(level=%i): ask for locking level change: %i->%i", level, old_level, level);
-
- if ( !memlock_table_inited )
-  memlock_table_init();
-
- if ( level == old_level ) {
-  ROAR_DBG("memlock_set_level(level=%i) = 0 // old and new level are the same, nothing to do", level);
-  return 0;
- }
-
- // TODO: fix those #ifdefs and replace them with more general tests
- if ( level == MEMLOCK_ALL ) {
-#ifdef ROAR_HAVE_MLOCKALL
-  // if we do not have ROAR_HAVE_MLOCKALL we do not have MCL_* flags.
-  // we just try to lock all known segments as fallback.
-  old_level = MEMLOCK_ALL;
-  return roar_mm_mlockall(MCL_CURRENT|MCL_FUTURE);
-#endif
- } else if ( level == MEMLOCK_ALLCUR ) {
-#ifdef ROAR_HAVE_MLOCKALL
-  old_level = MEMLOCK_ALLCUR;
-  return roar_mm_mlockall(MCL_CURRENT);
-#endif
- } else if ( old_level == MEMLOCK_ALL || old_level == MEMLOCK_ALLCUR ) {
-#ifdef ROAR_HAVE_MUNLOCKALL
-  ret = roar_mm_munlockall();
-  // after roar_mm_munlockall() we need to re-lock all segemnts of target locking level.
-  i = old_level;
-  old_level = MEMLOCK_NONE;
-  return memlock_set_level(i);
-#endif
- }
-
- for (i = 0; i < MAX_SEGMENTS; i++) {
-  if ( memlock_table[i].addr != NULL ) {
-   ROAR_DBG("memlock_set_level(level=%i): found registerd segment %i at %p with %llu Byte length", level, i, memlock_table[i].addr, (unsigned long long int)memlock_table[i].len);
-   if ( level > old_level ) {
-    if ( memlock_table[i].level > old_level && memlock_table[i].level <= level )
-     if ( memlock_lock(&(memlock_table[i])) == -1 )
-      ret = -1;
-   } else {
-    if ( memlock_table[i].level <= old_level && memlock_table[i].level > level )
-     if ( memlock_unlock(&(memlock_table[i])) == -1 )
-      ret = -1;
-   }
-  }
- }
-
- old_level = level;
-
- ROAR_DBG("memlock_set_level(level=%i) = %i", level, ret);
- return ret;
-}
-
-//ll
Index: roard/meta.c
===================================================================
--- roard/meta.c	(revision 6052)
+++ 	(revision )
@@ -1,248 +1,0 @@
-//meta.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifdef ROAR_SUPPORT_META
-
-int stream_meta_set   (int id, int type, const char * name, const char * val) {
- int i;
- struct roar_stream_server * s = g_streams[id];
-
- roar_notify_core_emit_simple(ROAR_OE_STREAM_META_UPDATE, -1, id, ROAR_OT_STREAM, ROAR_META_MODE_SET, -1, NULL, 0);
-
- if ( s == NULL )
-  return -1;
-
- for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++)
-  if ( s->meta[i].type == type ) {
-   s->meta[i].type = ROAR_META_TYPE_NONE;
-   if ( s->meta[i].value != NULL )
-    roar_mm_free(s->meta[i].value);
-   s->meta[i].value = NULL;
-  }
-
- return stream_meta_add(id, type, name, val);
-}
-
-int stream_meta_add   (int id, int type, const char * name, const char * val) {
- int i;
- char * c;
- struct roar_stream_server * s = g_streams[id];
-
- roar_notify_core_emit_simple(ROAR_OE_STREAM_META_UPDATE, -1, id, ROAR_OT_STREAM, ROAR_META_MODE_ADD, -1, NULL, 0);
-
- if ( s == NULL )
-  return -1;
-
- for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) {
-  if ( s->meta[i].type == ROAR_META_TYPE_NONE ) {
-   s->meta[i].type = type;
-
-   if ( name == NULL ) {
-    s->meta[i].key[0] = 0;
-   } else {
-    strncpy(s->meta[i].key, name, ROAR_META_MAX_NAMELEN);
-   }
-
-   if ( (c = strdup(val)) == NULL ) {
-    s->meta[i].type = ROAR_META_TYPE_NONE;
-    s->meta[i].key[0] = 0;
-    return -1;
-   }
-
-   s->meta[i].value = c;
-
-   ROAR_DBG("stream_meta_add(id=%i, type=%i, name='%s', val='%s') = 0", id, type, name, val);
-
-   return 0;
-  }
- }
-
- return -1;
-}
-
-int stream_meta_get   (int id, int type, const char * name, char * val, size_t len) {
- size_t i;
- size_t vallen;
- struct roar_stream_server * s = g_streams[id];
-
- if ( s == NULL )
-  return -1;
-
- for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) {
-  if ( s->meta[i].type == type ) {
-   if ( name != NULL )
-    if ( strncmp(s->meta[i].key, name, ROAR_META_MAX_NAMELEN) != 0 )
-     continue;
-
-   if ( s->meta[i].value == NULL )
-    return -1;
-
-   if ( (vallen = strlen(s->meta[i].value)) > (len - 1) ) {
-    ROAR_DBG("stream_meta_get(*): val too small: need %i have %i", vallen, len);
-    return -1;
-   }
-
-   strncpy(val, s->meta[i].value, vallen);
-   val[vallen] = 0;
-
-   return 0;
-  }
- }
-
- return -1;
-}
-
-int stream_meta_list  (int id, int * types, size_t len) {
- int i, j;
- int have = 0;
- int found;
- struct roar_stream_server * s = g_streams[id];
-
- if ( s == NULL )
-  return -1;
-
- if ( len < ROAR_META_MAX_PER_STREAM ) // TODO: find a way we do not need this
-  return -1;
-
- types[0] = -1;
-
- for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) {
-  found = 0;
-  for (j = 0; j < have; j++)
-   if ( types[j] == s->meta[i].type ) {
-    found = 1;
-    break;
-   }
-
-  if ( !found )
-   types[have++] = s->meta[i].type;
- }
-
- return have;
-}
-
-int stream_meta_clear (int id) {
- int i;
- struct roar_stream_server * s = NULL;
-
- if ( id < 0 || id > ROAR_STREAMS_MAX ) {
-  ROAR_ERR("stream_meta_clear(id=%i): Can not clear meta data on stream: invalid stream ID", id);
-  return -1;
- }
-
- roar_notify_core_emit_simple(ROAR_OE_STREAM_META_UPDATE, -1, id, ROAR_OT_STREAM, ROAR_META_MODE_CLEAR, -1, NULL, 0);
-
- s = g_streams[id];
-
- if ( s == NULL )
-  return -1;
-
- for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) {
-  s->meta[i].type   = ROAR_META_TYPE_NONE;
-  if ( s->meta[i].value )
-   roar_mm_free(s->meta[i].value);
-  s->meta[i].value  = NULL;
-  s->meta[i].key[0] = 0;
- }
-
- return 0;
-}
-
-int stream_meta_finalize(int id) {
- register int dir;
- register int co, ci, i;
- struct roar_stream_server * s;
-
- roar_notify_core_emit_simple(ROAR_OE_STREAM_META_UPDATE, -1, id, ROAR_OT_STREAM, ROAR_META_MODE_FINALIZE, -1, NULL, 0);
-
- if ( streams_get_flag(id, ROAR_FLAG_META) != 1 ) // ignore non meta streams
-  return 0;
-
- dir = ROAR_STREAM(g_streams[id])->dir;
-
- if ( dir != ROAR_DIR_PLAY   && dir != ROAR_DIR_META  &&  // ignore on non input streams
-      dir != ROAR_DIR_FILTER && dir != ROAR_DIR_BIDIR &&
-      dir != ROAR_DIR_RECPLAY )
-  return 0;
-
- ROAR_DBG("stream_meta_finalize(id=%i) = ?", id);
-
- for (co = 0; co < ROAR_STREAMS_MAX; co++) {
-  if ( g_streams[co] == NULL )
-   continue;
-
-  dir = ROAR_STREAM(g_streams[co])->dir;
-
-  if ( dir != ROAR_DIR_MONITOR && dir != ROAR_DIR_FILTER &&
-       dir != ROAR_DIR_META    && dir != ROAR_DIR_BIDIR  &&
-       dir != ROAR_DIR_OUTPUT                             )
-   continue;
-
-  if ( streams_get_flag(co, ROAR_FLAG_META) != 1 )
-   continue;
-
-  ROAR_DBG("stream_meta_finalize(id=%i): found output stream: id=%i", id, co);
-  stream_meta_clear(co);
-
-  for (ci = 0; ci < ROAR_STREAMS_MAX; ci++) {
-   if ( g_streams[ci] == NULL )
-    continue;
-
-   dir = ROAR_STREAM(g_streams[ci])->dir;
-
-   if ( dir != ROAR_DIR_PLAY   && dir != ROAR_DIR_META &&
-        dir != ROAR_DIR_FILTER && dir != ROAR_DIR_BIDIR )
-    continue;
-
-   if ( streams_get_flag(ci, ROAR_FLAG_META) != 1 )
-    continue;
-
-   ROAR_DBG("stream_meta_finalize(id=%i): found input stream: id=%i", id, ci);
-
-   // ok, next we copy the date of ci to co:
-   s = g_streams[ci];
-
-   for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) {
-    if ( s->meta[i].type == ROAR_META_TYPE_NONE )
-     continue;
-
-    ROAR_DBG("stream_meta_finalize(id=%i): found meta data, copy: %i->%i", id, ci, co);
-    stream_meta_add(co, s->meta[i].type, s->meta[i].key, s->meta[i].value); // ignore errors
-   }
-  }
-
-  // ask the codec filter to update meta data:
-  ROAR_DBG("stream_meta_finalize(id=%i): Asking stream %i to update meta data", id, co);
-  streams_ctl(co, ROAR_CODECFILTER_CTL_META_UPDATE, NULL); // ignore errors...
- }
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/midi.c
===================================================================
--- roard/midi.c	(revision 6052)
+++ 	(revision )
@@ -1,1081 +1,0 @@
-//midi.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-
-// declared 'extern'
-struct midi_config midi_config;
-struct midi_state_mess g_midi_mess;
-#ifndef ROAR_WITHOUT_DCOMP_CB
-struct midi_state_cb g_midi_cb;
-#endif
-struct midi_clock g_midi_clock;
-struct midi_mixer g_midi_mixer;
-// //
-
-#if defined(ROAR_HAVE_IO_POSIX) && !defined(ROAR_TARGET_WIN32)
-#define _HAVE_CONSOLE
-#endif
-
-int midi_init_config(void) {
- midi_config.init        = 1;
- midi_config.inited      = 0;
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
- midi_config.init_cb     = 0;
- midi_config.console_dev = NULL;
-#endif
-
- return 0;
-}
-
-int midi_init (void) {
- struct roar_stream_server * ss;
- char cmap[16];
- int i;
-
- midi_config.inited = 0;
-
- if ( midi_config.init ) {
-#ifndef ROAR_WITHOUT_DCOMP_CB
-  if ( midi_config.init_cb ) {
-   if ( midi_cb_init() == -1 ) {
-    ROAR_WARN("Can not initialize MIDI subsystem component CB");
-   }
-  } else {
-   g_midi_cb.console = -1;
-  }
-#endif
-
-  if ( midi_clock_init() == -1 ) {
-   ROAR_WARN("Can not initialize MIDI subsystem component clock");
-  }
-
- }
-
- g_midi_mess.buf = NULL;
-
- if ( (g_midi_mixer.stream = add_mixer(ROAR_SUBSYS_MIDI, _MIXER_NAME("MIDI"), &ss)) == -1 ) {
-  ROAR_WARN("Can not create MIDI mixer");
- }
-
- roardsp_chanlist_init(cmap,   16, ROARDSP_CHANLIST_MAP_MIDI);
- streams_set_map(g_midi_mixer.stream, cmap, 16);
-
- ss->state = ROAR_STREAMSTATE_OLD;
-
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( g_streams[i] != NULL ) {
-   if ( streams_get_subsys(i) == ROAR_SUBSYS_MIDI ) {
-    streams_set_mixer_stream(i, g_midi_mixer.stream);
-   }
-  }
- }
-
- midi_config.inited |= MIDI_INITED_MAIN;
-
- return 0;
-}
-
-int midi_free (void) {
- if ( midi_reinit() == -1 )
-  return -1;
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
- if ( midi_cb_free() == -1 )
-  return -1;
-#endif
-
- return 0;
-}
-
-int midi_update(void) {
-
- if ( g_midi_clock.stream != -1 )
-  midi_check_bridge(g_midi_clock.stream);
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
- midi_conv_mes2ssynth();
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
- return midi_cb_update();
-#else
- return 0;
-#endif
-}
-
-int midi_reinit(void) {
-
- if ( g_midi_mess.buf != NULL )
-  roar_buffer_free(g_midi_mess.buf);
-
- g_midi_mess.buf = NULL;
-
- return 0;
-}
-
-// STREAMS:
-
-int midi_check_stream  (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
- struct roar_buffer        *   b;
- void                      * buf;
- ssize_t                     len;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("midi_check_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- if ( s->dir == ROAR_DIR_BRIDGE )
-  return midi_check_bridge(id);
-
- switch (s->info.codec) {
-  case ROAR_CODEC_MIDI:
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- if ( roar_buffer_new_data(&b, MIDI_READ_SIZE, &buf) == -1 ) {
-  ROAR_ERR("midi_check_stream(id=%i): Can not alloc buffer space!", id);
-  ROAR_DBG("midi_check_stream(id=%i) = -1", id);
-  return -1;
- }
-
- if ( (len = stream_vio_s_read(ss, buf, MIDI_READ_SIZE)) < 1 ) {
-  streams_delete(id);
-  roar_buffer_free(b);
-  return -1;
- }
-
- if ( roar_buffer_set_len(b, len) == -1 ) {
-  ROAR_WARN("midi_check_stream(id=%i): Can not set buffer size. BAD.", id);
-  roar_buffer_free(b);
-  streams_delete(id);
-  return -1;
- }
-
- if ( stream_add_buffer(id, &b) == -1 ) {
-  roar_buffer_free(b);
-  streams_delete(id);
-  return -1;
- }
-
- switch (s->info.codec) {
-  case ROAR_CODEC_MIDI:
-    return midi_conv_midi2mes(id);
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- ROAR_DBG("midi_check_stream(id=%i) = 0", id);
- return 0;
-}
-
-int midi_send_stream   (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("midi_send_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- switch (s->info.codec) {
-  case ROAR_CODEC_MIDI:
-    return midi_conv_mes2midi(id);
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- return 0;
-}
-
-#if 1
-static int _cache_to_mes(struct midi_message * mes, unsigned char * data, size_t len,
-                         int id, struct roar_stream_server * ss) {
- unsigned char type = *data;
-
- ROAR_DBG("_cache_to_mes(*): type=0x%.2X", (unsigned int)type);
-
- if (type == MIDI_TYPE_CLOCK_TICK || type == MIDI_TYPE_CLOCK_START || type == MIDI_TYPE_CLOCK_STOP ) {
-  if ( len != 1 )
-   return -1;
-
-  mes->type = type;
-
-  if ( type == MIDI_TYPE_CLOCK_TICK ) {
-// TODO:
-   ROAR_STREAM(ss)->pos = ROAR_MATH_OVERFLOW_ADD(ROAR_STREAM(ss)->pos, 1);
-  }
- } else {
-  mes->type    = type & 0xF0;
-  mes->channel = type & 0x0F;
-
-  switch (mes->type) {
-   case MIDI_TYPE_NOTE_ON:
-   case MIDI_TYPE_NOTE_OFF:
-     if ( len != 3 )
-      return -1;
-     roar_midi_note_from_midiid(&(mes->d.note), data[1]);
-
-     // if velocity is zero we have a NOTE OFF event
-     if ( data[2] == 0 )
-      mes->type = MIDI_TYPE_NOTE_OFF;
-   case MIDI_TYPE_PA:
-   case MIDI_TYPE_CONTROLER:
-     mes->kk = data[1];
-     mes->vv = data[2];
-    break;
-   case MIDI_TYPE_PROGRAM:
-   case MIDI_TYPE_MA:
-     if ( len != 2 )
-      return -1;
-     mes->vv = data[1];
-    break;
-   case MIDI_TYPE_PB:
-   case MIDI_TYPE_SYSEX:
-     ROAR_WARN("_cache_to_mes(id=%i): Message of Type 0x%.2X (PB or SysEx) not yet supported", id, (unsigned int)type);
-     return -1;
-    break;
-  }
- }
-
- switch (mes->type) {
-  case MIDI_TYPE_CONTROLER:
-    switch (mes->kk) {
-     case MIDI_CCE_MAIN_VOL:
-       if ( (516U * (unsigned int)mes->vv) > 65100 ) { // max volume
-        ss->mixer.mixer[mes->channel] = 65535;
-       } else {
-        ss->mixer.mixer[mes->channel] = 516 * mes->vv;
-       }
-      break;
-    }
-   break;
- }
-
- ROAR_DBG("_cache_to_mes(*) = 0");
- return 0;
-}
-
-int midi_conv_midi2mes (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
- size_t have;
- void * bufdata;
- unsigned char * data;
- unsigned char   cache[3];
- size_t cachepos = 0;
- int sync = 1;
- struct roar_buffer        * buf = NULL;
- struct midi_message       * mes = NULL;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("midi_conv_midi2mes(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- while (ss->buffer != NULL) {
-  if ( roar_buffer_get_len(ss->buffer, &have) == -1 )
-   return -1;
-  if ( roar_buffer_get_data(ss->buffer, &bufdata) == -1 )
-   return -1;
-  data = bufdata;
-
-  while (have) {
-   if ( !sync ) {
-    if ( *data & 0x80 ) {
-     cachepos = 0;
-     sync = 1;
-    } else {
-     data++;
-     have--;
-     continue;
-    }
-   }
-
-   if ( (*data & 0x80) && cachepos != 0 ) {
-    // submit cache.
-
-    if ( midi_new_bufmes(&buf, &mes) == -1 ) {
-     // this is bad.
-     // TODO: handle better.
-     return -1;
-    }
-
-    if ( _cache_to_mes(mes, cache, cachepos, id, ss) == -1 ) {
-     ROAR_WARN("midi_conv_midi2mes(id=%i): Message can not be parsed.", id);
-     roar_buffer_free(buf);
-    } else {
-     midi_add_buf(id, &buf); // FIXME: don't we need error handling here?
-    }
-
-    cachepos = 0;
-   } else if ( cachepos == sizeof(cache) ) {
-    // lost sync.
-    sync = 0;
-    continue;
-   }
-
-   ROAR_DBG("midi_conv_midi2mes(id=%i): cache[%u] = 0x%.2X", id, (unsigned int)cachepos, (unsigned int)*data);
-   cache[cachepos++] = *data;
-   data++;
-   have--;
-  }
-
-  if ( roar_buffer_next(&(ss->buffer)) == -1 ) {
-   ROAR_WARN("midi_conv_midi2mes(id=%i): Can not move to next buffer segment. BAD.", id);
-   break;
-  }
- }
-
- if ( cachepos ) {
-  if ( midi_new_bufmes(&buf, &mes) == -1 ) {
-   // this is bad.
-   // TODO: handle better.
-   return -1;
-  }
-
-  if ( _cache_to_mes(mes, cache, cachepos, id, ss) == -1 ) {
-   roar_buffer_free(buf);
-  } else {
-   midi_add_buf(id, &buf); // FIXME: don't we need error handling here?
-   cachepos = 0;
-  }
- }
-
- if ( cachepos ) {
-  if ( roar_buffer_new_data(&buf, cachepos, &bufdata) == -1 )
-   return -1;
-
-  memcpy(bufdata, cache, cachepos);
-
-  ss->buffer = buf;
- }
-
- return 0;
-}
-#else
-int midi_conv_midi2mes (int id) {
- void          * bufdata;
- unsigned char * data;
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
- struct roar_buffer        * buf = NULL;
- struct midi_message       * mes = NULL;
- size_t need = 0, have = 0, last_have = 0, old_have = 0;
- int alive = 1;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("midi_conv_midi2mes(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- while (ss->buffer != NULL && alive) {
-  ROAR_DBG("midi_conv_midi2mes(id=%i): ss->buffer=%p, alive=%i", id, ss->buffer, alive);
-
-  if ( roar_buffer_get_data(ss->buffer, &bufdata) == -1 ) {
-   alive = 0;
-   continue;
-  }
-
-  data = bufdata;
-
-  if ( roar_buffer_get_len(ss->buffer, &have) == -1 ) {
-   alive = 0;
-   continue;
-  }
-  old_have = have;
-
-  while (have && alive) {
-   ROAR_DBG("midi_conv_midi2mes(id=%i): have=%llu, alive=%i", id, (long long unsigned int)have, alive);
-
-   if ( *data & 0x80 ) {
-    if ( buf != NULL ) {
-     midi_add_buf(id, buf);
-     buf = NULL;
-    }
-
-    last_have = have;
-
-    need = 0;
-    if ( midi_new_bufmes(&buf, &mes) == -1 ) {
-     alive = 0;
-     continue;
-    }
-
-    if (*data == MIDI_TYPE_CLOCK_TICK || *data == MIDI_TYPE_CLOCK_START || *data == MIDI_TYPE_CLOCK_STOP ) {
-     mes->type = *data;
-
-     if ( *data == MIDI_TYPE_CLOCK_TICK ) {
-      s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1);
-     }
-    } else {
-     mes->type    = *data & 0xF0;
-     mes->channel = *data & 0x0F;
-     switch (*data & 0xF0) {
-      case MIDI_TYPE_NOTE_ON:
-      case MIDI_TYPE_NOTE_OFF:
-        need = 2;
-       break;
-      case MIDI_TYPE_PA:
-        need = 2;
-       break;
-      case MIDI_TYPE_CONTROLER:
-        need = 2;
-       break;
-      case MIDI_TYPE_PROGRAM:
-        need = 1;
-       break;
-      case MIDI_TYPE_MA:
-        need = 1;
-       break;
-      case MIDI_TYPE_PB:
-      case MIDI_TYPE_SYSEX:
-        need = 1;
-       break;
-     }
-    }
-
-   } else {
-
-    if ( mes == NULL ) {
-     ROAR_WARN("midi_conv_midi2mes(id=%i): Lost sync.", id);
-     data++;
-     have--;
-     continue;
-    }
-
-    switch (mes->type) {
-      case MIDI_TYPE_NOTE_ON:
-      case MIDI_TYPE_NOTE_OFF:
-       if ( need == 2 ) {
-        roar_midi_note_from_midiid(&(mes->d.note), *data);
-
-        // if velocity is zero we have a NOTE OFF event
-        if ( data[1] == 0 )
-         mes->type = MIDI_TYPE_NOTE_OFF;
-       }
-      case MIDI_TYPE_PA:
-      case MIDI_TYPE_CONTROLER:
-        if ( need == 2 ) {
-         mes->kk = *data;
-        } else {
-         mes->vv = *data;
-        }
-       break;
-      case MIDI_TYPE_PROGRAM:
-      case MIDI_TYPE_MA:
-        mes->vv = *data;
-       break;
-      case MIDI_TYPE_PB:
-      case MIDI_TYPE_SYSEX:
-        ROAR_WARN("midi_conv_midi2mes(id=%i): Message of Type 0x%.2X (PB or SysEx) not yet supported", id, mes->type);
-       break;
-    }
-
-    if ( need )
-     need--;
-
-    if ( !need ) {
-     switch (mes->type) {
-      case MIDI_TYPE_CONTROLER:
-       switch (mes->kk) {
-        case MIDI_CCE_MAIN_VOL:
-         if ( 516 * mes->vv > 65100 ) { // max volume
-          ss->mixer.mixer[mes->channel] = 65535;
-         } else {
-          ss->mixer.mixer[mes->channel] = 516 * mes->vv;
-         }
-         break;
-       }
-      break;
-     }
-    }
-
-   }
-   data++;
-   have--;
-  }
-
-  if ( need ) {
-   ROAR_DBG("midi_conv_midi2mes(id=%i) = ?", id);
-   if ( roar_buffer_set_offset(ss->buffer, old_have - last_have) == -1 ) {
-    ROAR_ERR("midi_conv_midi2mes(*): FIXME: BUG!!! Need to restore buffer here with corrected length");
-   }
-  } else if ( !have ) {
-   roar_buffer_next(&(ss->buffer));
-  }
-
-  if ( need && buf != NULL ) {
-   roar_buffer_free(buf);
-   buf = NULL;
-  } else if ( buf != NULL ) {
-   midi_add_buf(id, buf);
-   buf = NULL;
-  }
- }
-
- return 0;
-}
-#endif
-
-#define _nb  len++; *(d++)
-int midi_conv_mes2midi (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
- struct roar_buffer        * buf = g_midi_mess.buf;
- struct midi_message       * mes = NULL;
- void                      * bufdata;
- unsigned char               data[3];
- unsigned char             * d;
- int                         len;
- int                         send_clock;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("midi_conv_mes2midi(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- send_clock = streams_get_flag(id, ROAR_FLAG_SYNC);
-
- if ( roar_buffer_ref(buf) == -1 )
-  return -1;
-
- roar_buffer_foreach(buf) {
-  if ( roar_buffer_get_data(buf, &bufdata) == -1 ) {
-   return -1;
-  }
-
-  mes = bufdata;
-
-  if (mes->type == MIDI_TYPE_CLOCK_TICK || mes->type == MIDI_TYPE_CLOCK_START || mes->type == MIDI_TYPE_CLOCK_STOP ) {
-   if ( send_clock ) {
-    if ( stream_vio_s_write(ss, &(mes->type), 1) != 1 ) {
-     streams_delete(id);
-     return -1;
-    }
-   }
-
-   if ( mes->type == MIDI_TYPE_CLOCK_TICK ) {
-    s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, 1);
-   }
-  } else {
-   len = 0;
-   d   = data;
-
-   _nb = (mes->type & 0xF0) | (mes->channel & 0x0F);
-
-   switch (mes->type) {
-    case MIDI_TYPE_CONTROLER:
-      switch (mes->kk) {
-       case MIDI_CCE_MAIN_VOL:
-         if ( 516U * (unsigned int)mes->vv > 65100 ) { // max volume
-          ss->mixer.mixer[mes->channel] = 65535;
-         } else {
-          ss->mixer.mixer[mes->channel] = 516 * mes->vv;
-         }
-        break;
-      }
-    case MIDI_TYPE_NOTE_ON:
-    case MIDI_TYPE_NOTE_OFF:
-    case MIDI_TYPE_PA:
-      _nb = mes->kk;
-      _nb = mes->vv;
-     break;
-    case MIDI_TYPE_PROGRAM:
-    case MIDI_TYPE_MA:
-      _nb = mes->vv;
-     break;
-    case MIDI_TYPE_PB:
-    case MIDI_TYPE_SYSEX:
-     break;
-   }
-
-   if ( stream_vio_s_write(ss, data, len) != len ) {
-    streams_delete(id);
-    return -1;
-   }
-  }
- }
-
- return 0;
-}
-#undef _nb
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-int midi_conv_mes2ssynth(void) {
- struct roar_buffer        * buf = g_midi_mess.buf;
- struct midi_message       * mes = NULL;
- void                      * bufdata;
-
- if ( roar_buffer_ref(g_midi_mess.buf) == -1 )
-  return -1;
-
- roar_buffer_foreach(buf) {
-  if ( roar_buffer_get_data(buf, &bufdata) == -1 ) {
-   return -1;
-  }
-
-  mes = bufdata;
-
-  if ( ssynth_eval_message(mes) == -1 )
-   return -1;
- }
-
- return 0;
-}
-#endif
-
-int midi_new_bufmes    (struct roar_buffer ** buf, struct midi_message ** mes) {
- if ( buf == NULL || mes == NULL )
-  return -1;
-
- *buf = (void*)(*mes = NULL);
-
- if ( roar_buffer_new_data(buf, sizeof(struct midi_message), (void**)mes) == -1 ) {
-  *buf = (void*)(*mes = NULL);
-  return -1;
- }
-
- memset((void*)*mes, 0, sizeof(struct midi_message));
-
- (*mes)->type = MIDI_TYPE_NONE;
-
- return 0;
-}
-
-int midi_add_buf       (int id, struct roar_buffer ** buf) {
-#ifdef DEBUG
- struct midi_message * mes;
- void * bufdata;
-#endif
-
- if ( id == -1 || buf == NULL || *buf == NULL )
-  return -1;
-
-#ifdef DEBUG
- if ( roar_buffer_get_data(*buf, &bufdata) == -1 )
-  return -1;
-
- mes = bufdata;
-
- ROAR_DBG("midi_add_buf(id=%i, buf=%p) = ?", id, buf);
- ROAR_DBG("midi_add_buf(*): MIDI Message of Type 0x%.2X", mes->type);
- ROAR_DBG("midi_add_buf(*): Channel: %i", mes->channel);
- ROAR_DBG("midi_add_buf(*): flags=0x%.2X", mes->flags);
- ROAR_DBG("midi_add_buf(*): kk=0x%.2X, vv=0x%.2X", mes->kk, mes->vv);
-#endif
-
- if ( g_midi_mess.buf == NULL ) {
-  g_midi_mess.buf = *buf;
- } else {
-  if ( roar_buffer_moveinto(g_midi_mess.buf, buf) == -1 ) {
-   ROAR_DBG("midi_add_buf(*) = -1");
-   return -1;
-  }
- }
-
- ROAR_DBG("midi_add_buf(*) = 0");
- return 0;
-}
-
-// bridges:
-int midi_check_bridge  (int id) {
-
- ROAR_DBG("midi_check_bridge(id=%i) = ?", id);
-
- if ( id == g_midi_clock.stream ) {
-  midi_clock_tick();
-
-  return 0;
- }
-
- return -1;
-}
-
-// clock:
-
-int midi_clock_init (void) {
- struct roar_stream * s;
- struct roar_stream_server * ss;
-
- if ( (g_midi_clock.stream = streams_new()) == -1 ) {
-  ROAR_WARN("Error while initializing MIDI subsystem component clock");
-  return -1;
- }
-
- client_stream_add(g_self_client, g_midi_clock.stream);
-
- midi_vio_set_dummy(g_midi_clock.stream);
-
- streams_get(g_midi_clock.stream, &ss);
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- s->pos_rel_id    =  g_midi_clock.stream;
-
- s->info.codec    =  ROAR_CODEC_MIDI;
- ss->codec_orgi   =  ROAR_CODEC_MIDI;
-
- s->info.channels = 1; // we have only one channel, ticking on channel 0
- s->info.rate     = ROAR_MIDI_TICKS_PER_BEAT; // one beat per sec
- s->info.bits     = ROAR_MIDI_BITS;
-
- if ( streams_set_dir(g_midi_clock.stream, ROAR_DIR_BRIDGE, 1) == -1 ) {
-  ROAR_WARN("Error while initializing MIDI subsystem component clock");
-  return -1;
- }
-
- streams_set_name(g_midi_clock.stream, "MIDI Clock");
-
- streams_set_flag(g_midi_clock.stream, ROAR_FLAG_PRIMARY);
- streams_set_flag(g_midi_clock.stream, ROAR_FLAG_SYNC);
-
- midi_clock_set_bph(3600); // one beat per sec
-
- ss->state = ROAR_STREAMSTATE_NEW;
-
- midi_config.inited |= MIDI_INITED_CLOCK;
-
- return 0;
-}
-
-int midi_clock_set_bph (uint_least32_t bph) {
- uint_least32_t sph = g_sa->rate/2 * 75 * g_sa->channels; // samples per houre
-
- g_midi_clock.bph  = bph;
-
- g_midi_clock.spt  = sph/bph;
-
- g_midi_clock.nt   = ROAR_MATH_OVERFLOW_ADD(g_pos, g_midi_clock.spt);
-
- return 0;
-}
-
-int midi_clock_tick (void) {
- struct roar_buffer  * buf;
- struct midi_message * mes;
- struct roar_stream_server * ss;
-#ifdef DEBUG
- unsigned int diff;
-#endif
-
- if ( streams_get(g_midi_clock.stream, &ss) == -1 ) {
-  ROAR_ERR("midi_clock_tick(void): Something very BAD happend: can not get stream object of my own stream!");
-  g_midi_clock.stream = -1;
-  ROAR_WARN("midi_clock_tick(void): Disabled MIDI Clock");
-  return -1;
- }
-
- // the strange expr at the end is to avoid warp around bugs.
- while ( g_pos >= g_midi_clock.nt && !(g_pos > (uint32_t)4294900000LU && g_midi_clock.nt < (uint32_t)1000LU) ) {
-#ifdef DEBUG
-  diff = g_pos - g_midi_clock.nt;
-  ROAR_DBG("midi_clock_tick(void): g_pos is %u samples (%5.2f%%) after of nt.", diff, (float)diff/g_midi_clock.spt);
-#endif
-
-  g_midi_clock.nt   = ROAR_MATH_OVERFLOW_ADD(g_midi_clock.nt, g_midi_clock.spt);
-
-  if ( streams_get_flag(g_midi_clock.stream, ROAR_FLAG_SYNC) ) {
-   ROAR_DBG("midi_clock_tick(void): TICK! (nt=%lu)", (unsigned long int)g_midi_clock.nt);
-   if ( midi_new_bufmes(&buf, &mes) == -1 ) {
-    ROAR_ERR("midi_clock_tick(void): Can not create Clock-Tick-Message");
-   }
-
-   mes->type = MIDI_TYPE_CLOCK_TICK;
-
-   if ( midi_add_buf(g_midi_clock.stream, &buf) == -1 ) {
-    ROAR_ERR("midi_clock_tick(void): Can not add Clock-Tick-Message");
-    roar_buffer_free(buf);
-    return -1;
-   }
-
-   ROAR_STREAM(ss)->pos = ROAR_MATH_OVERFLOW_ADD(ROAR_STREAM(ss)->pos, 1);
-   ss->state = ROAR_STREAMSTATE_OLD;
-  } else {
-   ROAR_DBG("midi_clock_tick(void): silent tick. (nt=%lu)", (unsigned long int)g_midi_clock.nt);
-  }
- }
-
- return 0;
-}
-
-// CB:
-
-#ifndef ROAR_WITHOUT_DCOMP_CB
-int midi_cb_init (void) {
-#ifdef _HAVE_CONSOLE
- struct roar_stream * s;
- struct roar_stream_server * ss;
- int i;
- char * files[] = {
-                   "/NX",
-                   "/dev/roarconsole",
-                   "/dev/console",
-#ifdef __linux__
-                   "/dev/tty0",
-                   "/dev/vc/0",
-#endif
-                   NULL
-                  };
-
- g_midi_cb.console  = -1;
- g_midi_cb.stream   = -1;
- g_midi_cb.stoptime =  0;
- g_midi_cb.playing  =  0;
-
- if ( midi_config.console_dev != NULL ) {
-  files[0] = midi_config.console_dev;
- }
-
- for (i = 0; files[i] != NULL; i++) {
-  if ( (g_midi_cb.console = open(files[i], O_WRONLY|O_NOCTTY, 0)) != -1 )
-   break;
- }
-
- if ( g_midi_cb.console == -1 )
-  return -1;
-
- if ( (g_midi_cb.stream = streams_new()) == -1 ) {
-  ROAR_WARN("Error while initializing MIDI subsystem component CB");
-  midi_cb_free();
-  return -1;
- }
-
- client_stream_add(g_self_client, g_midi_clock.stream);
-
- midi_vio_set_dummy(g_midi_cb.stream);
-
- streams_get(g_midi_cb.stream, &ss);
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- s->pos_rel_id    = -1;
-
- s->info.codec    =  0;
- ss->codec_orgi   =  0;
-
- s->info.channels =  1;
- s->info.rate     = 1193180;
- s->info.bits     =  8;
-
- if ( streams_set_dir(g_midi_cb.stream, ROAR_DIR_BRIDGE, 1) == -1 ) {
-  ROAR_WARN("Error while initializing MIDI subsystem component CB");
-  midi_cb_free();
-  return -1;
- }
-
- streams_set_name(g_midi_cb.stream, "Console speaker bridge");
-
- streams_set_flag(g_midi_cb.stream, ROAR_FLAG_OUTPUT);
- streams_set_flag(g_midi_cb.stream, ROAR_FLAG_PRIMARY);
- streams_set_flag(g_midi_cb.stream, ROAR_FLAG_HWMIXER);
- streams_set_flag(g_midi_cb.stream, ROAR_FLAG_MUTE);
-
- midi_config.inited |= MIDI_INITED_CB;
-
- return 0;
-#else
- g_midi_cb.console  = -1;
- g_midi_cb.stream   = -1;
-
- return -1;
-#endif
-}
-
-int midi_cb_free (void) {
-#ifdef _HAVE_CONSOLE
-
- midi_cb_stop();
-
- if ( g_midi_cb.stream != -1 )
-  streams_delete(g_midi_cb.stream);
-
- if ( g_midi_cb.console != -1 )
-  close(g_midi_cb.console);
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int midi_cb_play(float t, float freq, int override) {
- float samples_per_sec /* S/s */ = g_sa->rate * g_sa->channels;
-
-/*
-#define MIDI_CB_NOOVERRIDE 0
-#define MIDI_CB_OVERRIDE   1
-*/
- if ( g_midi_cb.playing && override != MIDI_CB_OVERRIDE )
-  return -1;
-
- g_midi_cb.stoptime = ROAR_MATH_OVERFLOW_ADD(g_pos, samples_per_sec*t);
- midi_cb_start(freq);
-
- return 0;
-}
-
-int midi_cb_update (void) {
-
- if ( !streams_get_flag(g_midi_cb.stream, ROAR_FLAG_MUTE) ) {
-  if ( midi_cb_readbuf() == -1 )
-   return -1;
- } else if ( g_midi_cb.playing ) {
-  midi_cb_stop();
- }
-
- if ( !g_midi_cb.playing )
-  return 0;
-
-/*
- if ( g_midi_cb.stoptime <= g_pos )
-  midi_cb_stop();
-*/
-
- ROAR_DBG("midi_cb_update(void) = ?");
-
- return 0;
-}
-
-int midi_cb_start(float freq) {
-// On linux this uses ioctl KIOCSOUND
-#ifdef __linux__
- if ( g_midi_cb.console == -1 )
-  return -1;
-
- if ( ioctl(g_midi_cb.console, KIOCSOUND, freq == 0 ? 0 : (int)(1193180.0/freq)) == -1 )
-  return -1;
-
- g_midi_cb.playing = 1;
-
- return 0;
-#else
- return -1;
-#endif
-}
-
-int midi_cb_stop (void) {
-#ifdef __linux__
- int ret;
-
- ret = midi_cb_start(0);
- g_midi_cb.playing = 0;
-
- return ret;
-#else
- return -1;
-#endif
-}
-
-int midi_cb_readbuf(void) {
- struct roar_buffer        * buf = g_midi_mess.buf;
- struct midi_message       * mes = NULL;
- void                      * bufdata;
-
- ROAR_DBG("midi_cb_readbuf(void) = ?");
-
- roar_buffer_foreach(buf) {
-  ROAR_DBG("midi_cb_readbuf(void): buf=%p", buf);
-
-  if ( roar_buffer_get_data(buf, &bufdata) == -1 ) {
-   return -1;
-  }
-
-  mes = bufdata;
-
-  switch (mes->type) {
-   case MIDI_TYPE_NOTE_ON:
-     midi_cb_start(mes->d.note.freq);
-    break;
-   case MIDI_TYPE_NOTE_OFF:
-     midi_cb_stop();
-    break;
-   case MIDI_TYPE_CONTROLER:
-     if ( mes->kk == MIDI_CCE_ALL_NOTE_OFF ) /* all note off */
-      midi_cb_stop();
-    break;
-  }
- }
-
- return 0;
-}
-#endif
-
-// VIO:
-
-static int midi_vio_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- if ( cmd == ROAR_VIO_CTL_NONBLOCK )
-  return 0;
- return -1;
-}
-
-static int     midi_vio_ok(struct roar_vio_calls * vio, ...) {
- return 0;
-}
-
-int     midi_vio_set_dummy(int stream) {
- struct roar_stream_server * ss;
-
- if ( streams_get(stream, &ss) == -1 )
-  return -1;
-
- ss->vio.read     = NULL;
- ss->vio.write    = NULL;
- ss->vio.lseek    = NULL;
- ss->vio.sync     = (int (*)(struct roar_vio_calls * vio))midi_vio_ok;
- ss->vio.ctl      = midi_vio_ctl;
- ss->vio.close    = (int (*)(struct roar_vio_calls * vio))midi_vio_ok;
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/mixer.c
===================================================================
--- roard/mixer.c	(revision 6052)
+++ roard/mixer.c	(revision 0)
@@ -1,88 +1,104 @@
 //mixer.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-int need_vol_change  (int channels, struct roar_mixer_settings * set) {
- int i;
+int mix_clients (void * output, int bits, void ** input, int samples) {
+ if ( bits == 8 ) {
+  return mix_clients_8bit(output, input, samples);
+ } else if ( bits == 16 ) {
+  return mix_clients_16bit(output, input, samples);
+ } else if ( bits == 24 ) {
+  return mix_clients_24bit(output, input, samples);
+ } else if ( bits == 32 ) {
+  return mix_clients_32bit(output, input, samples);
+ } else {
+  return -1;
+ }
+}
 
- if ( set == NULL || channels < 1 || channels > ROAR_MAX_CHANNELS )
-  return -1;
+int mix_clients_8bit (void * output, void ** input, int samples) {
+ int i, s;
+ int c;
 
- if ( set->rpg_mul != set->rpg_div )
-  return 1;
+ for (s = 0; s < samples; s++) {
+  c = 0;
 
- for (i = 0; i < channels; i++)
-  if ( set->mixer[i] != set->scale )
-   return 1;
+  for (i = 0; input[i] != NULL; i++)
+   c += ((char**)input)[i][s];
+
+  if ( c > 127 )
+   c = 127;
+  else if ( c < -128 )
+   c = -128;
+  ((char*)output)[s] = (char)c;
+ }
 
  return 0;
 }
 
-#define _err() streams_delete(stream); return -1
-int add_mixer (int subsys, char * name, struct roar_stream_server ** ss_ptr) {
- struct roar_stream_server * ss;
- int stream;
+int mix_clients_16bit (void * output, void ** input, int samples) {
+ int i, s;
+ int c;
+ int16_t ** in  = (int16_t**) input;
+ int16_t *  out = output;
 
- if ( (stream = streams_new()) == -1 )
+#ifdef DEBUG
+ for (i = 0; input[i] != NULL; i++)
+  ROAR_DBG("mix_clients_16bit(*): input[%i] = %p", i, input[i]);
+#endif
+
+/*
+ if ( input[0] != NULL )
+  write(1, input[0], samples*2);
+*/
+
+/*
+ if ( input[0] != NULL ) {
+  memcpy(output, input[0], samples*2);
   return -1;
+ }
+*/
 
- if ( streams_get(stream, &ss) == -1 ) {
-  _err();
+ for (s = 0; s < samples; s++) {
+  c = 0;
+  for (i = 0; input[i] != NULL; i++)
+   c += in[i][s];
+
+  if ( c > 32767 )
+   c = 32767;
+  else if ( c < -32768 )
+   c = -32768;
+
+  out[s] = c;
  }
 
- if ( streams_set_name(stream, name) == -1 ) {
-  _err();
+ return 0;
+}
+
+int mix_clients_24bit (void * output, void ** input, int samples) {
+ return -1;
+}
+
+int mix_clients_32bit (void * output, void ** input, int samples) {
+/*
+ int i, s;
+ int c;
+
+ for (s = 0; s < samples; s++) {
+  c = 0;
+
+  for (i = 0; input[i]; i++)
+   c += ((int**)input)[i][s];
+
+  if ( c > 127 )
+   c = 127;
+  else if ( c < -128 )
+   c = -128;
+  ((int*)output)[s] = (char)c;
  }
 
- if ( client_stream_add(g_self_client, stream) == -1 ) {
-  _err();
- }
-
- if ( streams_set_dir(stream, ROAR_DIR_MIXING, 1) == -1 ) {
-  _err();
- }
-
- // the mixers are the most sync thing we have...
- if ( streams_set_rawflag(stream, ROAR_FLAG_SYNC) == -1 ) {
-  _err();
- }
-
- if ( streams_set_flag(stream, ROAR_FLAG_IMMUTABLE) == -1 ) {
-  _err();
- }
-
- switch (subsys) {
-  case ROAR_SUBSYS_WAVEFORM:
-    ss->delay = _MEGA/ROAR_OUTPUT_CFREQ;
-   break;
- }
-
- if ( ss_ptr != NULL )
-  *ss_ptr = ss;
-
- return stream;
+ return 0;
+*/
+ return 1;
 }
 
Index: roard/network.c
===================================================================
--- roard/network.c	(revision 6052)
+++ roard/network.c	(revision 0)
@@ -1,107 +1,49 @@
 //network.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-#ifdef ROAR_SUPPORT_LISTEN
+int net_check_listen  (void) {
+ int r;
+ fd_set sl;
+ struct timeval tv;
 
-#ifdef ROAR_BROKEN_PEERCRED
-#undef SO_PEERCRED
-#endif
+ FD_ZERO(&sl);
+ FD_SET(g_listen_socket, &sl);
 
-#ifdef ROAR_HAVE_SELECT
-#define _CAN_OPERATE
-#endif
+ tv.tv_sec  = 0;
+ tv.tv_usec = 1;
 
-int net_check_listen  (void) {
- struct roar_vio_selecttv rtv;
- struct roar_vio_select   sv[ROAR_MAX_LISTEN_SOCKETS];
- size_t num = 0;
- ssize_t ret;
- size_t i;
-
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-  if ( g_listen[i].used ) {
-   ROAR_VIO_SELECT_SETVIO(&(sv[num]), &(g_listen[i].sock), ROAR_VIO_SELECT_READ);
-   sv[num].ud.si = i;
-   num++;
-  }
+ if ((r = select(g_listen_socket + 1, &sl, NULL, NULL, &tv)) > 0) {
+  ROAR_DBG("net_check_listen(void): We have a connection!");
+  return net_get_new_client();
  }
 
- if ( num == 0 )
-  return 0;
-
- rtv.sec  = 0;
- rtv.nsec = 1000;
-
- if ( (ret = roar_vio_select(sv, num, &rtv, NULL)) > 0 ) {
-  for (i = 0; i < num; i++) {
-   if ( sv[i].eventsa & ROAR_VIO_SELECT_READ ) {
-    if ( net_get_new_client(&(g_listen[sv[i].ud.si])) == -1 )
-     return -1;
-   }
-  }
- }
-
- return ret;
+ return r;
 }
 
-int net_get_new_client (struct roard_listen * lsock) {
+int net_get_new_client (void) {
  int fh;
- int socket;
- struct roar_vio_calls    vio;
- struct sockaddr_storage  addr;
- socklen_t                addrlen = sizeof(addr);
+ int client;
 
- if ( roar_vio_ctl(&(lsock->sock), ROAR_VIO_CTL_GET_FH, &socket) == -1 ) {
-  // next is needed for winsock:
-  if ( roar_vio_ctl(&(lsock->sock), ROAR_VIO_CTL_GET_SELECT_FH, &socket) == -1 ) {
-   ROAR_DBG("net_get_new_client(void) = -1 // can not find any acceptable socket to accept() on");
-   return -1;
-  }
- }
-
- fh = accept(socket, (struct sockaddr*)&addr, &addrlen);
+ fh = accept(g_listen_socket, NULL, NULL);
 
  ROAR_DBG("net_get_new_client(void): fh = %i", fh);
 
- if ( fh == -1 )
-  return -1;
+ client = clients_new();
 
- if ( clients_new_from_fh2(fh, lsock->proto, ROAR_BYTEORDER_NETWORK, 1, lsock, (struct sockaddr*)&addr, addrlen) == -1 ) {
-  if ( roar_vio_open_fh_socket(&vio, fh) == -1 ) {
-   close(fh);
-   return -1;
-  }
-  roar_vio_close(&vio);
+ if ( clients_set_fh(client, fh) == -1 ) {
+  ROAR_ERR("net_get_new_client(void): Can not set client's fh");
+
+  clients_delete(client);
+  close(fh);
+
+  ROAR_DBG("net_get_new_client(void) = -1");
   return -1;
  }
+
+// close(fh);
 
  return 0;
 }
 
-#endif
-
 //ll
Index: roard/output.c
===================================================================
--- roard/output.c	(revision 6052)
+++ roard/output.c	(revision 0)
@@ -1,38 +1,19 @@
 //output.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-// stuff we defined 'extern'
-void         * g_output_buffer     = NULL;
-void         * g_input_buffer      = NULL;
-size_t         g_output_buffer_len = 0;
-// //
+/*
+void         * g_output_buffer;
+unsigned int   g_output_buffer_len;
+*/
 
 int output_buffer_init   (struct roar_audio_info * info) {
- size_t   size;
+ size_t   size; // = ROAR_OUTPUT_BUFFER_SAMPLES;
  void   * buf;
+
+/*
+ size *= info->channels;
+ size *= info->bits / 8;
+*/
 
  size = ROAR_OUTPUT_CALC_OUTBUFSIZE(info);
@@ -40,5 +21,5 @@
  ROAR_DBG("output_buffer_init(*): output buffer size is %i", size);
 
- if ( (buf = roar_mm_malloc(size)) == NULL )
+ if ( (buf = malloc(size)) == NULL )
   return -1;
 
@@ -46,17 +27,5 @@
  g_output_buffer_len = size;
 
- if ( (buf = roar_mm_malloc(size)) == NULL ) {
-  g_output_buffer     = NULL;
-  g_output_buffer_len = 0;
-  roar_mm_free(g_output_buffer);
-  return -1;
- }
-
- g_input_buffer = buf;
-
  ROAR_DBG("output_buffer_init(*): output buffer is at %p", buf);
-
- memlock_register(MEMLOCK_LOW, g_output_buffer, size);
- memlock_register(MEMLOCK_LOW, g_input_buffer,  size);
 
  output_buffer_reinit();
@@ -76,12 +45,8 @@
  ROAR_DBG("output_buffer_init(*): freeing output buffer at %p", g_output_buffer);
 
- if ( g_output_buffer != NULL )
-  roar_mm_free(g_output_buffer);
-
- if ( g_input_buffer != NULL )
-  roar_mm_free(g_input_buffer);
+ if ( g_output_buffer )
+  free(g_output_buffer);
 
  g_output_buffer     = NULL;
- g_input_buffer      = NULL;
  g_output_buffer_len = 0;
 
@@ -89,436 +54,8 @@
 }
 
+int output_buffer_flush  (DRIVER_USERDATA_T inst, int driver) {
+ ROAR_DBG("output_buffer_init(*): flushing output buffer");
 
-
-
-
-
-#ifdef ROAR_DRIVER_DEFAULT
-int output_add_default (char * drv, char * dev, char * opts, int prim, int count) {
- return output_add(drv, dev, opts, prim, count);
-}
-#else
-int output_add_default (char * drv, char * dev, char * opts, int prim, int count) {
- char * drvs[] = {
-  // operating system depended things:
-#ifdef __OpenBSD__
-  /* OpenBSD use sndio natively, this check is discusses with upstream (See ML archive August 2010) */
-  "sndio",
-#endif
-#ifdef ROAR_TARGET_WIN32
-  /* on Win32 we use WMM API. We may also test for ROAR_HAVE_LIBWINMM. I'm not sure what is better.
-   * both, WMM and UNIX like stuff is supported in cygwin.
-   */
-  "wmm",
-#endif
-  // native and pseudo-native interfaces:
-  "oss", "alsa", "sndio", "wmm",
-  // sound libs:
-  "ao", "portaudio",
-  // other sound systems:
-  "esd", "rsound", "artsc", "pulsesimple", "roar",
-  // libroareio's drivers:
-  "cdriver",
-  // specal buildins:
-  "sysclock", "null",
-  // terminator:
-  NULL
- };
- int i;
- int ret;
- int _alive;
- char * _opts;
-
- if ( drv != NULL )
-  return output_add(drv, dev, opts, prim, count);
-
- if ( dev != NULL ) {
-  ROAR_WARN("add_default_output(drv=(none), dev='%s', opts='%s', prim=%i, count=%i): It's not recommended to use device name without driver name.", dev, opts, prim, count);
- }
-
- for (i = 0; drvs[i] != NULL; i++) {
-  ROAR_INFO("add_default_output(*): trying driver %s", ROAR_DBG_INFO_INFO, drvs[i]);
-  _alive = alive; // save global alive setting
-
-  if ( opts == NULL ) {
-   _opts = NULL;
-  } else {
-   _opts = roar_mm_strdup(opts);
-  }
-
-  ret = output_add(drvs[i], dev, _opts, prim, count);
-
-  if ( _opts != NULL )
-   roar_mm_free(_opts);
-
-  if ( ret != -1 )
-   return ret;
-
-  alive = _alive; // restore global alive setting
-  ROAR_INFO("add_default_output(*): Driver %s faild to load", ROAR_DBG_INFO_VERBOSE, drvs[i]);
- }
-
- return -1;
-}
-#endif
-
-
-#define _CKPARAM(n) if ( n (v == NULL) ) { \
-                     ROAR_WARN("add_output(drv='%s', dev='%s', opts=..., prim=%i, count=%i): " \
-                               "Parameter '%s' expects %s parameter.", \
-                               drv, dev, prim, count, k, (n 1) ? "a" : "no"); \
-                     error++; \
-                    } else
-
-int output_add (char * drv, char * dev, char * opts, int prim, int count) {
- int stream;
- int default_flags = 0;
- struct roar_stream * s;
- struct roar_stream_server * ss;
- char * k, * v;
-#ifdef ROAR_DRIVER_CODEC
- char * to_free = NULL;
-#endif
- int sync = 0, f_mmap = 0;
- int32_t blocks = -1, blocksize = -1;
- int dir = ROAR_DIR_OUTPUT;
- int error = 0;
- // DMX:
- int32_t channel  = -1;
- int32_t universe = -1;
- uint16_t tu16;
- float q = -32e6;
- char * strtok_store;
-
- ROAR_INFO("add_output(drv='%s', dev='%s', opts='%s', prim=%i, count=%i): trying to add output driver", ROAR_DBG_INFO_INFO, drv, dev, opts, prim, count);
-
- if ( drv == NULL && count == 0 ) {
-#ifdef ROAR_DRIVER_DEFAULT
-  drv  = ROAR_DRIVER_DEFAULT;
-  prim = 1;
-  sync = 1;
-
-#ifdef ROAR_DRIVER_CODEC
-  if ( opts == NULL ) {
-   opts = to_free = roar_mm_strdup("codec=" ROAR_DRIVER_CODEC);
-  }
-#endif
-#else
-  ROAR_ERR("add_output(*): Can not find default driver");
-  return -1;
-#endif
- }
-
- if ( opts == NULL && count == 0 ) {
-  ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-  default_flags = ROAR_FLAG_AUTOCONF|ROAR_FLAG_RECSOURCE;
-  sync = 1;
-  prim = 1; // if ( prim == 0 ) prim = 1; -> prim allways = 1
- }
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-
- if ( (stream = streams_new()) == -1 ) {
-  ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
-  if ( prim ) alive = 0;
-  return -1;
- }
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-
- streams_get(stream, &ss);
- s = ROAR_STREAM(ss);
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-
- memset(&(s->info), 0xFF, sizeof(struct roar_audio_info)); // set everything to -1
-
- s->pos_rel_id = -1;
-// s->info.codec = codec;
-
- // seting default flags:
- streams_set_flag(stream, default_flags);
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-
- if ( opts == NULL ) {
-  k = NULL;
- } else {
-  k = roar_mm_strtok_r(opts, ",", &strtok_store);
- }
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s'): initial k='%s'(%p)", drv, dev, opts, k, k);
-
- while (k != NULL) {
-//  ROAR_WARN("add_output(*): opts: %s", k);
-
-  if ( (v = strstr(k, "=")) != NULL ) {
-   *v++ = 0;
-  }
-
-  ROAR_DBG("add_output(*): opts: k='%s', v='%s'", k, v);
-  if ( strcmp(k, "rate") == 0 ) {
-   _CKPARAM()
-    s->info.rate = atoi(v);
-  } else if ( strcmp(k, "channels") == 0 ) {
-   _CKPARAM()
-    s->info.channels = atoi(v);
-  } else if ( strcmp(k, "bits") == 0 ) {
-   _CKPARAM()
-    s->info.bits = atoi(v);
-  } else if ( strcmp(k, "codec") == 0 ) {
-   _CKPARAM()
-    if ( (s->info.codec = roar_str2codec(v)) == -1 ) {
-     ROAR_ERR("add_output(*): unknown codec '%s'", v);
-     error++;
-    }
-  } else if ( strcmp(k, "q") == 0 ) {
-   _CKPARAM()
-    q = atof(v);
-  } else if ( strcmp(k, "blocks") == 0 ) {
-   _CKPARAM()
-    blocks = atoi(v);
-  } else if ( strcmp(k, "blocksize") == 0 ) {
-   _CKPARAM()
-    blocksize = atoi(v);
-  } else if ( strcmp(k, "mmap") == 0 ) {
-   _CKPARAM(!)
-    f_mmap = 1;
-  } else if ( strcmp(k, "subsystem") == 0 ) {
-   _CKPARAM() {
-    if ( !strcasecmp(v, "wave") || !strcasecmp(v, "waveform") ) {
-     dir = ROAR_DIR_OUTPUT;
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-    } else if ( !strcasecmp(v, "midi") ) {
-     dir = ROAR_DIR_MIDI_OUT;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-    } else if ( !strcasecmp(v, "light") ) {
-     dir = ROAR_DIR_LIGHT_OUT;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-    } else if ( !strcasecmp(v, "raw") ) {
-     dir = ROAR_DIR_RAW_OUT;
-#endif
-    } else if ( !strcasecmp(v, "complex") ) {
-     dir = ROAR_DIR_COMPLEX_OUT;
-    } else {
-     ROAR_ERR("add_output(*): unknown/unsupported subsystem '%s'", k);
-     error++;
-    }
-   }
-  // DMX:
-  } else if ( strcmp(k, "channel") == 0 ) {
-   _CKPARAM() {
-    channel  = atoi(v);
-    if ( channel < 0 || channel > 65535 ) {
-     ROAR_ERR("add_output(*): Invalide channel (not within 0..65535): %i", channel);
-     channel = -1;
-     error++;
-    }
-   }
-  } else if ( strcmp(k, "universe") == 0 ) {
-   _CKPARAM() {
-    universe = atoi(v);
-    if ( universe < 0 || universe > 255 ) {
-     ROAR_ERR("add_output(*): Invalide universe (not within 0..255): %i", universe);
-     universe = -1;
-     error++;
-    }
-   }
-
-  } else if ( strcmp(k, "name") == 0 ) {
-   _CKPARAM() {
-    if ( streams_set_name(stream, v) == -1 ) {
-     ROAR_ERR("add_output(*): Can not set Stream name");
-     error++;
-    }
-   }
-
-  } else if ( strcmp(k, "meta") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_META);
-  } else if ( strcmp(k, "sync") == 0 ) {
-   _CKPARAM(!)
-    sync = 1;
-  } else if ( strcmp(k, "primary") == 0 ) {
-   _CKPARAM(!)
-    prim = 1;
-
-  } else if ( strcmp(k, "cleanmeta") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_CLEANMETA);
-  } else if ( strcmp(k, "autoconf") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_AUTOCONF);
-  } else if ( strcmp(k, "recsource") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_RECSOURCE);
-  } else if ( strcmp(k, "passmixer") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_PASSMIXER);
-  } else if ( strcmp(k, "recsource") == 0 ) {
-   _CKPARAM(!)
-    streams_set_flag(stream, ROAR_FLAG_RECSOURCE);
-  } else {
-   ROAR_ERR("add_output(*): unknown option '%s'", k);
-   error++;
-  }
-
-  if ( error ) {
-   streams_delete(stream);
-   if ( prim ) alive = 0;
-#ifdef ROAR_DRIVER_CODEC
-   if ( to_free != NULL )
-    roar_mm_free(to_free);
-#endif
-   return -1;
-  }
-
-  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
- }
-
- ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = ?", drv, dev, opts);
-
- // set audio info...
- switch (dir) {
-  case ROAR_DIR_LIGHT_OUT:
-    switch (s->info.codec) {
-     case ROAR_CODEC_DMX512:
-     case -1:
-       if ( s->info.rate == -1 )
-        s->info.rate = ROAR_OUTPUT_CFREQ;
-
-       s->info.channels =   0;
-       s->info.bits     =   8;
-       s->info.codec    = ROAR_CODEC_DMX512; // in case codec == -1
-      break;
-    }
-   break;
-  case ROAR_DIR_MIDI_OUT:
-    switch (s->info.codec) {
-     case ROAR_CODEC_MIDI:
-     case -1:
-       if ( s->info.rate == -1 )
-        s->info.rate    = ROAR_MIDI_TICKS_PER_BEAT;
-
-       s->info.channels = ROAR_MIDI_CHANNELS_DEFAULT;
-       s->info.bits     = ROAR_MIDI_BITS;
-       s->info.codec    = ROAR_CODEC_MIDI; // in case codec == -1
-      break;
-    }
-   break;
-  case ROAR_DIR_RAW_OUT:
-    if ( s->info.rate == -1 )
-     s->info.rate = 0;
-    if ( s->info.bits == -1 )
-     s->info.bits = 0;
-    if ( s->info.channels == -1 )
-     s->info.channels = 0;
-    if ( s->info.codec == -1 )
-     s->info.codec = 0;
-   break;
- }
-
- if ( s->info.rate == -1 )
-  s->info.rate = g_sa->rate;
- if ( s->info.bits == -1 )
-  s->info.bits = g_sa->bits;
- if ( s->info.channels == -1 )
-  s->info.channels = g_sa->channels;
- if ( s->info.codec == -1 )
-  s->info.codec = g_sa->codec;
-
- 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);
-
- if ( streams_set_dir(stream, dir, 1) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
-#ifdef ROAR_DRIVER_CODEC
- if ( to_free != NULL )
-  roar_mm_free(to_free);
-#endif
-
- if ( s->info.codec == ROAR_CODEC_ALAW || s->info.codec == ROAR_CODEC_MULAW )
-  s->info.bits = 8; // needed to open OSS driver, will be overriden by codecfilter
-
- ROAR_STREAM_SERVER(s)->codec_orgi = s->info.codec;
-
- if ( driver_openvio(&(ss->vio), &(ss->driver_id), drv, dev, &(s->info), -1, ss) == -1 ) {
-  ss->driver_id = -1; // don't close a driver not opened...
-  memset(&(ss->vio), 0, sizeof(struct roar_vio_calls));
-  streams_delete(stream);
-  if ( prim ) alive = 0;
-  ROAR_ERR("add_output(drv='%s', dev='%s', opts='%s'): can not open output driver.", drv, dev, opts);
-  ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
-  return -1;
- }
-
- _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAMID, &stream)); // ignore errors here
- _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAM,   s)); // ignore errors here
-
- if ( blocks != -1 ) {
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DBLOCKS, &blocks) == -1 ) {
-   ROAR_WARN("add_output(drv='%s', dev='%s', opts='%s'): can not set number of blocks.", drv, dev, opts);
-  }
- }
-
- if ( blocksize != -1 ) {
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DBLKSIZE, &blocksize) == -1 ) {
-   ROAR_WARN("add_output(drv='%s', dev='%s', opts='%s'): can not set blocksize.", drv, dev, opts);
-  }
- }
-
- // TODO: we shoudld *really* check for errors here...
- if ( channel != -1 ) {
-  tu16 = channel;
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DMXSCHAN, &tu16) == -1 ) {
-   streams_delete(stream);
-   if ( prim ) alive = 0;
-   ROAR_ERR("add_output(drv='%s', dev='%s', opts='%s'): can not set DMX channel number.", drv, dev, opts);
-   ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
-   return -1;
-  }
- }
- if ( universe != -1 ) {
-  tu16 = universe;
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_DMXUNIV, &tu16) == -1 ) {
-   streams_delete(stream);
-   if ( prim ) alive = 0;
-   ROAR_ERR("add_output(drv='%s', dev='%s', opts='%s'): can not set DMX universe.", drv, dev, opts);
-   ROAR_DBG("add_output(drv='%s', dev='%s', opts='%s') = -1", drv, dev, opts);
-   return -1;
-  }
- }
-
- ROAR_DBG("add_output(*): ss->driver_id=%i", ss->driver_id);
-
- streams_set_fh(stream, -1); // update some internal structures
-
- if ( q > -1e6 ) {
-  ROAR_DBG("add_output(*): setting q=%f", q);
-  streams_ctl(stream, ROAR_CODECFILTER_CTL_SET_Q|ROAR_STREAM_CTL_TYPE_FLOAT, &q);
- }
-
- client_stream_add(g_self_client, stream);
-
- if ( prim ) {
-  streams_mark_primary(stream);
-  s->pos_rel_id = stream;
- }
-
- if ( sync ) {
-  streams_set_flag(stream, ROAR_FLAG_SYNC);
- } else {
-  streams_reset_flag(stream, ROAR_FLAG_SYNC);
- }
-
- if ( f_mmap )
-  streams_set_flag(stream, ROAR_FLAG_MMAP);
-
- 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);
- return 0;
+ return driver_write(inst, driver, g_output_buffer, g_output_buffer_len);
 }
 
Index: roard/plugins.c
===================================================================
--- roard/plugins.c	(revision 6052)
+++ 	(revision )
@@ -1,273 +1,0 @@
-//plugins.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#define MAX_PLUGINS    8
-
-static struct _roard_plugin {
- struct roar_dl_lhandle     * lhandle;
-} g_plugins[MAX_PLUGINS];
-static struct _roard_plugin * _pp = NULL;
-
-static int _plugins_inited = 0;
-
-static int plugin_callback(enum roar_dl_fnreg_action action, int fn, int subtype, const void * object, size_t objectlen, int version, int options, void * userdata, struct roar_dl_lhandle * lhandle);
-static const struct roar_dl_fnreg _plugin_callbacks = {
- .fn = -1,
- .subtype = -1,
- .version = -1,
- .callback = plugin_callback,
- .userdata = NULL
-};
-
-static struct _roard_plugin * _find_free(void) {
- int i;
-
- ROAR_DBG("_find_free(void) = ?");
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( g_plugins[i].lhandle == NULL ) {
-   memset(&(g_plugins[i]), 0, sizeof(struct _roard_plugin));
-   ROAR_DBG("_find_free(void) = %p // i=%i", &(g_plugins[i]), i);
-   return &(g_plugins[i]);
-  }
- }
-
- ROAR_DBG("_find_free(void) = NULL");
- return NULL;
-}
-
-int plugins_preinit  (void) {
- ROAR_DBG("plugins_preinit(void) = ?");
-
- memset(g_plugins, 0, sizeof(g_plugins));
-
-#ifdef DEBUG
- print_pluginlist(FORMAT_NATIVE);
-#endif
-
- ROAR_DBG("plugins_preinit(void) = 0");
- return 0;
-}
-
-static inline void plugins_delete(struct _roard_plugin * plugin) {
- ROAR_DBG("plugins_delete(plugin=%p) = ?", plugin);
-
- roar_dl_appsched_trigger(plugin->lhandle, ROAR_DL_APPSCHED_FREE);
-
- roar_dl_close(plugin->lhandle);
- memset(plugin, 0, sizeof(struct _roard_plugin));
- plugin->lhandle = NULL;
-}
-
-static int plugins_init_one(struct _roard_plugin * plugin) {
- if ( plugin == NULL )
-  return -1;
-
- ROAR_DBG("plugins_init_one(plugin=%p) = ?", plugin);
-
- _pp = plugin;
-
- if ( roar_dl_ra_init(plugin->lhandle, NULL, NULL) == -1 ) {
-  ROAR_WARN("plugins_init(void): Can not RA init lib at %p: %s", plugin->lhandle, roar_error2str(roar_error));
-  plugins_delete(plugin);
-  return -1;
- }
-
- roar_dl_appsched_trigger(plugin->lhandle, ROAR_DL_APPSCHED_INIT);
-
- _pp = NULL;
-
- return 0;
-}
-
-int plugins_init  (void) {
- size_t i;
-
- ROAR_DBG("plugins_init(void) = ?");
-
-#ifdef DEBUG
- print_pluginlist(FORMAT_NATIVE);
-#endif
-
- if ( _plugins_inited ) {
-  ROAR_DBG("plugins_init(void) = -1 // error=BUSY");
-  roar_err_set(ROAR_ERROR_BUSY);
-  return -1;
- }
-
- ROAR_DL_RFNREG(ROAR_DL_HANDLE_APPLICATION, _plugin_callbacks);
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( g_plugins[i].lhandle != NULL ) {
-   plugins_init_one(&(g_plugins[i]));
-  }
- }
-
- _plugins_inited = 1;
-
-#ifdef DEBUG
- print_pluginlist(FORMAT_NATIVE);
-#endif
-
- ROAR_DBG("plugins_init(void) = 0");
- return 0;
-}
-
-int plugins_free  (void) {
- int i;
-
- ROAR_DBG("plugins_free(void) = ?");
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( g_plugins[i].lhandle != NULL ) {
-   plugins_delete(&(g_plugins[i]));
-  }
- }
-
- return plugins_preinit();
-}
-
-int plugins_update   (void) {
- int ret = 0;
- int i;
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  if ( g_plugins[i].lhandle != NULL ) {
-   if ( roar_dl_appsched_trigger(g_plugins[i].lhandle, ROAR_DL_APPSCHED_UPDATE) == -1 )
-    if ( roar_error != ROAR_ERROR_NOENT )
-     ret = -1;
-  }
- }
-
- return ret;
-}
-
-int plugins_load  (const char * filename, const char * args) {
- struct _roard_plugin * next = _find_free();
- struct roar_dl_librarypara * para;
-
- ROAR_DBG("plugins_load(filename=\"%s\", args=\"%s\") = ?", filename, args);
-
- if ( next == NULL )
-  return -1;
-
- if ( (para = roar_dl_para_new(args, NULL, ROARD_DL_APPNAME, ROARD_DL_ABIVERSION)) == NULL ) {
-  ROAR_WARN("Can not load plugin (allocate para set): %s: %s", filename, roar_error2str(roar_error));
-  return -1;
- }
-
- next->lhandle = roar_dl_open(filename, ROAR_DL_FLAG_PLUGIN, 0 /* we delay this until plugins_init() */, para);
- roar_dl_para_unref(para);
-
- if ( next->lhandle == NULL ) {
-  ROAR_ERR("plugins_load(filename='%s'): can not load plugin: %s", filename, roar_dl_errstr(NULL));
-  return -1;
- }
-
- if ( _plugins_inited )
-  return plugins_init_one(next);
-
- return 0;
-}
-
-void print_pluginlist(enum output_format format) {
- const struct roar_dl_libraryname * libname;
- struct _roard_plugin * p;
- size_t i;
-
- switch (format) {
-  case FORMAT_NATIVE:
-    printf("  Name\n");
-    printf("   Attributes\n");
-    printf("-----------------------------------------------------\n");
-   break;
-  case FORMAT_WIKI:
-  case FORMAT_CSV:
-  default:
-    roar_err_set(ROAR_ERROR_NOTSUP);
-    return;
- }
-
- for (i = 0; i < MAX_PLUGINS; i++) {
-  p = &(g_plugins[i]);
-  if ( p->lhandle == NULL )
-   continue;
-
-  libname = roar_dl_getlibname(p->lhandle);
-  if ( libname == NULL ) {
-  } else {
-   printf("  %s\n", libname->libname);
-   printf("   Flags:       %s\n", "");
-   if ( libname->description != NULL )
-    printf("   Description: %s\n", libname->description);
-   if ( libname->contact != NULL )
-    printf("   Contact:     %s\n", libname->contact);
-  }
- }
-}
-
-static int plugin_callback(enum roar_dl_fnreg_action action, int fn, int subtype, const void * object, size_t objectlen, int version, int options, void * userdata, struct roar_dl_lhandle * lhandle) {
-
- (void)options, (void)userdata;
-
- ROAR_DBG("plugin_callback(action=%i, fn=%i, subtype=%i, object=%p, objectlen=%llu, version=%i, options=0x%x, userdata=%p, lhandle=%p) = ?", (int)action, fn, subtype, object, (long long unsigned int)objectlen, version, options, userdata, lhandle);
-
- switch (fn) {
-  case ROAR_DL_FN_PROTO:
-    if ( subtype != ROAR_DL_PROTO_SUBTYPE ) {
-     ROAR_DBG("plugin_callback(action=%i, fn=%i, subtype=%i, object=%p, objectlen=%llu, version=%i, options=0x%x, userdata=%p, lhandle=%p) = -1 // error=TYPEMM", (int)action, fn, subtype, object, (long long unsigned int)objectlen, version, options, userdata, lhandle);
-
-     roar_err_set(ROAR_ERROR_TYPEMM);
-     return -1;
-    }
-    if ( objectlen != ROAR_DL_PROTO_SIZE ) {
-     ROAR_DBG("plugin_callback(action=%i, fn=%i, subtype=%i, object=%p, objectlen=%llu, version=%i, options=0x%x, userdata=%p, lhandle=%p) = -1 // error=BADLIB", (int)action, fn, subtype, object, (long long unsigned int)objectlen, version, options, userdata, lhandle);
-     roar_err_set(ROAR_ERROR_BADLIB);
-     return -1;
-    }
-    if ( version != ROAR_DL_PROTO_VERSION ) {
-     ROAR_DBG("plugin_callback(action=%i, fn=%i, subtype=%i, object=%p, objectlen=%llu, version=%i, options=0x%x, userdata=%p, lhandle=%p) = -1 // error=BADVERSION", (int)action, fn, subtype, object, (long long unsigned int)objectlen, version, options, userdata, lhandle);
-     roar_err_set(ROAR_ERROR_BADVERSION);
-     return -1;
-    }
-    switch (action) {
-     case ROAR_DL_FNREG:
-       return clients_register_proto_common(object, lhandle);
-      break;
-     case ROAR_DL_FNUNREG:
-       return clients_unregister_proto(((const struct roard_proto *)object)->proto);
-      break;
-    }
-   break;
- }
-
- ROAR_DBG("plugin_callback(action=%i, fn=%i, subtype=%i, object=%p, objectlen=%llu, version=%i, options=0x%x, userdata=%p, lhandle=%p) = -1 // error=NOTSUP", (int)action, fn, subtype, object, (long long unsigned int)objectlen, version, options, userdata, lhandle);
- roar_err_set(ROAR_ERROR_NOTSUP);
- return -1;
-}
-
-//ll
Index: roard/raw.c
===================================================================
--- roard/raw.c	(revision 6052)
+++ 	(revision )
@@ -1,70 +1,0 @@
-//raw.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-
-int raw_check_stream  (int id) {
- struct roar_stream        *    s;
- struct roar_stream_server *   ss;
- struct roar_buffer        *  buf;
- void                      * data;
- ssize_t                     len;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("raw_check_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- if ( s->pos_rel_id == -1 )
-  return -1;
-
- // TODO: do we really need a buffer object here? wouldn't space on stack be ok?
- if ( roar_buffer_new_data(&buf, RAW_READ_LEN, &data) == -1 )
-  return -1;
-
- if ( (len = stream_vio_s_read(ss, data, RAW_READ_LEN)) < 1 ) {
-  // this is len=0 -> eof OR len=-1 -> error
-  streams_delete(id);
-  roar_buffer_free(buf);
-  return -1;
- }
-
- if ( stream_vio_write(s->pos_rel_id, data, len) != len ) {
-  // we are hard here as this is needed to ensure data integrety
-  streams_delete(s->pos_rel_id);
- }
-
- roar_buffer_free(buf);
-
- return 0;
-}
-
-#endif
-
-//ll
Index: roard/rdtcs.c
===================================================================
--- roard/rdtcs.c	(revision 6052)
+++ 	(revision )
@@ -1,176 +1,0 @@
-//rdtcs.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-
-// declared 'extern'
-struct rdtcs_state g_rdtcs;
-
-int rdtcs_init  (void) {
- return 0;
-}
-
-int rdtcs_free  (void) {
- return 0;
-}
-
-int rdtcs_init_config  (void) {
- memset(&g_rdtcs, 0, sizeof(g_rdtcs));
-
- strncpy(g_rdtcs.rds.ps, RDTCS_RDS_PS_DEFAULT, RDTCS_RDS_PS_LEN);
- g_rdtcs.rds.ps[RDTCS_RDS_PS_LEN] = 0;
-
- g_rdtcs.rds.pty   = RDTCS_RDS_PTY_DEFAULT;
- g_rdtcs.rds.pi    = RDTCS_RDS_PI_DEFAULT;
- g_rdtcs.rds.flags = RDTCS_RDS_FLAG_NONE;
-
- return 0;
-}
-
-int rdtcs_rds_set_ps  (char * ps) {
- int i;
-
- if ( ps == NULL )
-  return -1;
-
- if ( strlen(ps) > 8 )
-  return -1;
-
- // coppy string converting to upper case:
- for (i = 0; ps[i]; i++) {
-  g_rdtcs.rds.ps[i] = toupper(ps[i]);
- }
-
- g_rdtcs.rds.ps[i] = 0; // terminating \0
-
- return 0;
-}
-
-int rdtcs_rds_set_pty (char * pty) {
- if ( pty == NULL )
-  return -1;
-
- return -1;
-}
-
-int rdtcs_rds_set_flag  (unsigned int flag, int reset) {
- 
- g_rdtcs.rds.flags |= flag;
-
- if ( reset )
-  g_rdtcs.rds.flags -= flag;
-
- return 0;
-}
-
-
-int rdtcs_check_stream  (int id) {
- return -1;
-}
-
-int rdtcs_send_stream   (int id) {
- struct roar_stream        *   s;
- struct roar_stream_server *  ss;
-
- if ( g_streams[id] == NULL )
-  return -1;
-
- ROAR_DBG("rdtcs_send_stream(id=%i) = ?", id);
-
- s = ROAR_STREAM(ss = g_streams[id]);
-
- switch (s->info.codec) {
-  case ROAR_CODEC_RDS:
-    return rdtcs_send_stream_rds(id, ss);
-   break;
-  default:
-    streams_delete(id);
-    return -1;
- }
-
- return 0;
-}
-
-int rdtcs_send_stream_rds  (int id, struct roar_stream_server *  ss) {
- struct roar_stream        *   s;
-
- s = ROAR_STREAM(ss);
-
-
- return rdtcs_send_stream_rds_group(id, ss);
-}
-
-int rdtcs_send_stream_rds_group  (int id, struct roar_stream_server *  ss) {
- char out[RDTCS_RDS_GROUP_LEN];
- char * c;
- int      block[4] = {RDTCS_RDS_BLOCK_A, RDTCS_RDS_BLOCK_B, RDTCS_RDS_BLOCK_C0, RDTCS_RDS_BLOCK_D};
- uint16_t data[4];
- uint16_t crc;
- register uint32_t s;
- int i, fill;
-
- // TODO: think about byte order!
-
- for (i = 0; i < 4; i++) data[i] = 0;
-
- data[0] = g_rdtcs.rds.pi;
-
- memset(out, 0, sizeof(out));
-
- c    = out;
- s    = 0;
- fill = 0;
- for (i = 0; i < 4; i++) {
-  // data is 16 bit long
-  s |= data[i] << (fill & 0xFFFF);
-  fill += 16;
-
-  crc = rdtcs_rds_crc_calc(data[i], block[i]);
-
-  // CRC is 10 bit long
-  s |= crc << (fill & 0x03FF);
-  fill += 10;
-
-  // shift all complet bytes we allready have out
-  while (fill >= 8) {
-   *c     = s & 0xFF;
-    c++;
-    s   >>= 8;
-    fill -= 8;
-  }
- }
-
- return stream_vio_s_write(ss, out, RDTCS_RDS_GROUP_LEN) == RDTCS_RDS_GROUP_LEN ? 0 : -1;
-}
-
-uint16_t rdtcs_rds_crc_calc      (uint16_t data, int block) {
- return 0xAAAA;
-}
-
-#endif
-
-//ll
Index: roard/req.c
===================================================================
--- roard/req.c	(revision 6052)
+++ roard/req.c	(revision 0)
@@ -1,114 +1,23 @@
 //req.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-/* ckport options:
- * massage <-> object converters:
- * ckport: ignore-symbol: roar_stream_s2m of target libroar0
- * ckport: ignore-symbol: roar_stream_m2s of target libroar0
- * ckport: ignore-symbol: roar_ctl_c2m of target libroar0
- * ckport: ignore-symbol: roar_ctl_ia2m of target libroar0
- * ckport: ignore-symbol: roar_ctl_m2f of target libroar0
- * Caps support:
- * ckport: ignore-symbol: roar_caps_from_msg of target libroar0
- * ckport: ignore-symbol: roar_caps_to_msg of target libroar0
- * Server info:
- * ckport: ignore-symbol: roar_server_info_to_mes of target libroar0
- * PASSFH:
- * ckport: ignore-symbol: roar_socket_recv_fh of target libroar0
- * AUTH:
- * ckport: ignore-symbol: roar_auth_from_mes of target libroar0
- * ckport: ignore-symbol: roar_auth_to_mes of target libroar0
- * Events:
- * ckport: ignore-symbol: roar_event_from_blob of target libroar0
- * Filter:
- * ckport: ignore-symbol: roar_filter_match of target libroar0
- */
-
 #include "roard.h"
 
-// include for uname() used by req_on_server_info()
-#ifdef ROAR_HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-
-static void * _dataspace(struct roar_message * mes, char ** data, uint32_t flags[2], size_t len) {
- if ( len <= LIBROAR_BUFFER_MSGDATA )
-  return mes->data;
-
- if ( *data != NULL )
-  roar_mm_free(*data);
-
- *data = roar_mm_malloc(len);
-
- ROAR_DBG("_dataspace(mes=%p, data=%p, flags=%p, len=%llu): *data=%p", mes, data, flags, (long long unsigned int)len, *data);
-
- if ( *data == NULL )
-  return NULL;
-
- flags[1] |= COMMAND_FLAG_OUT_LONGDATA;
-
- return *data;
-}
-
-int req_on_noop        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- (void)client, (void)data, (void)flags;
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 0;
- return 0;
-}
-
-int req_on_quit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- (void)client, (void)data;
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 0;
- flags[1] |= COMMAND_FLAG_OUT_DELETE;
- return 0;
-}
-
-int req_on_identify    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_client_server * cs;
- struct roar_client        * c;
+int req_on_noop        (int client, struct roar_message * mes, char * data) {
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
+ return 0;
+}
+
+int req_on_identify    (int client, struct roar_message * mes, char * data) {
+ struct roar_client * c;
  int max_len;
 
- (void)data, (void)flags;
-
  if ( mes->datalen < 1 )
   return -1;
 
- clients_get_server(client, &cs);
-
- c = ROAR_CLIENT(cs);
+ clients_get(client, &c);
 
  if ( mes->data[0] == 1 ) {
-  if ( c->pid == -1 ) {
-   c->pid       = ROAR_NET2HOST32(*(uint32_t*)((mes->data)+1));
-   ROAR_DBG("req_on_identify(): new PID: c->pid = %i", c->pid);
-  }
-
-  ROAR_DBG("req_on_identify(): final PID: c->pid = %i", c->pid);
+  c->pid       = ROAR_NET2HOST32(*(uint32_t*)((mes->data)+1));
 
   max_len = (mes->datalen - 5) < (ROAR_BUFFER_NAME-1) ? (mes->datalen - 5) : (ROAR_BUFFER_NAME-1);
@@ -117,11 +26,5 @@
   c->name[max_len] = 0;
 
-  // we set the acclevel to IDENTED here.
-  // if it is alreay > IDENTED we reset it anyway
-  // as potential auth relevent data changed.
-  cs->acclev = ACCLEV_IDENTED;
-
   mes->cmd     = ROAR_CMD_OK;
-  mes->pos     = g_pos;
   mes->datalen = 0;
 
@@ -134,111 +37,24 @@
 }
 
-int req_on_auth        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_error_frame   error_frame;
- void                    * error_data;
- struct roar_message       error_mes;
- struct roar_client_server * cs;
- struct roar_auth_message    authmes;
- int next = -1;
- int ret;
-
- (void)flags;
-
- clients_get_server(client, &cs);
-
+int req_on_auth        (int client, struct roar_message * mes, char * data) {
  // TODO: add code to support some auth.
-
- if ( roar_auth_from_mes(&authmes, mes, *data) == -1 )
-  return -1;
-
- ROAR_INFO("req_on_auth(client=%i,...): authtype=%s(%i), len=%llu bytes", ROAR_DBG_INFO_VERBOSE,
-                           client, roar_autht2str(authmes.type), authmes.type, (long long unsigned int)authmes.len);
-
- ROAR_DBG("req_on_auth(client=%i,...): CALL auth_client_ckeck(cs=%p, &authmes=%p, &next=%p)", client, cs, &authmes, &next);
- ret = auth_client_ckeck(cs, &authmes, &next);
- ROAR_DBG("req_on_auth(client=%i,...): RET %i // next=%s(%i)", client, ret, roar_autht2str(next), next);
-
- if ( ret != 1 ) {
-  ROAR_DBG("req_on_auth(client=%i,...) = ?", client);
-
-  if ( next != -1 ) {
-   ROAR_DBG("req_on_auth(client=%i,...) = ?", client);
-   memset(&authmes, 0, sizeof(authmes));
-
-   authmes.type = next;
-
-   if ( roar_auth_to_mes(&error_mes, NULL, &authmes) == -1 )
-    return -1;
-
-   ROAR_DBG("req_on_auth(client=%i,...) = ?", client);
-
-   if ( roar_err_init(&error_frame) == -1 )
-    return -1;
-
-   ROAR_DBG("req_on_auth(client=%i,...) = ?", client);
-
-   error_frame.ra_errno = ROAR_ERROR_PERM;
-   error_frame.datalen  = error_mes.datalen;
-
-   error_data   = roar_err_buildmsg(mes, NULL, &error_frame);
-   ROAR_DBG("req_on_auth(client=%i,...): error_data=%p", client, error_data);
-
-   memcpy(error_data, error_mes.data, error_mes.datalen);
-
-   mes->cmd     = ROAR_CMD_ERROR;
-   mes->pos     = g_pos;
-
-   ROAR_DBG("req_on_auth(client=%i,...): mes=%p{.datalen=%i}", client, mes, (int)mes->datalen);
-   ROAR_DBG("req_on_auth(client=%i,...) = 0 // cmd=ERROR", client);
-   return 0;
-  }
-
-  ROAR_DBG("req_on_auth(client=%i,...) = 0", client);
-  return -1;
- }
-
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 0;
-
- ROAR_DBG("req_on_auth(client=%i,...) = 0", client);
- return 0;
-}
-
-
-int req_on_whoami      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- (void)data, (void)flags;
-
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 1;
- mes->data[0] = client;
- return 0;
-}
-
-
-int req_on_new_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
+ return 0;
+}
+
+
+int req_on_new_stream  (int client, struct roar_message * mes, char * data) {
  int stream;
- struct roar_stream_server * ss;
- struct roar_stream        * s;
- struct roar_stream * source_stream;
- struct roar_audio_info * info;
- struct roar_audio_info * source_info;
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): creating stream...", client);
+ struct roar_stream * s;
+
  if ((stream = streams_new()) == -1 )
   return -1;
 
- ROAR_DBG("req_on_new_stream(client=%i, ...): stream=%i", client, stream);
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): getting stream...", client);
- if ( streams_get(stream, &ss) == -1 ) {
+ if ( streams_get(stream, (struct roar_stream_server **)&s) == -1 ) {
   streams_delete(stream);
   return -1;
  }
 
- s = ROAR_STREAM(ss);
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): set client of stream...", client);
  if ( client_stream_add(client, stream) == -1 ) {
   streams_delete(stream);
@@ -246,5 +62,4 @@
  }
 
- ROAR_DBG("req_on_new_stream(client=%i, ...): loading stream from message...", client);
  if ( roar_stream_m2s(s, mes) == -1 ) {
   streams_delete(stream);
@@ -252,119 +67,4 @@
  }
 
- ROAR_DBG("req_on_new_stream(client=%i, ...): setting id and codec of stream...", client);
- ROAR_STREAM(s)->id = stream; // roar_stream_m2s() resets this
- ROAR_STREAM_SERVER(s)->codec_orgi = ROAR_STREAM(s)->info.codec;
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): setting direction stream...", client);
- // int streams_set_dir    (int id, int dir, int defaults)
- if ( streams_set_dir(stream, ROAR_STREAM(s)->dir, 1) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): checking mixer settings...", client);
- if ( mes->stream != -1 && mes->stream != ss->mixer_stream ) {
-  streams_delete(stream);
-  return -1;
- }
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): setting up direction specific stream settings...", client);
- switch (ROAR_STREAM(s)->dir) {
-  case ROAR_DIR_LIGHT_IN:
-  case ROAR_DIR_LIGHT_OUT:
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-    info = &(ROAR_STREAM(s)->info);
-
-    info->channels = 0;
-    info->bits     = 0;
-    info->rate     = 0;
-#else
-    streams_delete(stream);
-    return -1;
-#endif
-
-   break;
-  case ROAR_DIR_MIDI_IN:
-  case ROAR_DIR_MIDI_OUT:
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-    info = &(ROAR_STREAM(s)->info);
-
-    info->channels = ROAR_MIDI_CHANNELS_DEFAULT;
-    info->bits     = ROAR_MIDI_BITS;
-    info->rate     = 0;
-#else
-    streams_delete(stream);
-    return -1;
-#endif
-
-   break;
-
-  case ROAR_DIR_RAW_IN:
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-    if ( ROAR_STREAM(s)->pos_rel_id == -1     ||
-         ROAR_STREAM(s)->pos_rel_id == stream ||
-         streams_get_dir(ROAR_STREAM(s)->pos_rel_id) != ROAR_DIR_RAW_OUT
-       ) {
-     ROAR_STREAM(s)->pos_rel_id = -1; // force this here as it will try to delete itself while deleting
-                                      // in case rel_id == stream
-     streams_delete(stream);
-     return -1;
-    }
-#else
-  case ROAR_DIR_RAW_OUT:
-    streams_delete(stream);
-    return -1;
-#endif
-
-   break;
-  case ROAR_DIR_THRU:
-
-    if ( ROAR_STREAM(s)->pos_rel_id == -1 || ROAR_STREAM(s)->pos_rel_id == stream ) {
-     ROAR_STREAM(s)->pos_rel_id = -1; // force this here as it will try to delete itself while deleting
-                                      // in case rel_id == stream
-     streams_delete(stream);
-     return -1;
-    }
-
-    if ( streams_get_clientobj(ROAR_STREAM(s)->pos_rel_id, &source_stream) == -1 ) {
-     streams_delete(stream);
-     return -1;
-    }
-
-    info        = &(ROAR_STREAM(s)->info);
-    source_info = &(ROAR_STREAM(source_stream)->info);
-
-    info->channels = source_info->channels;
-    info->bits     = source_info->bits;
-    info->rate     = source_info->rate;
-    info->codec    = source_info->codec;
-    ROAR_STREAM_SERVER(s)->codec_orgi = ROAR_STREAM_SERVER(source_stream)->codec_orgi;
-
-   break;
-  case ROAR_DIR_FILTER:
-    info        = &(ROAR_STREAM(s)->info);
-
-    if ( ROAR_STREAM(s)->pos_rel_id == -1 ) {
-     source_info = g_sa;
-    } else {
-     if ( streams_get_clientobj(ROAR_STREAM(s)->pos_rel_id, &source_stream) == -1 ) {
-      streams_delete(stream);
-      return -1;
-     }
-     source_info = &(ROAR_STREAM(source_stream)->info);
-    }
-
-    if ( info->channels != source_info->channels || info->bits != source_info->bits ||
-         info->codec    != source_info->codec    || info->rate != source_info->rate ) {
-     // the stream parameters don't match the one of the stream being filtered.
-     // -> delete and reject the stream.
-     streams_delete(stream);
-     return -1;
-    }
-   break;
- }
-
- ROAR_DBG("req_on_new_stream(client=%i, ...): returning (OK, stream=%i)...", client, stream);
-
  mes->cmd     = ROAR_CMD_OK;
  mes->stream  = stream;
@@ -374,680 +74,73 @@
 }
 
-int req_on_exec_stream (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_message    m;
- struct roar_client   * c;
- struct roar_connection con;
- int16_t * d = (int16_t*)mes->data;
- int sock;
- int i;
+int req_on_exec_stream (int client, struct roar_message * mes, char * data) {
  int r;
 
- ROAR_DBG("req_on_exec_stream(client=%i, mes={stream=%i,...},...): execing stream", client, mes->stream);
-
-
- if ( mes->stream != -1 ) {
-  if ( streams_is_ready(mes->stream) ) {
-   flags[1] |= COMMAND_FLAG_OUT_CLOSECON;
-  } else {
-   if ( (r = client_stream_exec(client, mes->stream)) == -1 )
-    return -1;
-  }
-
-  ROAR_DBG("req_on_exec_stream(client=%i, mes={stream=%i,...},...): returning (OK)...", client, mes->stream);
-  mes->cmd     = ROAR_CMD_OK;
-  mes->datalen = 0;
-  return 0;
- }
-
- ROAR_DBG("req_on_exec_stream(client=%i,...): non stream exec", client);
-
- if ( mes->datalen < 4*2 )
-  return -1;
-
- ROAR_DBG("req_on_exec_stream(client=%i,...) = ?", client);
-
- for (i = 0; i < 4; i++) {
-  d[i] = ROAR_NET2HOST16(d[i]);
- }
-
- if ( d[0] != 0 ) // version
-  return -1;
-
- if ( d[1] != 0 ) // flags
-  return -1;
-
- if ( clients_get_protohandle(d[2]) == NULL )
-  return -1;
-
- ROAR_DBG("req_on_exec_stream(client=%i,...) = ?", client);
-
- memset(&m, 0, sizeof(m));
-
- m.cmd = ROAR_CMD_OK;
-
- flags[1] |= COMMAND_FLAG_OUT_NOSEND;
-
- c = ROAR_CLIENT(g_clients[client]);
-
- sock = c->fh;
-
- if ( sock == -1 )
-  return -1;
-
- ROAR_DBG("req_on_exec_stream(client=%i,...) = ?", client);
-
- roar_connect_fh(&con, sock);
-
- roar_send_message(&con, &m, NULL);
-
- clients_set_fh(client, -1);
- clients_delete(client);
-
- ROAR_DBG("req_on_exec_stream(client=%i,...): calling clients_new_from_fh(): sock=%i, d={?, ?, %i, %i}", client, sock, (int)d[2], (int)d[3]);
- if ( clients_new_from_fh(sock, d[2], d[3], 1) == -1 ) {
-  close(sock);
- }
-
- ROAR_DBG("req_on_exec_stream(client=%i,...) = 0", client);
-
- return 0;
-}
-
-int req_on_con_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- char   host[80] = {0};
- int    port = 0;
- int    type = ROAR_SOCKET_TYPE_NONE;
- int    transport_protocol = ROAR_PROTO_NONE;
- int    fh;
- int    len;
-
- if ( mes->datalen < 4 ) {
-  roar_err_set(ROAR_ERROR_BADMSG);
-  return -1;
- }
-
- if ( mes->datalen > 80 ) { // we do not support long messages here
-  roar_err_set(ROAR_ERROR_MSGSIZE);
-  return -1;
- }
-
- switch (*(mes->data)) {
-  case 0: // version 0 packet:
-    type = (unsigned)mes->data[1];
-    port = ROAR_NET2HOST16(((uint16_t*)mes->data)[1]);
-
-    len = mes->datalen - 4;
-
-    strncpy(host, &(mes->data[4]), len);
-    host[len] = 0;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NSVERSION);
-    return -1;
-   break;
- }
-
- if ( type > ROAR_SOCKET_TYPE_MAX ) {
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- switch (type) {
-  case ROAR_SOCKET_TYPE_NONE:
-  case ROAR_SOCKET_TYPE_FORK:
-  case ROAR_SOCKET_TYPE_GENSTR:
-    roar_err_set(ROAR_ERROR_INVAL);
-    return -1;
-   break;
-  case ROAR_SOCKET_TYPE_FILE:
-    roar_err_set(ROAR_ERROR_PERM);
-    return -1;
-   break;
-  default:
-    // pass.
-   break;
- }
-
- switch (transport_protocol) {
-  case ROAR_PROTO_NONE:
-  case ROAR_PROTO_SIMPLE: // same a NONE, plain data over socket. diffrence is only in setup.
-    transport_protocol = ROAR_PROTO_NONE;
-   break;
-  default:
-    roar_err_set(ROAR_ERROR_NOSYS);
-    return -1;
-   break;
- }
-
- ROAR_DBG("req_on_con_stream(*): CONNECT(type=%i, host='%s', port=%i)", type, host, port);
-
- roar_libroar_nowarn();
- fh = roar_socket_open(ROAR_SOCKET_MODE_CONNECT, type, host, port);
- roar_libroar_warn();
-
- if ( fh == -1 )
-  return -1;
-
- if ( client_stream_set_fh(client, mes->stream, fh) == -1 ) {
-  close(fh);
-  return 1;
- }
-
- mes->datalen = 0;
- mes->cmd     = ROAR_CMD_OK;
-
- return 0;
-}
-
-int req_on_passfh      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- int sock = clients_get_fh(client);
- int16_t * d = (int16_t*)mes->data;
- struct roard_listen * lsock;
- int listening;
- int fh;
- int i;
-
- ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...) = ?", client, mes->stream);
-
- if ( (fh = roar_socket_recv_fh(sock, NULL, NULL)) == -1 ) {
-  ROAR_WARN("req_on_passfh(client=%i, mes={stream=%i,...},...): was unabled to get filehandle from remote end. bad.", client, mes->stream);
-  ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): returning (ERROR)...", client, mes->stream);
-  return -1;
- }
-
- ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): fh=%i", client, mes->stream, fh);
-
- if ( mes->stream != -1 ) { // stream pass:
-  ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): This is a stream passfh", client, mes->stream);
-
-  if ( client_stream_set_fh(client, mes->stream, fh) == -1 ) {
-   close(fh);
-   ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): returning (ERROR)...", client, mes->stream);
-   return -1;
-  }
-
-  ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): returning (OK)...", client, mes->stream);
-
-  mes->datalen = 0;
-  mes->cmd     = ROAR_CMD_OK;
-
-  return 0;
- }
-
-// non-stream pass:
-
- ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): This is a client passfh", client, mes->stream);
-
-/*
- 0: Version,   16
- 1: Flags,     16
- 2: Protocol,  16
- 3: Byteorder, 16
- Options...
-*/
-
- if ( mes->datalen < 4*2 )
-  return -1;
-
- for (i = 0; i < 4; i++) {
-  d[i] = ROAR_NET2HOST16(d[i]);
- }
-
- if ( d[0] != 0 ) // version
-  return -1;
-
- listening = d[1] & ROAR_CLIENTPASS_FLAG_LISTEN;
-
- if ( listening )
-  d[1] -= ROAR_CLIENTPASS_FLAG_LISTEN;
-
- if ( d[1] != 0 ) // flags
-  return -1;
-
- if ( listening ) {
-  if ( get_listen(&lsock, NULL) == -1 ) {
-   close(fh);
-   return -1;
-  }
-
-  roar_vio_open_fh_socket(&(lsock->sock), fh);
-  lsock->used   = 1;
-  lsock->proto  = d[2];
- } else {
-  if ( clients_new_from_fh(fh, d[2], d[3], 1) == -1 )
-   return -1;
- }
-
- ROAR_DBG("req_on_passfh(client=%i, mes={stream=%i,...},...): returning (OK)...", client, mes->stream);
-
- mes->datalen = 0;
- mes->cmd     = ROAR_CMD_OK;
-
- return 0;
-}
-
-#ifdef ROAR_SUPPORT_META
-int req_on_set_meta    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- int type;
- int mode;
- int namelen, vallen;
- char   val[255+1];
- char   name[ROAR_META_MAX_NAMELEN+1];
-
- if ( mes->datalen < 3 )
-  return -1;
-
- if ( mes->data[0] != 0 ) // version
-  return -1;
-
- mode = (unsigned) mes->data[1];
- type = (unsigned) mes->data[2];
-
- ROAR_DBG("req_on_set_meta(*): mode=%i, type=%i", mode, type);
-
- if ( mode == ROAR_META_MODE_CLEAR ) {
-  stream_meta_clear(mes->stream);
-  mes->datalen = 0;
-  mes->cmd     = ROAR_CMD_OK;
-  return 0;
- } else if ( mode == ROAR_META_MODE_DELETE ) { // unsuppoerted at the moment
-  return -1;
- } else if ( mode == ROAR_META_MODE_FINALIZE ) {
-  stream_meta_finalize(mes->stream);
-  mes->datalen = 0;
-  mes->cmd     = ROAR_CMD_OK;
-  return 0;
- } else if ( mode == ROAR_META_MODE_SET || mode == ROAR_META_MODE_ADD ) {
-  if ( mes->datalen < 5 )
-   return -1;
-
-  namelen = (unsigned) mes->data[3];
-  vallen  = (unsigned) mes->data[4];
-
-  ROAR_DBG("req_on_set_meta(*): namelen=%i, vallen=%i", namelen, vallen);
-
-  if ( mes->datalen < (5 + namelen + vallen) )
-   return -1;
-
-  if ( namelen > ROAR_META_MAX_NAMELEN )
-   return -1;
-
-  strncpy(name, &(mes->data[5]), namelen);
-  name[namelen] = 0;
-
-  if ( vallen > 255 )
-   return -1;
-
-  strncpy(val, &(mes->data[5+namelen]), vallen);
-  val[vallen] = 0;
-
-  if ( mode == ROAR_META_MODE_SET ) {
-   if ( stream_meta_set(mes->stream, type, name, val) == -1 )
-    return -1;
-  } else {
-   if ( stream_meta_add(mes->stream, type, name, val) == -1 )
-    return -1;
-  }
-
-  mes->datalen = 0;
-  mes->cmd     = ROAR_CMD_OK;
-  return 0;
- } else { // unknown mode!
-  return -1;
- }
-
+ if ( (r = client_stream_exec(client, mes->stream)) == -1 )
+  return -1;
+
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
+
+ return 0;
+}
+
+
+int req_on_set_meta    (int client, struct roar_message * mes, char * data) {
  return -1;
 }
 
-int req_on_get_meta    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- int vallen;
- int type;
- char val[LIBROAR_BUFFER_MSGDATA-1];
-
+
+int req_on_server_oinfo    (int client, struct roar_message * mes, char * data) {
+ struct roar_stream s;
+//ROAR_DIR_OUTPUT
+
+ s.dir           = ROAR_DIR_OUTPUT;
+ s.pos_rel_id    = -1;
+ s.info.rate     = g_sa->rate;
+ s.info.bits     = g_sa->bits;
+ s.info.channels = g_sa->channels;
+ s.info.codec    = g_sa->codec;
+
+ if ( roar_stream_s2m(&s, mes) == -1 )
+  return -1;
+
+ mes->cmd = ROAR_CMD_OK;
+
+ return 0;
+}
+
+
+int req_on_get_standby (int client, struct roar_message * mes, char * data) {
+ mes->cmd = ROAR_CMD_OK;
+ mes->datalen = 2;
+
+ *((uint16_t*)mes->data) = ROAR_HOST2NET16((unsigned) g_standby);
+
+ return 0;
+}
+
+int req_on_set_standby (int client, struct roar_message * mes, char * data) {
  if ( mes->datalen != 2 )
   return -1;
 
- if ( mes->data[0] != 0 ) // version
-  return -1;
-
- type = (unsigned) mes->data[1];
-
- if ( stream_meta_get(mes->stream, type, NULL, val, LIBROAR_BUFFER_MSGDATA-2) == -1 )
-  return -1;
-
- vallen = strlen(val);
-
- mes->cmd     = ROAR_CMD_OK;
- mes->datalen = 2 + vallen;
-
- mes->data[0] = 0;
- mes->data[1] = (unsigned char) vallen;
-
- val[vallen] = 0;
-
- strncpy(&(mes->data[2]), val, vallen+1);
-
- return 0;
-}
-
-int req_on_list_meta   (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- int i;
- int len = 0;
- int types[ROAR_META_MAX_PER_STREAM];
-
- if ( mes->datalen != 1 )
-  return -1;
-
- if ( mes->data[0] != 0 ) // version
-  return -1;
-
- if ( (len = stream_meta_list(mes->stream, types, ROAR_META_MAX_PER_STREAM)) == -1 )
-  return -1;
-
- mes->cmd     = ROAR_CMD_OK;
- mes->datalen = 1 + len;
- mes->data[0] = 0;
-
- for (i = 0; i < len; i++)
-  mes->data[i+1] = types[i];
-
- return 0;
-}
-#endif
-
-int req_on_gettimeofday (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_time curtime;
- uint64_t * d64 = (uint64_t *)mes->data;
-
- ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
-
- if ( *data != NULL ) {
-  return -1;
- }
-
- ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
-
- if ( mes->datalen && mes->datalen < 8 ) {
-  return -1;
- }
-
- ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
-
- if ( mes->datalen >= 8 ) {
-  if ( *d64 != 0 ) {
-   return -1;
-  }
- }
-
- ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
-
- if ( roar_clock_gettime(&curtime, ROAR_CLOCK_REALTIME) == -1 )
-  return -1;
-
- if ( roar_time_to_msg(mes, &curtime) == -1 )
-  return -1;
-
- mes->cmd = ROAR_CMD_OK;
-
- ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
-
- return 0;
-}
-
-int req_on_server_info (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
-#ifdef ROAR_HAVE_UNAME
- struct utsname utsname;
-#endif
-#ifdef ROAR_HAVE_GETVERSIONEX
- OSVERSIONINFO osinfo;
- char buf_release[80];
-#endif
- struct roar_server_info info;
- uint16_t * d16;
-#ifdef ROAR_HAVE_GETHOSTID
- long hostid;
- char hostidbuf[64];
-#endif
-
- if ( mes->datalen != 4 )
-  return -1;
-
- d16 = (uint16_t*)mes->data;
-
- // check version.
- if ( ROAR_NET2HOST16(d16[0]) != 0 )
-  return -1;
-
- switch (ROAR_NET2HOST16(d16[1])) {
-  case ROAR_IT_SERVER:
-   memset(&info, 0, sizeof(info));
-
-   // the following if is optimized out by compiler.
-   if ( ROAR_VERSION_DISTRIBUTION_STRING[0] == 0 ) {
-    info.version = "roard/" ROAR_VERSION_STRING " <" ROAR_DEV_VENDOR_STRING ">";
-   } else {
-    info.version = "roard/" ROAR_VERSION_STRING " <" ROAR_DEV_VENDOR_STRING "> (" ROAR_VERSION_DISTRIBUTION_STRING ")";
-   }
-
-   info.build   = ROAR_BUILD_STAMP;
-   info.license = ROAR_LICENSE_GPLv3_0;
-
-#ifdef ROAR_HAVE_GETHOSTID
-   hostid = gethostid();
-   snprintf(hostidbuf, sizeof(hostidbuf), sizeof(long) == 8 ? "0x%.16lx" : "0x%.8lx", hostid);
-   info.hostid = hostidbuf;
-#endif
-
-   if ( !!strcmp(g_config->location, CONF_DEF_STRING) )
-    info.location = g_config->location;
-
-   if ( !!strcmp(g_config->description, CONF_DEF_STRING) )
-    info.description = g_config->description;
-
-   info.contact = g_config->contact;
-   info.serial  = g_config->serial;
-   info.uiurl   = g_config->uiurl;
-
-#ifdef ROAR_HAVE_UNAME
-   if ( uname(&utsname) == 0 ) {
-    roar_random_salt_nonce(&utsname, sizeof(utsname));
-    info.un.sysname  = utsname.sysname;
-    info.un.release  = utsname.release;
-    info.un.nodename = utsname.nodename;
-    info.un.machine  = utsname.machine;
-   }
-#endif
-#ifdef ROAR_HAVE_GETVERSIONEX
-   osinfo.dwOSVersionInfoSize = sizeof(osinfo);
-   if ( GetVersionEx(&osinfo) ) {
-    info.un.sysname = "Windows";
-    snprintf(buf_release, sizeof(buf_release), "%i.%i.%i",
-               (int)osinfo.dwMajorVersion, (int)osinfo.dwMinorVersion, (int)osinfo.dwBuildNumber);
-    buf_release[sizeof(buf_release)-1] = 0;
-    info.un.release = buf_release;
-   }
-#endif
-
-   *data = NULL;
-
-   if ( roar_server_info_to_mes(mes, &info, (void**)data) == -1 )
-    return -1;
-
-   if ( *data != NULL )
-    flags[1] |= COMMAND_FLAG_OUT_LONGDATA;
-  break;
-  default: /* unknown request */
-    return -1;
-   break;
- }
-
- mes->cmd = ROAR_CMD_OK;
-
- return 0;
-}
-
-int req_on_server_oinfo    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_stream s;
- int dir = ROAR_DIR_PLAY;
- int subsys;
-//ROAR_DIR_OUTPUT
-
- if ( mes->datalen != 0 ) {
-  if ( mes->datalen != 2 )
-   return -1;
-
-  if ( mes->data[0] != 0 )
-   return -1;
-
-  dir = mes->data[1];
- }
-
- subsys = streams_dir2subsys(dir);
-
- memset(&s, 0, sizeof(struct roar_stream));
-
- s.dir           = ROAR_DIR_MIXING;
- s.pos_rel_id    = -1;
-
- switch (subsys) {
-  case ROAR_SUBSYS_WAVEFORM:
-    s.info.rate     = g_sa->rate;
-    s.info.bits     = g_sa->bits;
-    s.info.channels = g_sa->channels;
-    s.info.codec    = g_sa->codec;
-    s.pos           = g_pos;
-   break;
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-  case ROAR_SUBSYS_MIDI:
-   break;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-  case ROAR_SUBSYS_LIGHT:
-    s.info.rate     = ROAR_OUTPUT_CFREQ;
-    s.info.bits     = ROAR_LIGHT_BITS;
-    s.info.channels = g_light_state.channels;
-   break;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-  case ROAR_SUBSYS_RAW:
-    // no need to set anything here.
-   break;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-  case ROAR_SUBSYS_RDTCS:
-    s.info.rate     = ROAR_OUTPUT_CFREQ;
-    s.info.bits     = ROAR_RDTCS_BITS;
-    s.info.channels = ROAR_RDTCS_CHANNELS;
-    s.info.codec    = ROAR_RDTCS_CODEC;
-   break;
-#endif
-  default:
-    return -1;
-   break;
- }
-
- if ( roar_stream_s2m(&s, mes) == -1 )
-  return -1;
-
- mes->cmd = ROAR_CMD_OK;
-
- return 0;
-}
-
-int req_on_caps        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_caps caps;
- struct roar_stds * stds;
- size_t i;
-
- if ( roar_caps_from_msg(&caps, mes, *data) == -1 )
-  return -1;
-
- // handle the data from the caps command here...
-
- if ( !(caps.flags & ROAR_CF_REQUEST) ) {
-  mes->cmd = ROAR_CMD_OK;
-  mes->datalen = 0;
-  return 0;
- }
-
- mes->datalen = 0;
-
- switch (caps.type) {
-  case ROAR_CT_STANDARDS:
-    if ( (stds = roar_stds_new(g_caps_stds.stds_len)) == NULL )
-     return -1;
-
-    for ( i = 0; i < stds->stds_len; i++) {
-     stds->stds[i] = ROAR_HOST2NET32(g_caps_stds.stds[i]);
-    }
-
-    caps.data = stds->stds;
-    caps.len  = stds->stds_len * 4;
-    // TODO: add support for **data.
-    if ( roar_caps_to_msg(mes, &caps, NULL) == -1 ) {
-     roar_stds_free(stds);
-     return -1;
-    }
-    roar_stds_free(stds);
-   break;
-  default:
-    return -1;
-   break;
- }
-
- mes->cmd = ROAR_CMD_OK;
-
- return 0;
-}
-
-int req_on_get_standby (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- uint16_t * d16 = (uint16_t*)mes->data;
-
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 2;
-
- *d16 = ROAR_HOST2NET16((unsigned) g_standby);
-
- return 0;
-}
-
-int req_on_set_standby (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- uint16_t * d16 = (uint16_t*)mes->data;
-
- if ( mes->datalen != 2 )
-  return -1;
-
- g_standby = ROAR_NET2HOST16(*d16);
-
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_exit      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- int term = 0;
-
- if ( mes->datalen == 1 )
-  term = mes->data[0];
-
- mes->cmd     = ROAR_CMD_OK;
- mes->pos     = g_pos;
- mes->datalen = 0;
-
- ROAR_DBG("req_on_exit(*): term=%i", term);
-
- if ( term ) {
-  cleanup_listen_socket(1);
- } else {
-  alive = 0;
- }
-
- return 0;
-}
-
-int req_on_list_clients(int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+ g_standby = ROAR_NET2HOST16(*((uint16_t*)mes->data));
+
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
+
+ return 0;
+}
+
+int req_on_exit      (int client, struct roar_message * mes, char * data) {
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
+
+ alive = 0;
+
+ return 0;
+}
+
+int req_on_list_clients(int client, struct roar_message * mes, char * data) {
  unsigned char filter, cmp;
  uint32_t id;
@@ -1074,34 +167,21 @@
  return 0;
 }
-int req_on_list_streams(int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+int req_on_list_streams(int client, struct roar_message * mes, char * data) {
  unsigned char filter, cmp;
  uint32_t id;
  int streams[ROAR_STREAMS_MAX];
  int i, c = 0;
- int match;
 
  if ( roar_ctl_m2f(mes, &filter, &cmp, &id) == -1 )
   return -1;
 
+ // TODO: add code to support filter
+ if ( filter != ROAR_CTL_FILTER_ANY )
+  return -1;
+
  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( g_streams[i] == NULL )
-   continue;
-
-  match = 0;
-
-  switch (filter) {
-   case ROAR_CTL_FILTER_ANY:
-     match = 1;
-    break;
-   case ROAR_CTL_FILTER_DIR:
-     match = roar_filter_match(cmp, id, ROAR_STREAM(g_streams[i])->dir);
-    break;
-   default: // unsupported filter...
-     return -1;
-    break;
+  if ( g_streams[i] != NULL ) {
+   streams[c++] = i;
   }
-
-  if ( match )
-   streams[c++] = i;
  }
 
@@ -1113,15 +193,10 @@
 }
 
-int req_on_get_client  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+int req_on_get_client  (int client, struct roar_message * mes, char * data) {
  struct roar_client * c;
- int ret;
 
  if ( mes->datalen != 1 )
   return -1;
 
- if ( *data != NULL )
-  roar_mm_free(*data);
- *data = NULL;
-
  if ( clients_get(mes->data[0], &c) == -1 )
   return -1;
@@ -1129,13 +204,8 @@
  mes->cmd = ROAR_CMD_OK;
 
- ret = roar_ctl_c2m2(mes, c, (void**)data);
-
- if ( *data != NULL )
-  flags[1] |= COMMAND_FLAG_OUT_LONGDATA;
-
- return ret;
-}
-
-int req_on_get_stream  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+ return roar_ctl_c2m(mes, c);
+}
+
+int req_on_get_stream  (int client, struct roar_message * mes, char * data) {
  struct roar_stream_server * s;
 
@@ -1147,502 +217,18 @@
 
  mes->cmd = ROAR_CMD_OK;
- mes->stream = mes->data[0];
 
  return roar_stream_s2m(ROAR_STREAM(s), mes);
 }
 
-int req_on_get_stream_para (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_stream * s;
- struct roar_stream_server * ss;
- struct roar_audio_info * audio_info;
- struct roar_stream_ltm * ltm;
- struct roar_stream_rpg   rpg;
- uint16_t * d  = (uint16_t *) mes->data;
- int64_t * d64 = ( int64_t *) mes->data;
- int64_t * d64ptr;
- int i, h, k;
- char * str;
- size_t needed;
- int test, bits;
-
- ROAR_DBG("req_on_get_stream_para(client=%i, mes=%p{.stream=%i, .datalen=%i,...}, data=%p, flags=%p) = ?", client, mes, (int)mes->stream, (int)mes->datalen, data, flags);
-
- if ( mes->datalen < 4 )
-  return -1;
-
- for (i = 0; i < 2; i++) {
-  d[i] = ROAR_NET2HOST16(d[i]);
- }
-
- if ( d[0] != 0 ) {
-  ROAR_WARN("req_on_get_stream_para(*): unsupported command version: %i, %i", (int)d[0], (int)d[1]);
-  return -1;
- }
-
- switch (d[1]) {
-  case ROAR_STREAM_PARA_INFO:
-    if ( streams_get(mes->stream, &ss) == -1 ) {
-     ROAR_WARN("req_on_get_stream_para(*): request on non existing (or other error?) stream %i", mes->stream);
-     return -1;
-    }
-
-    if ( streams_calc_delay(mes->stream) == -1 ) {
-     ROAR_WARN("req_on_get_stream_para(*): can not calc delay for stream %i", mes->stream);
-    }
-
-    s = ROAR_STREAM(ss);
-
-    audio_info = &(s->info);
-
-    mes->datalen = 2*12;
-
-    d[ 2] = ROAR_OUTPUT_CALC_OUTBUFSIZE(audio_info);
-    d[ 3] = ss->pre_underruns;
-    d[ 4] = ss->post_underruns;
-    d[ 5] = ss->codec_orgi;
-    d[ 6] = (ss->flags & 0xFFFF) | (ss->primary ? ROAR_FLAG_PRIMARY : 0) | (ss->driver_id != -1 ? ROAR_FLAG_OUTPUT : 0);
-    d[ 7] = ss->delay/1000;
-    d[ 8] = ss->state;
-    d[ 9] = (ss->flags & 0xFFFF0000) >> 16;
-    d[10] = ss->mixer_stream;
-    d[11] = ss->role;
-
-    ROAR_DBG("req_on_get_stream_para(*): ss->driver_id=%i", ss->driver_id);
-
-    ROAR_DBG("req_on_get_stream_para(*): delay=%i, send delay=%i", ss->delay, d[7]);
-
-    for (i = 0; i < mes->datalen/2; i++) {
-     d[i] = ROAR_HOST2NET16(d[i]);
-    }
-
-    mes->pos = s->pos;
-   break;
-
-  case ROAR_STREAM_PARA_NAME:
-   str = streams_get_name(mes->stream);
-
-   if ( str == NULL )
-    return -1;
-
-    mes->datalen = 4 + strlen(str);
-
-    if ( mes->datalen > LIBROAR_BUFFER_MSGDATA )
-     return -1;
-
-    strncpy(((char*)&(mes->data))+4, str, mes->datalen);
-
-    d[0] = ROAR_HOST2NET16(d[0]);
-    d[1] = ROAR_HOST2NET16(d[1]);
-   break;
-
-  case ROAR_STREAM_PARA_CHANMAP:
-    if ( streams_get(mes->stream, &ss) == -1 ) {
-     ROAR_WARN("req_on_get_stream_para(*): request on non existing (or other error?) stream %i", mes->stream);
-     return -1;
-    }
-
-    s = ROAR_STREAM(ss);
-
-    memcpy(&(mes->data[4]), ss->chanmap.in, s->info.channels);
-    mes->datalen = 2*2 + s->info.channels;
-
-    d[0] = ROAR_HOST2NET16(d[0]);
-    d[1] = ROAR_HOST2NET16(d[1]);
-   break;
-
-  case ROAR_STREAM_PARA_LTM:
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM request...", client);
-
-    if ( mes->datalen < (6 * 2) ) {
-     ROAR_ERR("req_on_get_stream_para(client=%i, ...): LTM request of client is corruped: message too short", client);
-     return -1;
-    }
-
-    for (i = 2; i < mes->datalen/2; i++) {
-     d[i] = ROAR_NET2HOST16(d[i]);
-    }
-
-    if ( d[2] != ROAR_LTM_SST_GET_RAW ) {
-     ROAR_ERR("req_on_get_stream_para(client=%i, ...): LTM request of client is corruped: unknown LTM subtype: %i", client, (int)d[2]);
-     return -1;
-    }
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM request of type GET_RAW", client);
-
-    test = d[5];
-    bits = 0;
-    while (test) {
-     if ( test & 0x1 )
-      bits++;
-
-     test >>= 1;
-    }
-
-    needed = 0;
-
-    if ( mes->stream == -1 ) {
-     ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM multi-stream request...", client);
-
-     for (i = 6; i < mes->datalen/2; i++) {
-      if ( (ltm = streams_ltm_get(d[i], d[5], d[3])) == NULL )
-       return -1;
-
-      needed += ltm->channels;
-     }
-    } else {
-     ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM single-stream request for stream %i...", client, mes->stream);
-     if ( (ltm = streams_ltm_get(mes->stream, d[5], d[3])) == NULL )
-      return -1;
-
-     needed = ltm->channels;
-    }
-
-    needed *= bits;
-
-    needed += mes->stream == -1 ? (mes->datalen/2) - 6 : 1;
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): data size for answer is %i 64 bit sub-packets", client, (int)needed);
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): mes->datalen=%i, data=%p{%p}", client, (int)mes->datalen, data, *data);
-    d64 = _dataspace(mes, data, flags, needed * 8);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-
-    if ( (d = roar_mm_malloc(mes->datalen)) == NULL )
-     return -1;
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d=%p, data=%p{%p}", client, d, data, *data);
-
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): mes->datalen=%i, data=%p{%p}", client, (int)mes->datalen, data, *data);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-    memcpy(d, mes->data, mes->datalen);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-
-    d64ptr = d64;
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): mes->datalen=%i, data=%p{%p}", client, (int)mes->datalen, data, *data);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-
-    if ( mes->stream == -1 ) {
-     for (i = 6; i < mes->datalen/2; i++) {
-      ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-
-      if ( (ltm = streams_ltm_get(d[i], d[5], d[3])) == NULL )
-       return -1;
-
-      *d64ptr = ltm->channels & 0xFFFF;
-       d64ptr++;
-
-      for (h = 0; h < ltm->channels; h++) {
-       for (k = 0; k < ROAR_LTM_MTBITS; k++) {
-        if ( d[5] & (1<<k) ) {
-         switch (1<<k) {
-          case ROAR_LTM_MT_RMS:
-            *d64ptr = ltm->cur[h].rms;
-           break;
-          default:
-            ROAR_ERR("req_on_get_stream_para(client=%i, ...): client requets unknown MT for LTM: bit %i", client, k);
-         }
-         d64ptr++;
-        }
-       }
-      }
-     }
-    } else {
-     if ( (ltm = streams_ltm_get(mes->stream, d[5], d[3])) == NULL )
-      return -1;
-
-     *d64ptr = ltm->channels & 0xFFFF;
-      d64ptr++;
-
-     for (h = 0; h < ltm->channels; h++) {
-      for (k = 0; k < ROAR_LTM_MTBITS; k++) {
-       if ( d[5] & (1<<k) ) {
-        switch (1<<k) {
-         case ROAR_LTM_MT_RMS:
-           *d64ptr = ltm->cur[h].rms;
-           ROAR_DBG("req_on_get_stream_para(client=%i, ...): rms=%lli to %p", client, (long long int)*d64ptr, d64ptr);
-          break;
-         default:
-           ROAR_ERR("req_on_get_stream_para(client=%i, ...): client requets unknown MT for LTM: bit %i", client, k);
-        }
-        d64ptr++;
-       }
-      }
-     }
-    }
-
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-
-    roar_mm_free(d);
-
-    for (i = 0; i < needed; i++) {
-     d64[i] = ROAR_HOST2NET64(d64[i]);
-    }
-
-    mes->datalen = needed * 8;
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM d64=%p, d64ptr=%p", client, d64, d64ptr);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM final message has %i byte of data", client, (int)mes->datalen);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): d64=%p, data=%p{%p}", client, d64, data, *data);
-    ROAR_DBG("req_on_get_stream_para(client=%i, ...): LTM GET_RAW request: OK. returning...", client);
-   break;
-
-  case ROAR_STREAM_PARA_RPG:
-    if ( streams_get_rpg(mes->stream, &rpg) == -1 ) {
-     return -1;
-    }
-
-    mes->datalen = 2*5;
-
-    d[2] = rpg.mode;
-    d[3] = rpg.mul;
-    d[4] = rpg.div;
-
-    for (i = 0; i < mes->datalen/2; i++) {
-     d[i] = ROAR_HOST2NET16(d[i]);
-    }
-   break;
-
-  default:
-    ROAR_WARN("req_on_get_stream_para(*): unsupported command: %i", d[1]);
-    return -1;
- }
-
- ROAR_DBG("req_on_get_stream_para(client=%i, mes=%p{.stream=%i, .datalen=%i,...}, data=%p, flags=%p) = 0 // returning OK", client, mes, (int)mes->stream, (int)mes->datalen, data, flags);
- mes->cmd = ROAR_CMD_OK;
- return 0;
-}
-
-int req_on_set_stream_para (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_stream_server * ss;
- struct roar_stream_rpg rpg;
- uint16_t * d = (uint16_t *) mes->data;
- uint32_t tmp, tmp2, flagstore;
- int protect = 0;
- int i;
-
- if ( mes->datalen < 2*2 )
-  return -1;
-
- for (i = 0; i < 2; i++) {
-  d[i] = ROAR_NET2HOST16(d[i]);
- }
-
- if ( d[0] != 0 )
-  return -1;
-
- switch (d[1]) {
-  case ROAR_STREAM_PARA_FLAGS:
-    if ( mes->datalen != 2*4 && mes->datalen != 2*5 )
-     return -1;
-
-    d[2] = ROAR_NET2HOST16(d[2]);
-    d[3] = ROAR_NET2HOST16(d[3]);
-
-    ROAR_DBG("req_on_set_stream_para(*): request seems to be valid");
-
-    tmp = 0;
-
-    if ( mes->datalen == 2*5 ) {
-     d[4] = ROAR_NET2HOST16(d[4]);
-     tmp   = d[4];
-     tmp <<= 16;
-    }
-
-    tmp |= d[3];
-
-    if ( d[2] & ROAR_PROTECT_FLAG ) {
-     protect = 1;
-     d[2] -= ROAR_PROTECT_FLAG;
-    }
-
-    switch (d[2]) {
-     case ROAR_SET_FLAG:
-       if ( streams_set_flag(mes->stream, tmp) == -1 )
-        return -1;
-      break;
-     case ROAR_RESET_FLAG:
-       if ( streams_reset_flag(mes->stream, tmp) == -1 )
-        return -1;
-      break;
-     case ROAR_NOOP_FLAG:
-      break;
-     case ROAR_TOGGLE_FLAG:
-       if ( streams_get(mes->stream, &ss) == -1 )
-        return -1;
-
-       flagstore = ss->flags;
-
-       tmp2 = flagstore & tmp; // those are the flags we need to reset.
-       ROAR_DBG("req_on_set_stream_para(*): tmp2=0x%.8lx", (long int)tmp2);
-       if ( tmp2 )
-        if ( streams_reset_flag(mes->stream, tmp2) == -1 )
-         return -1;
-
-       tmp2 = (flagstore ^ tmp) & tmp; // those are the flags we need to set.
-       ROAR_DBG("req_on_set_stream_para(*): tmp2=0x%.8lx", (long int)tmp2);
-       if ( tmp2 )
-        if ( streams_set_flag(mes->stream, tmp2) == -1 )
-         return -1;
-      break;
-     default:
-       return -1;
-      break;
-    }
-
-   ROAR_DBG("req_on_set_stream_para(*): protect=%i", protect);
-   if ( protect )
-    if ( streams_protect_flag(mes->stream, tmp) == -1 )
-     return -1;
-
-   break;
-  case ROAR_STREAM_PARA_CHANMAP:
-    if ( streams_set_map(mes->stream, &(mes->data[4]), mes->datalen - 4) == -1 )
-     return -1;
-   break;
-  case ROAR_STREAM_PARA_ROLE:
-    if ( mes->datalen != 2*3 )
-     return -1;
-
-    d[2] = ROAR_NET2HOST16(d[2]);
-
-    if ( streams_set_role(mes->stream, d[2]) == -1 )
-     return -1;
-   break;
-  case ROAR_STREAM_PARA_LTM:
-    if ( mes->datalen < (6 * 2) )
-     return -1;
-
-    for (i = 2; i < mes->datalen/2; i++) {
-     d[i] = ROAR_NET2HOST16(d[i]);
-    }
-
-    if ( mes->stream == -1 ) {
-     for (i = 6; i < mes->datalen/2; i++)
-      if ( streams_ltm_ctl(d[i], d[5], d[3], d[2]) == -1 )
-       return -1;
-    } else {
-     if ( streams_ltm_ctl(mes->stream, d[5], d[3], d[2]) == -1 )
-      return -1;
-    }
-   break;
-  case ROAR_STREAM_PARA_RPG:
-    if ( mes->datalen != (5 * 2) )
-     return -1;
-
-    for (i = 2; i < mes->datalen/2; i++) {
-     d[i] = ROAR_NET2HOST16(d[i]);
-    }
-
-    rpg.mode = d[2];
-    rpg.mul  = d[3];
-    rpg.div  = d[4];
-
-    if ( streams_set_rpg(mes->stream, &rpg) == -1 )
-     return -1;
-   break;
-  default:
-    ROAR_WARN("req_on_set_stream_para(*): unsupported command version: %i, %i", d[0], d[1]);
-    return -1;
-   break;
- }
-
- mes->cmd     = ROAR_CMD_OK;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_kick (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_stream_server * ss;
- uint16_t * info = (uint16_t *) mes->data;
- int is_stream = 0;
+int req_on_kick (int client, struct roar_message * mes, char * data) {
+ uint16_t * info = mes->data;
 
  if ( mes->datalen != 4 )
   return -1;
 
- info[0] = ROAR_NET2HOST16(info[0]);
- info[1] = ROAR_NET2HOST16(info[1]);
-
- switch (info[0]) {
-  case ROAR_OT_CLIENT:
-    clients_delete(info[1]);
-   break;
-  case ROAR_OT_STREAM:
-    is_stream = 1;
-   break;
-  case ROAR_OT_SOURCE:
-    if ( streams_get_flag(info[1], ROAR_FLAG_SOURCE) != 1 )
-     return -1;
-    is_stream = 1;
-   break;
-  case ROAR_OT_OUTPUT:
-    if ( streams_get(info[1], &ss) == -1 )
-     return -1;
-
-    if ( ss->driver_id == -1 )
-     return -1;
-
-    is_stream = 1;
-   break;
-  case ROAR_OT_MIXER:
-    if ( streams_get(info[1], &ss) == -1 )
-     return -1;
-
-    if ( ROAR_STREAM(ss)->dir != ROAR_DIR_MIXING )
-     return -1;
-
-    is_stream = 1;
-   break;
-  case ROAR_OT_BRIDGE:
-    if ( streams_get(info[1], &ss) == -1 )
-     return -1;
-
-    if ( ROAR_STREAM(ss)->dir != ROAR_DIR_BRIDGE )
-     return -1;
-
-    is_stream = 1;
-   break;
-  default:
-/* TODO: those types should be handled, too:
-#define ROAR_OT_SAMPLE    4
-#define ROAR_OT_LISTEN    8
-#define ROAR_OT_ACTION    9
-#define ROAR_OT_MSGQUEUE 10
-#define ROAR_OT_MSGBUS   11
-*/
-    return -1;
-   break;
- }
-
- if ( is_stream ) {
-  if ( streams_get_flag(info[1], ROAR_FLAG_IMMUTABLE) == 1 )
-   return -1;
-
+ if ( info[0] == ROAR_OT_CLIENT ) {
+  clients_delete(info[1]);
+ } else if ( info[0] == ROAR_OT_STREAM ) {
   streams_delete(info[1]);
- }
-
- mes->cmd     = ROAR_CMD_OK;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_attach      (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- uint16_t * info = (uint16_t *) mes->data;
-
- if ( mes->datalen < 6 )
-  return -1;
-
- info[0] = ROAR_NET2HOST16(info[0]);
- info[1] = ROAR_NET2HOST16(info[1]);
- info[2] = ROAR_NET2HOST16(info[2]);
-
- if ( info[0] != 0 )
-  return -1;
-
- if ( info[1] == ROAR_ATTACH_SIMPLE ) {
-  if ( client_stream_move(info[2], mes->stream) == -1 )
-   return -1;
  } else {
   return -1;
@@ -1655,300 +241,30 @@
 }
 
-int req_on_set_vol (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_mixer_settings tmpmixer;
- struct roar_stream_server * s;
- uint16_t * info = (uint16_t *) mes->data;
- uint16_t   version;
- uint16_t   scale = 65535;
- int stream;
- int i;
- int chans;
-
- ROAR_DBG("req_on_set_vol(*) = ?");
- ROAR_DBG("req_on_set_vol(*): mes->datalen=%i", mes->datalen);
-
- if ( mes->datalen < (4*2) )
-  return -1;
-
- version = ROAR_NET2HOST16(info[0]);
- ROAR_DBG("req_on_set_vol(*): version=%i", (int)version);
-
- switch (version) {
-  case 0:
-    stream = ROAR_NET2HOST16(info[1]);
-   break;
-  case 1:
-    stream = mes->stream;
-    scale  = ROAR_NET2HOST16(info[1]);
-   break;
-  default:
-    return -1;
-   break;
- }
- ROAR_DBG("req_on_set_vol(*): stream=%i", stream);
-
- if ( scale == 0 )
-  return -1;
-
- // TODO: change this code.
- //       we should not directly change the stream object but use some stream_*()-func
- //       for that job.
-
- if ( stream < 0 || stream >= ROAR_STREAMS_MAX )
-  return -1;
-
- s = g_streams[stream];
-
- if ( s == NULL )
-  return -1;
-
- ROAR_DBG("req_on_set_vol(*): s=%p", s);
-
- info[2] = ROAR_NET2HOST16(info[2]);
-
- switch (info[2]) {
-  case ROAR_SET_VOL_ALL:
-    chans = (mes->datalen/2) - 3;
-    ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ALL, channes=%i", chans);
-
-    if ( chans >= ROAR_MAX_CHANNELS )
-     return -1;
-
-    ROAR_DBG("req_on_set_vol(*): mixer at %p", s->mixer.mixer);
-
-    for (i = 0; i < chans; i++) {
-     s->mixer.mixer[i] = ROAR_NET2HOST16(info[i+3]);
-     ROAR_DBG("req_on_set_vol(*): channel %i: %i", i, ROAR_NET2HOST16(info[i+3]));
-    }
-
-    s->mixer.scale = scale;
-
-    ROAR_DBG("req_on_set_vol(*): mixer changed!");
-
-   break;
-  case ROAR_SET_VOL_ONE:
-    ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ONE");
-    if ( ROAR_NET2HOST16(info[3]) >= ROAR_MAX_CHANNELS )
-     return -1;
-
-    s->mixer.mixer[ROAR_NET2HOST16(info[3])] = ROAR_NET2HOST16(info[4]);
-
-    s->mixer.scale = scale;
-   break;
-  case ROAR_SET_VOL_UNMAPPED:
-    chans = (mes->datalen/2) - 3;
-
-    if ( chans >= ROAR_MAX_CHANNELS )
-     return -1;
-
-    memcpy(&tmpmixer, &(s->mixer), sizeof(tmpmixer));
-
-    for (i = 0; i < chans; i++) {
-     tmpmixer.mixer[i] = ROAR_NET2HOST16(info[i+3]);
-    }
-
-    tmpmixer.scale = scale;
-
-    if ( roar_conv_volume(&(s->mixer), &tmpmixer, ROAR_STREAM(s)->info.channels, chans) == -1 )
-     return -1;
-
-   break;
-  case ROAR_SET_VOL_MS:
-  default:
-    return -1;
- }
-
- if ( streams_set_mixer(stream) == -1 )
-  return -1;
-
- mes->cmd     = ROAR_CMD_OK;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_get_vol (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- uint16_t * info = (uint16_t *) mes->data;
- uint16_t   version = -1;
- int stream;
- struct roar_stream_server * s;
- int i;
- int chans;
-
- ROAR_DBG("req_on_get_vol(*) = ?");
- ROAR_DBG("req_on_get_vol(*): mes->datalen=%i", mes->datalen);
-
- if ( mes->datalen < 2 ) {
-  return -1;
- }
-
- version = ROAR_NET2HOST16(info[0]);
-
- switch (version) {
-  case 0:
-    if ( mes->datalen < (2*2) )
-     return -1;
-
-    stream = ROAR_NET2HOST16(info[1]);
-   break;
-  case 1:
-    stream = mes->stream;
-   break;
-  default:
-    return -1;
-   break;
- }
-
- ROAR_DBG("req_on_get_vol(*): stream=%i", stream);
-
- // TODO: change this code.
- //       we should not directly change the stream object but use some stream_*()-func
- //       for that job.
-
- if ( stream < 0 || stream >= ROAR_STREAMS_MAX )
-  return -1;
-
- s = g_streams[stream];
-
- if ( s == NULL )
-  return -1;
-
- ROAR_DBG("req_on_get_vol(*): s=%p", s);
-
- // ok, we have everything
-
- info[0] = ROAR_HOST2NET16(version);
-
- switch (version) {
-  case 0:
-    info[1] = ROAR_HOST2NET16(chans = ROAR_STREAM(s)->info.channels);
-
-    for (i = 0; i < chans; i++)
-     info[2+i] = ROAR_HOST2NET16(s->mixer.mixer[i]);
-
-     mes->datalen = (2 + chans)*2;
-   break;
-  case 1:
-    info[1] = ROAR_HOST2NET16(chans = ROAR_STREAM(s)->info.channels);
-    info[2] = ROAR_HOST2NET16(s->mixer.scale);
-    info[3] = ROAR_HOST2NET16(s->mixer.rpg_mul);
-    info[4] = ROAR_HOST2NET16(s->mixer.rpg_div);
-
-    for (i = 0; i < chans; i++)
-     info[5+i] = ROAR_HOST2NET16(s->mixer.mixer[i]);
-
-     mes->datalen = (5 + chans)*2;
-   break;
-  default:
-    return -1;
-   break;
- }
-
- mes->cmd = ROAR_CMD_OK;
-
- return 0;
-}
-
-int req_on_add_data (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
+
+int req_on_add_data (int client, struct roar_message * mes, char * data) {
  struct roar_buffer * b;
- void               * buf;
-
- if ( roar_buffer_new_data(&b, mes->datalen, &buf) == -1 ) {
+ char               * buf;
+
+ if ( roar_buffer_new(&b, mes->datalen) == -1 ) {
   ROAR_ERR("req_on_add_data(*): Can not alloc buffer space!");
   ROAR_DBG("req_on_add_data(*) = -1");
   return -1;
  }
+
+ roar_buffer_get_data(b, (void **)&buf);
 
  if ( data == NULL ) {
   memcpy(buf, mes->data, mes->datalen);
  } else {
-  memcpy(buf, *data, mes->datalen);
- }
-
- if ( stream_add_buffer(mes->stream, &b) == -1 ) {
+  memcpy(buf, data, mes->datalen);
+ }
+
+ if ( stream_add_buffer(mes->stream, b) == -1 ) {
   roar_buffer_free(b);
   return -1;
  }
 
- mes->cmd     = ROAR_CMD_OK_STOP;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_beep        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- struct roar_beep bs;
- int16_t * info = (int16_t*)mes->data;
- int stream;
-
- memset(&bs, 0, sizeof(bs));
-
- if ( mes->datalen > 0 ) {
-  if ( mes->datalen < 2 )
-   return -1;
-
-  if ( ROAR_NET2HOST16(info[0]) != 0 ) /* version */
-   return -1;
-
-  if ( mes->datalen != 8*2 )
-   return -1;
-
-  bs.vol  = ROAR_NET2HOST16(info[1]);
-  bs.time = ROAR_NET2HOST16(info[2]);
-  bs.freq = ROAR_NET2HOST16(info[3]);
-  bs.type = ROAR_NET2HOST16(info[4]);
-  bs.x    = ROAR_NET2HOST16(info[5]);
-  bs.y    = ROAR_NET2HOST16(info[6]);
-  bs.z    = ROAR_NET2HOST16(info[7]);
- }
-
- if ( (stream = beep_start(client, &bs)) == -1 )
-  return -1;
-
- mes->stream  = stream;
- mes->cmd     = ROAR_CMD_OK_STOP;
- mes->datalen = 0;
-
- return 0;
-}
-
-int req_on_wait        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
- uint16_t * u16 = (uint16_t*)mes->data;
- struct roar_event events[4];
- size_t left, tmp;
- size_t num = 0;
- void * vp = mes->data;
-
- vp += 4;
-
- // check for complet header...
- if ( mes->datalen < 4 )
-  return -1;
-
- u16[0] = ROAR_NET2HOST16(u16[0]);
- u16[1] = ROAR_NET2HOST16(u16[1]);
-
- // do we support version and flags?
- if ( u16[0] != 0 || u16[1] != 0 )
-  return -1;
-
- memset(events, 0, sizeof(events));
-
- left = mes->datalen - 4;
-
- while (left) {
-  tmp = left;
-  if ( roar_event_from_blob(&(events[num]), vp, &tmp) == -1 )
-   return -1;
-
-  vp   += tmp;
-  left -= tmp;
-  num++;
- }
-
- if ( clients_wait(client, events, num) == -1 )
-  return -1;
-
- flags[1] |= COMMAND_FLAG_OUT_NOSEND;
+ mes->cmd     = ROAR_CMD_OK;
+ mes->datalen = 0;
 
  return 0;
Index: roard/roard.c
===================================================================
--- roard/roard.c	(revision 6052)
+++ roard/roard.c	(revision 0)
@@ -1,331 +1,35 @@
 //roard.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-/* ckport options:
- * Stuff checked by configure:
- * ckport: ignore-symbol: getuid of target win32
- * ckport: ignore-symbol: setuid of target win32
- * ckport: ignore-symbol: getgid of target win32
- * ckport: ignore-symbol: setgid of target win32
- * ckport: ignore-symbol: setsid of target win32
- * ckport: ignore-symbol: kill of target win32
- * ckport: ignore-symbol: chroot of target win32
- * ckport: ignore-symbol: fork of target win32
- * ckport: ignore-symbol: getservbyname of target win32
- * ckport: ignore-symbol: nice of target win32
- *
- */
 
 #include "roard.h"
 
-enum metaaction {
- MA_ACTION,
- MA_LIST_PROTO,
- MA_LIST_PLUGIN
-};
-
-enum action {
- START,
- STOP,
- RESTART,
- RESTART_RETRY,
- SHUTDOWN
-};
-
-enum af_mode {
- AF_MODE_NONE,
- AF_MODE_LOAD,
- AF_MODE_GEN
-};
-
-// some stuff we only define extern globally.
-int g_verbose = ROAR_DBG_INFO_NONE;
-
-int alive;
-#ifdef ROAR_SUPPORT_LISTEN
-int g_no_listen;
-#endif
-
-uint32_t g_pos; // current position in output stream
-
-int g_standby;
-int g_autostandby;
-
-struct roard_listen g_listen[ROAR_MAX_LISTEN_SOCKETS];
-
-int g_self_client;
-
-int g_terminate;
-
-struct roar_audio_info * g_sa, * g_max_sa;
-
-struct roard_config * g_config;
-
-struct counters g_counters;
-// end of extern block.
-
-#ifdef ROAR_SUPPORT_LISTEN
-static const char * server[ROAR_MAX_LISTEN_SOCKETS];
-#endif
-
-#if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_FS_POSIX)
-#define SUPPORT_PIDFILE
-static char * pidfile = NULL;
-#endif
-
-#if defined(ROAR_HAVE_SETGID) || defined(ROAR_HAVE_SETUID)
-static int    setids    = 0;
-#endif
-
-#ifdef ROAR_HAVE_LIBX11
-static char * x11display = NULL;
-#endif
-
-#ifdef ROAR_HAVE_MAIN_ARGS
 void usage (void) {
  printf("Usage: roard [OPTIONS]...\n\n");
 
- printf("Misc Options:\n\n");
- printf(
-#if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32)
-        " --daemon              - Bring the server into background after init\n"
-#endif
-        " --verbose             - Be more verbose, can be used multiple times\n"
-        " --terminate           - Terminate after last client quited\n"
-        " --start               - No op parameter (starting roard is default operation)\n"
-        " --restart             - Trys to stop an old instance and start a new with new settings\n"
-        " --stop                - Stops a running roard (provide --pidfile!)\n"
-        " --shutdown            - Terminates a running roard (provide --pidfile!)\n"
-        " --realtime            - Trys to get realtime priority,\n"
-        "                         give multible times for being more realtime\n"
-        " --memlock LEVEL       - Set default memory locking level to LEVEL\n"
-        " --watchdog            - Enable watchdog\n"
-        " --watchdog-time TIME  - Set watchdog time to TIME (in ms)\n"
-#ifdef ROAR_HAVE_CHROOT
-        " --chroot DIR          - chroots to the given dir\n"
-#endif
-#ifdef ROAR_HAVE_SETGID
-        " --setgid              - GroupID to the audio group as specified via -G\n"
-#endif
-#ifdef ROAR_HAVE_SETUID
-        " --setuid              - UserID to the audio user as specified via -U\n"
-#endif
-        " --sysclocksync        - calculate exact sample rate using the system clock\n"
-        " --location  LOC       - Set lion readable location of server\n"
-        " --description  DESC   - Set lion readable description of server\n"
-        " --contact CONTACT     - Set contact for this server\n"
-        " --serial SERIAL       - Set serial for this device or server\n"
-        "                         (for embedded devices only)\n"
-        " --uiurl UIURL         - Set URL for userinterface of this device or server\n"
-        "                         (for embedded devices only)\n"
-#ifdef SUPPORT_PIDFILE
-        " --pidfile PIDFILE     - Write a pidfile at PIDFILE\n"
-#endif
-#ifdef ROAR_HAVE_SYSLOG
-        " --log-syslog          - Log Warnings, Errors, ... to syslog\n"
-#endif
-#ifdef ROAR_HAVE_SYSTEM
-        " --script-postdown S   - Run command lion S after complet shutdown.\n"
-#endif
-       );
-
- printf("\nAuth Options:\n\n");
- printf(
-        " --guest-acclev ACCLEV - Sets the access level for guest access to ACCLEV,\n"
-        "                         Use \"none\" to disable guest access.\n"
-        " --trust-acclev ACCLEV - Sets the access level for trust-authed\n"
-        "                         connections to ACCLEV. Use \"none\" to disable trust auth.\n"
-        " --trust-root          - Trust root user\n"
-        " --no-trust-root       - Don't trust root user\n"
-        " --authfile-gen FILE   - Generate an new authfile\n"
-        " --authfile-load FILE  - Load an authfile\n"
-        " --authfile-type TYPE  - Type of authfile\n"
-        " --authfile-acclev ACCLEV\n"
-        "                       - Sets the access level for authfile\n"
-        " --new-authfile        - Parameters for new authfile follow\n"
-       );
-
- printf("\nPlugin Options:\n\n");
- printf(
-        " --plugin-load FILE    - Load plugin FILE\n"
-        " --plugin-args ARGS    - Arguments for the plugin\n"
-        "                         (must be given before the --plugin-load)\n"
-        " --list-plugins        - List loaded plugins\n"
-       );
-
- printf("\nAudio Options:\n\n");
+ printf("Audio Options:\n\n");
  printf(
         " -R  --rate   RATE     - Set server rate\n"
         " -B  --bits   BITS     - Set server bits\n"
         " -C  --chans  CHANNELS - Set server channels\n"
-        " --aiprofile  PROFILE  - Use the given audio profile\n"
        );
 
- printf("\nStream Options:\n\n");
- printf(
-        " --stream-flags D=F    - Set default flags for stream directions\n"
-        "                         D is the stream direction and F is a comma separated\n"
-        "                         list of flags in form +flag or -flag to set or unset\n"
-        "                         a flag as default or remove it from the default\n"
-       );
- printf("\nStream Options:\n\n");
- printf(
-        " --list-rolestack      - Show the current role stack\n"
-        " --rolestack-push R:A  - Add a rule for role R with action A on top\n"
-        "                         of the role stack.\n"
-       );
+ printf("\nDriver Options:\n\n");
+ printf(" -d  --driver DRV      - Set the driver, use '-d list' to get a list (default: %s)\n", ROAR_DRIVER_DEFAULT);
+ printf(" -D  --device DEV      - Set the device\n");
+ printf(" -dO OPTS              - Set output options\n");
 
- printf("\nOutput Options:\n\n");
- printf(" -o  --odriver DRV     - Set the driver, use '--list-driver' to get a list\n");
- printf(" -O  --odevice DEV     - Set the device\n");
- printf(" -oO OPTS              - Set output options\n");
- printf(" -oN                   - Adds another output\n");
- printf(" -oP                   - Mark output as primary\n");
-#ifdef ROAR_DRIVER_DEFAULT
- printf(" --list-driver         - List all drivers (default driver: %s)\n", ROAR_DRIVER_DEFAULT);
-#else
- printf(" --list-driver         - List all drivers (default driver: (autodetect))\n");
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
  printf("\nSource Options:\n\n");
  printf(" -s  --source DRV      - Use DRV as input driver\n"
         " -S           DEV      - Use DEV as input device\n"
         " -sO          OPTS     - Use OPTS as input options\n"
-        " -sN                   - Adds another source\n"
         " -sP                   - Make souce as primary\n"
        );
- printf(" --list-sources        - List all sources\n");
-#endif
 
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- printf("\nHardware Mixer Options:\n\n");
- printf(" -m  --mixer  DRV      - Use DRV as mixer driver\n"
-        " -M           DEV      - Use DEV as mixer device\n"
-        " -mO          OPTS     - Use OPTS as mixer options\n"
-        " -mN                   - Adds another mixer\n"
-        " -mP                   - Make mixer as primary\n"
-       );
- printf(" --list-mixers         - List all mixers\n");
-#endif
-
- printf("\nCodec Filter Options:\n\n");
- printf(" --list-cf             - List all codec filter\n"
-       );
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- printf("\nMIDI Options:\n\n");
- printf(" --midi-no-console     - Disable console based MIDI synth\n"
-        " --midi-console-enable - Enables the console based MIDI synth\n"
-        " --midi-console DEV    - Set device for MIDI console\n"
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-        " --ssynth-enable       - Enable simple software synth\n"
-        " --ssynth-disable      - Disable simple software synth\n"
-#endif
-       );
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- printf("\nLight Control Options:\n\n");
- printf(" --light-channels NUM  - Sets the number of channels for Light control (default: %i)\n",
-                                  LIGHT_CHANNELS_DEFAULT
-       );
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
- printf("\nRadio Data and Transmitter Control System Options:\n\n");
- printf(" --rds-pi   PI         - Sets the RDS Programme Identification (PI)\n"
-        " --rds-ps   PS         - Sets the RDS Programme Service Name (PS)\n"
-        " --rds-pty  PTY        - Sets the RDS Programme Type (PTY)\n"
-        " --rds-tp              - Sets the RDS Traffic Programme (TP) flag\n"
-        " --rds-ct              - Enables sending of RDS Clock Time (CT)\n"
-       );
-#endif
-
-#ifdef ROAR_HAVE_LIBX11
- printf("\nX11 Options:\n\n");
- printf(
-        " --x11-display DISPLAY - Set display for X11\n"
-        " --display DISPLAY     - Set display for X11\n"
-       );
-#endif
 
  printf("\nServer Options:\n\n");
  printf(" -t  --tcp             - Use TCP listen socket\n"
-#ifdef ROAR_HAVE_UNIX
         " -u  --unix            - Use UNIX Domain listen socket (default)\n"
-#endif
-#ifdef ROAR_HAVE_LIBDNET
-        " -n  --decnet          - use DECnet listen socket\n"
-#endif
-        " -4                    - Use IPv4 connections (implies -t)\n"
-#ifdef AF_INET6
-        " -6                    - Use IPv6 connections (implies -t)\n"
-#endif
-#ifdef IPV6_ADDRFORM
-        " -64                   - Try to downgrade sockets from IPv6 into IPv4,\n"
-        "                         this is normaly not useful.\n"
-#endif
         " -p  --port            - TCP Port to bind to\n"
         " -b  --bind            - IP/Hostname to bind to\n"
-        "     --sock            - Filename for UNIX Domain Socket\n"
-        "     --proto PROTO     - Use PROTO as protocol on Socket\n"
-        "     --proto-dir DIR   - Set direction parameter for protocol\n"
-        "     --proto-rate RATE - Set sample rate parameter for protocol\n"
-        "     --proto-bits BITS - Set bits per sample parameter for protocol\n"
-        "     --proto-codec E   - Set codec parameter for protocol\n"
-        "     --proto-chans C   - Set number of channels parameter for protocol\n"
-        "     --proto-aiprofile PROFILE\n"
-        "                       - Sets the audio profile for socket\n" 
-        "     --proto-profile P - Set profile for listen socket\n"
-        "     --list-proto      - List supported protocols\n"
-        "     --list-profiles   - List supported profiles for --proto-profile\n"
-        "     --list-aiprofiles - List supported profiles for --proto-aiprofile\n"
-        "     --new-sock        - Parameters for new socket follow\n"
-#ifdef ROAR_HAVE_LIBSLP
-        "     --slp             - Enable OpenSLP support\n"
-#endif
-#ifdef ROAR_HAVE_LIBX11
-        "     --x11             - Enable X11 support\n"
-#endif
-        " --jumbo-mtu MTU       - Sets the MTU for Jumbo Packets\n"
-        " -G  GROUP             - Sets the group for the UNIX Domain Socket, (default: %s)\n"
-        "                         You need the permissions to change the GID\n"
-        " -U  USER              - Sets the user for the UNIX Domain Socket, (default: do not set)\n"
-        "                         You need the permissions to change the UID (normaly only root has)\n"
-        " --no-listen           - Do not listen for new clients\n"
-        "                         (only useful for relaing, impleys --terminate)\n"
-        " --client-fh           - Comunicate with a client over this handle\n"
-        "                         (only useful for relaing)\n"
-        " --close-fh            - Closes the given fh\n"
-        " --standby             - Start in standby state\n"
-        " --auto-standby        - Automatical goes into standby if there are no streams\n",
-#ifdef ROAR_DEFAULT_SOCKGRP
-        ROAR_DEFAULT_SOCKGRP
-#else
-        "(none)"
-#endif
+        " -s  --sock            - Filename for UNIX Domain Socket\n"
        );
 // printf("\n Options:\n\n");
@@ -333,1227 +37,103 @@
 }
 
-#endif
-
-
-struct counters * counters_getptr(void) {
- return &g_counters;
-}
-
-#define _pmsg(format, args...) roar_debug_msg(type, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
-#define _pmsgc(group, counter, name) _pmsg("  Counter %-10s: %" LIBROAR__ll "u", (name), (LIBROAR__longlong unsigned int)(counters->group.counter))
-void counters_print(int type, int force) {
- struct counters * counters = counters_getptr();
- if ( type != ROAR_DEBUG_TYPE_INFO || force || (ROAR_DBG_INFOVAR) >= ROAR_DBG_INFO_INFO ) {
-  _pmsg("--- Counter Listing ---");
-  _pmsg(" Current:");
-  _pmsgc(cur, clients, "Clients");
-  _pmsgc(cur, streams, "Streams");
-  _pmsg(" Total:");
-  _pmsgc(sum, clients, "Clients");
-  _pmsgc(sum, streams, "Streams");
-  _pmsg("--- End of Counter Listing ---");
- }
-}
-#undef _pmsgc
-#undef _pmsg
-
-int restart_server (const char * server, int terminate) {
- struct roar_connection con;
-#ifdef ROAR_HAVE_KILL
- char buf[80];
- ssize_t l;
- struct roar_vio_calls fh;
- pid_t pid;
- int ok;
-
- ROAR_INFO("restart_server(server='%s', terminate=%i): trying to restart server", ROAR_DBG_INFO_INFO, server, terminate);
-
- if ( pidfile != NULL ) {
-  if ( roar_vio_open_dstr_simple(&fh, pidfile, O_RDONLY) ) {
-   ROAR_WARN("restart_server(*): Can not read pidfile: %s", pidfile);
-  } else {
-   l = roar_vio_read(&fh, buf, 80);
-   roar_vio_close(&fh);
-   if ( l > 0 ) {
-    buf[l-1] = 0;
-    buf[79]  = 0;
-    pid = atoi(buf);
-    if ( terminate ) {
-     ok = kill(pid, SIGUSR1);
-    } else {
-     ok = kill(pid, SIGINT);
-    }
-    if ( ok == 0 ) {
-     return 0;
-    } else {
-     ROAR_WARN("restart_server(*): Can not kill roard by pidfile");
-    }
-   } else {
-    ROAR_WARN("restart_server(*): Can not find a PID in the pidfile");
-   }
-  }
- }
-#endif
-
- if ( roar_simple_connect(&con, server, "roard") == -1 ) {
-  return -1;
- }
-
- if ( roar_terminate(&con, terminate) == -1 ) {
-  return -1;
- }
-
- return roar_disconnect(&con);
-}
-
-#define R_SETUID 1
-#define R_SETGID 2
-
-int init_config (void) {
- int i;
-
- memset(g_config, 0, sizeof(struct roard_config));
-
- for (i = 0; i < ROAR_DIR_DIRIDS; i++) {
-  g_config->streams[i].mixer_channels = 1;
-  g_config->streams[i].mixer.rpg_mul  = 1;
-  g_config->streams[i].mixer.rpg_div  = 1;
-  g_config->streams[i].mixer.scale    = 65535;
-  g_config->streams[i].mixer.mixer[0] = g_config->streams[i].mixer.scale;
-  g_config->streams[i].rpgmode        = ROAR_RPGMODE_ALBUMTRACK;
- }
-
- g_config->streams[ROAR_DIR_PLAY    ].flags = ROAR_FLAG_META;
- g_config->streams[ROAR_DIR_OUTPUT  ].flags = ROAR_FLAG_PASSMIXER;
- g_config->streams[ROAR_DIR_FILTER  ].flags = ROAR_FLAG_SYNC;
- g_config->streams[ROAR_DIR_MIDI_OUT].flags = ROAR_FLAG_SYNC;
- g_config->streams[ROAR_DIR_BIDIR   ].flags = ROAR_FLAG_ANTIECHO;
-
- g_config->location    = CONF_DEF_STRING;
- g_config->description = CONF_DEF_STRING;
- g_config->contact     = NULL;
- g_config->serial      = NULL;
- g_config->uiurl       = NULL;
-
- g_config->memlock_level = -1;
-
-#ifdef ROAR_HAVE_SYSTEM
- g_config->scripts.post_shutdown = NULL;
-#endif
-
- return 0;
-}
-
-#ifdef ROAR_SUPPORT_LISTEN
-int init_listening (void) {
- int i;
-
- memset(g_listen, 0, sizeof(g_listen));
-
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-  g_listen[i].proto  = ROAR_PROTO_ROARAUDIO;
-  server[i]          = NULL;
- }
-
- return 0;
-}
-
-int get_listen(struct roard_listen ** sock, const char *** sockname) {
- int i;
-
- if ( sock == NULL )
-  return -1;
-
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-  if ( ! g_listen[i].used ) {
-   server[i] = NULL;
-   *sock = &(g_listen[i]);
-
-   if ( sockname != NULL )
-    *sockname = &(server[i]);
-
-   return 0;
-  }
- }
-
- return -1;
-}
-
-#ifdef ROAR_SUPPORT_LISTEN
-static const struct _listen_profile {
- const char * name;
- int          type;
- int          port;
- const char * sockaddr;
- int          proto;
- int          dir;
- const char * aiprofile;
- const char * desc;
-} _g_listen_profiles[] = {
- // RoarAudio:
-#ifdef ROAR_HAVE_UNIX
- {"roar-usock",     ROAR_SOCKET_TYPE_UNIX,   0,                 "~/" ROAR_DEFAULT_SOCK_USER,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio default user profile"},
- {"roar-gsock",     ROAR_SOCKET_TYPE_UNIX,   0,                 ROAR_DEFAULT_SOCK_GLOBAL,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio default global profile"},
-#endif
-#ifdef ROAR_HAVE_IPV4
- {"roar-tcp",       ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PORT, ROAR_DEFAULT_INET4_HOST,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio local TCP profile"},
- {"roar-tcp-pub",   ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"roar-tcp6",      ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_PORT, ROAR_DEFAULT_INET6_HOST,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio local TCP profile"},
- {"roar-tcp-pub6",  ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_LIBDNET
- {"roar-dnet",      ROAR_SOCKET_TYPE_DECNET, 0,                 ROAR_DEFAULT_LISTEN_OBJECT,
-                    ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio default DECnet"},
-#endif
-#ifdef ROAR_HAVE_UNIX
- {"roar-abstract",  ROAR_SOCKET_TYPE_UNKNOWN,   0,              "+abstract",        ROAR_PROTO_ROARAUDIO, -1, NULL,
-                    "RoarAudio abstract namespace profile"},
-#endif
-
- // EsounD:
-#if !defined(ROAR_WITHOUT_DCOMP_EMUL_ESD) && defined(ROAR_HAVE_H_ESD)
-#ifdef ROAR_HAVE_UNIX
- {"esd-unix",       ROAR_SOCKET_TYPE_UNIX,   0,                 ROAR_DEFAULT_ESD_GSOCK,
-                    ROAR_PROTO_ESOUND,    -1, NULL,
-                    "EsounD default local profile"},
-#endif
-#ifdef ROAR_HAVE_IPV4
- {"esd-tcp",        ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET4_LOCALHOST,
-                    ROAR_PROTO_ESOUND,    -1, NULL,
-                    "EsounD local TCP profile"},
- {"esd-tcp-pub",    ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_ESOUND,    -1, NULL,
-                    "EsounD network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"esd-tcp6",       ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET6_LOCALHOST,
-                    ROAR_PROTO_ESOUND,    -1, NULL,
-                    "EsounD local TCP profile"},
- {"esd-tcp-pub6",   ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_ESD_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_ESOUND,    -1, NULL,
-                    "EsounD network TCP profile"},
-#endif
-#endif
-
- // RSound:
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND
-#ifdef ROAR_HAVE_UNIX
- {"rsound-unix",    ROAR_SOCKET_TYPE_UNIX,   0,                 ROAR_DEFAULT_RSOUND_GSOCK,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound default local profile"},
-#endif
-#ifdef ROAR_HAVE_IPV4
- {"rsound-tcp",     ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET4_LOCALHOST,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound local TCP profile"},
- {"rsound-tcp-pub", ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"rsound-tcp6",    ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET6_LOCALHOST,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound local TCP profile"},
- {"rsound-tcp-pub6", ROAR_SOCKET_TYPE_TCP6,  ROAR_DEFAULT_RSOUND_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_LIBDNET
- {"rsound-dnet",    ROAR_SOCKET_TYPE_DECNET, 0,                 ROAR_DEFAULT_RSOUND_OBJECT,
-                    ROAR_PROTO_RSOUND,    -1, NULL,
-                    "RSound DECnet profile"},
-#endif
-#endif
-
- // PulseAudio Simple:
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE
-#ifdef ROAR_HAVE_IPV4
- {"pas-play-tcp",   ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PA_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_SIMPLE, ROAR_DIR_PLAY, "default",
-                    "PulseAudio Simple TCP play profile"},
- {"pas-mon-tcp",    ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_PA_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_SIMPLE, ROAR_DIR_MONITOR, "default",
-                    "PulseAudio Simple TCP monitor profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"pas-play-tcp6",  ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_PA_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_SIMPLE, ROAR_DIR_PLAY, "default",
-                    "PulseAudio Simple TCP play profile"},
- {"pas-mon-tcp6",   ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_PA_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_SIMPLE, ROAR_DIR_MONITOR, "default",
-                    "PulseAudio Simple TCP monitor profile"},
-#endif
-#endif
-
- // RPlay:
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY
-#ifdef ROAR_HAVE_IPV4
- {"rplay-tcp",      ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET4_LOCALHOST,
-                    ROAR_PROTO_RPLAY,     -1, NULL,
-                    "RPlay local TCP profile"},
- {"rplay-tcp-pub",  ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_RPLAY,     -1, NULL,
-                    "RPlay network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"rplay-tcp6",     ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET6_LOCALHOST,
-                    ROAR_PROTO_RPLAY,     -1, NULL,
-                    "RPlay local TCP profile"},
- {"rplay-tcp-pub6", ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_RPLAY_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_RPLAY,     -1, NULL,
-                    "RPlay network TCP profile"},
-#endif
-#endif
-
-// Gopher:
-#ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER
-#ifdef ROAR_HAVE_IPV4
- {"gopher-tcp",     ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET4_LOCALHOST,
-                    ROAR_PROTO_GOPHER,    -1, NULL,
-                    "Gopher local TCP profile"},
- {"gopher-tcp-pub", ROAR_SOCKET_TYPE_TCP,    ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET4_ANYHOST,
-                    ROAR_PROTO_GOPHER,    -1, NULL,
-                    "Gopher network TCP profile"},
-#endif
-#ifdef ROAR_HAVE_IPV6
- {"gopher-tcp6",    ROAR_SOCKET_TYPE_TCP6,   ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET6_LOCALHOST,
-                    ROAR_PROTO_GOPHER,    -1, NULL,
-                    "Gopher local TCP profile"},
- {"gopher-tcp-pub6", ROAR_SOCKET_TYPE_TCP6,  ROAR_DEFAULT_GOPHER_PORT, ROAR_NET_INET6_ANYHOST,
-                    ROAR_PROTO_GOPHER,    -1, NULL,
-                    "Gopher network TCP profile"},
-#endif
-#endif
-
- // End of List:
- {NULL, -1, -1, NULL, -1, -1, NULL, NULL}
-};
-
-void listen_listen_profiles (void) {
- const struct _listen_profile * p;
- char * type;
- int i;
- char port[8];
-
- printf("Name            Type    Address          Port    Protocol  Dir        Audio Profile - Description\n");
- printf("-------------------------------------------------------------------------------------------------\n");
-      //roar-tcp-pub 0.0.0.0       16002   RoarAudio unknown    (null) - (null)
-
- for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) {
-  switch (p->type) {
-   case ROAR_SOCKET_TYPE_UNIX:   type = "UNIX";   break;
-   case ROAR_SOCKET_TYPE_TCP:    type = "TCP";    break;
-   case ROAR_SOCKET_TYPE_DECNET: type = "DECnet"; break;
-   case ROAR_SOCKET_TYPE_TCP6:   type = "TCP6";   break;
-   default:
-     type = "unknown";
-    break;
-  }
-
-  if ( p->port ) {
-   snprintf(port, sizeof(port)-1, "%i", p->port);
-   port[sizeof(port)-1] = 0;
-  } else {
-   strcpy(port, "(none)");
-  }
-
-  printf("%-15s %-7s %-16s %-7s %-9s %-10s %-13s - %s\n",
-           p->name,
-           type,
-           p->sockaddr, port,
-           roar_proto2str(p->proto),
-           p->dir == -1 ? "(none)" : roar_dir2str(p->dir), p->aiprofile == NULL ? "(none)" : p->aiprofile,
-           p->desc == NULL ? "" : p->desc);
- }
-}
-
-int get_listen_profile (const char * name,
-                        int * port, const char ** sockaddr, int * type,
-                        int * proto,
-                        int * dir, struct roar_audio_info * info) {
- static char buf[1024];
- const struct _listen_profile * p;
- int i;
-
- for (i = 0; (p = &(_g_listen_profiles[i]))->name != NULL; i++) {
-  if ( !strcasecmp(p->name, name) ) {
-   *port     = p->port;
-
-   if ( p->type == ROAR_SOCKET_TYPE_UNIX && p->sockaddr[0] != '+' ) {
-    if ( roar_env_render_path_r(buf, sizeof(buf), p->sockaddr) == -1 )
-     continue;
-   } else {
-    strncpy(buf, p->sockaddr, sizeof(buf));
-   }
-   *sockaddr = buf;
-   *type     = p->type;
-
-   *proto    = p->proto;
-   *dir      = p->dir;
-
-   if ( p->aiprofile != NULL ) {
-    if ( roar_profile2info(info, p->aiprofile) == -1 ) {
-     ROAR_ERR("Unknown audio profile: %s", p->aiprofile);
-     return -1;
-    }
-   }
-   return 0;
-  }
- }
-
- return -1;
-}
-#endif
-
-int add_listen (const char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info) {
-#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
- struct group   * grp  = NULL;
-#endif
-#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
- struct passwd  * pwd  = NULL;
-#endif
-#ifdef ROAR_HAVE_UNIX
- char * env_roar_proxy_backup;
-#endif
- int    sockid = -1;
-#ifdef ROAR_HAVE_UNIX
- int    sock;
-#endif
- int    i;
-
- ROAR_INFO("add_listen(addr='%s', port=%i, sock_type=%i, user='%s', group='%s', proto=%s(%i), dir=%s(%i), info={.rate=%u, .bits=%u, .channels=%u, .codec=%s(%u)}): trying to add listen socket",
-            ROAR_DBG_INFO_INFO,
-            addr, port, sock_type, user, group, roar_proto2str(proto), proto, roar_dir2str(dir), dir,
-            info->rate, info->bits, info->channels, roar_codec2str(info->codec), info->codec);
-
- if ( *addr != 0 ) {
-  for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-   if ( ! g_listen[i].used ) {
-    sockid = i;
-    break;
-   }
-  }
-
-  if ( sockid == -1 )
-   return -1;
-
-  g_listen[sockid].proto = proto;
-
-  ROAR_DBG("add_listen(*): proto=0x%.4x", proto);
-
-  if ( roar_vio_open_socket_listen(&(g_listen[sockid].sock), sock_type, addr, port) == -1 ) {
-#ifdef ROAR_HAVE_UNIX
-   if ( *addr == '/' ) {
-    if ( (env_roar_proxy_backup = (char*)roar_env_get("ROAR_PROXY")) != NULL ) {
-     env_roar_proxy_backup = roar_mm_strdup(env_roar_proxy_backup);
-     unsetenv("ROAR_PROXY");
-    }
-    if ( (sock = roar_socket_connect(ROAR_SOCKET_TYPE_UNKNOWN, addr, port)) != -1 ) {
-     close(sock);
-     ROAR_ERR("Can not open listen socket: Socket allready in use");
-     return -1;
-    } else {
-     unlink(addr);
-     if ( roar_vio_open_socket_listen(&(g_listen[sockid].sock), sock_type, addr, port) == -1 ) {
-      ROAR_ERR("Can not open listen socket: %s", strerror(errno));
-      return -1;
-     }
-    }
-    if ( env_roar_proxy_backup != NULL ) {
-     setenv("ROAR_PROXY", env_roar_proxy_backup, 0);
-     roar_mm_free(env_roar_proxy_backup);
-    }
-#else
-   if (0) { // noop
-#endif
-   } else {
-    ROAR_ERR("Can not open listen socket: %s", strerror(errno));
-    return -1;
-   }
-  }
-
-  ROAR_DBG("add_listen(*) = ?");
-
-#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
-  if ( group != NULL ) {
-   if ( (grp = getgrnam(group)) == NULL ) {
-    ROAR_ERR("Can not get GID for group %s: %s", group, strerror(errno));
-   }
-  }
-#endif
-
-  ROAR_DBG("add_listen(*) = ?");
-
-#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
-  if ( user != NULL ) {
-   if ( (pwd = getpwnam(user)) == NULL ) {
-    ROAR_ERR("Can not get UID for user %s: %s", user, strerror(errno));
-   }
-  }
-#endif
-
-  ROAR_DBG("add_listen(*) = ?");
-
-#if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_UNIX)
-  if ( *addr == '/' ) {
-   if ( grp != NULL || pwd != NULL ) {
-     if ( chown(addr, pwd != NULL ? pwd->pw_uid : (uid_t)-1, grp != NULL ? grp->gr_gid : (gid_t)-1) == -1 )
-      return -1;
-   }
-#ifdef ROAR_HAVE_GETUID
-   if ( grp != NULL ) {
-    if ( getuid() == 0 )
-     if ( chmod(addr, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1 )
-      return -1;
-   }
-#endif
-  }
-#endif
- }
-
- ROAR_DBG("add_listen(*) = ?");
-
- // in case we opened the listening socket correctly.
- if ( dir == -1 )
-  dir = ROAR_DIR_PLAY;
-
- g_listen[sockid].inst.stpl.dir = dir;
- memcpy(&(g_listen[sockid].inst.stpl.info), info, sizeof(struct roar_audio_info));
-
- switch (dir) {
-  case ROAR_DIR_PLAY:
-  case ROAR_DIR_RECORD:
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_FILTER:
-  case ROAR_DIR_BIDIR:
-  case ROAR_DIR_RECPLAY:
-    if ( !g_listen[sockid].inst.stpl.info.rate )
-     g_listen[sockid].inst.stpl.info.rate = g_sa->rate;
-
-    if ( !g_listen[sockid].inst.stpl.info.bits )
-     g_listen[sockid].inst.stpl.info.bits = g_sa->bits;
-
-    if ( !g_listen[sockid].inst.stpl.info.channels )
-     g_listen[sockid].inst.stpl.info.channels = g_sa->channels;
-
-    if ( !g_listen[sockid].inst.stpl.info.codec )
-     g_listen[sockid].inst.stpl.info.codec = g_sa->codec;
-   break;
- }
-
- g_listen[sockid].used = 1;
- server[sockid]        = addr;
-
- return 0;
-}
-
-static int check_listen(void) {
- const struct roard_proto_handle * proto;
- const char * protoname;
- char buffer[80];
- size_t i, j;
-
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-  if ( g_listen[i].used ) {
-   proto = clients_get_protohandle(g_listen[i].proto);
-   if ( proto != NULL )
-    continue;
-   protoname = roar_proto2str(g_listen[i].proto);
-   if ( protoname == NULL ) {
-    ROAR_ERR("check_listen(void): protocol %i is unknown (protocol ID not assigned?).", g_listen[i].proto);
-   } else {
-    ROAR_DBG("check_listen(void): Unknown protocol %s(%i) is used.", protoname, g_listen[i].proto);
-    snprintf(buffer, sizeof(buffer), "protocol-%s", protoname);
-    for (j = 0; buffer[j]; j++)
-     buffer[j] = tolower(buffer[j]);
-
-    ROAR_DBG("check_listen(void): Trying to load plugin \"%s\"", buffer);
-    if ( plugins_load(buffer, NULL) == -1 ) {
-     ROAR_WARN("check_listen(void): unabled to load plugin: %s: %s", buffer, roar_errorstring);
-    }
-   }
-
-   // recheck:
-   proto = clients_get_protohandle(g_listen[i].proto);
-   if ( proto == NULL ) {
-    ROAR_WARN("check_listen(void): Protocol %s(%i) is still unknown. Deleting listen socket.", protoname, g_listen[i].proto);
-    roar_vio_close(&(g_listen[i].sock));
-#ifdef ROAR_HAVE_UNIX
-    if ( server[i] != NULL )
-     if ( server[i][0] == '/' )
-      unlink(server[i]);
-#endif
-    g_listen[i].used = 0;
-    server[i] = NULL;
-   }
-  }
- }
-
- return 0;
-}
-#endif
-
-#ifdef ROAR_HAVE_MAIN_ARGS
-static void list_aiprofiles (void) {
- struct roar_audio_info info;
- const char * list[1024];
- const char * mime;
- ssize_t ret;
- ssize_t i;
-
- ret = roar_profiles_list(list, 1024, 0);
-
- if ( ret == -1 )
-  return;
-
- printf("  Name             Rate  Bits  Channels  Codec\n");
- printf("-----------------------------------------------------------------------------\n");
- for (i = 0; i < ret; i++) {
-  if ( roar_profile2info(&info, list[i]) == -1 ) {
-   printf("  %-10s --- unknown parameters ---\n", list[i]);
-   continue;
-  }
-
-  mime = roar_codec2mime(info.codec);
-
-  printf("  %-16s %5u %4u  %8u  %3u (%s%s%s%s)\n", list[i],
-            info.rate, info.bits, info.channels,
-            info.codec, roar_codec2str(info.codec),
-            info.codec == ROAR_CODEC_DEFAULT ? " native" : "",
-            mime == NULL ? "" : " mimetype:",
-            mime == NULL ? "" : mime
-        );
- }
-}
-#endif
-
-int update_stream_flags (char * str) {
- int    dir;
- char * flags;
- char * k;
- int    op;
- int    flag;
-
- if ( (flags = strstr(str, "=")) == NULL )
-  return -1;
-
- *flags = 0;
-  flags++;
-
- if ( (dir = roar_str2dir(str)) == -1 )
-  return -1;
-
- while (flags != NULL) {
-  k = flags;
-  flags = strstr(flags, ",");
-
-  if ( flags != NULL )
-   *(flags++) = 0;
-
-  switch (*k) {
-   case '+': k++; op = ROAR_SET_FLAG;   break;
-   case '-': k++; op = ROAR_RESET_FLAG; break;
-   default:
-     op = ROAR_SET_FLAG;
-  }
-
-  flag = 0;
-
-  if ( !strcmp(k, "sync") ) {
-   flag = ROAR_FLAG_SYNC;
-  } else if ( !strcmp(k, "meta") ) {
-   flag = ROAR_FLAG_META;
-  } else if ( !strcmp(k, "cleanmeta") ) {
-   flag = ROAR_FLAG_CLEANMETA;
-  } else if ( !strcmp(k, "pause") ) {
-   flag = ROAR_FLAG_PAUSE;
-  } else if ( !strcmp(k, "mute") ) {
-   flag = ROAR_FLAG_MUTE;
-  } else if ( !strcmp(k, "antiecho") ) {
-   flag = ROAR_FLAG_ANTIECHO;
-  } else if ( !strcmp(k, "passmixer") ) {
-   flag = ROAR_FLAG_PASSMIXER;
-  } else if ( !strcmp(k, "recsource") ) {
-   flag = ROAR_FLAG_RECSOURCE;
-  } else {
-   return -1;
-  }
-
-  g_config->streams[dir].flags |= flag;
-
-  if ( op == ROAR_RESET_FLAG )
-   g_config->streams[dir].flags -= flag;
- }
-
- return 0;
-}
-
-int add_authfile (const char * file, const char * type, enum af_mode mode, enum roard_client_acclev acclev) {
- struct roar_authfile * authfile = NULL;
- struct roar_authfile_key *  key = NULL;
- int af_type = ROAR_AUTHFILE_TYPE_AUTO;
- void * keydata;
- int i;
-
- if ( type == NULL ) {
-  // noop.
- } else if ( !strcasecmp(type, "roar") ) {
-  af_type = ROAR_AUTHFILE_TYPE_ROAR;
- } else if ( !strcasecmp(type, "roar") ) {
-  af_type = ROAR_AUTHFILE_TYPE_ROAR;
- } else if ( !strcasecmp(type, "esd") ) {
-  af_type = ROAR_AUTHFILE_TYPE_ESD;
- } else if ( !strcasecmp(type, "pulse") ) {
-  af_type = ROAR_AUTHFILE_TYPE_PULSE;
- } else if ( !strcasecmp(type, "htpasswd") ) {
-  af_type = ROAR_AUTHFILE_TYPE_HTPASSWD;
- } else if ( !strcasecmp(type, "xauth") ) {
-  af_type = ROAR_AUTHFILE_TYPE_XAUTH;
- } else {
-  ROAR_ERR("add_authfile(*): unknown authfile type '%s'.", type);
-  return -1;
- }
-
- if ( mode == AF_MODE_GEN && af_type == ROAR_AUTHFILE_TYPE_AUTO )
-  af_type = ROAR_AUTHFILE_TYPE_ESD;
-
- switch (mode) {
-  case AF_MODE_NONE:
-    return 0;
-   break;
-  case AF_MODE_GEN:
-    switch (af_type) {
-     case ROAR_AUTHFILE_TYPE_ESD:
-       key = roar_authfile_key_new_random(ROAR_AUTH_T_COOKIE, 16, NULL);
-      break;
-     case ROAR_AUTHFILE_TYPE_PULSE:
-       key = roar_authfile_key_new_random(ROAR_AUTH_T_COOKIE, 256, NULL);
-      break;
-     default:
-       return -1;
-      break;
-    }
-
-    if ( key == NULL ) {
-     ROAR_ERR("add_authfile(*): Can not generate key.");
-     return -1;
-    }
-
-    if ( (authfile = roar_authfile_open(af_type, file, 1, ROAR_AUTHFILE_VERSION_AUTO)) == NULL ) {
-     roar_authfile_key_unref(key);
-     return -1;
-    }
-
-    if ( roar_authfile_add_key(authfile, key) == -1 ) {
-     ROAR_WARN("add_authfile(*): Can not add key to authfile.");
-    }
-
-    keydata = roar_mm_memdup(key->data, key->len);
-
-    if ( keydata == NULL ) {
-     ROAR_WARN("add_authfile(*): Can not allocate memory for key.");
-    } else if ( auth_addkey_cookie(acclev, keydata, key->len) == -1 ) {
-     ROAR_WARN("add_authfile(*): Can not add key to internal key storage.");
-    }
-
-    roar_authfile_key_unref(key);
-    if ( roar_authfile_close(authfile) != 0 )
-     return -1;
-    return 0;
-   break;
-  case AF_MODE_LOAD:
-    if ( (authfile = roar_authfile_open(af_type, file, 0, ROAR_AUTHFILE_VERSION_AUTO)) == NULL ) {
-     return -1;
-    }
-
-    for (i = 0; ; i++) {
-     key = roar_authfile_lookup_key(authfile, ROAR_AUTH_T_AUTO, i, NULL);
-     if ( key == NULL )
-      break;
-
-     if ( key->type == ROAR_AUTH_T_COOKIE ) {
-      keydata = roar_mm_memdup(key->data, key->len);
-
-      if ( keydata == NULL ) {
-       ROAR_WARN("add_authfile(*): Can not allocate memory for key.");
-      } else if ( auth_addkey_cookie(acclev, keydata, key->len) == -1 ) {
-       ROAR_WARN("add_authfile(*): Can not add key to internal key storage.");
-      }
-     } else {
-      ROAR_WARN("add_authfile(*): Unknown key type: %i", key->type);
-     }
-
-     roar_authfile_key_unref(key);
-    }
-
-    if ( roar_authfile_close(authfile) != 0 )
-     return -1;
-    return 0;
-   break;
- }
-
- return -1;
-}
-
-// X11:
-#ifdef ROAR_HAVE_LIBX11
-int register_x11 (int unreg, const char * sockname) {
- struct roar_x11_connection * x11con = NULL;
- int ret = 0;
-
- if ( (x11con = roar_x11_connect(x11display)) == NULL ) {
-  ROAR_ERR("Can not connect to X11 server for %sregistering", unreg ? "un" : "");
-  return -1;
- }
-
- if ( unreg ) {
-  if ( roar_x11_delete_prop(x11con, "ROAR_SERVER") == -1 ) {
-   ret = -1;
-   ROAR_ERR("Error while unregistereing from X11");
-  } else {
-   ROAR_INFO("Successfully unregistered from X11", ROAR_DBG_INFO_INFO);
-  }
- } else {
-  if ( roar_x11_set_prop(x11con, "ROAR_SERVER", sockname) == -1 ) {
-   ret = -1;
-   ROAR_ERR("Error while registereing to X11");
-  } else {
-   ROAR_INFO("Successfully registered to X11", ROAR_DBG_INFO_INFO);
-  }
- }
-
- roar_x11_disconnect(x11con);
-
- return ret;
-}
-#endif
-
-// SLP:
-void register_slp_callback(SLPHandle hslp, SLPError errcode, void * cookie) {
- (void)hslp;
- /* return the error code in the cookie */
- *(SLPError*)cookie = errcode;
-}
-
-int register_slp (int unreg, const char * sockname) {
-#ifdef ROAR_HAVE_LIBSLP
- static int regged = 0;
- static const char * sn = NULL;
- SLPError err;
- SLPError callbackerr;
- SLPHandle hslp;
- char addr[1024];
- char attr[1024] = "";
- char * location;
- char * description;
- char * standards;
-
- if ( sockname != NULL )
-  sn = sockname;
-
- snprintf(addr, sizeof(addr), ROAR_SLP_URL_TYPE_ROAR "://%s", sn);
-
- err = SLPOpen("en", SLP_FALSE, &hslp);
-
- if (err != SLP_OK) {
-  ROAR_ERR("Error opening slp handle: Error #%i", err);
-  return -1;
- }
-
- if (!unreg) {
-
-  if ( SLPEscape(g_config->location, &location, SLP_FALSE) != SLP_OK ) {
-   ROAR_ERR("Error using SLPEscape() on server location, really bad!");
-   SLPClose(hslp);
-   return -1;
-  }
-
-  if ( SLPEscape(g_config->description, &description, SLP_FALSE) != SLP_OK ) {
-   ROAR_ERR("Error using SLPEscape() on server location, really bad!");
-   SLPClose(hslp);
-   return -1;
-  }
-
-  standards = stds_string();
-
-  if ( standards == NULL ) {
-   if ( (standards = roar_mm_malloc(1)) == NULL ) {
-    SLPClose(hslp);
-    return -1;
-   }
-   standards[0] = 0;
-  }
-
-  snprintf(attr, sizeof(attr), "(wave-rate=%i),(wave-channels=%i),(wave-bits=%i),"
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-                               "(light-channels=%i),"
-#endif
-                               "(standards=%s),"
-                               "(location=%s),(description=%s)",
-           g_sa->rate, g_sa->channels, g_sa->bits,
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-           g_light_state.channels,
-#endif
-           standards,
-           location, description
-          );
-
-  roar_mm_free(standards);
-
-  /* Register a service with SLP */
-  err = SLPReg(hslp,
-               addr,
-               SLP_LIFETIME_MAXIMUM,
-               0,
-               attr,
-               SLP_TRUE,
-               register_slp_callback,
-               &callbackerr);
-  regged = 1;
- } else if ( unreg && regged ) {
-  err = SLPDereg(hslp, addr, register_slp_callback, &callbackerr);
-  regged = 0;
- } else {
-  SLPClose(hslp);
-  return -1;
- }
-
- /* err may contain an error code that occurred as the slp library    */
- /* _prepared_ to make the call.                                     */
- if ( err != SLP_OK ) {
-  ROAR_ERR("Error (de)registering service with slp: Error #%i", err);
-  return -1;
- }
-
- /* callbackerr may contain an error code (that was assigned through */
- /* the callback cookie) that occurred as slp packets were sent on    */
- /* the wire */
- if (callbackerr != SLP_OK) {
-  ROAR_ERR("Error (de)registering service with slp: Error #%i", callbackerr);
-  return -1;
- }
-
- SLPClose(hslp);
- return 0;
-#else
- return -1;
-#endif
-}
-
-static int auth_setup (enum roard_client_acclev none_acclev,
-                       enum roard_client_acclev trust_acclev, int trust_root, uid_t trust_uid, gid_t trust_gid) {
- union auth_typeunion * key;
- size_t i;
-
- // Info:
- // if a authlevel is <= ACCLEV_IDENTED we do not need to add this to the keyring
- // as ACCLEV_IDENTED is already gained if IDENTIFY call was done correctly.
-
- if ( !(none_acclev <= ACCLEV_IDENTED) ) {
-  if ( auth_addkey_anonymous(none_acclev) == -1 )
-   return -1;
- }
-
- if ( !(trust_acclev <= ACCLEV_IDENTED) ) {
-  if ( (key = auth_regkey_simple(ROAR_AUTH_T_TRUST, trust_acclev)) == NULL )
-   return -1;
-
-  // zerosize all counters.
-  memset(key, 0, sizeof(union auth_typeunion));
-
-  i = 0;
-
-  if ( trust_uid != (uid_t)-1 )
-   key->trust.uids[i++] = trust_uid;
-
-#ifdef ROAR_ROOT_UID
-  if ( trust_root )
-   key->trust.uids[i++] = ROAR_ROOT_UID;
-#endif
-
-  key->trust.uids_len = i;
-
-  i = 0;
-
-  if ( trust_gid != (gid_t)-1 )
-   key->trust.gids[i++] = trust_gid;
-
-  key->trust.gids_len = i;
- }
-
- return 0;
-}
-
-
-#if defined(ROAR_HAVE_MAIN_ARGS) && !defined(ROAR_WITHOUT_DCOMP_LIGHT)
-struct light_filter {
- const char * name;
- char * para;
-};
-
-static int light_filter_add(int primary, struct light_filter * filter) {
- struct roar_keyval * kv;
- ssize_t kvlen;
- int ret;
- int err;
-
- if ( filter->para == NULL ) {
-  kvlen = -1;
-  kv = NULL;
- } else {
-  kvlen = roar_keyval_split(&kv, filter->para, NULL, NULL, 1);
-  if ( kvlen == -1 ) {
-   ROAR_ERR("light_filter_add(primar=%i, filter={name='%s', para=%p}): Can not split string: %s", primary, filter->name, filter->para, roar_errorstring);
-   return -1;
-  }
- }
-
- ret = light_filter_load(primary, filter->name, 1, kv, kvlen);
- err = roar_error;
- if ( kv != NULL )
-  roar_mm_free(kv);
-
- if ( ret == -1 ) {
-  roar_err_set(err);
-  ROAR_ERR("light_filter_add(primary=%i, filter={name='%s', para=%p}): Can not load filter: %s", primary, filter->name, filter->para, roar_errorstring);
-  return -1;
- }
-
- return 0;
-}
-#endif
-
-// MAIN:
-
-#ifdef ROAR_HAVE_MAIN_ARGS
 int main (int argc, char * argv[]) {
-#else
-int main (void) {
-#endif
-#ifdef ROAR_HAVE_MAIN_ARGS
- enum metaaction metaaction = MA_ACTION;
- enum action action = START;
  int i;
  char * k;
- enum output_format print_format = FORMAT_NATIVE;
- const struct rolestack * rolestack;
- const char * plugin_args = NULL;
-#endif
-#if defined(ROAR_SUPPORT_LISTEN) && defined(ROAR_HAVE_GETUID)
- char user_sock[80]  = {0};
-#endif
- struct roar_audio_info sa, max_sa;
- struct roard_config config;
-#if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32)
- int    daemon       = 0;
-#endif
- int_least32_t watchdog_time = 0; // -1: default, 0: disabled, > 0: user set time.
- int    realtime     = 0;
- int    sysclocksync = 0;
-// char * server = ROAR_DEFAULT_SOCK_GLOBAL;
-#ifdef ROAR_SUPPORT_LISTEN
- int    port       = ROAR_DEFAULT_PORT;
- const char * sock_addr  = NULL;
- int    sock_proto = ROAR_PROTO_ROARAUDIO;
- int    sock_dir   = -1;
- struct roar_audio_info sock_info = {0, 0, 0, 0};
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
- char * s_drv     = NULL;
- char * s_dev     = NULL;
- char * s_con     = NULL;
- char * s_opt     = NULL;
- int    s_prim    = 0;
-#endif
- char * o_drv     = NULL;
- char * o_dev     = NULL;
- char * o_opts    = NULL;
- int    o_prim    = 0;
- int    o_count   = 0;
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- char * m_drv     = NULL;
- char * m_dev     = NULL;
- char * m_opts    = NULL;
- int    m_prim    = 0;
- int    m_count   = 0;
-#endif
- enum roard_client_acclev none_acclev  = ACCLEV_ALL;
- enum roard_client_acclev trust_acclev = ACCLEV_ALL;
- int                      trust_root   = 1;
- char * af_file                        = NULL;
- char * af_type                        = NULL;
- enum af_mode af_mode                  = AF_MODE_NONE;
- enum roard_client_acclev af_acclev    = ACCLEV_ALL;
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- uint32_t light_channels = LIGHT_CHANNELS_DEFAULT;
-#endif
-#ifdef ROAR_DEFAULT_SOCKGRP
- char * sock_grp  = ROAR_DEFAULT_SOCKGRP;
-#else
- char * sock_grp  = NULL;
-#endif
- char * sock_user = NULL;
-#ifdef ROAR_SUPPORT_LISTEN
- int    sock_type = ROAR_SOCKET_TYPE_UNKNOWN;
-#endif
-#ifdef ROAR_HAVE_LIBSLP
- int    reg_slp   = 0;
-#endif
-#ifdef ROAR_HAVE_LIBX11
- int    reg_x11   = 0;
-#endif
-#ifdef ROAR_HAVE_CHROOT
- char * chrootdir = NULL;
-#endif
-#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
- struct group   * grp  = NULL;
-#endif
-#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
- struct passwd  * pwd  = NULL;
-#endif
-#ifdef ROAR_HAVE_GETSERVBYNAME
- struct servent * serv = NULL;
-#endif
- struct roar_client * self = NULL;
-#ifdef ROAR_HAVE_LIBDNET
- char decnethost[80];
-#endif
-#ifdef SUPPORT_PIDFILE
- struct roar_vio_calls pidfile_vio;
-#endif
-#if defined(ROAR_HAVE_MAIN_ARGS) && !defined(ROAR_WITHOUT_DCOMP_LIGHT)
- struct light_filter light_filter[32] = {{"chain", NULL}};
- int    light_filter_count = 1;
- char * light_filter_para  = NULL;
-#endif
+ struct roar_audio_info sa;
+ char * driver = NULL;
+ char * device = NULL;
+ char * opts   = NULL;
+ char * server = ROAR_DEFAULT_HOST;
+ int      port = ROAR_DEFAULT_PORT;
+ int               drvid;
+ char * s_dev  = NULL;
+ char * s_con  = NULL;
+ char * s_opt  = NULL;
+ int    s_prim = 0;
+ DRIVER_USERDATA_T drvinst;
 
- ROAR_DBG("main(*): starting roard...");
+ g_listen_socket = -1;
+ g_standby       =  0;
 
-// NOTE: those to lions can generate a memory leak. The OS will clean that up on exit.
- if ( roar_env_get("ROAR_DRIVER") != NULL )
-  o_drv = roar_mm_strdup(roar_env_get("ROAR_DRIVER"));
- if ( roar_env_get("ROAR_DEVICE") != NULL )
-  o_dev = roar_mm_strdup(roar_env_get("ROAR_DEVICE"));
+ sa.bits     = ROAR_BITS_DEFAULT;
+ sa.channels = ROAR_CHANNELS_DEFAULT;
+ sa.rate     = ROAR_RATE_DEFAULT;
+ sa.codec    = ROAR_CODEC_DEFAULT;
 
- g_standby       =  0;
- g_autostandby   =  0;
- alive           =  1;
-#ifdef ROAR_SUPPORT_LISTEN
- g_no_listen     =  0;
-#else
- g_terminate     =  1;
-#endif
+ g_sa = &sa;
 
- g_verbose       = ROAR_DBG_INFO_NONE;
-
- _LIBROAR_IGNORE_RET(roar_profile2info(&sa, "default-server"));
-
- g_sa        = &sa;
- g_max_sa    = &max_sa;
-
- memcpy(g_max_sa, g_sa, sizeof(max_sa));
-
- counters_init();
-
- g_config = &config;
-
- if ( init_config() == -1 ) {
-  ROAR_ERR("Can not init default config!");
+ if ( sources_init() == -1 ) {
+  ROAR_ERR("Can not init sources!");
   return 1;
  }
 
- // load config
- _LIBROAR_IGNORE_RET(roar_libroar_get_config());
+ for (i = 1; i < argc; i++) {
+  k = argv[i];
 
- // init notify core:
- // TODO: reconsider number of lists.
- if ( roar_notify_core_new_global(-1) == -1 ) {
-  ROAR_ERR("Can not init notify core!");
+  if ( strcmp(k, "-h") == 0 || strcmp(k, "--help") == 0 ) {
+   usage();
+   return 0;
+
+  } else if ( strcmp(k, "-R") == 0 || strcmp(k, "--rate") == 0 ) {
+   sa.rate = atoi(argv[++i]);
+  } else if ( strcmp(k, "-B") == 0 || strcmp(k, "--bits") == 0 ) {
+   sa.bits = atoi(argv[++i]);
+  } else if ( strcmp(k, "-C") == 0 || strcmp(k, "--chans") == 0 ) {
+   sa.channels = atoi(argv[++i]);
+
+  } else if ( strcmp(k, "-d") == 0 || strcmp(k, "--driver") == 0 ) {
+   driver = argv[++i];
+   if ( strcmp(driver, "list") == 0 ) {
+    print_driverlist();
+   }
+  } else if ( strcmp(k, "-D") == 0 || strcmp(k, "--device") == 0 ) {
+   device = argv[++i];
+  } else if ( strcmp(k, "-dO") == 0 ) {
+   opts = argv[++i];
+
+  } else if ( strcmp(k, "-s") == 0 || strcmp(k, "--source") == 0 ) {
+   k = argv[++i];
+   if ( sources_add(k, s_dev, s_con, s_opt, s_prim) == -1 ) {
+    ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, k);
+   }
+   s_opt = s_dev = s_con = NULL;
+   s_prim = 0;
+  } else if ( strcmp(k, "-S") == 0 ) {
+   s_dev = argv[++i];
+  } else if ( strcmp(k, "-sO") == 0 ) {
+   s_opt = argv[++i];
+  } else if ( strcmp(k, "-sC") == 0 ) {
+   s_con = argv[++i];
+  } else if ( strcmp(k, "-sP") == 0 ) {
+   s_prim = 1;
+
+  } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--port") == 0 ) {
+   port = atoi(argv[++i]);
+  } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 ) {
+   server = argv[++i];
+
+  } else {
+   usage();
+   return 1;
+  }
+
+ }
+
+ ROAR_DBG("Server config: rate=%i, bits=%i, chans=%i", sa.rate, sa.bits, sa.channels);
+
+ if ( (g_listen_socket = roar_socket_listen(ROAR_SOCKET_TYPE_UNKNOWN, server, port)) == -1 ) {
+  ROAR_ERR("Can not open listen socket!");
   return 1;
  }
 
- if ( roar_notify_core_register_proxy(NULL, roar_notify_proxy_std, NULL) == -1 ) {
-  ROAR_ERR("Can not init notify core!");
+ if ( output_buffer_init(&sa) == -1 ) {
+  ROAR_ERR("Can not init output buffer!");
   return 1;
  }
 
- rolestack_init();
-
- if ( auth_init() == -1 ) {
-  ROAR_ERR("Can not init auth subsystem!");
+ if ( driver_open(&drvinst, &drvid, driver, device, &sa) == -1 ) {
+  ROAR_ERR("Can not open output driver!");
   return 1;
  }
-
-#ifdef ROAR_SUPPORT_LISTEN
- if ( init_listening() == -1 ) {
-  ROAR_ERR("Can not init listening sockets!");
-  return 1;
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- if ( midi_init_config() == -1 ) {
-  ROAR_ERR("Can not init MIDI config!");
-  return 1;
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
- if ( ssynth_init_config() == -1 ) {
-  ROAR_ERR("Can not init ssynth config!");
-  return 1;
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
- if ( rdtcs_init_config() == -1 ) {
-  ROAR_ERR("Can not init RDTCS config!");
-  return 1;
- }
-#endif
-
- if ( plugins_preinit() == -1 ) {
-  ROAR_ERR("Can not pre-init plugins!");
-  return 1;
- }
-
-#ifdef ROAR_SUPPORT_LISTEN
-#ifndef ROAR_TARGET_WIN32
- sock_addr = ROAR_DEFAULT_SOCK_GLOBAL;
-#else
- sock_addr = ROAR_DEFAULT_HOST;
-#endif
-
-#ifdef ROAR_HAVE_GETUID
- if ( getuid() != 0 && roar_env_get("HOME") != NULL ) {
-/*
-  snprintf(user_sock, 79, "%s/%s", (char*)getenv("HOME"), ROAR_DEFAULT_SOCK_USER);
-*/
-  if ( roar_env_render_path_r(user_sock, sizeof(user_sock), "~/" ROAR_DEFAULT_SOCK_USER) == -1 ) {
-   strncpy(user_sock, "/NX-SOCK", sizeof(user_sock));
-  }
-  sock_addr = user_sock;
-  ROAR_DBG("main(*): setting sock_addr='%s'", sock_addr);
- }
-#endif
-
- if ( roar_env_get("ROAR_SERVER") != NULL )
-  sock_addr = roar_env_get("ROAR_SERVER");
-#endif
 
  if ( clients_init() == -1 ) {
@@ -1563,1216 +143,34 @@
 
  if ( streams_init() == -1 ) {
-  ROAR_ERR("Can not init streams!");
+  ROAR_ERR("Can not nit streams!");
   return 1;
  }
 
- if ( (g_self_client = clients_new()) == -1 ) {
-  ROAR_ERR("Can not create self client!");
-  return 1;
- }
-
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
- if ( sources_init() == -1 ) {
-  ROAR_ERR("Can not init sources!");
-  return 1;
- }
-
- if ( (sources_set_client(g_self_client)) == -1 ) {
-  ROAR_ERR("Can not init set source client!");
-  return 1;
- }
-#endif
-
-#ifdef ROAR_HAVE_MAIN_ARGS
- for (i = 1; i < argc; i++) {
-  k = argv[i];
-
-  if ( strcmp(k, "-h") == 0 || strcmp(k, "--help") == 0 ) {
-   usage();
-   return 0;
-
-  } else if ( strcmp(k, "--start") == 0 ) {
-   // this is a no op
-   action = START;
-  } else if ( strcmp(k, "--restart") == 0 ) {
-   action = RESTART;
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( restart_server(sock_addr, 1) == -1 ) {
-    ROAR_WARN("Can not terminate old server (not running at %s?), will retry later.", sock_addr);
-    action = RESTART_RETRY;
-   }
-#else
-   ROAR_ERR("--restart not supported");
-#endif
-  } else if ( strcmp(k, "--shutdown") == 0 ) {
-   action = SHUTDOWN;
-  } else if ( strcmp(k, "--stop") == 0 ) {
-   action = STOP;
+ signal(SIGINT,  on_sig_int);
+ signal(SIGPIPE, SIG_IGN);  // ignore broken pipes
 
 
-  } else if ( strcmp(k, "--demon") == 0 || strcmp(k, "--daemon") == 0 ) {
-#if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32)
-   daemon = 1;
-#else
-   ROAR_ERR("--daemon not supported");
-#endif
-  } else if ( strcmp(k, "--verbose") == 0 ) {
-   g_verbose++;
-
-  } else if ( strcmp(k, "--print-format") == 0 ) {
-   k = argv[++i];
-   if ( !strcasecmp(k, "native") ) {
-    print_format = FORMAT_NATIVE;
-   } else if ( !strcasecmp(k, "wiki") ) {
-    print_format = FORMAT_WIKI;
-   } else if ( !strcasecmp(k, "csv") ) {
-    print_format = FORMAT_CSV;
-   } else {
-    ROAR_WARN("Unknown print format: %s", k);
-   }
-
-  } else if ( strcmp(k, "--print-format") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-
-  } else if ( strcmp(k, "--terminate") == 0 ) {
-   g_terminate = 1;
-  } else if ( strcmp(k, "--sysclocksync") == 0 ) {
-   sysclocksync = 1000;
-  } else if ( strcmp(k, "--realtime") == 0 ) {
-   realtime++;
-  } else if ( strcmp(k, "--memlock") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->memlock_level = memlock_str2level(argv[++i]);
-  } else if ( strcmp(k, "--watchdog") == 0 ) {
-   if ( watchdog_time == 0 )
-    watchdog_time = -1;
-  } else if ( strcmp(k, "--watchdog-time") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-    watchdog_time = atoi(argv[++i]);
-  } else if ( strcmp(k, "--chroot") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_HAVE_CHROOT
-   chrootdir = argv[++i];
-#else
-   ROAR_ERR("--chroot not supported");
-   i++;
-#endif
-  } else if ( strcmp(k, "--setgid") == 0 ) {
-#ifdef ROAR_HAVE_SETGID
-   setids |= R_SETGID;
-#else
-   ROAR_ERR("--setgid not supported");
-#endif
-  } else if ( strcmp(k, "--setuid") == 0 ) {
-#ifdef ROAR_HAVE_SETUID
-   setids |= R_SETUID;
-#else
-   ROAR_ERR("--setuid not supported");
-#endif
-  } else if ( strcmp(k, "--location") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->location = argv[++i];
-  } else if ( strcmp(k, "--description") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->description = argv[++i];
-  } else if ( strcmp(k, "--contact") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->contact = argv[++i];
-  } else if ( strcmp(k, "--serial") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->serial = argv[++i];
-  } else if ( strcmp(k, "--uiurl") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->uiurl = argv[++i];
-  } else if ( strcmp(k, "--pidfile") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef SUPPORT_PIDFILE
-   pidfile = argv[++i];
-#else
-   ROAR_ERR("--pidfile not supported");
-   i++;
-#endif
-  } else if ( strcmp(k, "--log-syslog") == 0 ) {
-#ifdef ROAR_HAVE_SYSLOG
-   roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG);
-#else
-   ROAR_ERR("--log-syslog not supported");
-#endif
-  } else if ( strcmp(k, "--script-postdown") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_HAVE_SYSTEM
-   g_config->scripts.post_shutdown = argv[++i];
-#else
-   ROAR_ERR("--script-postdown not supported");
-   i++;
-#endif
-
-
-  } else if ( strcmp(k, "--plugin-load") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   if ( plugins_load(argv[++i], plugin_args) == -1 ) {
-    ROAR_ERR("Can not load plugin");
-   }
-   plugin_args = NULL;
-  } else if ( strcmp(k, "--plugin-args") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   plugin_args = argv[++i];
-  } else if ( strcmp(k, "--list-plugins") == 0 ) {
-   metaaction = MA_LIST_PLUGIN;
-
-  } else if ( strcmp(k, "--light-filter-load") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   if ( light_filter_count == (sizeof(light_filter)/sizeof(*light_filter)) ) {
-    ROAR_ERR("Can not load any more light filters: %s", argv[++i]);
-   } else {
-    light_filter[light_filter_count].name = argv[++i];
-    light_filter[light_filter_count].para = light_filter_para;
-    light_filter_count++;
-   }
-   light_filter_para = NULL;
-  } else if ( strcmp(k, "--light-filter-load-primary") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   light_filter[0].name = argv[++i];
-   light_filter[0].para = light_filter_para;
-  } else if ( strcmp(k, "--light-filter-args") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   light_filter_para = argv[++i];
-
-  } else if ( strcmp(k, "--guest-acclev") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   none_acclev = clients_str2acclev(argv[++i]);
-   if ( none_acclev == -1 ) {
-    ROAR_ERR("Invalid access level: %s", argv[i]);
-    return 1;
-   }
-  } else if ( strcmp(k, "--trust-acclev") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   trust_acclev = clients_str2acclev(argv[++i]);
-   if ( trust_acclev == -1 ) {
-    ROAR_ERR("Invalid access level: %s", argv[i]);
-    return 1;
-   }
-  } else if ( strcmp(k, "--trust-root") == 0 ) {
-   trust_root = 1;
-  } else if ( strcmp(k, "--no-trust-root") == 0 ) {
-   trust_root = 0;
-
-  } else if ( strcmp(k, "--authfile-gen") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   af_file = argv[++i];
-   af_mode = AF_MODE_GEN;
-  } else if ( strcmp(k, "--authfile-load") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   af_file = argv[++i];
-   af_mode = AF_MODE_LOAD;
-  } else if ( strcmp(k, "--authfile-type") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   af_type = argv[++i];
-  } else if ( strcmp(k, "--authfile-acclev") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   af_acclev = clients_str2acclev(argv[++i]);
-  } else if ( strcmp(k, "--new-authfile") == 0 ) {
-   if ( af_mode != AF_MODE_NONE ) {
-    if ( add_authfile(af_file, af_type, af_mode, af_acclev) == -1 ) {
-     ROAR_ERR("main(*): adding authfile '%s' failed!", af_file);
-    }
-   }
-   af_file   = NULL;
-   af_type   = NULL;
-   af_mode   = AF_MODE_NONE;
-   af_acclev = ACCLEV_ALL;
-
-  } else if ( strcmp(k, "--list-cf") == 0 ) {
-   print_codecfilterlist();
-   return 0;
-
-  } else if ( strcmp(k, "-R") == 0 || strcmp(k, "--rate") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   sa.rate = atoi(argv[++i]);
-  } else if ( strcmp(k, "-B") == 0 || strcmp(k, "--bits") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   sa.bits = atoi(argv[++i]);
-  } else if ( strcmp(k, "-C") == 0 || strcmp(k, "--chans") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   sa.channels = atoi(argv[++i]);
-
-  } else if ( strcmp(k, "--aiprofile") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   if ( roar_profile2info(&sa, argv[++i]) == -1 ) {
-    ROAR_ERR("Unknown audio profile: %s", argv[i]);
-    return 1;
-   }
-   sa.codec    = ROAR_CODEC_DEFAULT;
-
-  } else if ( strcmp(k, "--stream-flags") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   if ( update_stream_flags(argv[++i]) == -1 ) {
-    ROAR_ERR("Can not set stream flags");
-    return 1;
-   }
-
-  } else if ( strcmp(k, "--list-rolestack") == 0 ) {
-   print_rolestack();
-   return 0;
-  } else if ( strcmp(k, "--rolestack-push") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-  if ( (rolestack = rolestack_parse(argv[++i])) == NULL ) {
-   ROAR_ERR("Can not parse rolestack request: %s", roar_error2str(roar_error));
-  } else {
-   if ( rolestack_push(rolestack) == -1 ) {
-    ROAR_ERR("Can not push request to rolestack: %s", roar_error2str(roar_error));
-   }
-  }
-
-  } else if ( strcmp(k, "--list-aiprofiles") == 0 ) {
-   list_aiprofiles();
-   return 0;
-
-  } else if ( strcmp(k, "--list-driver") == 0 ) {
-   print_driverlist(print_format);
-   return 0;
-
-  } else if ( strcmp(k, "-o") == 0 || strcmp(k, "--odriver") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   o_drv  = argv[++i];
-  } else if ( strcmp(k, "-O") == 0 || strcmp(k, "--odevice") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   o_dev  = argv[++i];
-  } else if ( strcmp(k, "-oO") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   o_opts = argv[++i];
-  } else if ( strcmp(k, "-oP") == 0 ) {
-   o_prim = 1;
-  } else if ( strcmp(k, "-oN") == 0 ) {
-   if ( action == START || action == RESTART ) {
-    if ( output_add(o_drv, o_dev, o_opts, o_prim, o_count) != -1 )
-     o_count++;
-
-    o_drv  = o_dev = o_opts = NULL;
-    o_prim = 0;
-   }
-
-  } else if ( strcmp(k, "-s") == 0 || strcmp(k, "--source") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   s_drv = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "-S") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   s_dev = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "-sO") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   s_opt = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "-sC") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   s_con = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "-sP") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   s_prim = 1;
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-#endif
-  } else if ( strcmp(k, "-sN") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) {
-    ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv);
-   }
-   s_opt = s_dev = s_con = NULL;
-   s_drv = NULL;
-   s_prim = 0;
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-#endif
-  } else if ( strcmp(k, "--list-sources") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-   print_sourcelist();
-   return 0;
-#else
-   ROAR_ERR("main(*): No support for sources compiled in");
-   return 1;
-#endif
-
-  } else if ( strcmp(k, "-m") == 0 || strcmp(k, "--mixer") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   m_drv  = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-  } else if ( strcmp(k, "-M") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   m_dev  = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-  } else if ( strcmp(k, "-mO") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   m_opts = argv[++i];
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-  } else if ( strcmp(k, "-mP") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   m_prim = 1;
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-  } else if ( strcmp(k, "-mN") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   if ( hwmixer_add(m_drv, m_dev, m_opts, m_prim, m_count) != -1 )
-    m_count++;
-
-   m_drv  = o_dev = o_opts = NULL;
-   m_prim = 0;
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-  } else if ( strcmp(k, "--list-mixers") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   print_hwmixerlist();
-   return 0;
-#else
-   ROAR_ERR("main(*): No support for mixer compiled in");
-   return 1;
-#endif
-
-  } else if ( strcmp(k, "--light-channels") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-   light_channels = atoi(argv[++i]);
-#else
-   ROAR_WARN("main(*): no light subsystem compiled in");
-   i++;
-#endif
-
-  } else if ( strcmp(k, "--rds-pi") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-   g_rdtcs.rds.pi = atoi(argv[++i]);
-#else
-   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "--rds-ps") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-   if ( rdtcs_rds_set_ps(argv[++i]) == -1 ) {
-    ROAR_ERR("Can not set RDS PS to '%s' (longer than 8 chars?)", argv[i]);
-    return 1;
-   }
-#else
-   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "--rds-pty") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-   if ( rdtcs_rds_set_pty(argv[++i]) == -1 ) {
-    ROAR_ERR("Can not set RDS PTY to '%s'", argv[i]);
-    return 1;
-   }
-#else
-   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
-   i++;
-#endif
-  } else if ( strcmp(k, "--rds-tp") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-   if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_TP, 0) == -1 ) {
-    ROAR_ERR("Can not set RDS TP flag");
-    return 1;
-   }
-#else
-   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
-#endif
-  } else if ( strcmp(k, "--rds-ct") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-   if ( rdtcs_rds_set_flag(RDTCS_RDS_FLAG_CT, 0) == -1 ) {
-    ROAR_ERR("Can not set RDS CT flag");
-    return 1;
-   }
-#else
-   ROAR_WARN("main(*): no RDTCS subsystem compiled in");
-#endif
-
-
-  } else if ( strcmp(k, "--midi-no-console") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_CB
-   midi_config.init_cb = 0;
-#else
-   // no warning here as this is the disable option
-#endif
-  } else if ( strcmp(k, "--midi-console-enable") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_CB
-   midi_config.init_cb = 1;
-#else
-   ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in");
-#endif
-  } else if ( strcmp(k, "--midi-console") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifndef ROAR_WITHOUT_DCOMP_CB
-   midi_config.console_dev = argv[++i];
-   midi_config.init_cb = 1;
-#else
-   ROAR_ERR("main(*): No support for MIDI subsystem part CB compiled in");
-   i++;
-#endif
-
-  } else if ( strcmp(k, "--ssynth-enable") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-   ssynth_conf.enable = 1;
-#else
-   ROAR_ERR("main(*): No support for ssynth compiled in");
-#endif
-  } else if ( strcmp(k, "--ssynth-disable") == 0 ) {
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-   ssynth_conf.enable = 0;
-#else
-   // we can safely ignore the disable
-#endif
-
-  } else if ( strcmp(k, "--x11-display") == 0 || strcmp(k, "--display") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_HAVE_LIBX11
-   x11display = argv[++i];
-#else
-   ROAR_ERR("No X11 support compiled in!");
-   return 1;
-#endif
-
-
-  } else if ( strcmp(k, "-p") == 0 || strcmp(k, "--port") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   // This is only useful in INET not UNIX mode.
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( *sock_addr == '/' )
-    sock_addr = ROAR_DEFAULT_HOST;
-
-   errno = 0;
-   if ( (port = atoi(argv[++i])) < 1 ) {
-#ifdef ROAR_HAVE_GETSERVBYNAME
-    if ( (serv = getservbyname(argv[i], "tcp")) == NULL ) {
-     ROAR_ERR("Unknown service: %s: %s", argv[i], strerror(errno));
-     return 1;
-    }
-    // NOTE: we need to use ROAR_NET2HOST16() here even if s_port is of type int!
-    ROAR_DBG("main(*): serv = {s_name='%s', s_aliases={...}, s_port=%i, s_proto='%s'}",
-            serv->s_name, ROAR_NET2HOST16(serv->s_port), serv->s_proto);
-    port = ROAR_NET2HOST16(serv->s_port);
-#else
-    ROAR_ERR("invalite port number: %s", argv[i]);
-    return 1;
-#endif
-   }
-#endif
-  } else if ( strcmp(k, "-b") == 0 || strcmp(k, "--bind") == 0 || strcmp(k, "--sock") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_addr = argv[++i];
-#else
-   i++;
-#endif
-
-  } else if ( strcmp(k, "--proto") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( (sock_proto = roar_str2proto(argv[++i])) == -1 ) {
-    ROAR_ERR("Unknown protocol: %s", argv[i]);
-    return 1;
-   }
-#endif
-  } else if ( strcmp(k, "--proto-dir") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( (sock_dir = roar_str2dir(argv[++i])) == -1 ) {
-    ROAR_ERR("Unknown stream direction: %s", argv[i]);
-    return 1;
-   }
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--proto-rate") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_info.rate = atoi(argv[++i]);
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--proto-bits") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_info.bits = atoi(argv[++i]);
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--proto-chans") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_info.channels = atoi(argv[++i]);
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--proto-codec") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( (sock_info.codec = roar_str2codec(argv[++i])) == -1 ) {
-    ROAR_ERR("Unknown codec: %s", argv[i]);
-    return 1;
-   }
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--proto-aiprofile") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( roar_profile2info(&sock_info, argv[++i]) == -1 ) {
-    ROAR_ERR("Unknown audio profile: %s", argv[i]);
-    return 1;
-   }
-#else
-   i++;
-#endif
-  } else if ( strcmp(k, "--list-profiles") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   listen_listen_profiles();
-   return 0;
-#endif
-  } else if ( strcmp(k, "--proto-profile") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( get_listen_profile(argv[++i], &port, &sock_addr, &sock_type, &sock_proto, &sock_dir, &sock_info) == -1 ) {
-    ROAR_ERR("Unknown listen profile: %s", argv[i]);
-    return 1;
-   }
-#else
-   i++;
-#endif
-
-
-  } else if ( strcmp(k, "--list-proto") == 0 ) {
-   metaaction = MA_LIST_PROTO;
-
-  } else if ( strcmp(k, "-t") == 0 || strcmp(k, "--tcp") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( sock_type != ROAR_SOCKET_TYPE_TCP && sock_type != ROAR_SOCKET_TYPE_TCP6 )
-    sock_type = ROAR_SOCKET_TYPE_TCP;
-
-   if ( *sock_addr == '/' )
-    sock_addr = ROAR_DEFAULT_HOST;
-#endif
-
-  } else if ( strcmp(k, "-4") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_type = ROAR_SOCKET_TYPE_TCP;
-   if ( *sock_addr == '/' )
-    sock_addr = ROAR_DEFAULT_HOST;
-#endif
-  } else if ( strcmp(k, "-6") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-#ifdef AF_INET6
-   sock_type = ROAR_SOCKET_TYPE_TCP6;
-   if ( *sock_addr == '/' )
-    sock_addr = ROAR_DEFAULT_HOST;
-#else
-    ROAR_ERR("No IPv6 support compiled in!");
-    return 1;
-#endif
-#endif
-
-  } else if ( strcmp(k, "-u") == 0 || strcmp(k, "--unix") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   // ignore this case as it is the default behavor.
-   sock_type = ROAR_SOCKET_TYPE_UNIX;
-#endif
-
-  } else if ( strcmp(k, "-n") == 0 || strcmp(k, "--decnet") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-#ifdef ROAR_HAVE_LIBDNET
-    port   = ROAR_DEFAULT_NUM;
-    strcpy(decnethost, ROAR_DEFAULT_LISTEN_OBJECT);
-    sock_addr = decnethost;
-    sock_type = ROAR_SOCKET_TYPE_DECNET;
-#else
-    ROAR_ERR("No DECnet support compiled in!");
-    return 1;
-#endif
-#endif
-  } else if ( strcmp(k, "--new-sock") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   if ( action == START || action == RESTART ) {
-    if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto, sock_dir, &sock_info) != 0 ) {
-     ROAR_ERR("Can not open listen socket!");
-     return 1;
-    }
-   }
-#endif
-
-  } else if ( strcmp(k, "--slp") == 0 ) {
-#ifdef ROAR_HAVE_LIBSLP
-   reg_slp = 1;
-#else
-   ROAR_ERR("No OpenSLP support compiled in!");
-   return 1;
-#endif
-
-  } else if ( strcmp(k, "--x11") == 0 ) {
-#ifdef ROAR_HAVE_LIBX11
-   reg_x11 = 1;
-#else
-   ROAR_ERR("No X11 support compiled in!");
-   return 1;
-#endif
-
-
-  } else if ( strcmp(k, "--jumbo-mtu") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   g_config->jumbo_mtu = atoi(argv[++i]);
-
-  } else if ( strcmp(k, "-G") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   sock_grp  = argv[++i];
-  } else if ( strcmp(k, "-U") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   sock_user = argv[++i];
-
-  } else if ( strcmp(k, "--no-listen") == 0 ) {
-#ifdef ROAR_SUPPORT_LISTEN
-   sock_addr   = "";
-   g_terminate = 1;
-   g_no_listen = 1;
-#endif
-  } else if ( strcmp(k, "--client-fh") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-   if ( clients_new_from_fh(atoi(argv[++i]), ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 1) == -1 ) {
-    ROAR_ERR("main(*): Can not set client's fh");
-    return 1;
-   }
-  } else if ( strcmp(k, "--close-fh") == 0 ) {
-   ROAR_CKHAVEARGS(1);
-#ifdef ROAR_HAVE_IO_POSIX
-   close(atoi(argv[++i]));
-#else
-   i++;
-   ROAR_WARN("can not close file handle %s (closing not supported)", argv[i]);
-#endif
-
-  } else if ( strcmp(k, "--standby") == 0 ) {
-   g_standby = 1;
-  } else if ( strcmp(k, "--auto-standby") == 0 ) {
-   g_autostandby = 1;
-  } else {
-   ROAR_ERR("Unknown option: %s", k);
-   usage();
-   return 1;
-  }
-
- }
-#endif
-
-#ifdef ROAR_HAVE_MAIN_ARGS
- if ( metaaction != MA_ACTION )
-  action = START;
-
- switch (action) {
-  case START:
-    // NO-OP.
-   break;
-  case RESTART:
-    // NO-OP, done before.
-   break;
-  case STOP:
-#ifdef ROAR_SUPPORT_LISTEN
-    if ( restart_server(sock_addr, 0) == -1 ) {
-     ROAR_WARN("Can not stop old server (not running at %s?)", sock_addr);
-     return 1;
-    }
-    return 0;
-#else
-    ROAR_ERR("--stop not supported");
-    return 1;
-#endif
-   break;
-  case SHUTDOWN:
-#ifdef ROAR_SUPPORT_LISTEN
-    if ( restart_server(sock_addr, 1) == -1 ) {
-     ROAR_WARN("Can not terminate old server (not running at %s?)", sock_addr);
-     return 1;
-    }
-    return 0;
-#else
-    ROAR_ERR("--shutdown not supported");
-    return 1;
-#endif
-   break;
-  case RESTART_RETRY:
-#ifdef ROAR_SUPPORT_LISTEN
-    if ( restart_server(sock_addr, 1) == -1 ) {
-     ROAR_WARN("Can not terminate old server (again) (not running at %s?), tring to continue anyway", sock_addr);
-     action = RESTART;
-    }
-#endif
-   break;
- }
-#endif
-
- // if g_verbose is high we load external debugging modules.
- if ( g_verbose >= 4 ) {
-  if ( plugins_load("debug-notify", NULL) == -1 ) {
-   ROAR_WARN("main(*): Can not load debugger plugin: %s", roar_error2str(roar_error));
-  }
- }
-
- if ( af_mode != AF_MODE_NONE ) {
-  if ( add_authfile(af_file, af_type, af_mode, af_acclev) == -1 ) {
-   ROAR_ERR("main(*): adding authfile '%s' failed!", af_file);
-  }
- }
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- if ( m_drv != NULL ) {
-  if ( hwmixer_add(m_drv, m_dev, m_opts, m_prim, m_count) == -1 ) {
-   ROAR_ERR("main(*): adding mixer '%s' via '%s' failed!", m_dev, m_drv);
-  }
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
- if ( s_drv != NULL || s_dev != NULL ) {
-  if ( sources_add(s_drv, s_dev, s_con, s_opt, s_prim) == -1 ) {
-   ROAR_ERR("main(*): adding source '%s' via '%s' failed!", s_dev, s_drv);
-  }
- }
-#endif
-
- if ( output_add_default(o_drv, o_dev, o_opts, o_prim, o_count) == -1 ) {
-  ROAR_ERR("Can not initialize default driver");
-  return 1;
- }
-
- ROAR_INFO("Server config: rate=%i, bits=%i, chans=%i", ROAR_DBG_INFO_NOTICE, sa.rate, sa.bits, sa.channels);
-
- if ( waveform_init() == -1 ) {
-  ROAR_ERR("Can not initialize Waveform subsystem");
-  return 1;
- }
-
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- if ( midi_init() == -1 ) {
-  ROAR_ERR("Can not initialize MIDI subsystem");
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
- if ( ssynth_init() == -1 ) {
-  ROAR_ERR("Can not initialize ssynth subsystem");
- }
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- if ( light_init(light_channels) == -1 ) {
-  ROAR_ERR("Can not initialize light control subsystem");
- }
- light_filter_add(1, &(light_filter[0]));
- for (i = 1; i < light_filter_count; i++)
-  light_filter_add(0, &(light_filter[i]));
-#endif
-
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
- if ( rdtcs_init() == -1 ) {
-  ROAR_ERR("Can not initialize RDTCS subsystem");
- }
-#endif
-
- if ( plugins_init() == -1 ) {
-  ROAR_ERR("Can not initialize plugins");
- }
-
-#ifdef ROAR_SUPPORT_LISTEN
- if ( !g_no_listen ) {
-  if ( add_listen(sock_addr, port, sock_type, sock_user, sock_grp, sock_proto, sock_dir, &sock_info) != 0 ) {
-   ROAR_ERR("Can not open listen socket!");
-   return 1;
-  }
- }
-#endif
-
- if ( output_buffer_init(&sa) == -1 ) {
-  ROAR_ERR("Can not init output buffer!");
-  return 1;
- }
-
- if ( samples_init() == -1 ) {
-  ROAR_ERR("Can not init samples!");
-  return 1;
- }
-
- if ( check_listen() == -1 ) {
-  ROAR_ERR("Can not check listen sockets. BAD.");
-  return 1;
- }
-
-#ifdef ROAR_HAVE_MAIN_ARGS
- // check meta action now as everything is set up.
- switch (metaaction) {
-  case MA_ACTION: /* noop */; break;
-  case MA_LIST_PROTO:
-    print_protolist(print_format);
-    return 0;
-   break;
-  case MA_LIST_PLUGIN:
-    print_pluginlist(print_format);
-    return 0;
-   break;
- }
-#endif
-
- // we should handle this on microcontrollers, too.
-#if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_TARGET_WIN32)
- signal(SIGINT,  on_sig_int);
- signal(SIGTERM, on_sig_term);
- signal(SIGCHLD, on_sig_chld);
- signal(SIGUSR1, on_sig_usr1);
- signal(SIGPIPE, SIG_IGN);  // ignore broken pipes
-#endif
-
- if ( g_config->memlock_level == -1 ) {
-  g_config->memlock_level = MEMLOCK_DEFAULT;
-  // do not print warning in case of failure and useage of default level.
-  memlock_set_level(g_config->memlock_level);
- } else {
-  if ( memlock_set_level(g_config->memlock_level) == -1 ) {
-   ROAR_WARN("Can not set memory locking level to target level.");
-  }
- }
-
- if ( realtime ) {
-#ifdef DEBUG
-  ROAR_WARN("compiled with -DDEBUG but realtime is enabled: for real realtime support compile without -DDEBUG");
-#endif
-
-#ifdef ROAR_HAVE_NICE
-  // this stupid error check is because type of returned data of nice() changed
-  // too often. On some systems it may return 0/-1, on some new nice value or
-  // mixed forms of both.
-  errno = 0;
-  (void)nice(-5*realtime); // -5 for each --realtime
-  if ( errno ) {
-   ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno));
-  }
-#else
-  ROAR_WARN("Can not decrease nice value by %i: %s", 5*realtime, strerror(errno));
-#endif
-/*
-#ifdef __linux__
-  if ( ioprio_set(IOPRIO_WHO_PROCESS, getpid(), IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0)) == -1 )
-   ROAR_WARN("Can not set io priority: %s", strerror(errno));
-#endif
-*/
- }
-
-#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_IO_POSIX)
- if ( setids & R_SETGID ) {
-  if ( sock_grp == NULL ) {
-   ROAR_ERR("Can not set GID if no groupname is supplied");
-   return 1;
-  }
-  if ( (grp = getgrnam(sock_grp)) == NULL ) {
-   ROAR_ERR("Can not get GID for group %s: %s", sock_grp, strerror(errno));
-   return 1;
-  }
-  if ( setgroups(0, (const gid_t *) NULL) == -1 ) {
-   ROAR_ERR("Can not clear supplementary group IDs: %s", strerror(errno));
-  }
-  if ( grp == NULL || setgid(grp->gr_gid) == -1 ) {
-   ROAR_ERR("Can not set GroupID: %s", strerror(errno));
-  }
- }
-#endif
-
-
- clients_set_pid(g_self_client, getpid());
-#ifdef ROAR_HAVE_GETUID
- clients_set_uid(g_self_client, getuid());
-#endif
-#ifdef ROAR_HAVE_GETGID
- clients_set_gid(g_self_client, getgid());
-#endif
- clients_get(g_self_client, &self);
-
- if ( self == NULL ) {
-  ROAR_ERR("Can not get self client!");
-  return 1;
- }
-
- strcpy(self->name, "RoarAudio daemon internal");
-
- if ( roar_nnode_free(&(self->nnode)) == -1 )
-  return 1;
-
- // not fully correct but ok as workaorund
- // so tools assume that roard runs on the same machine as
- // they in case they use AF_UNIX:
- if ( roar_nnode_new(&(self->nnode), ROAR_SOCKET_TYPE_UNIX) == -1 )
-  return 1;
-
-#if defined(ROAR_HAVE_FORK) || defined(ROAR_TARGET_WIN32)
- if ( daemon ) {
-#ifdef ROAR_HAVE_SYSLOG
-  roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG);
-#else
-  roar_debug_set_stderr_fh(-1);
-#endif
-
-#ifdef ROAR_TARGET_WIN32
-  FreeConsole();
-#else
-
-  close(ROAR_STDIN );
-  close(ROAR_STDOUT);
-  close(ROAR_STDERR);
-
-  if ( roar_fork(NULL) )
-   ROAR_U_EXIT(0);
-
-#ifdef ROAR_HAVE_SETSID
-  setsid();
-#endif
-  clients_set_pid(g_self_client, getpid()); // reset pid as it changed
-#endif
- }
-#endif
-
- if ( watchdog_time ) {
-  if ( watchdog_time == -1 )
-   watchdog_time = 5000;
-  roar_watchdog_start(ROAR_WATCHDOG_CONF_DEFAULTS, watchdog_time, NULL);
- }
-
-#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
- // early test for UID as we need this for the pidfile and the setuid()
- if ( sock_user != NULL ) {
-  if ( (pwd = getpwnam(sock_user)) == NULL ) {
-   ROAR_ERR("Can not get UID for user %s: %s", sock_user, strerror(errno));
-   return 1;
-  }
- }
-#endif
-
- ROAR_INFO("Process ID: %i", ROAR_DBG_INFO_INFO, (int)getpid());
-
-#ifdef SUPPORT_PIDFILE
- if ( pidfile != NULL ) {
-  if ( roar_vio_open_dstr_simple(&pidfile_vio, pidfile, O_WRONLY|O_CREAT) == -1 ) {
-   ROAR_ERR("Can not write pidfile: %s", pidfile);
-  } else {
-   roar_vio_printf(&pidfile_vio, "%i\n", getpid());
-   roar_vio_close(&pidfile_vio);
-  }
-#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
-  if ( pwd != NULL || grp != NULL ) {
-   if ( chown(pidfile, pwd != NULL ? pwd->pw_uid : (uid_t)-1, grp != NULL ? grp->gr_gid : (gid_t)-1) == -1 ) {
-    ROAR_WARN("Can not change ownership of pidfile: %s: %s", pidfile, strerror(errno));
-   }
-  }
-  if ( chmod(pidfile, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) == -1 ) {
-   ROAR_WARN("Can not change permissions of pidfile: %s: %s", pidfile, strerror(errno));
-  }
-#endif
- }
-#endif
-
-#ifdef ROAR_HAVE_CHROOT
- if (chrootdir) {
-  if ( chroot(chrootdir) == -1 ) {
-   ROAR_ERR("Can not chroot to %s: %s", chrootdir, strerror(errno));
-   return 2;
-  }
-  if ( chdir("/") == -1 ) {
-   ROAR_ERR("Can not chdir to /: %s", strerror(errno));
-   return 2;
-  }
- }
-#endif
-
-#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX)
- if ( setids & R_SETUID ) {
-  if ( sock_user == NULL ) {
-   ROAR_ERR("Can not set UID if no username is supplied");
-   return 1;
-  }
-  if ( pwd == NULL || setuid(pwd->pw_uid) == -1 ) {
-   ROAR_ERR("Can not set UserID: %s", strerror(errno));
-   return 3;
-  }
-#ifdef ROAR_HAVE_GETUID
-  clients_set_uid(g_self_client, getuid());
-#endif
- }
-#endif
-
- // setup auth:
-#if defined(ROAR_HAVE_GETUID) && defined(ROAR_HAVE_GETGID)
- if ( auth_setup(none_acclev, trust_acclev, trust_root, getuid(), getgid()) == -1 ) {
-#else
- if ( auth_setup(none_acclev, trust_acclev, trust_root, -1, -1) == -1 ) {
-#endif
-  ROAR_ERR("Can not set up auth. Bad.");
-  alive = 0;
- }
-
- // Register with OpenSLP:
-#ifdef ROAR_HAVE_LIBSLP
- if ( reg_slp ) {
-  register_slp(0, sock_addr);
- }
-#endif
-
-#ifdef ROAR_HAVE_LIBX11
- if ( reg_x11 ) {
-  register_x11(0, sock_addr);
- }
-#endif
-
- // update sync counter.
- streams_change_sync_num(-1, 0);
-
- ROAR_INFO("Startup complet", ROAR_DBG_INFO_INFO);
-
  // start main loop...
- ROAR_INFO("Entering main loop", ROAR_DBG_INFO_INFO);
- main_loop(&sa, sysclocksync);
- ROAR_INFO("Left main loop", ROAR_DBG_INFO_INFO);
+ main_loop(drvid, drvinst, &sa);
 
  // clean up.
  clean_quit_prep();
+ driver_close(drvinst, drvid);
  output_buffer_free();
 
- roar_notify_core_free(NULL);
-
- ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO);
-
-#ifdef ROAR_HAVE_SYSTEM
- if ( g_config->scripts.post_shutdown != NULL )
-  system(g_config->scripts.post_shutdown);
-#endif
-
- ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO);
  return 0;
 }
 
-void cleanup_listen_socket (int terminate) {
- int i;
-
- ROAR_DBG("cleanup_listen_socket(terminate=%i) = (void)?", terminate);
-
- ROAR_INFO("Cleaning up listen sockets", ROAR_DBG_INFO_INFO);
-
- // Deregister from SLP:
-#ifdef ROAR_HAVE_LIBSLP
- register_slp(1, NULL);
-#endif
-
-#ifdef ROAR_HAVE_LIBX11
- register_x11(1, NULL);
-#endif
-
-#ifdef ROAR_SUPPORT_LISTEN
- for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) {
-  if ( g_listen[i].used  ) {
-   roar_vio_close(&(g_listen[i].sock));
-
-   g_listen[i].used = 0;
-
-#ifdef ROAR_HAVE_UNIX
-   if ( server[i] != NULL )
-    if ( *(server[i]) == '/' )
-     unlink(server[i]);
-#endif
-  }
- }
-
-#endif
-
- if ( terminate )
-  g_terminate = 1;
-}
-
 void clean_quit_prep (void) {
- cleanup_listen_socket(0);
-
- plugins_free();
-
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
+ close(g_listen_socket);
  sources_free();
-#endif
  streams_free();
  clients_free();
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
- ssynth_free();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_CB
- midi_cb_stop(); // stop console beep
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
- midi_free();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
- light_free();
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
- rdtcs_free();
-#endif
-
- waveform_free();
-
-#ifdef SUPPORT_PIDFILE
- if ( pidfile != NULL )
-  unlink(pidfile);
-#endif
-
- auth_free();
 }
 
 void clean_quit (void) {
- ROAR_INFO("Shuting down", ROAR_DBG_INFO_INFO);
-
- counters_print(ROAR_DEBUG_TYPE_INFO, 0);
-
  clean_quit_prep();
+// driver_close(drvinst, drvid);
 // output_buffer_free();
-
- roar_notify_core_free(NULL);
-
- ROAR_INFO("Shuting down complete", ROAR_DBG_INFO_INFO);
-
-#ifdef ROAR_HAVE_SYSTEM
- if ( g_config->scripts.post_shutdown != NULL )
-  system(g_config->scripts.post_shutdown);
-#endif
-
- ROAR_INFO("Exiting, no error", ROAR_DBG_INFO_INFO);
  exit(0);
 }
Index: roard/rolestack.c
===================================================================
--- roard/rolestack.c	(revision 6052)
+++ 	(revision )
@@ -1,152 +1,0 @@
-//rolestack.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#define STACKSIZE 16
-
-static struct rolestack g_rolestack[STACKSIZE];
-
-void rolestack_init(void) {
- int i;
-
- for (i = 0; i < STACKSIZE; i++) {
-  g_rolestack[i].index  = i;
-  g_rolestack[i].role   = ROAR_ROLE_UNKNOWN;
-  g_rolestack[i].action = RS_MIX;
- }
-
- g_rolestack[0].role = ROAR_ROLE_NONE;
-}
-
-void print_rolestack(void) {
- int i;
-
- printf("Index Role             Action\n");
- printf("-----------------------------\n");
- for (i = 0; i < STACKSIZE && g_rolestack[i].role != ROAR_ROLE_UNKNOWN; i++) {
-  printf("%-5i %-16s %s\n", g_rolestack[i].index,
-          roar_role2str(g_rolestack[i].role), rolestack_action2str(g_rolestack[i].action));
- }
-}
-
-const struct rolestack * rolestack_get_role(int role) {
- int i;
-
- ROAR_DBG("rolestack_get_role(role=%i) = ?", role);
-
- if ( role == -1 )
-  return &(g_rolestack[0]);
-
- for (i = STACKSIZE - 1; i >= 0; i--)
-  if ( g_rolestack[i].role == role )
-   return &(g_rolestack[i]);
-
- return &(g_rolestack[0]);
-}
-
-int rolestack_push(const struct rolestack * role) {
- int i;
-
- for (i = 0; i < STACKSIZE; i++) {
-  if ( g_rolestack[i].role == ROAR_ROLE_UNKNOWN ) {
-   memcpy(&(g_rolestack[i]), role, sizeof(g_rolestack[i]));
-   g_rolestack[i].index = i;
-   return 0;
-  }
- }
-
- roar_err_set(ROAR_ERROR_NOMEM);
- return -1;
-}
-
-enum rs_action rolestack_str2action(const char * str) {
- if ( str == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if (!strcasecmp(str, "mix")) {
-  return RS_MIX;
- } else if (!strcasecmp(str, "kick")) {
-  return RS_KICK;
- } else if (!strcasecmp(str, "mute")) {
-  return RS_MUTE;
- } else if (!strcasecmp(str, "pause")) {
-  return RS_PAUSE;
- }
-
- return RS_ERROR;
-}
-
-const char * rolestack_action2str(enum rs_action action) {
- switch (action) {
-  case RS_ERROR: return "(error)"; break;
-  case RS_MIX:   return "mix";     break;
-  case RS_MUTE:  return "mute";    break;
-  case RS_PAUSE: return "pause";   break;
-  case RS_KICK:  return "kick";    break;
- }
-
- return "(unknown)";
-}
-
-const struct rolestack * rolestack_parse(const char * str) {
- static struct rolestack ret;
- char * role, * action;
-
- if ( str == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return NULL;
- }
-
- role = roar_mm_strdup(str);
- if ( role == NULL )
-  return NULL;
-
- if ( (action = strstr(role, ":")) == NULL ) {
-  roar_mm_free(role);
-  roar_err_set(ROAR_ERROR_BADMSG);
-  return NULL;
- }
-
- *action = 0;
-  action++;
-
- ret.index  = -1;
- ret.role   = roar_str2role(role);
- ret.action = rolestack_str2action(action);
-
- roar_mm_free(role);
-
- if ( ret.role == -1 || ret.action == RS_ERROR ) {
-  roar_err_set(ROAR_ERROR_BADMSG);
-  return NULL;
- }
-
- return &ret;
-}
-
-//ll
Index: roard/sample.c
===================================================================
--- roard/sample.c	(revision 6052)
+++ 	(revision )
@@ -1,127 +1,0 @@
-//sample.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-// declared 'extern'
-struct roar_sample * g_samples[ROAR_SAMPLES_MAX];
-
-int samples_init      (void) {
- int i;
-
- for (i = 0; i < ROAR_SAMPLES_MAX; i++)
-  g_samples[i] = NULL;
-
- return 0;
-}
-
-
-int samples_free      (void) {
- int i;
-
- for (i = 0; i < ROAR_SAMPLES_MAX; i++)
-  if ( g_samples[i] != NULL )
-   samples_delete(i);
-
- return 0;
-}
-
-int samples_new       (void) {
- struct roar_sample * c = roar_mm_malloc(sizeof(struct roar_sample));
- int i;
-
- if ( c == NULL )
-  return -1;
-
- c->name[0] = 0;
- c->data    = NULL;
-
- for (i = 0; i < ROAR_SAMPLES_MAX; i++) {
-  if ( g_samples[i] == NULL ) {
-   g_samples[i] = c;
-   return i;
-  }
- }
-
- roar_mm_free(c);
-
- return -1;
-}
-
-int samples_delete    (int id) {
- struct roar_sample * c = g_samples[id];
-
- if ( c == NULL )
-  return -1;
-
- if ( c->data != NULL )
-  roar_buffer_free(c->data);
-
- roar_mm_free(c);
-
- g_samples[id] = NULL;
-
- return 0;
-}
-
-int samples_set_name  (int id, char * name) {
- struct roar_sample * c = g_samples[id];
-
- if ( c == NULL )
-  return -1;
-
- strncpy(c->name, name, ROAR_BUFFER_NAME-1);
-
- c->name[ROAR_BUFFER_NAME-1] = 0;
-
- return 0;
-}
-
-int samples_add_data  (int id, void * data, size_t len) {
- struct roar_buffer * new;
- struct roar_sample * c = g_samples[id];
- int save_err;
-
- if ( c == NULL )
-  return -1;
-
- if ( roar_buffer_new(&new, len) == -1 )
-  return -1;
-
- if ( c->data == NULL ) {
-  c->data = new;
- } else {
-  if ( roar_buffer_moveinto(c->data, &new) == -1 ) {
-   save_err = roar_error;
-   roar_buffer_free(new);
-   roar_err_set(save_err);
-   return -1;
-  }
- }
-
- return 0;
-}
-
-//ll
Index: roard/signals.c
===================================================================
--- roard/signals.c	(revision 6052)
+++ roard/signals.c	(revision 0)
@@ -1,44 +1,8 @@
 //signals.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-// we should add signal handling on micro controllsers here.
-
-#if !defined(ROAR_TARGET_MICROCONTROLLER) && !defined(ROAR_TARGET_WIN32)
-
 void on_sig_int (int signum) {
- ROAR_INFO("got SIGINT", ROAR_DBG_INFO_NOTICE);
-
- // TODO: implement some kind of termonate/force depending on how many ^Cs we get
- on_sig_term(signum);
-}
-
-void on_sig_term (int signum) {
- (void)signum;
-
- ROAR_INFO("got SIGTERM (or called by SIGINT handler)", ROAR_DBG_INFO_NOTICE);
+ ROAR_DBG("got SIGINT");
 
  alive = 0;
@@ -46,24 +10,3 @@
 }
 
-void on_sig_chld (int signum) {
- (void)signum;
-
- ROAR_INFO("got SIGCHLD", ROAR_DBG_INFO_NOTICE);
-
- wait(NULL);
-
- signal(SIGCHLD, on_sig_chld);
-}
-
-void on_sig_usr1 (int signum) {
- (void)signum;
-
- ROAR_INFO("got SIGUSR1", ROAR_DBG_INFO_NOTICE);
-
- cleanup_listen_socket(1);
-}
-
-#endif
-
-
 //ll
Index: roard/sources.c
===================================================================
--- roard/sources.c	(revision 6052)
+++ roard/sources.c	(revision 0)
@@ -1,100 +1,11 @@
 //sources.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
 
 #include "roard.h"
 
-#ifndef ROAR_WITHOUT_DCOMP_SOURCES
-
-static int g_source_client = -1;
-
-#define ROAR_SOURCE_DEFAULT "cf"
-
-struct roar_source g_source[] = {
- {"raw",  "DSTR source",                 "/some/file",     SRC_FLAG_FHSEC, ROAR_SUBSYS_WAVEFORM, NULL,  sources_add_dstr},
- {"cf",   "Old CF source",               "/some/file.ext", SRC_FLAG_NONE,  ROAR_SUBSYS_WAVEFORM, sources_add_cf,   NULL},
- {"roar", "New simple RoarAudio source", "some.host",      SRC_FLAG_NONE,  ROAR_SUBSYS_WAVEFORM, NULL, sources_add_roar},
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
- {"oss",  "OSS CDriver",                 "/dev/audio",     SRC_FLAG_NONE,  ROAR_SUBSYS_WAVEFORM, NULL, sources_add_cdriver},
-#endif
- {"radionoise", "Noise source at -102dB", NULL,            SRC_FLAG_NONE, ROAR_SUBSYS_WAVEFORM, NULL, sources_add_radionoise},
- {NULL, NULL, NULL, SRC_FLAG_NONE, 0, NULL, NULL} // EOL
-};
-
 int sources_init (void) {
+ g_source_client = -1;
  return 0;
 }
 
-void print_sourcelist (void) {
- int i;
- char subsys[7] = "      ";
-
- printf("  Source    Flag Subsys - Description (devices)\n");
- printf("-------------------------------------------------------\n");
-
- for (i = 0; g_source[i].name != NULL; i++) {
-  strncpy(subsys, "      ", 6);
-
-  if ( g_source[i].subsystems & ROAR_SUBSYS_WAVEFORM )
-   subsys[0] = 'W';
-  if ( g_source[i].subsystems & ROAR_SUBSYS_MIDI )
-   subsys[1] = 'M';
-  if ( g_source[i].subsystems & ROAR_SUBSYS_CB )
-   subsys[2] = 'C';
-  if ( g_source[i].subsystems & ROAR_SUBSYS_LIGHT )
-   subsys[3] = 'L';
-  if ( g_source[i].subsystems & ROAR_SUBSYS_RAW )
-   subsys[4] = 'R';
-  if ( g_source[i].subsystems & ROAR_SUBSYS_COMPLEX )
-   subsys[5] = 'X';
-
-  if ( g_source[i].devices != NULL ) {
-   printf("  %-10s %c%c%c %6s - %s (devices: %s)\n", g_source[i].name,
-                 g_source[i].flags & SRC_FLAG_FHSEC      ? 's' : ' ',
-                 g_source[i].old_open != NULL            ? 'S' : ' ',
-                 g_source[i].new_open != NULL            ? 'N' : ' ',
-                 subsys,
-                 g_source[i].desc, g_source[i].devices);
-  } else {
-   printf("  %-9s %c%c%c %6s - %s\n", g_source[i].name,
-                 g_source[i].flags & SRC_FLAG_FHSEC      ? 's' : ' ',
-                 g_source[i].old_open != NULL            ? 'S' : ' ',
-                 g_source[i].new_open != NULL            ? 'N' : ' ',
-                 subsys,
-                 g_source[i].desc);
-  }
- }
-}
-
-
-int sources_set_client (int client) {
- if ( client >= 0 ) {
-  g_source_client = client;
-  return 0;
- } else {
-  return -1;
- }
-}
 
 int sources_free (void) {
@@ -102,384 +13,7 @@
 }
 
-int sources_add (char * driver, char * device, char * container, char * options, int primary) {
- int i;
-
- if ( driver == NULL )
-  driver = ROAR_SOURCE_DEFAULT;
-
- for (i = 0; g_source[i].name != NULL; i++) {
-  if ( !strcmp(g_source[i].name, driver) ) {
-   if ( g_source[i].new_open != NULL ) {
-    return sources_add_new(&(g_source[i]), driver, device, options, primary);
-   } else if ( g_source[i].old_open != NULL ) {
-    return g_source[i].old_open(driver, device, container, options, primary);
-   } else {
-    ROAR_ERR("sources_add(driver='%s', ...): Found source but did not find any open rutine", driver);
-    return -1;
-   }
-  }
- }
-
- ROAR_ERR("sources_add(driver='%s', ...): Source not found", driver);
+int sources_add (char * driver, char * device, char * containe, char * options, int primary) {
  return -1;
 }
 
-int sources_add_new (struct roar_source * source,
-                     char * driver, char * device,
-                     char * options, int primary) {
- int  stream;
- int  fh = -1;
- struct roar_stream        *  s;
- struct roar_stream_server * ss;
- char * k, * v;
- int error = 0;
- int f_sync = 0, f_mmap = 0;
- int codec;
- char * strtok_store;
-
- if ( source == NULL )
-  return -1;
-
- if ( (stream = streams_new()) == -1 ) {
-  return -1;
- }
-
- if ( streams_get(stream, &ss) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- codec = s->info.codec;
-
- if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- s->pos_rel_id = -1;
-
- if ( options == NULL ) {
-  k = NULL;
- } else {
-  k = roar_mm_strtok_r(options, ",", &strtok_store);
- }
- while (k != NULL) {
-  if ( (v = strstr(k, "=")) != NULL ) {
-   *v++ = 0;
-  }
-
-  if ( strcmp(k, "rate") == 0 ) {
-   s->info.rate = roar_str2rate(v);
-  } else if ( strcmp(k, "channels") == 0 ) {
-   s->info.channels = roar_str2channels(v);
-  } else if ( strcmp(k, "bits") == 0 ) {
-   s->info.bits = roar_str2bits(v);
-  } else if ( strcmp(k, "codec") == 0 ) {
-   if ( (codec = roar_str2codec(v)) == -1 ) {
-    ROAR_ERR("sources_add_new(*): unknown codec '%s'", v);
-    error++;
-   }
-
-  } else if ( strcmp(k, "name") == 0 ) {
-   if ( streams_set_name(stream, v) == -1 ) {
-    ROAR_ERR("add_output(*): Can not set Stream name");
-    error++;
-   }
-
-  } else if ( strcmp(k, "mmap") == 0 ) {
-   f_mmap = 1;
-  } else if ( strcmp(k, "sync") == 0 ) {
-   f_sync = 1;
-  } else if ( strcmp(k, "primary") == 0 ) {
-   primary = 1;
-  } else if ( strcmp(k, "meta") == 0 ) {
-   streams_set_flag(stream, ROAR_FLAG_META);
-  } else if ( strcmp(k, "cleanmeta") == 0 ) {
-   streams_set_flag(stream, ROAR_FLAG_CLEANMETA);
-  } else if ( strcmp(k, "autoconf") == 0 ) {
-   streams_set_flag(stream, ROAR_FLAG_AUTOCONF);
-
-  } else {
-   ROAR_ERR("sources_add_new(*): unknown option '%s'", k);
-   error++;
-  }
-
-  if ( error ) {
-   streams_delete(stream);
-   if ( primary ) alive = 0;
-   return -1;
-  }
-
-  k = roar_mm_strtok_r(NULL, ",", &strtok_store);
- }
-
- if ( primary )
-  streams_mark_primary(stream);
-
- streams_set_flag(stream, ROAR_FLAG_SOURCE);
- client_stream_add(g_source_client, stream);
-
- if ( codec == ROAR_CODEC_ALAW || codec == ROAR_CODEC_MULAW )
-  s->info.bits = 8; // needed to open OSS driver, will be overriden by codecfilter
-
- s->info.codec = codec;
- ROAR_STREAM_SERVER(s)->codec_orgi = codec;
-
- if ( source->new_open(stream, device, fh, driver) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAMID, &stream)); // ignore errors here
- _LIBROAR_IGNORE_RET(roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_SET_SSTREAM,   s)); // ignore errors here
-
- if ( f_sync ) {
-  streams_set_flag(stream, ROAR_FLAG_SYNC);
- } else {
-  streams_reset_flag(stream, ROAR_FLAG_SYNC);
- }
-
- if ( f_mmap )
-  streams_set_flag(stream, ROAR_FLAG_MMAP);
-
- return 0;
-}
-
-int sources_add_dstr  (int stream   , const char * device, int fh, const char * driver) {
- struct roar_stream_server * ss;
- struct roar_vio_defaults def;
-
- (void)driver;
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 )
-  return -1;
-
- streams_get(stream, &ss);
-
- if ( fh > -1 ) {
-  if ( roar_vio_open_fh(&(ss->vio), fh) == -1 )
-   return -1;
- } else {
-  if ( roar_vio_open_dstr(&(ss->vio), device, &def, 1) == -1 )
-   return -1;
- }
-
- return streams_set_fh(stream, -2);
-}
-
-#define _ret(x) streams_delete(stream); return (x)
-
-int sources_add_cf (const char * driver, const char * device, const char * container, const char * options, int primary) {
- int  stream;
- int  codec;
- int  len;
- char buf[64];
- struct roar_stream    * s;
- struct roar_vio_calls * vio;
- struct roar_vio_defaults def;
-
- (void)driver, (void)container;
-
- if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 )
-  return -1;
-
- if ( (stream = streams_new()) == -1 ) {
-  return -1;
- }
-
- streams_get_clientobj(stream, &s);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
-  streams_delete(stream);
-  return -1;
- }
-
- s->pos_rel_id = -1;
-
-/*
- if ( (fh = open(device, O_RDONLY, 0644)) == -1 ) {
-  return -1;
- }
-*/
-
- vio = &(ROAR_STREAM_SERVER(s)->vio);
-
- if ( roar_vio_open_dstr(vio, device, &def, 1) == -1 ) {
-  roar_vio_clear_calls(vio); // clear the VIO object again
-                            // from things roar_vio_open_dstr() left.
-  _ret(-1);
- }
-
- ROAR_DBG("sources_add_cf(*) = ?");
-
- // TODO: find out a better way of doing auto detetion without need for seek!
- if ( options == NULL ) {
-  if ( (len = roar_vio_read(vio, buf, 64)) < 1 ) {
-   _ret(-1);
-  }
-
-  if ( roar_vio_lseek(vio, -len, SEEK_CUR) == (roar_off_t)-1 ) {
-   _ret(-1);
-  }
-
-  if ( (codec = roar_file_codecdetect(buf, len)) == -1 ) {
-   _ret(-1);
-  }
- } else {
-  if ( !strncmp(options, "codec=", 6) )
-   options += 6;
-
-  if ( (codec = roar_str2codec(options)) == -1 ) {
-   _ret(-1);
-  }
- }
-
- s->info.codec = codec;
-
- ROAR_STREAM_SERVER(s)->codec_orgi = codec;
-
- ROAR_DBG("sources_add_cf(*) = ?");
- streams_set_fh(stream, -2);
- ROAR_DBG("sources_add_cf(*) = ?");
- streams_set_socktype(stream, ROAR_SOCKET_TYPE_FILE);
-
- if ( primary )
-  streams_mark_primary(stream);
-
- streams_set_flag(stream, ROAR_FLAG_SOURCE);
- client_stream_add(g_source_client, stream);
-
- return 0;
-}
-
-#undef _ret
-
-#ifndef ROAR_WITHOUT_DCOMP_CDRIVER
-int sources_add_cdriver (int stream   , const char * device, int fh, const char * driver) {
- struct roar_stream_server * ss;
-
- if ( fh > -1 )
-  return -1;
-
- if ( streams_get(stream, &ss) == -1 )
-  return -1;
-
- if ( !strncmp(driver, "cdriver:", 8) )
-  driver += 8;
-
- ROAR_DBG("sources_add_cdriver(stream=%i, device='%s', fh=%i, driver='%s') = ?", stream, device, fh, driver);
-
- if ( roar_cdriver_open(&(ss->vio), driver, device, &(ROAR_STREAM(ss)->info), ROAR_DIR_RECORD) == -1 )
-  return -1;
-
- return streams_set_fh(stream, -2);
-}
-#endif
-
-static ssize_t sources_radionoise_read (struct roar_vio_calls * vio, void *buf, size_t count) {
- int32_t * pcm = buf;
- int16_t noise;
- size_t len, i;
-
- (void)vio;
-
- ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=%llu) = 0", vio, buf, (long long unsigned int)count);
-
- // ensure size is a multiple of 4.
- count -= count & 0x03LLU;
-
- if ( count == 0 )
-  return 0;
-
- if ( buf == NULL )
-  return -1;
-
- roar_random_gen_nonce(buf, count);
-
- len = count / 4;
-
- for (i = 0; i < len; i++) {
-  noise  = pcm[i] & 0xFFFF;
-  pcm[i] = ((int32_t)noise << 16) >> 17;
- }
-
- ROAR_DBG("sources_radionoise_read(vio=%p, buf=%p, count=?) = %llu", vio, buf, (long long unsigned int)count);
- return count;
-}
-
-static int     sources_radionoise_return_zero (struct roar_vio_calls * vio) {
- (void)vio;
-
- ROAR_DBG("sources_radionoise_return_zero(vio=%p) = 0", vio);
-
- return 0;
-}
-
-static int  sources_radionoise_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
- (void)vio, (void)data;
-
- if ( cmd == ROAR_VIO_CTL_NONBLOCK )
-  return 0;
-
- roar_err_set(ROAR_ERROR_BADRQC);
- return -1;
-}
-
-int sources_add_radionoise (int stream, const char * device, int fh, const char * driver) {
- struct roar_stream_server * ss;
- struct roar_audio_info    * info;
-
- (void)device, (void)driver;
-
- if ( fh > -1 )
-  return -1;
-
- if ( streams_get(stream, &ss) == -1 )
-  return -1;
-
- info = &(ROAR_STREAM(ss)->info);
-
- info->codec = ROAR_CODEC_DEFAULT;
- info->bits  = 32;
-
- memset(&(ss->vio), 0, sizeof(struct roar_vio_calls));
- ss->vio.flags    = ROAR_VIO_FLAGS_NONE;
- ss->vio.refc     = 1;
- ss->vio.read     = sources_radionoise_read;
- ss->vio.close    = sources_radionoise_return_zero;
- ss->vio.sync     = sources_radionoise_return_zero;
- ss->vio.ctl      = sources_radionoise_ctl;
-
- return streams_set_fh(stream, -2);
-}
-
-int sources_add_roar (int stream, const char * device, int fh, const char * driver) {
- struct roar_stream_server * ss;
- struct roar_stream        * s;
-
- (void)driver;
-
- if ( fh > -1 )
-  return -1;
-
- if ( streams_get(stream, &ss) == -1 )
-  return -1;
-
- s = ROAR_STREAM(ss);
-
- if ( roar_vio_simple_stream(&(ss->vio), s->info.rate, s->info.channels, s->info.bits, s->info.codec,
-                             device, ROAR_DIR_MONITOR, "roard", -1) == -1 )
-  return -1;
-
- return streams_set_fh(stream, -2);
-}
-
-#endif
-
 //ll
Index: roard/ssynth.c
===================================================================
--- roard/ssynth.c	(revision 6052)
+++ 	(revision )
@@ -1,326 +1,0 @@
-//ssynth.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-#ifndef ROAR_WITHOUT_DCOMP_SSYNTH
-
-static const float ssynth_polys[SSYNTH_POLY_POLYMAX][SSYNTH_POLY_COEFF] = {
-       {0.300000,  0.958333, -0.550000,  0.091667},
-       {0.700010, -0.083333, -0.150000,  0.033333}
-      };
-
-struct ssynth_conf ssynth_conf;
-
-struct ssynth_state {
- int stream;
- struct {
-  int stage;
-  char vv_down, vv_up;
-  struct roar_note_octave   note;
-  struct roar_synth_state   synth;
-  struct roar_fader_state   fader;
-  struct roar_buffer      * buf;
- } notes[SSYNTH_NOTES_MAX];
-} g_ssynth;
-
-int ssynth_init_config(void) {
- memset(&ssynth_conf, 0, sizeof(ssynth_conf));
-
- return 0;
-}
-
-#define _err() streams_delete(sid); return -1
-int ssynth_init (void) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- int sid;
-
- if ( !ssynth_conf.enable )
-  return 0;
-
- memset(&g_ssynth, 0, sizeof(g_ssynth));
- g_ssynth.stream = -1;
-
- if ( (sid = streams_new()) == -1 )
-  return -1;
-
- if ( streams_set_client(sid, g_self_client) == -1 ) {
-  _err();
- }
-
- if ( streams_set_dir(sid, ROAR_DIR_BRIDGE, 1) == -1 ) {
-  _err();
- }
-
- if ( streams_set_flag(sid, ROAR_FLAG_PRIMARY) == -1 ) {
-  _err();
- }
-
- if ( streams_set_name(sid, "Simple Synthesizer") == -1 ) {
-  _err();
- }
-
- if ( streams_get(sid, &ss) == -1 ) {
-  _err();
- }
-
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- s->info.channels = 1;
- s->info.codec    = ROAR_CODEC_DEFAULT;
-
- g_ssynth.stream  = sid;
-
- return 0;
-}
-
-int ssynth_free (void) {
- int i;
-
- if ( !ssynth_conf.enable )
-  return 0;
-
- for (i = 0; i < SSYNTH_NOTES_MAX; i++) {
-  if ( g_ssynth.notes[i].buf != NULL ) {
-   roar_buffer_free(g_ssynth.notes[i].buf);
-   g_ssynth.notes[i].buf = NULL;
-  }
- }
-
- return streams_delete(g_ssynth.stream);
-}
-
-int ssynth_update (void) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- struct roar_buffer        * buf;
- struct roar_buffer        * outbuf;
- void                      * outbufdata;
- void                      * indbufs[SSYNTH_NOTES_MAX+1];
- int                         curin = 0;
- size_t buflen;
- size_t needlen;
- int i;
-
- if ( !ssynth_conf.enable )
-  return 0;
-
- ROAR_DBG("ssynth_update(void) = ?");
-
- if ( streams_get(g_ssynth.stream, &ss) == -1 ) {
-  return -1;
- }
-
- memset(indbufs, 0, sizeof(indbufs));
-
- s = ROAR_STREAM(ss);
-
- needlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(&(s->info));
-
- ROAR_DBG("ssynth_update(void): needlen=%lu", (unsigned long)needlen);
-
- for (i = 0; i < SSYNTH_NOTES_MAX; i++) {
-  if ( g_ssynth.notes[i].stage != SSYNTH_STAGE_UNUSED ) {
-   ROAR_DBG("ssynth_update(void): used note slot: %i", i);
-   if ( g_ssynth.notes[i].buf == NULL ) {
-    if ( roar_buffer_new(&buf, needlen) == -1 )
-     continue;
-
-    g_ssynth.notes[i].buf = buf;
-   } else {
-    buf = g_ssynth.notes[i].buf;
-
-    if ( roar_buffer_get_len(buf, &buflen) == -1 )
-     continue;
-
-    if ( buflen < needlen ) {
-     if ( roar_buffer_set_len(buf, needlen) == -1 )
-      continue;
-    }
-   }
-
-   if ( roar_buffer_get_data(buf, &(indbufs[curin])) == -1 )
-    continue;
-
-   if ( ssynth_note_render(i, indbufs[curin]) == -1 )
-    continue;
-
-   curin++;
-  }
- }
-
- ROAR_DBG("ssynth_update(void): found streams: %i", curin);
-
- if ( curin > 0 ) {
-  if ( roar_buffer_new(&outbuf, needlen) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_data(outbuf, &outbufdata) == -1 ) {
-   roar_buffer_free(outbuf);
-   return -1;
-  }
-
-  if ( roar_mix_pcm(outbufdata, g_sa->bits, indbufs, ROAR_OUTPUT_BUFFER_SAMPLES) == -1 ) {
-   roar_buffer_free(outbuf);
-   return -1;
-  }
-
-  if ( stream_add_buffer(g_ssynth.stream, &outbuf) == -1 ) {
-   roar_buffer_free(outbuf);
-   return -1;
-  }
- }
-
- ROAR_DBG("ssynth_update(void) = 0");
- return 0;
-}
-
-
-int ssynth_note_new(struct roar_note_octave * note, char vv) {
- int i;
-
- ROAR_DBG("ssynth_note_new(note=%p, vv=%i) = ?", note, vv);
-
- for (i = 0; i < SSYNTH_NOTES_MAX; i++) {
-  if ( g_ssynth.notes[i].stage == SSYNTH_STAGE_UNUSED ) {
-   // TODO: do some error checking here
-   g_ssynth.notes[i].vv_down = vv;
-   memcpy(&(g_ssynth.notes[i].note), note, sizeof(struct roar_note_octave));
-   roar_synth_init(&(g_ssynth.notes[i].synth), &(g_ssynth.notes[i].note), g_sa->rate);
-   roar_synth_set_volume(&(g_ssynth.notes[i].synth), 0.25);
-   roar_synth_set_func(&(g_ssynth.notes[i].synth), ROAR_SYNTH_SYNF_TRAP);
-   ssynth_note_set_stage(i, SSYNTH_STAGE_KEYSTROKE);
-   ROAR_DBG("ssynth_note_new(note=%p, vv=%i) = %i", note, vv, i);
-   return i;
-  }
- }
-
- ROAR_DBG("ssynth_note_new(note=%p, vv=%i) = -1", note, vv);
- return -1;
-}
-
-int ssynth_note_free(int id) {
- g_ssynth.notes[id].stage = SSYNTH_STAGE_UNUSED;
- return 0;
-}
-
-int ssynth_note_find(struct roar_note_octave * note) {
- struct roar_note_octave * cn;
- int i;
-
- for (i = 0; i < SSYNTH_NOTES_MAX; i++) {
-  if ( g_ssynth.notes[i].stage == SSYNTH_STAGE_UNUSED )
-   continue;
-
-  cn = &(g_ssynth.notes[i].note);
-
-  if ( !(note->note == cn->note && note->octave == cn->octave) )
-   continue;
-
-  return i;
- }
-
- return -1;
-}
-
-int ssynth_note_set_stage(int id, int stage) {
- int r = -1;
-
- switch (stage) {
-  case SSYNTH_STAGE_UNUSED:
-    r = ssynth_note_free(id);
-   break;
-  case SSYNTH_STAGE_KEYSTROKE:
-    r = roar_fader_init(&(g_ssynth.notes[id].fader), ssynth_polys[SSYNTH_POLY_KEYDOWN], SSYNTH_POLY_COEFF);
-   break;
-  case SSYNTH_STAGE_MIDSECTION:
-    r = 0;
-   break;
-  case SSYNTH_STAGE_KEYRELEASE:
-    r = roar_fader_init(&(g_ssynth.notes[id].fader), ssynth_polys[SSYNTH_POLY_KEYUP], SSYNTH_POLY_COEFF);
-   break;
- }
-
- if ( r == 0 )
-  g_ssynth.notes[id].stage = stage;
-
- return r;
-}
-
-int ssynth_note_render   (int id, void * data) {
- if ( g_sa->bits != 16 )
-  return -1;
-
- return roar_synth_pcmout_i161(&(g_ssynth.notes[id].synth), data, ROAR_OUTPUT_BUFFER_SAMPLES);
-}
-
-int ssynth_note_on       (struct roar_note_octave * note, char vv) {
- ROAR_DBG("ssynth_note_on(note=%p, vv=%i) = ?", note, vv);
- return ssynth_note_new(note, vv);
-}
-
-int ssynth_note_off      (struct roar_note_octave * note, char vv) {
- int id;
-
- (void)vv;
-
- ROAR_DBG("ssynth_note_off(note=%p, vv=%i) = ?", note, vv);
-
- if ( (id = ssynth_note_find(note)) == -1 )
-  return -1;
-
- // add support to for keyups...
-
- return ssynth_note_free(id);
-}
-
-int ssynth_eval_message (struct midi_message * mes) {
- if ( !ssynth_conf.enable )
-  return -1;
-
- ROAR_DBG("ssynth_eval_message(mes=%p) = ?", mes);
-
- switch (mes->type) {
-  case MIDI_TYPE_NOTE_OFF:
-    return ssynth_note_off(&(mes->d.note), mes->vv);
-   break;
-  case MIDI_TYPE_NOTE_ON:
-    return ssynth_note_on(&(mes->d.note), mes->vv);
-   break;
-  default:
-    /* ignore all other events at the moment */
-    return 0;
- }
-
- ROAR_DBG("ssynth_eval_message(mes=%p) = -1", mes);
- return -1;
-}
-
-#endif
-
-//ll
Index: roard/streams.c
===================================================================
--- roard/streams.c	(revision 6052)
+++ roard/streams.c	(revision 0)
@@ -1,134 +1,8 @@
 //streams.c:
 
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
 #include "roard.h"
-
-// declared 'extern'
-struct roar_stream_server * g_streams[ROAR_STREAMS_MAX];
-
-#define _CHECK_SID_RET(id,ret) if ( (id) < 0 || (id) > ROAR_STREAMS_MAX || g_streams[(id)] == NULL ) return (ret)
-#define _CHECK_SID(id)         _CHECK_SID_RET((id), -1)
-
-static int streams_thru_num     =  0;
-static int streams_sync_num     =  0;
-int streams_recsource_id = -1;
-
-static const struct rolestack * streams_rolestack = NULL;
-static int streams_role_num     =  0;
-
-
-static void _streams_change_state(struct roar_stream_server * s, const int new, const char * func) {
- register int id  = ROAR_STREAM(s)->id;
- register int old = s->state;
-
- s->state = new;
-
- if ( func == NULL ) {
-  func = "(unknown)";
- }
-
- ROAR_INFO("_streams_change_state[by %s](id=%i): stream state: %s->%s", ROAR_DBG_INFO_VERBOSE,
-            func,
-            ROAR_STREAM(s)->id,
-            roar_streamstate2str(old), roar_streamstate2str(new));
-
- roar_notify_core_emit_simple(ROAR_OE_BASICS_CHANGE_STATE, -1, id, ROAR_OT_STREAM, old, new, NULL, 0);
-}
-
-void streams_change_sync_num(int id, int diff) {
- struct roar_stream_server * ss;
- int i;
-
- if ( diff != 0 )
-  if ( streams_get_dir(id) != ROAR_DIR_OUTPUT )
-   return;
-
- ROAR_INFO("streams_change_sync_num(id=%i, diff=%i): Number of sync streams changed from %i to %i",
-           ROAR_DBG_INFO_VERBOSE,
-           id, diff,
-           streams_sync_num, streams_sync_num + diff);
- streams_sync_num += diff;
-
- if ( !streams_sync_num && alive ) {
-  ROAR_INFO("streams_change_sync_num(id=%i, diff=%i): Number of sync streams changed to zero. Bad.",
-            ROAR_DBG_INFO_VERBOSE, id, diff
-            );
-
-  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-   if ( (ss = g_streams[i]) == NULL )
-    continue;
-
-   if ( ROAR_STREAM(ss)->dir != ROAR_DIR_OUTPUT )
-    continue;
-
-   if ( !ss->ready )
-    continue;
-
-   if ( ss->state == ROAR_STREAMSTATE_CLOSING )
-    continue;
-
-   if ( streams_get_flag(i, ROAR_FLAG_PRIMARY) ) {
-    ROAR_DBG("streams_change_sync_num(*): try to set sync on primary stream %i", i);
-    streams_set_flag(i, ROAR_FLAG_SYNC);
-    if ( streams_sync_num )
-     return;
-   }
-  }
-
-  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-   if ( (ss = g_streams[i]) == NULL )
-    continue;
-
-   if ( ROAR_STREAM(ss)->dir != ROAR_DIR_OUTPUT )
-    continue;
-
-   if ( !ss->ready )
-    continue;
-
-   if ( ss->state == ROAR_STREAMSTATE_CLOSING )
-    continue;
-
-   if ( !streams_get_flag(i, ROAR_FLAG_PRIMARY) ) {
-    ROAR_DBG("streams_change_sync_num(*): try to set sync on non-primary stream %i", i);
-    streams_set_flag(i, ROAR_FLAG_SYNC);
-    if ( streams_sync_num )
-     return;
-   }
-  }
-
-  ROAR_INFO("streams_change_sync_num(id=%i, diff=%i): Can not auto set sync flag to an output. Very Bad",
-            ROAR_DBG_INFO_VERBOSE, id, diff
-            );
-  ROAR_WARN("streams_change_sync_num(id=%i, diff=%i): Lost all sync streams and failed to set a new one. Very Bad.",
-            id, diff);
- }
-}
 
 int streams_init (void) {
  int i;
-
- streams_rolestack = rolestack_get_role(-1); // get default
 
  for (i = 0; i < ROAR_STREAMS_MAX; i++)
@@ -152,19 +26,10 @@
 
 int streams_new    (void) {
- int i, j;
- struct roar_stream        * n = NULL;
- struct roar_stream_server * s = NULL;
-
-#ifdef ROAR_SUPPORT_LISTEN
- if ( g_terminate && !g_no_listen ) // don't accept new streams in case of termination state
-  return -1;
-#else
- if ( g_terminate )                 // don't accept new streams in case of termination state
-  return -1;
-#endif
+ int i;
+ struct roar_stream * n = NULL;
 
  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
   if ( g_streams[i] == NULL ) {
-   s = ROAR_STREAM_SERVER(n = ROAR_STREAM(roar_mm_malloc(sizeof(struct roar_stream_server))));
+   n = malloc(sizeof(struct roar_stream_server));
    if ( n == NULL ) {
     ROAR_ERR("streams_new(void): can not allocate memory for new stream: %s", strerror(errno));
@@ -173,75 +38,18 @@
    }
 
-   memset(s, 0, sizeof(struct roar_stream_server));
-
    n->id         = i;
    n->fh         = -1;
-   n->pos_rel_id = -1;
-/*
+//   n->pos_rel_id = i;
    n->database   = NULL;
    n->dataoff    = NULL;
    n->datalen    = 0;
    n->offset     = 0;
-*/
-   n->pos        = 0;
-
-   s->name            = NULL;
-
-   s->state           = ROAR_STREAMSTATE_INITING;
-
-   s->client          = -1;
-   s->socktype        = ROAR_SOCKET_TYPE_UNKNOWN;
-   s->buffer          = NULL;
-   s->need_extra      =  0;
-   s->output          = NULL;
-   s->is_new          =  1;
-   s->codecfilter     = -1;
-   s->pre_underruns   =  0;
-   s->post_underruns  =  0;
-   s->delay           =  0;
-   s->codec_orgi      = -1;
-   s->primary         =  0;
-   s->ready           =  0;
-   s->outputbuffer    = NULL;
-   s->prethru         = NULL;
-   s->mixer_stream    = -1;
-   s->role            = ROAR_ROLE_UNKNOWN;
-   s->parent_stream   = -1;
-   s->single_sink_c   =  0;
-   s->single_sink_self_c =  0;
-
-   s->mixer.scale     = 65535;
-   s->mixer.rpg_mul   = 1;
-   s->mixer.rpg_div   = 1;
-   for (j = 0; j < ROAR_MAX_CHANNELS; j++)
-    s->mixer.mixer[j] = 65535;
-
-#ifdef ROAR_SUPPORT_META
-   for (j = 0; j < ROAR_META_MAX_PER_STREAM; j++) {
-    s->meta[j].type   = ROAR_META_TYPE_NONE;
-    s->meta[j].key[0] = 0;
-    s->meta[j].value  = NULL;
-   }
-#endif
-
-   roar_vio_clear_calls(&(s->vio));
-   roar_vio_clear_calls(&(s->jumbo));
-   s->viop      = &(s->vio);
-   s->driver_id = -1;
-   s->flags     =  ROAR_FLAG_NONE;
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-   s->mixerstream =  NULL;
-#endif
-
-   s->rpgmode = ROAR_RPGMODE_DEFAULT;
-
-   //roardsp_fchain_init(&(s->fc));
-
-   g_streams[i] = s;
-   counters_inc(streams, 1);
-   ROAR_INFO("streams_new(void): New stream %i created (state=initing)", ROAR_DBG_INFO_VERBOSE, i);
-   ROAR_DBG("streams_new(void): n->id=%i", n->id);
-   roar_notify_core_emit_snoargs(ROAR_OE_BASICS_NEW, -1, i, ROAR_OT_STREAM);
+
+   ((struct roar_stream_server*)n)->client     = -1;
+   ((struct roar_stream_server*)n)->buffer     = NULL;
+   ((struct roar_stream_server*)n)->need_extra = 0;
+   ((struct roar_stream_server*)n)->output     = NULL;
+
+   g_streams[i] = (struct roar_stream_server*)n;
    ROAR_DBG("streams_new(void) = %i", i);
    return i;
@@ -253,154 +61,27 @@
 
 int streams_delete (int id) {
- struct roar_stream_server * s;
- int prim;
- int no_vio_close = 0;
- int i;
- int client;
-
- _CHECK_SID(id);
-
- if ( (s = g_streams[id]) == NULL )
+ if ( g_streams[id] == NULL )
   return 0;
 
  ROAR_DBG("streams_delete(id=%i) = ?", id);
- ROAR_DBG("streams_delete(id=%i): g_streams[id]->id=%i", id, ROAR_STREAM(s)->id);
-
- // in case we are allready closing it...
- if ( s->state == ROAR_STREAMSTATE_CLOSING )
-  return 0;
-
- _streams_change_state(s, ROAR_STREAMSTATE_CLOSING, "streams_delete");
- roar_notify_core_emit_snoargs(ROAR_OE_BASICS_DELETE, -1, id, ROAR_OT_STREAM);
-
- streams_set_role(id, -1);
-
- prim = s->primary;
-
- if ( prim )
-  alive = 0;
-
- if ( s->flags & ROAR_FLAG_SINGLESINK )
-  streams_set_single_sink(id, 1);
-
- counters_inc(streams, -1);
-
- if ( streams_get_flag(id, ROAR_FLAG_RECSOURCE) == 1 )
-  streams_reset_flag(id, ROAR_FLAG_RECSOURCE);
-
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == id ) {
-   switch (ROAR_STREAM(g_streams[i])->dir) {
-    case ROAR_DIR_THRU:
-    case ROAR_DIR_RAW_IN:
-      if ( i != id )
-       streams_delete(i);
-     break;
-    default:
-      if ( streams_get_flag(i, ROAR_FLAG_VIRTUAL) == 1 ) {
-       if ( i != id ) {
-        ROAR_DBG("streams_delete(id=%i): Deleting virtual child stream %i", id, i);
-        streams_delete(i);
-       }
-      } else {
-       ROAR_STREAM(g_streams[i])->pos_rel_id = -1;
-      }
-   }
-  }
- }
-
- if ( ROAR_STREAM(s)->dir == ROAR_DIR_THRU )
-  streams_thru_num--;
-
- if ( streams_get_flag(id, ROAR_FLAG_VIRTUAL) == 1 ) {
-  // we un-group the stream here to avoid a client deleting the parent deleting the client deleting ...
-  i      = ROAR_STREAM(s)->pos_rel_id;
-  if ( i != -1 ) {
-   ROAR_STREAM(s)->pos_rel_id = -1;
-   client = streams_get_client(id);
-   streams_set_client(id, -1);
-   ROAR_DBG("streams_delete(id=%i): Stream has flag virtual, notifying parent stream %i", id, i);
-   streams_ctl(i, ROAR_CODECFILTER_CTL_VIRTUAL_DELETE|ROAR_STREAM_CTL_TYPE_INT, &id);
-   ROAR_DBG("streams_delete(id=%i): Notify send to stream %i", id, i);
-   streams_set_client(id, client);
-   ROAR_STREAM(s)->pos_rel_id = i;
-  }
- }
-
-#ifdef ROAR_SUPPORT_META
- // delete meta data form other meta streams if needed
- if ( streams_get_flag(id, ROAR_FLAG_META) == 1 ) {
-  ROAR_DBG("streams_delete(id=%i): deleting meta stream!", id);
-  stream_meta_clear(id);
-  stream_meta_finalize(id);
- }
-#endif
-
- if ( s->codecfilter != -1 ) {
-  codecfilter_close(s->codecfilter_inst, s->codecfilter);
-  s->codecfilter_inst = NULL;
-  s->codecfilter = -1;
- }
-
- if ( s->driver_id != -1 ) {
-  driver_closevio(&(s->vio), s->driver_id);
-  roar_vio_clear_calls(&(s->vio));
-  s->driver_id = -1;
-  no_vio_close =  1;
- }
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- if ( s->mixerstream != NULL ) {
-  hwmixer_close(id);
- }
-#endif
-
- // all IO is no disconnected:
- s->ready = 0;
-
- // re-try reset after all IO is disconnected.
- if ( streams_get_flag(id, ROAR_FLAG_RECSOURCE) == 1 )
-  streams_reset_flag(id, ROAR_FLAG_RECSOURCE);
-
- //roardsp_fchain_uninit(&(s->fc));
-
- if ( s->client != -1 ) {
+
+ if ( g_streams[id]->client != -1 ) {
   ROAR_DBG("streams_delete(id=%i): Stream is owned by client %i", id, g_streams[id]->client);
-  client_stream_delete(s->client, id);
- }
-
- stream_outputbuffer_destroy(id);
- stream_prethru_destroy(id);
-
- if ( s->buffer != NULL )
-  roar_buffer_free(s->buffer);
-
- if ( s->output != NULL )
-  roar_mm_free(s->output);
-
-/*
- if ( ROAR_STREAM(s)->fh != -1 )
-  close(ROAR_STREAM(s)->fh);
-*/
-
- if ( s->flags & ROAR_FLAG_SYNC )
-  streams_change_sync_num(id, -1);
-
- if ( !no_vio_close )
-  roar_vio_close(s->viop);
-
- if ( s->name != NULL )
-  roar_mm_free(s->name);
-
- roar_mm_free(s);
+  client_stream_delete(g_streams[id]->client, id);
+ }
+
+ if ( g_streams[id]->buffer != NULL )
+  roar_buffer_free(g_streams[id]->buffer);
+
+ if ( g_streams[id]->output != NULL )
+  free(g_streams[id]->output);
+
+ if ( ROAR_STREAM(g_streams[id])->fh != -1 )
+  close(ROAR_STREAM(g_streams[id])->fh);
+
+ free(g_streams[id]);
 
  g_streams[id] = NULL;
 
- if ( prim && alive ) {
-  alive = 0;
-  clean_quit();
- }
-
- ROAR_INFO("streams_delete(id=%i): stream deleted", ROAR_DBG_INFO_VERBOSE, id);
  ROAR_DBG("streams_delete(id=%i) = 0", id);
  return 0;
@@ -408,8 +89,7 @@
 
 int streams_set_client (int id, int client) {
-
- _CHECK_SID(id);
-
- ROAR_DBG("streams_set_client(id=%i): g_streams[id]->id=%i", id, ROAR_STREAM(g_streams[id])->id);
+ if ( g_streams[id] == NULL )
+  return -1;
+
  g_streams[id]->client = client;
 
@@ -417,521 +97,21 @@
 }
 
-int streams_get_client (int id) {
- _CHECK_SID(id);
-
- return g_streams[id]->client;
-}
-
-int streams_set_dir    (int id, int dir, int defaults) {
- struct roar_stream_server * ss;
- int mixer;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL ) {
-  ROAR_ERR("streams_set_dir(id=%i, dir=%i, defaults=%i) = -1 // error=NOENT", id, dir, defaults);
-  roar_err_set(ROAR_ERROR_NOENT);
-  return -1;
- }
-
- ROAR_STREAM(ss)->dir = dir;
-
- if ( dir == ROAR_DIR_THRU )
-  streams_thru_num++;
-
- if ( defaults ) {
-  if ( dir <= 0 || dir >= ROAR_DIR_DIRIDS ) {
-   ROAR_ERR("streams_set_dir(id=%i, dir=%i, defaults=%i) = -1 // error=INVAL", id, dir, defaults);
-   roar_err_set(ROAR_ERROR_INVAL);
-   return -1;
-  }
-
-  ROAR_DBG("streams_set_dir(*): g_config->streams[dir=%i].flags = 0x%.4x", dir, g_config->streams[dir].flags);
-
-  if ( streams_set_flag(id, g_config->streams[dir].flags) == -1 ) {
-   ROAR_WARN("streams_set_dir(*) = -1 // can not set stream flags");
-   return -1;
-  }
-
-   ss->mixer.scale   = g_config->streams[dir].mixer.scale;
-   ss->mixer.rpg_mul = g_config->streams[dir].mixer.rpg_mul;
-   ss->mixer.rpg_div = g_config->streams[dir].mixer.rpg_div;
- }
-
- if ( dir != ROAR_DIR_MIXING ) {
-  switch (streams_get_subsys(id)) {
-   case ROAR_SUBSYS_WAVEFORM:
-     streams_set_mixer_stream(id, g_waveform_mixer.stream);
-     roardsp_chanlist_init(ss->chanmap.in,  ROAR_STREAM(ss)->info.channels, ROARDSP_CHANLIST_MAP_ROARAUDIO);
-    break;
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-   case ROAR_SUBSYS_MIDI:
-     roardsp_chanlist_init(ss->chanmap.in,  ROAR_STREAM(ss)->info.channels, ROARDSP_CHANLIST_MAP_MIDI);
-     streams_set_mixer_stream(id, g_midi_mixer.stream);
-    break;
-#endif
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-   case ROAR_SUBSYS_LIGHT:
-     streams_set_mixer_stream(id, g_light_mixer.stream);
-    break;
-#endif
-  }
-
-  if ( streams_get_ssdir(id) & STREAM_DIR_OUT ) {
-   if ( (mixer = streams_get_mixer_stream(id)) != -1 ) {
-    if ( g_streams[mixer]->flags & ROAR_FLAG_SINGLESINK ) {
-     streams_set_mixer_stream(id, -1);
-     return -1;
-    }
-   }
-  }
-
-  memcpy(ss->chanmap.out, ss->chanmap.in, sizeof(ss->chanmap.out));
-  streams_set_map(id, NULL, 0);
+int streams_set_fh     (int id, int fh) {
+ if ( g_streams[id] == NULL )
+  return -1;
+
+ ((struct roar_stream *)g_streams[id])->fh = fh;
+
+ if ( ((struct roar_stream *)g_streams[id])->dir == ROAR_DIR_FILTER ) {
+  return 0;
  } else {
-  streams_set_mixer_stream(id, id);
- }
-
- ROAR_DBG("streams_set_dir(*) = 0");
- return 0;
-}
-
-int streams_get_dir    (int id) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- return ROAR_STREAM(ss)->dir;
-}
-
-int streams_set_mixer_stream(int id, int mixer) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- ss->mixer_stream = mixer;
-
- return 0;
-}
-
-int streams_get_mixer_stream(int id) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- return ss->mixer_stream;
-}
-
-static int streams_set_role_handle(int id) {
-   switch (streams_rolestack->action) {
-    case RS_ERROR: /* nothing to do */; break;
-    case RS_MIX:   /* nothing to do */; break;
-    case RS_KICK:  streams_delete(id);  break;
-    case RS_MUTE:  streams_set_flag(id, ROAR_FLAG_MUTE);  break;
-    case RS_PAUSE: streams_set_flag(id, ROAR_FLAG_PAUSE); break;
-   }
- return 0;
-}
-
-int streams_set_role   (int id, int role) {
- struct roar_stream_server * ss;
- const struct rolestack * rs;
- int old_role;
- int i;
-
- ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- old_role = ss->role;
- ss->role = role;
-
- ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
- if ( ROAR_STREAM(ss)->dir != ROAR_DIR_PLAY )
-  return 0;
-
- ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
- if ( old_role == role ) {
-  ROAR_DBG("streams_set_role(id=%i, role=%i) = 0", id, role);
-  return 0;
- }
-
- if ( old_role != role && old_role != -1 && role != -1 ) {
-  streams_set_role(id, -1);
-  streams_set_role(id, role);
- }
-
- ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
- if ( ss->role != -1 && ss->role == streams_rolestack->role ) {
-  ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
-  streams_role_num--;
-  if ( streams_role_num == 0 ) {
-   streams_rolestack = rolestack_get_role(-1); // get default
-   for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-    if ( (ss = g_streams[i]) == NULL )
-     continue;
-    if ( ROAR_STREAM(ss)->dir != ROAR_DIR_PLAY )
-     continue;
-    if ( ss->role == -1 )
-     continue;
-    rs = rolestack_get_role(ss->role);
-    if ( rs->index > streams_rolestack->role ) {
-     streams_rolestack = rs;
-    }
-   }
-   for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-    if ( (ss = g_streams[i]) == NULL )
-     continue;
-    if ( ROAR_STREAM(ss)->dir != ROAR_DIR_PLAY )
-     continue;
-    if ( ss->role == streams_rolestack->role )
-     streams_role_num++;
-   }
-  }
- } else if ( role != -1 ) {
-  ROAR_DBG("streams_set_role(id=%i, role=%i) = ?", id, role);
-
-  rs = rolestack_get_role(role);
-  ROAR_DBG("streams_set_role(id=%i, role=%i): rs->index=%i, streams_rolestack->index=%i", id, role, rs->index, streams_rolestack->index);
-  if ( rs->index == streams_rolestack->index ) {
-   ROAR_DBG("streams_set_role(id=%i, role=%i): rs->index=%i, streams_rolestack->index=%i", id, role, rs->index, streams_rolestack->index);
-   streams_role_num++;
-  } else if ( rs->index > streams_rolestack->index ) {
-   ROAR_DBG("streams_set_role(id=%i, role=%i): rs=%p{.index=%i, .action=%s}", id, role, rs, rs->index, rolestack_action2str(rs->action));
-   streams_role_num  = 1;
-   streams_rolestack = rs;
-   for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-    if ( (ss = g_streams[i]) == NULL )
-     continue;
-    if ( ROAR_STREAM(ss)->dir != ROAR_DIR_PLAY )
-     continue;
-    rs = rolestack_get_role(ss->role);
-    ROAR_DBG("streams_set_role(id=%i, role=%i): i=%i, rs->index=%i, streams_rolestack->index=%i", id, role, i, rs->index, streams_rolestack->index);
-    if ( rs->index < streams_rolestack->index )
-     streams_set_role_handle(i);
-   }
-  } else {
-   ROAR_DBG("streams_set_role(id=%i, role=%i): streams_rolestack->action=%s", id, role, rolestack_action2str(streams_rolestack->action));
-   streams_set_role_handle(id);
-  }
- }
-
- ROAR_DBG("streams_set_role(id=%i, role=%i) = 0", id, role);
- return 0;
-}
-
-int streams_get_subsys (int id) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( ROAR_STREAM(ss)->dir == ROAR_DIR_THRU )
-  return streams_get_subsys(ROAR_STREAM(ss)->pos_rel_id);
-
- return streams_dir2subsys(ROAR_STREAM(ss)->dir);
-}
-
-int streams_dir2subsys (int dir) {
- switch (dir) {
-  case ROAR_DIR_PLAY:
-  case ROAR_DIR_RECORD:
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_FILTER:
-  case ROAR_DIR_OUTPUT:
-  case ROAR_DIR_BIDIR:
-  case ROAR_DIR_RECPLAY:
-    return ROAR_SUBSYS_WAVEFORM;
-   break;
-  case ROAR_DIR_MIDI_IN:
-  case ROAR_DIR_MIDI_OUT:
-    return ROAR_SUBSYS_MIDI;
-   break;
-  case ROAR_DIR_LIGHT_IN:
-  case ROAR_DIR_LIGHT_OUT:
-    return ROAR_SUBSYS_LIGHT;
-   break;
-  case ROAR_DIR_RAW_IN:
-  case ROAR_DIR_RAW_OUT:
-    return ROAR_SUBSYS_RAW;
-   break;
-  case ROAR_DIR_COMPLEX_IN:
-  case ROAR_DIR_COMPLEX_OUT:
-    return ROAR_SUBSYS_COMPLEX;
-   break;
-  case ROAR_DIR_MIXING:
-    return ROAR_SUBSYS_NONE;
-   break;
- }
-
- return -1;
-}
-
-int streams_get_ssdir  (int id) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- switch (ROAR_STREAM(ss)->dir) {
-  case ROAR_DIR_PLAY:
-  case ROAR_DIR_MIDI_IN:
-  case ROAR_DIR_LIGHT_IN:
-  case ROAR_DIR_RAW_IN:
-  case ROAR_DIR_COMPLEX_IN:
-    return STREAM_DIR_IN;
-   break;
-  case ROAR_DIR_RECORD:
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_OUTPUT:
-  case ROAR_DIR_MIDI_OUT:
-  case ROAR_DIR_LIGHT_OUT:
-  case ROAR_DIR_RAW_OUT:
-  case ROAR_DIR_COMPLEX_OUT:
-    return STREAM_DIR_OUT;
-   break;
-  case ROAR_DIR_MIXING:
-    return STREAM_DIR_NONE;
-   break;
-  case ROAR_DIR_FILTER:
-  case ROAR_DIR_BIDIR:
-  case ROAR_DIR_RECPLAY:
-    return STREAM_DIR_BIDIR;
-   break;
-  case ROAR_DIR_THRU:
-    return streams_get_ssdir(ROAR_STREAM(ss)->pos_rel_id);
-   break;
- }
-
- return -1;
-}
-
-#define _err() streams_delete(id); return -1;
-int streams_new_virtual (int parent, struct roar_stream_server ** stream) {
- struct roar_stream_server * parent_ss, * ss;
- struct roar_stream        * parent_s , *  s;
- int id = -1;
- int client, dir;
-
- if ( streams_get(parent, &parent_ss) == -1 )
-  return -1;
-
- if ( (client = streams_get_client(parent)) == -1 )
-  return -1;
-
- if ( (dir = streams_get_dir(parent)) == -1 )
-  return -1;
-
- if ( (id = streams_new()) == -1 ) {
-  return -1;
- }
-
- if ( client_stream_add(client, id) == -1 ) {
-  _err();
- }
-
- if ( streams_get(id, &ss) == -1 ) {
-  _err();
- }
-
- if ( streams_set_dir(id, dir, 1) == -1 ) {
-  _err();
- }
-
- s        = ROAR_STREAM(       ss);
- parent_s = ROAR_STREAM(parent_ss);
-
- s->pos_rel_id = parent;
-
- if ( streams_set_rawflag(id, ROAR_FLAG_VIRTUAL) == -1 ) {
-  _err();
- }
-
- if ( stream != NULL )
-  *stream = ss;
-
- return id;
-}
-#undef _err
-
-int streams_set_fh     (int id, int fh) {
- struct roar_stream_server * ss;
- struct roar_stream        * s;
- int dir;
- int nonblock = 1;
-
- _CHECK_SID(id);
-
- if ( (s = ROAR_STREAM(ss = g_streams[id])) == NULL )
-  return -1;
-
- if ( ss->ready && !(s->fh == -1 && fh == -2) ) {
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i) = -1 // try to set fh for stream which is already ready", id, fh);
-  return -1;
- }
-
- dir = s->dir;
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i): g_streams[id]->id=%i", id, fh, s->id);
-
- s->fh = fh;
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i): driverID=%i", id, fh, ss->driver_id);
-
- if ( ss->driver_id == -1 && fh != -2 ) {
-#ifndef ROAR_TARGET_WIN32
-  roar_vio_open_fh(&(ss->vio), fh);
-#else
-  roar_vio_open_fh_socket(&(ss->vio), fh);
-#endif
- }
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-
- switch (dir) {
-  case ROAR_DIR_THRU:
-  case ROAR_DIR_RAW_IN:
-  case ROAR_DIR_RAW_OUT:
-   break;
-  default:
-    ROAR_DBG("streams_set_fh(id=%i, fh=%i): codec=%s(%i)", id, fh, roar_codec2str(s->info.codec), s->info.codec);
-    if ( codecfilter_open(&(ss->codecfilter_inst), &(ss->codecfilter), NULL,
-                     s->info.codec, ss) == -1 ) {
-     streams_delete(id); // TODO: FIXME: is this correct? shoudn't we return -1 in any case here?
-     ROAR_DBG("streams_set_fh(id=%i, fh=%i) = -1", id, fh);
-     return -1;
-    }
-   break;
- }
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-
- if ( fh == -2 ) {
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_GET_READ_FH, &fh) == -1 ) {
-   fh = -2;
-  } else {
-   ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-   if ( fh < 0 ) {
-    fh = -2;
-   } else {
-    s->fh = fh;
-   }
-  }
- }
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-
- if ( fh == -1 || fh == -2 ) { // yes, this is valid, indecats full vio!
-  ss->ready = 1;
-  //ROAR_INFO("streams_set_fh(id=%i, fh=%i): stream state: %s->new", ROAR_DBG_INFO_VERBOSE, id, fh, roar_streamstate2str(ss->state));
-  _streams_change_state(ss, ROAR_STREAMSTATE_NEW, "streams_set_fh");
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i): s->fh=%i", id, fh, s->fh);
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i) = 0", id, fh);
-  return 0;
- }
-
- ROAR_DBG("streams_set_fh(id=%i, fh=%i) = ?", id, fh);
-
- switch (dir) {
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_RECORD:
-  case ROAR_DIR_OUTPUT:
-  case ROAR_DIR_MIDI_OUT:
-  case ROAR_DIR_LIGHT_OUT:
-  case ROAR_DIR_RAW_OUT:
-    ROAR_SHUTDOWN(fh, SHUT_RD);
-   break;
- }
-
- if ( dir >= ROAR_DIR_DIRIDS )
-  return -1;
-
- if ( g_config->streams[dir].flags & ROAR_FLAG_SYNC ) {
-  switch (dir) {
-   case ROAR_DIR_BRIDGE:
-   case ROAR_DIR_MIDI_OUT:
-    break;
-   default:
-     nonblock = 0;
-    break;
-  }
- }
-
-
- if ( !nonblock ) {
-  ss->ready = 1;
-  //ROAR_INFO("streams_set_fh(id=%i, fh=%i): stream state: %s->new", ROAR_DBG_INFO_VERBOSE, id, fh, roar_streamstate2str(ss->state));
-  _streams_change_state(ss, ROAR_STREAMSTATE_NEW, "streams_set_fh");
-
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i) = 0", id, fh);
-  return 0;
- } else {
-#ifndef ROAR_TARGET_WIN32
-  if ( roar_socket_nonblock(fh, ROAR_SOCKET_NONBLOCK) == -1 )
-   return -1;
-#endif
-
-  ss->ready = 1;
-  //ROAR_INFO("streams_set_fh(id=%i, fh=%i): stream state: %s->new", ROAR_DBG_INFO_VERBOSE, id, fh, roar_streamstate2str(ss->state));
-  _streams_change_state(ss, ROAR_STREAMSTATE_NEW, "streams_set_fh");
-
-  ROAR_DBG("streams_set_fh(id=%i, fh=%i) = 0", id, fh);
-  return 0;
- }
-}
-
-int streams_get_fh     (int id) {
- int ret;
-
- ROAR_DBG("streams_get_fh(id=%i) = ?", id);
-
- _CHECK_SID(id);
-
- ROAR_DBG("streams_get_fh(id=%i) = ?", id);
-
- ret = ROAR_STREAM(g_streams[id])->fh;
-
- ROAR_DBG("streams_get_fh(id=%i) = %i", id, ret);
-
- return ret;
-}
-
-int streams_set_null_io(int id) {
- struct roar_stream_server * ss;
- struct roar_stream        * s;
-
- _CHECK_SID(id);
-
- if ( (s = ROAR_STREAM(ss = g_streams[id])) == NULL )
-  return -1;
-
- s->fh = -1;
-
- return 0;
-}
+  return roar_socket_nonblock(fh, ROAR_SOCKET_NONBLOCK);
+ }
+}
+
 
 int streams_get    (int id, struct roar_stream_server ** stream) {
- _CHECK_SID(id);
+ if ( g_streams[id] == NULL )
+  return -1;
 
  *stream = g_streams[id];
@@ -940,863 +120,8 @@
 }
 
-int streams_get_clientobj (int id, struct roar_stream        ** stream) {
- _CHECK_SID(id);
-
- *stream = ROAR_STREAM(g_streams[id]);
-
- return 0;
-}
-
-int streams_set_socktype (int id, int socktype) {
- _CHECK_SID(id);
-
- g_streams[id]->socktype = socktype;
-
- return 0;
-}
-
-int streams_get_socktype (int id) {
- _CHECK_SID(id);
-
- return g_streams[id]->socktype;
-}
-
-int streams_is_ready     (int id) {
- _CHECK_SID(id);
-
- return g_streams[id]->ready;
-}
-
-int streams_is_new       (int id) {
- _CHECK_SID(id);
-
- return g_streams[id]->ready;
-}
-
-int streams_set_primary (int id, int prim) {
- _CHECK_SID(id);
-
- g_streams[id]->primary = prim;
-
- return 0;
-}
-
-int streams_mark_primary (int id) {
- return streams_set_primary(id, 1);
-}
-
-int streams_set_sync     (int id, int sync) {
- int fh = streams_get_fh(id);
-
- ROAR_DBG("streams_set_sync(id=%i, sync=%i) = ?", id, sync);
-
- _CHECK_SID(id);
-
- if ( fh > -1 ) {
-  if ( roar_socket_nonblock(fh, sync ? ROAR_SOCKET_BLOCK : ROAR_SOCKET_NONBLOCK) == -1 )
-   return -1;
-
-#ifdef ROAR_FDATASYNC
-  ROAR_FDATASYNC(fh);
-#endif
-
-  return 0;
- } else {
-  return roar_vio_nonblock(&(g_streams[id]->vio), sync);
- }
-}
-
-int streams_set_mmap (int id, int reset) {
- int use = !reset;
-
- _CHECK_SID(id);
-
- return roar_vio_ctl(&(g_streams[id]->vio), ROAR_VIO_CTL_SET_UMMAP, &use);
-}
-
-int streams_set_single_sink(int id, int reset) {
- struct roar_stream_server * self_ss, * ss;
- struct roar_stream                   *  s;
- int mixer;
- size_t count = 0;
- int i;
- int ssdir;
-
- /* FIXME: This code only uses one refc for the mixer shared with the inputs.
-  *        If the flag is unset on the mixer but got set by the sources the counter
-  *        may/will become corrupted.
-  */
-
- _CHECK_SID(id);
-
- self_ss = g_streams[id];
-
- mixer = self_ss->mixer_stream;
-
- ROAR_DBG("streams_set_single_sink(id=%i, reset=%i): mixer=%i", id, reset, mixer);
-
- if ( !reset && id != mixer )
-  if ( self_ss->flags & ROAR_FLAG_SINGLESINK )
-   return 0;
-
- if ( id == mixer ) {
-  if ( reset ) {
-   if ( self_ss->single_sink_self_c ) {
-    ROAR_DBG("streams_set_single_sink(id=%i, reset=%i): mixer=%i", id, reset, mixer);
-    self_ss->single_sink_self_c--;
-    self_ss->single_sink_c--;
-    if ( self_ss->single_sink_c == 0 ) {
-     ROAR_DBG("streams_set_single_sink(id=%i, reset=%i): mixer=%i", id, reset, mixer);
-     self_ss->flags |= ROAR_FLAG_SINGLESINK;
-     self_ss->flags -= ROAR_FLAG_SINGLESINK;
-    }
-    return 0;
-   } else {
-    return -1;
-   }
-  } else {
-   if ( self_ss->single_sink_c ) {
-    self_ss->single_sink_self_c++;
-    self_ss->single_sink_c++;
-    return 0;
-   }
-  }
- } else if ( reset ) {
-  ROAR_DBG("streams_set_single_sink(id=%i, reset=%i): mixer=%i", id, reset, mixer);
-
-  if ( (ss = g_streams[mixer]) == NULL )
-   return -1;
-
-  if ( ss->single_sink_c == 0 )
-   return -1;
-  ss->single_sink_c--;
-
-  if ( ss->single_sink_c == 0 ) {
-    self_ss->flags |= ROAR_FLAG_SINGLESINK;
-    self_ss->flags -= ROAR_FLAG_SINGLESINK;
-         ss->flags |= ROAR_FLAG_SINGLESINK;
-         ss->flags -= ROAR_FLAG_SINGLESINK;
-  }
-
-  return 0;
- }
-
-
-
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( (s = ROAR_STREAM((ss = g_streams[i]))) != NULL ) {
-   if ( s->dir == ROAR_DIR_THRU )
-    if ( s->pos_rel_id == id || s->pos_rel_id == mixer || g_streams[s->pos_rel_id]->mixer_stream == mixer )
-     return -1;
-
-   if ( ss->mixer_stream != mixer )
-    continue;
-
-   ssdir = streams_get_ssdir(i);
-
-   if ( ssdir & STREAM_DIR_OUT )
-    count++;
-  }
- }
-
- if ( count > 1 )
-  return -1;
-
- ss = g_streams[mixer];
-
- if ( id == mixer )
-  ss->single_sink_self_c++;
-
- ss->single_sink_c++;
-
- self_ss->flags |= ROAR_FLAG_SINGLESINK;
-      ss->flags |= ROAR_FLAG_SINGLESINK;
-
- return 0;
-}
-
-int streams_set_flag     (int id, uint32_t flag) {
- int parent;
- int tmp;
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- _CHECK_SID(id);
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_IMMUTABLE )
-  flag |= ROAR_FLAG_PRIMARY;
-
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- // check if flags we are going to change are protected:
- if ( g_streams[id]->flags_protection & flag )
-  return -1;
-
- flag |= g_streams[id]->flags;
- flag -= g_streams[id]->flags;
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_MMAP ) {
-  if ( streams_set_mmap(id, 0) == -1 ) {
-   flag -= ROAR_FLAG_MMAP;
-   return -1;
-  }
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_PRIMARY ) {
-  streams_set_primary(id, 1);
-  flag -= ROAR_FLAG_PRIMARY;
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_SINGLESINK ) {
-  if ( streams_set_single_sink(id, 0) == -1 ) {
-   return -1;
-  }
-  flag -= ROAR_FLAG_SINGLESINK;
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_VIRTUAL ) {
-  if ( (parent = ROAR_STREAM(g_streams[id])->pos_rel_id) == -1 )
-   return -1;
-
-  if ( streams_ctl(parent, ROAR_CODECFILTER_CTL_VIRTUAL_NEW|ROAR_STREAM_CTL_TYPE_INT, &id) == -1 ) {
-//   flag -= ROAR_FLAG_VIRTUAL;
-   return -1;
-  }
-
-  if ( client_stream_move(streams_get_client(parent), id) == -1 ) {
-   return -1;
-  }
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_SYNC ) {
-  ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-  switch (ROAR_STREAM(g_streams[id])->dir) {
-   // for this stream types the flag is used in the subsystem:
-   case ROAR_DIR_BRIDGE:
-   case ROAR_DIR_MIDI_OUT:
-    break;
-
-   // normal behavor (vio blocking):
-   default:
-     ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-     // the fh is updated as soon as the fh get ready in case the default ask to set sync
-     if ( g_streams[id]->ready || (!g_streams[id]->ready && !(g_config->streams[ROAR_STREAM(g_streams[id])->dir].flags & ROAR_FLAG_SYNC)) ) {
-      ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-      if ( streams_set_sync(id, 1) == -1 ) {
-       ROAR_WARN("streams_set_flag(id=%i, flag=0x%.8X): Can not set SYNC flag.", id, flag);
-       flag -= ROAR_FLAG_SYNC;
-      }
-     }
-    break;
-  }
-  ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
-  if ( flag & ROAR_FLAG_SYNC ) {
-   g_streams[id]->flags |= ROAR_FLAG_SYNC;
-   streams_change_sync_num(id, +1);
-  }
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_HWMIXER ) { // currently not supported -> ignored
-  g_streams[id]->flags |= flag;
-  if ( streams_set_mixer(id) == -1 ) {
-   g_streams[id]->flags -= flag;
-   return -1;
-  }
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( flag & ROAR_FLAG_RECSOURCE ) {
-  if ( streams_recsource_id != -1 ) {
-   if ( streams_reset_flag(streams_recsource_id, ROAR_FLAG_RECSOURCE) == -1 )
-    return -1;
-  }
-
-  if ( g_streams[id]->ready ) {
-   tmp = 1;
-   if ( stream_vio_ctl(id, ROAR_VIO_CTL_SET_RECORD, &tmp) == -1 )
-    return -1;
-  }
-
-  streams_recsource_id = id;
- }
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- g_streams[id]->flags |= flag;
-
-#ifdef ROAR_SUPPORT_META
- if ( flag & ROAR_FLAG_META )
-  stream_meta_finalize(id);
-#endif
-
- ROAR_DBG("streams_set_flag(id=%i, flag=0x%.8X) = 0", id, flag);
-
- return 0;
-}
-
-int streams_set_rawflag  (int id, uint32_t flag) {
- _CHECK_SID(id);
-
- g_streams[id]->flags |= flag;
-
- if ( flag & ROAR_FLAG_SYNC )
-  streams_change_sync_num(id, +1);
-
- return 0;
-}
-
-int streams_reset_flag   (int id, uint32_t flag) {
- int tmp;
-
- ROAR_DBG("streams_reset_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- _CHECK_SID(id);
-
- // check if flags we are going to change are protected:
- if ( g_streams[id]->flags_protection & flag )
-  return -1;
-
- if ( g_streams[id]->flags & ROAR_FLAG_IMMUTABLE ) {
-  flag |= ROAR_FLAG_PRIMARY;
-  flag -= ROAR_FLAG_PRIMARY;
- }
-
- flag &= g_streams[id]->flags;
-
- ROAR_DBG("streams_reset_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
- if ( (flag & ROAR_FLAG_RECSOURCE) && streams_recsource_id == id ) {
-  if ( g_streams[id]->ready ) {
-   tmp = 0;
-   if ( stream_vio_ctl(id, ROAR_VIO_CTL_SET_RECORD, &tmp) == -1 ) {
-    if ( alive ) { // do not warn if we are shutting down anyway.
-     ROAR_WARN("streams_reset_flag(id=%i, flag=0x%.8X): Driver refused to reset record flag.", id, flag);
-    }
-    ROAR_DBG("streams_reset_flag(id=%i, flag=0x%.8X) = -1", id, flag);
-    return -1;
-   }
-  }
-
-  streams_recsource_id = -1;
- }
-
- ROAR_DBG("streams_reset_flag(id=%i, flag=0x%.8X) = ?", id, flag);
-
-
- if ( flag & ROAR_FLAG_MMAP ) {
-  if ( streams_set_mmap(id, 1) == -1 ) {
-   flag -= ROAR_FLAG_MMAP;
-   return -1;
-  }
- }
-
- if ( flag & ROAR_FLAG_PRIMARY ) {
-  streams_set_primary(id, 0);
-  flag -= ROAR_FLAG_PRIMARY;
- }
-
- if ( flag & ROAR_FLAG_SINGLESINK ) {
-  if ( streams_set_single_sink(id, 1) == -1 ) {
-   return -1;
-  }
-  flag -= ROAR_FLAG_SINGLESINK;
- }
-
- if ( flag & ROAR_FLAG_SYNC ) {
-  // we refuse to reset the flag on FILTER streams
-  if ( streams_get_dir(id) == ROAR_DIR_FILTER ) {
-//   flags -= ROAR_FLAG_SYNC;
-   return -1;
-  } else {
-   if ( streams_set_sync(id, 0) == -1 )
-    return -1;
-
-   g_streams[id]->flags |= ROAR_FLAG_SYNC;
-   g_streams[id]->flags -= ROAR_FLAG_SYNC;
-   flag -= ROAR_FLAG_SYNC;
-   streams_change_sync_num(id, -1);
-  }
- }
-
- g_streams[id]->flags |= flag;
- g_streams[id]->flags -= flag;
-
- ROAR_DBG("streams_reset_flag(id=%i, flag=0x%.8X) = 0", id, flag);
-
- return 0;
-}
-
-int streams_get_flag     (int id, uint32_t flag) {
- _CHECK_SID(id);
-
- return g_streams[id]->flags & flag ? 1 : 0;
-}
-
-int streams_protect_flag (int id, uint32_t flag) {
- _CHECK_SID(id);
-
- g_streams[id]->flags_protection |= flag;
-
- return 0;
-}
-
-int streams_set_name     (int id, char * name) {
- char * str;
-
- _CHECK_SID(id);
-
- if ( (str = roar_mm_strdup(name)) == NULL )
-  return -1;
-
- if ( g_streams[id]->name != NULL )
-  roar_mm_free(g_streams[id]->name);
-
- g_streams[id]->name = str;
-
- return 0;
-}
-
-char * streams_get_name  (int id) {
- _CHECK_SID_RET(id, NULL);
-
- return g_streams[id]->name;
-}
-
-
-int streams_calc_delay    (int id) {
- struct roar_stream_server * ss;
- struct roar_stream        * s;
- register uint_least32_t d = 0;
- uint_least32_t t[1];
- uint64_t       tmp;
-
- _CHECK_SID(id);
-
- if ( (s = ROAR_STREAM(ss = g_streams[id])) == NULL )
-  return -1;
-
- // mixer store there value in ss->delay directly
- if ( s->dir == ROAR_DIR_MIXING )
-  return 0;
-
-#if 0
- // this only confuses the user...
- if ( ss->mixer_stream != id ) {
-  if ( streams_calc_delay(ss->mixer_stream) != -1 ) {
-   d += g_streams[ss->mixer_stream]->delay; // in case we can calc the delay
-                                            // the stream must exist, so no check here
-  }
- }
-#endif
-
- if ( ss->codecfilter != -1 ) {
-  if ( codecfilter_delay(ss->codecfilter_inst, ss->codecfilter, t) != -1 )
-   d += *t;
- }
-
- if ( ss->vio.ctl != NULL ) {
-  if ( roar_vio_ctl(&(ss->vio), ROAR_VIO_CTL_GET_DELAY, t) != -1 ) { // *t is in byte
-   ROAR_DBG("streams_calc_delay(id=%i): VIO delay in byte: %i", id, *t);
-   tmp = *t;
-   tmp *= 1000000; // musec per sec
-   tmp /= s->info.rate * s->info.channels * (s->info.bits/8);
-   ROAR_DBG("streams_calc_delay(id=%i): VIO delay in musec: %llu", id, tmp);
-
-   d += tmp;
-  }
- }
-
- ROAR_DBG("streams_calc_delay(id=%i): delay in musec: %i", id, d);
-
- ss->delay = d;
-
- return 0;
-}
-
-int streams_set_mixer    (int id) {
- struct roar_stream_server * ss;
- struct roar_stream_server * pmss;
- int i;
- int subsys;
- int tsubsys;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( streams_get_flag(id, ROAR_FLAG_PASSMIXER) == 1 ) {
-  if ( (subsys = streams_get_subsys(id)) == -1 )
-   return -1;
-
-  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-   if ( (pmss = g_streams[i]) != NULL ) {
-    if ( streams_get_flag(i, ROAR_FLAG_PASSMIXER) == 1 ) {
-     tsubsys = streams_get_subsys(i);
-     if ( tsubsys == subsys || tsubsys == ROAR_SUBSYS_NONE ) {
-      if ( &(pmss->mixer) != &(ss->mixer) ) {
-       if ( roar_conv_volume(&(pmss->mixer), &(ss->mixer),
-                             ROAR_STREAM(pmss)->info.channels, ROAR_STREAM(ss)->info.channels) == -1 ) {
-        ROAR_WARN("streams_set_mixer(id=%i): Can not convert mixer settings for stream %i", id, i);
-       }
-      }
-
-      // update hwmixers and the like but do not set mixer value recrusivly.
-      streams_reset_flag(i, ROAR_FLAG_PASSMIXER);
-      streams_set_mixer(i);
-      streams_set_flag(i, ROAR_FLAG_PASSMIXER);
-     }
-    }
-   }
-  }
- }
-
- roar_notify_core_emit_snoargs(ROAR_OE_STREAM_CHANGE_VOLUME, -1, id, ROAR_OT_STREAM);
-
- if ( !streams_get_flag(id, ROAR_FLAG_HWMIXER) )
-  return 0;
-
- if ( ss->driver_id != -1 ) {
-  return driver_set_volume(id, &(ss->mixer));
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
- } else if ( ss->mixerstream != NULL ) {
-  return hwmixer_set_volume(id, ss, ss->mixerstream, &(ss->mixer));
-#endif
- } else {
-  return 0;
- }
-}
-
-int streams_set_map      (int id, char * map, size_t len) {
- struct roar_stream_server * ss;
- int ssdir;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( map != NULL ) {
-  if ( ROAR_STREAM(ss)->info.channels != len )
-   return -1;
- }
-
- ssdir = streams_get_ssdir(id);
-
- switch (ssdir) {
-  case STREAM_DIR_IN:
-  case STREAM_DIR_NONE:
-    memset(ss->chanmap.in, 0, sizeof(ss->chanmap.in));
-
-    if ( map != NULL )
-     memcpy(ss->chanmap.in, map, len);
-
-    roardsp_chanmap_calc(&(ss->chanmap), ROARDSP_CHANMAP_MAP, 0);
-   break;
-  case STREAM_DIR_OUT:
-    memset(ss->chanmap.out, 0, sizeof(ss->chanmap.out));
-
-    if ( map != NULL )
-     memcpy(ss->chanmap.out, map, len);
-
-    roardsp_chanmap_calc(&(ss->chanmap), ROARDSP_CHANMAP_MAP, 0);
-   break;
-  default:
-    return -1;
- }
-
- return 0;
-}
-
-int streams_get_rpg      (int id, struct roar_stream_rpg * rpg) {
- _CHECK_SID(id);
-
- if ( rpg == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- rpg->mode = g_streams[id]->rpgmode;
- rpg->mul  = g_streams[id]->mixer.rpg_mul;
- rpg->div  = g_streams[id]->mixer.rpg_div;
-
- if ( rpg->mode == ROAR_RPGMODE_DEFAULT )
-  rpg->mode = g_config->streams[ROAR_STREAM(g_streams[id])->dir].rpgmode;
-
- return 0;
-}
-
-int streams_set_rpg      (int id, const struct roar_stream_rpg * rpg) {
- int mode;
-
- _CHECK_SID(id);
-
- if ( rpg == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- // test if we have a valid value at all.
- if ( rpg->mode > ROAR_RPGMODE_TRACKALBUM || rpg->mode < ROAR_RPGMODE_DEFAULT ) {
-  roar_err_set(ROAR_ERROR_RANGE);
-  return -1;
- }
-
- mode = g_streams[id]->rpgmode = rpg->mode;
-
- if ( mode == ROAR_RPGMODE_DEFAULT )
-  mode = g_config->streams[ROAR_STREAM(g_streams[id])->dir].rpgmode;
-
- switch (mode) {
-  case ROAR_RPGMODE_NONE:
-    g_streams[id]->mixer.rpg_mul = 1;
-    g_streams[id]->mixer.rpg_div = 1;
-   break;
-  case ROAR_RPGMODE_USER:
-    g_streams[id]->mixer.rpg_mul = rpg->mul;
-    g_streams[id]->mixer.rpg_div = rpg->div;
-   break;
- }
-
- return 0;
-}
-
-
-int streams_ltm_ctl      (int id, int mt, int window, int cmd) {
- struct roar_stream_server * ss;
- struct roar_stream_ltm *    ltm;
- int i;
-
- _CHECK_SID(id);
-
- // currently we only support the WORKBLOCK window
- if ( window != ROAR_LTM_WIN_WORKBLOCK )
-  return -1;
-
- // currently we only support ROAR_LTM_MT_RMS
- if ( (mt | ROAR_LTM_MT_RMS) - ROAR_LTM_MT_RMS )
-  return -1;
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- switch (cmd) {
-  case ROAR_LTM_SST_NOOP:
-    return 0;
-   break;
-  case ROAR_LTM_SST_REGISTER:
-    // test if the window is already registered:
-    for (i = 0; i < MAX_LTM_WINDOWS_PER_STREAM; i++) {
-     ltm = &(ss->ltm[i]);
-     if ( ltm->refc && ltm->window == window ) {
-      ltm->refc++;
-      ltm->mt |= mt;
-      return 0;
-     }
-    }
-
-    // register
-    for (i = 0; i < MAX_LTM_WINDOWS_PER_STREAM; i++) {
-     ltm = &(ss->ltm[i]);
-     if ( ltm->refc == 0 ) {
-      memset(ltm, 0, sizeof(struct roar_stream_ltm));
-      ltm->refc = 1;
-      ltm->window = window;
-      ltm->parent_window = -1;
-      ltm->mt = mt;
-      ltm->channels = ROAR_STREAM(ss)->info.channels;
-      if ( (ltm->cur = roar_mm_malloc(ltm->channels*sizeof(struct roar_ltm_vals))) == NULL ) {
-       ltm->refc = 0; // reset
-       return -1;
-      }
-      memset(ltm->cur, 0, ltm->channels*sizeof(struct roar_ltm_vals));
-      return 0;
-     }
-    }
-    return -1;
-   break;
-  case ROAR_LTM_SST_UNREGISTER:
-    for (i = 0; i < MAX_LTM_WINDOWS_PER_STREAM; i++) {
-     ltm = &(ss->ltm[i]);
-     if ( ltm->refc && ltm->window == window ) {
-      ltm->refc--;
-      if ( ! ltm->refc ) {
-       roar_mm_free(ltm->cur);
-       return 0;
-      }
-     }
-    }
-    return -1;
-   break;
-  default:
-    return -1;
-   break;
- }
-}
-
-int streams_ltm_calc     (int id, struct roar_audio_info * info, void * data, size_t len) {
- struct roar_stream_server * ss;
- struct roar_stream_ltm *    ltm = NULL;
- int64_t rmsbuf_real[8];
- int64_t * rmsbuf = rmsbuf_real;
- size_t samples = 0;
- int i;
-
- _CHECK_SID(id);
-
- if ( data == NULL || info == NULL )
-  return -1;
-
- if ( info->codec != ROAR_CODEC_DEFAULT )
-  return -1;
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- for (i = 0; i < MAX_LTM_WINDOWS_PER_STREAM; i++) {
-  if ( ss->ltm[i].refc && ss->ltm[i].window == ROAR_LTM_WIN_WORKBLOCK ) {
-   ltm = &(ss->ltm[i]);
-   break;
-  }
- }
-
- if ( ltm == NULL )
-  return -1;
-
- // TODO: support change of number of channels
- if ( ltm->channels != info->channels )
-  return -1;
-
- if ( len == 0 ) {
-  memset(ltm->cur, 0, ltm->channels * sizeof(struct roar_ltm_vals));
-  return 0;
- }
-
- // TODO: support more channels then rmsbuf_real has space for
- if ( ltm->channels > (sizeof(rmsbuf_real)/sizeof(*rmsbuf_real)) ) {
-  return -1;
- }
-
- samples = len / info->bits;
-
- if ( ltm->mt & ROAR_LTM_MT_RMS ) {
-  if ( roar_rms2_1_b_n(data, samples, rmsbuf, ltm->channels, info->bits) == -1 )
-   return -1;
-
-  for (i = 0; i < ltm->channels; i++) {
-   ltm->cur[i].rms = rmsbuf[i] << (64 - info->bits*2);
-  }
-
-  ROAR_DBG("streams_ltm_calc(id=%i,...): rmsbuf[0]=%lli", id, (long long int)rmsbuf[0]);
- }
-
- return 0;
-}
-
-struct roar_stream_ltm * streams_ltm_get(int id, int mt, int window) {
- struct roar_stream_server * ss;
- struct roar_stream_ltm *    ltm = NULL;
- int i;
-
- _CHECK_SID_RET(id, NULL);
-
- if ( (ss = g_streams[id]) == NULL )
-  return NULL;
-
- for (i = 0; i < MAX_LTM_WINDOWS_PER_STREAM; i++) {
-  if ( ss->ltm[i].refc && ss->ltm[i].window == window ) {
-   ltm = &(ss->ltm[i]);
-   break;
-  }
- }
-
- if ( ltm == NULL )
-  return NULL;
-
- if ( (ltm->mt & mt) != mt )
-  return NULL;
-
- return ltm;
-}
-
-#ifndef ROAR_WITHOUT_DCOMP_MIXER
-struct hwmixer_stream * streams_get_mixerstream(int id) {
- _CHECK_SID_RET(id, NULL);
-
- return g_streams[id]->mixerstream;
-}
-
-int streams_set_mixerstream(int id, struct hwmixer_stream * mstream) {
- _CHECK_SID(id);
-
- g_streams[id]->mixerstream = mstream;
-
- return 0;
-}
-
-int streams_read_mixervalues(int id) {
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( ss->mixerstream == NULL )
-  return -1;
-
- return hwmixer_get_volume(id, ss, ss->mixerstream, &(ss->mixer));
-}
-#endif
-
-int streams_ctl          (int id, int_least32_t cmd, void * data) {
- struct roar_stream_server * ss;
- int_least32_t comp;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- comp = cmd & ROAR_STREAM_CTL_COMPMASK;
-
- cmd &= ~comp;
-
- ROAR_DBG("streams_ctl(id=%i, cmd=?, data=%p): comp=0x%.8x, cmd=0x%.4x", id, data, comp, cmd);
-
- switch (comp) {
-  case ROAR_STREAM_CTL_COMP_BASE:
-   break;
-  case ROAR_STREAM_CTL_COMP_CF:
-    return codecfilter_ctl(ss->codecfilter_inst, ss->codecfilter, cmd, data);
-   break;
-  case ROAR_STREAM_CTL_COMP_DRV:
-   break;
-  default:
-   return -1;
- }
-
- return -1;
-}
 
 int streams_get_outputbuffer  (int id, void ** buffer, size_t size) {
- _CHECK_SID(id);
+ if ( g_streams[id] == NULL )
+  return -1;
 
  // output buffer size does never change.
@@ -1806,5 +131,5 @@
  }
 
- if ( (g_streams[id]->output = roar_mm_malloc(size)) == NULL ) {
+ if ( (g_streams[id]->output = malloc(size)) == NULL ) {
   ROAR_ERR("streams_get_outputbuffer(*): Can not alloc: %s", strerror(errno));
   return -1;
@@ -1816,152 +141,198 @@
 }
 
-int streams_fill_mixbuffer2 (int id, struct roar_audio_info * info) {
- size_t   outlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(info);
- void   * outdata;
- size_t   inlen;
- size_t   inlen_got;
- void   * indata = NULL;
- size_t   buflen;
- void   * bufdata = NULL;
- struct roar_buffer * bufbuf = NULL;
- int      is_the_same = 0;
- struct roar_audio_info    * stream_info;
- struct roar_stream        * s;
- struct roar_stream_server * ss;
-
- _CHECK_SID(id);
-
- if ( (s = ROAR_STREAM(ss = g_streams[id])) == NULL )
-  return -1;
+int streams_fill_mixbuffer (int id, struct roar_audio_info * info) {
+ // TODO: decide: is this the most complex, hacked, un-understadable,
+ //               un-writeable and even worse: un-readable
+ //               function in the whole project?
+ size_t todo = ROAR_OUTPUT_CALC_OUTBUFSIZE(info);
+ size_t todo_in;
+ size_t len, outlen;
+ size_t mul = 1, div = 1;
+ void * rest = NULL;
+ void * in   = NULL;
+ struct roar_buffer     * buf;
+ struct roar_audio_info * stream_info;
+ int is_the_same = 0;
+
+ if ( g_streams[id] == NULL )
+  return -1;
+
+ if ( streams_get_outputbuffer(id, &rest, todo) == -1 ) {
+  return -1;
+ }
+
+ if ( rest == NULL ) {
+  return -1;
+ }
 
  // set up stream_info
- stream_info = &(s->info);
+
+ stream_info = &(((struct roar_stream*)g_streams[id])->info);
 
  // calc todo_in
- inlen = ROAR_OUTPUT_CALC_OUTBUFSIZE(stream_info);
-
- buflen = ROAR_OUTPUT_CALC_OUTBUFSIZE_MAX(info, stream_info);
-
- ROAR_DBG("streams_fill_mixbuffer2(id=%i, info=%p{...}): inlen=%lu, buflen=%lu", id, info, (unsigned long)inlen, (unsigned long)buflen);
-
- if ( inlen == 0 ) {
-  ROAR_WARN("streams_fill_mixbuffer2(id=%i, info=%p{...}): inlen == 0, this should not happen!", id, info);
-  return -1;
- }
-
- if ( streams_get_outputbuffer(id, &outdata, outlen) == -1 ) {
-  return -1;
- }
-
- if ( outdata == NULL ) {
-  return -1;
- }
-
- ROAR_DBG("streams_fill_mixbuffer2(*): outdata=%p, len=%i->%i (in->out)", outdata, inlen, outlen);
+ todo_in = ROAR_OUTPUT_CALC_OUTBUFSIZE(stream_info);
+
+ // calc mul and div:
+ mul = todo    / todo_in;
+ div = todo_in / todo;
+
+ if ( mul == 0 ) {
+  mul = 1;
+ } else {
+  div = 1;
+ }
+
+ ROAR_DBG("streams_fill_mixbuffer(*): mul=%i, div=%i", mul, div);
+
+ ROAR_DBG("streams_fill_mixbuffer(*): rest=%p, todo=%i->%i (in->out)", rest, todo_in, todo);
+ // are both (input and output) of same format?
+
+
+ ROAR_DBG("streams_fill_mixbuffer(*): stream_info:");
+ roar_debug_audio_info_print(stream_info);
+ ROAR_DBG("streams_fill_mixbuffer(*): info:");
+ roar_debug_audio_info_print(info);
 
  is_the_same = stream_info->rate     == info->rate     && stream_info->bits  == info->bits &&
                stream_info->channels == info->channels && stream_info->codec == info->codec;
 
- ROAR_DBG("streams_fill_mixbuffer2(*): is_the_same=%i", is_the_same);
-
- if ( !is_the_same && buflen > outlen ) {
+ ROAR_DBG("streams_fill_mixbuffer(*): is_the_same=%i", is_the_same);
+
+/* How it works:
+ *
+ * set a counter to the number of samples we need.
+ * loop until we have all samples done or no samples are
+ * left in our input buffer.
+ * If there a no samples left in the input buffer: fill the rest
+ * of the output buffer with zeros.
+ *
+ * The loop:
+ * get a buffer from the input.
+ * if it's bigger than needed, set an offset.
+ * The rest of the data:
+ * 0) convert endianness (codec) from remote to local...
+ * 1) change bits in of the samples
+ * 2) change sample rate
+ * 3) change the nummber of channels
+ * 4) insert into output buffer
+ */
+
 /*
-  // this is not supported at the moment
-  memset(outdata, 0, outlen);
-  return -1;
+ // get our first buffer:
+
+ if ( stream_shift_buffer(id, &buf) == -1 ) {
+  return -1;
+ }
+
+ // first test for some basic simple cases...
+
+ if ( buf == NULL ) { // we habe nothing in input queue
+                      // we may memset() our output buffer OR
+                      // just return with -1 so we are going to
+                      // be ignored.
+  return -1;
+ }
 */
 
-  if ( roar_buffer_new(&bufbuf, buflen) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_data(bufbuf, &bufdata) == -1 )
-   return -1;
-  indata  = bufdata;
- } else {
-  indata  = outdata;
-  bufdata = outdata;
- }
-
- inlen_got = inlen;
-
- ROAR_DBG("streams_fill_mixbuffer2(id=%i, info=...): inlen_got=%u", id, inlen_got);
-
- if ( stream_shift_out_buffer(id, indata, &inlen_got) == -1 ) {
-  if ( ss->is_new ) {
-   ss->pre_underruns++;
-   roar_notify_core_emit_simple(ROAR_OE_STREAM_XRUN, -1, id, ROAR_OT_STREAM, ROAR_XRUN_UNDER_PRE, ss->pre_underruns, NULL, 0);
+ while (todo) { // main loop
+  ROAR_DBG("streams_fill_mixbuffer(*): looping...");
+  // exit loop if nothing is left, even if we need more data..
+  if ( stream_shift_buffer(id, &buf) == -1 )
+   break;
+  if ( buf == NULL )
+   break;
+
+  // read the data for this loop...
+  roar_buffer_get_data(buf, &in);
+  roar_buffer_get_len(buf, &len);
+
+  ROAR_DBG("streams_fill_mixbuffer(*): len = %i", len);
+
+  if ( len > todo_in ) {
+   roar_buffer_set_offset(buf, todo_in);
+   len = todo_in;
   } else {
-   ROAR_WARN("streams_fill_mixbuffer2(id=%i, info=...): underrun in stream", id);
-   ss->post_underruns++;
-   roar_notify_core_emit_simple(ROAR_OE_STREAM_XRUN, -1, id, ROAR_OT_STREAM, ROAR_XRUN_UNDER_POST, ss->post_underruns, NULL, 0);
+   roar_buffer_set_len(buf, 0); // queue for deletation
   }
-  memset(outdata, 0, outlen);
-  return 0;
- }
-
- ROAR_DBG("streams_fill_mixbuffer2(id=%i, info=...): inlen_got=%u", id, inlen_got);
-
- if ( ss->is_new ) {
-  //ROAR_INFO("streams_fill_mixbuffer2(id=%i, info=...): stream state: new->old", ROAR_DBG_INFO_VERBOSE, id);
-  _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_fill_mixbuffer2");
- }
-
- ss->is_new = 0;
-
- // check channel map:
-#if 0
- if ( roardsp_chanmap_mappcm(indata, indata, inlen, stream_info->channels, &(ss->chanmap), stream_info->bits) == -1 ) {
-  if ( bufbuf != NULL )
-   roar_buffer_free(bufbuf);
-  return -1;
- }
-#endif
-
- // TODO: this only works in case a we have a amp for the given stream parameters.
- if ( !streams_get_flag(id, ROAR_FLAG_HWMIXER) && !streams_get_flag(id, ROAR_FLAG_PASSMIXER) ) {
-  ROAR_DBG("streams_fill_mixbuffer2(*): CALL roar_amp_pcm(*)...");
-  if ( roar_amp_pcm(indata, stream_info->bits, indata, 8*inlen / stream_info->bits, stream_info->channels, &(ss->mixer)) == -1 )
-   return -1;
- }
-
- // check codec, bits, channels, rate...
- if ( is_the_same ) {
-  if ( indata != outdata )
-   memcpy(outdata, indata, inlen);
-
-  if ( inlen < outlen )
-   memset(outdata+inlen, 0, outlen-inlen);
- } else {
-//  if ( roar_conv(outdata, indata, (8*inlen_got*info->rate)/(stream_info->rate * stream_info->bits), stream_info, info) == -1 ) {
-  ROAR_DBG("streams_fill_mixbuffer2(*): CALL roar_conv2(*)...");
-  if ( roar_conv2(bufdata, indata, inlen, stream_info, info, outlen) == -1 ) {
-   if ( bufbuf != NULL )
-    roar_buffer_free(bufbuf);
+
+  // we now have 'len' bytes in 'in'
+
+  // calc how much outlen this has...
+  outlen = (len * mul) / div;
+
+  ROAR_DBG("streams_fill_mixbuffer(*): outlen = %i, buf = %p, len = %i", outlen, in, len);
+
+  if ( is_the_same ) {
+/*
+ * 0) convert endianness (codec) from remote to local...
+ * 1) change bits in of the samples
+ * 2) change sample rate
+ * 3) change the nummber of channels
+   \\==> skiping,...
+ */
+   // * 4) insert into output buffer
+   ROAR_DBG("streams_fill_mixbuffer(*): memcpy: in->rest: %p -> %p", in, rest);
+   if ( memcpy(rest, in, len) != rest ) {
+    ROAR_ERR("streams_fill_mixbuffer(*): memcpy returned invalid pointer.");
+   }
+
+  } else {
+
+/*
+   // * 0) convert endianness (codec) from remote to local...
+   if ( stream_info->codec != info->codec ) {
+    // we neet to convert...
+    return -1;
+   }
+
+   // * 1) change bits in of the samples
+   if ( stream_info->bits != info->bits ) {
+    return -1;
+   }
+
+   // * 2) change sample rate
+   if ( stream_info->rate != info->rate ) {
+    return -1;
+   }
+
+   // * 3) change the nummber of channels
+   if ( stream_info->channels != info->channels ) {
+    return -1;
+   }
+
+   // * 4) insert into output buffer
+*/
+  // hey! we have roar_conv() :)
+
+  if ( roar_conv(rest, in, 8*len / stream_info->bits, stream_info, info) == -1 )
    return -1;
   }
 
-//  memset(outdata, 0, outlen);
- }
-
- if ( bufbuf != NULL ) {
-  memcpy(outdata, bufdata, outlen);
-  roar_buffer_free(bufbuf);
- }
-
- streams_ltm_calc(id, stream_info, outdata, outlen);
-
- if ( streams_get_flag(id, ROAR_FLAG_ANTIECHO) ) {
-  ROAR_DBG("streams_fill_mixbuffer2(*): Calcing antiecho...");
-  // we can ignore errors here:
-  if ( stream_outputbuffer_request(id, &bufbuf, buflen) == 0 ) {
-   if ( roar_buffer_get_data(bufbuf, &bufdata) != -1 )
-    memcpy(bufdata, outdata, outlen);
-  }
- }
-
- ROAR_DBG("streams_fill_mixbuffer2(*): inlen_got=%llu, stream_info={.bits=%i, .rate=%i,...}", (long long unsigned int)inlen_got, stream_info->bits, stream_info->rate);
- s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, (inlen_got*8)/stream_info->bits);
-
- ROAR_DBG("streams_fill_mixbuffer2(*) = 0");
+  // we habe outlen bytes more...
+  todo    -= outlen;
+  rest    += outlen;
+  todo_in -= len;
+
+  roar_buffer_get_len(buf, &len);
+  ROAR_DBG("streams_fill_mixbuffer(*): New length of buffer %p is %i", buf, len);
+  if ( len == 0 )
+   roar_buffer_delete(buf, NULL);
+ }
+
+ //len = 0;
+ //buffer_get_len(buf, &len);
+
+/*
+ if ( len > 0 ) // we still have some data in this buffer, re-inserting it to the input buffers...
+  stream_unshift_buffer(id, buf);
+ else
+  buffer_delete(buf, NULL);
+*/
+
+ if ( todo > 0 ) { // zeroize the rest of teh buffer
+  memset(rest, 0, todo);
+  ROAR_ERR("streams_fill_mixbuffer(*): Underrun in stream: %i bytes missing, filling with zeros", todo);
+ }
+
  return 0;
 }
@@ -1969,27 +340,11 @@
 
 int streams_get_mixbuffers (void *** bufferlist, struct roar_audio_info * info, unsigned int pos) {
- static void * bufs[ROAR_STREAMS_MAX+1];
+ static void * bufs[ROAR_STREAMS_MAX];
  int i;
  int have = 0;
- int dir;
 
  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
   if ( g_streams[i] != NULL ) {
-   dir = streams_get_dir(i);
-
-   switch (dir) {
-    case ROAR_DIR_PLAY:
-    case ROAR_DIR_BIDIR:
-    case ROAR_DIR_RECPLAY:
-     break;
-    case ROAR_DIR_BRIDGE:
-      if ( g_streams[i]->buffer == NULL )
-       continue;
-     break;
-    default:
-      continue;
-   }
-
-   if ( streams_get_flag(i, ROAR_FLAG_PAUSE) )
+   if ( ((struct roar_stream *)g_streams[i])->dir != ROAR_DIR_PLAY )
     continue;
 
@@ -1999,216 +354,72 @@
     continue;
    }
-   if ( streams_fill_mixbuffer2(i, info) == -1 ) {
+   if ( streams_fill_mixbuffer(i, info) == -1 ) {
     ROAR_ERR("streams_get_mixbuffer(*): Can not fill output buffer for stream %i, this should not happen", i);
     continue;
    }
 
-//   printf("D: bufs[have=%i] = %p\n", have, bufs[have]);
-
    ROAR_DBG("streams_get_mixbuffers(*):  bufs[have] = %p", bufs[have]);
    ROAR_DBG("streams_get_mixbuffers(*): *bufs[have] = 0x%08x...", *(uint32_t*)bufs[have]);
 
-   if ( !streams_get_flag(i, ROAR_FLAG_MUTE) )
-    have++; // we have a new stream!
+   have++; // we have a new stream!
   }
  }
 
  bufs[have] = NULL;
- //printf("D: bufs[have=%i] = %p\n", have, bufs[have]);
 
  ROAR_DBG("streams_get_mixbuffers(*): have = %i", have);
 
  *bufferlist = bufs;
- return have;
-}
-
-
-int stream_add_buffer  (int id, struct roar_buffer ** buf) {
+ return 0;
+}
+
+
+int stream_add_buffer  (int id, struct roar_buffer * buf) {
  ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = ?", id, buf);
 
- _CHECK_SID(id);
+ if ( g_streams[id] == NULL )
+  return -1;
 
  if ( g_streams[id]->buffer == NULL ) {
-  g_streams[id]->buffer = *buf;
+  g_streams[id]->buffer = buf;
+  ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = 0", id, buf);
+  return 0;
+ }
+
+ ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = ?", id, buf);
+ return roar_buffer_add(g_streams[id]->buffer, buf);
+}
+
+int stream_shift_buffer   (int id, struct roar_buffer ** buf) {
+ struct roar_buffer * next;
+
+ if ( g_streams[id] == NULL )
+  return -1;
+
+ if ( g_streams[id]->buffer == NULL ) {
   *buf = NULL;
-  ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = 0", id, buf);
-  return 0;
- }
-
- ROAR_DBG("stream_add_buffer(id=%i, buf=%p) = ?", id, buf);
- return roar_buffer_moveinto(g_streams[id]->buffer, buf);
-}
-
-int stream_shift_out_buffer   (int id, void * data, size_t * len) {
- _CHECK_SID(id);
-
- if ( g_streams[id]->buffer == NULL )
-  return -1;
-
- return roar_buffer_shift_out(&(g_streams[id]->buffer), data, len);
-}
-
-int stream_outputbuffer_request(int id, struct roar_buffer ** buf, size_t len) {
- register struct roar_stream_server *  ss;
- size_t buflen;
- void * bufdata;
- int ret;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( buf != NULL ) /* just be be sure */
-  *buf = NULL;
-
- if ( ss->outputbuffer != NULL ) {
-  if ( roar_buffer_get_len(ss->outputbuffer, &buflen) == 0 ) {
-   if ( buflen == len ) {
-    if ( buf != NULL )
-     *buf = ss->outputbuffer;
-    return 0;
-   } else if ( buflen > len ) {
-    if ( roar_buffer_set_len(ss->outputbuffer, len) == 0 ) {
-     if ( buf != NULL )
-      *buf = ss->outputbuffer;
-     return 0;
-    }
-   }
-  }
-
-  // if the buffer is not suitable:
-
-  ret = roar_buffer_free(ss->outputbuffer);
-  ss->outputbuffer = NULL;
-  if ( ret == -1 )
-   return ret;
- }
-
- if ( roar_buffer_new(&(ss->outputbuffer), len) == -1 )
-  return -1;
-
- if ( roar_buffer_get_data(ss->outputbuffer, &bufdata) == -1 ) {
-  roar_buffer_free(ss->outputbuffer);
-  ss->outputbuffer = NULL;
-  return -1;
- }
-
- memset(bufdata, 0, len);
-
- if ( buf != NULL )
-  *buf = ss->outputbuffer;
-
- return 0;
-}
-
-int stream_outputbuffer_destroy(int id) {
- int ret;
- register struct roar_stream_server *  ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( ss->outputbuffer != NULL ) {
-  ret = roar_buffer_free(ss->outputbuffer);
-  ss->outputbuffer = NULL;
-  return ret;
- }
-
- return 0;
-}
-
-int stream_prethru_add(int id, struct roar_buffer ** buf) {
- register struct roar_stream_server *  ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( ss->prethru == NULL ) {
-  ss->prethru = *buf;
-  *buf = NULL;
-  return 0;
- }
-
- if ( roar_buffer_moveinto(ss->prethru, buf) == -1 ) {
-  return -1;
- }
-
- return 0;
-}
-
-int stream_prethru_add_data(int id, void ** buf, size_t len) {
- struct roar_buffer * buffer;
-
- _CHECK_SID(id);
-
- if ( roar_buffer_new_data(&buffer, len, buf) == -1 )
-  return -1;
-
- if ( stream_prethru_add(id, &buffer) == -1 ) {
-  roar_buffer_free(buffer);
-  return -1;
- }
-
- return 0;
-}
-
-int stream_prethru_destroy(int id) {
- int ret;
- register struct roar_stream_server *  ss;
-
- _CHECK_SID(id);
-
- if ( (ss = g_streams[id]) == NULL )
-  return -1;
-
- if ( ss->prethru != NULL ) {
-  ret = roar_buffer_free(ss->prethru);
-  ss->prethru = NULL;
-  return ret;
- }
-
- return 0;
-}
-
-int stream_prethru_send(int dst, int src) {
- struct roar_stream_server *  dst_ss, * src_ss;
- struct roar_buffer * bufbuf;
- void * bufdata;
- size_t buflen;
-
- ROAR_DBG("stream_prethru_send(dst=%i, src=%i) = ?", dst, src);
-
- _CHECK_SID(dst);
- _CHECK_SID(src);
-
- if ( (dst_ss = g_streams[dst]) == NULL )
-  return -1;
-
- if ( (src_ss = g_streams[src]) == NULL )
-  return -1;
-
- bufbuf = src_ss->prethru;
-
- ROAR_DBG("stream_prethru_send(dst=%i, src=%i): prethru buffer at %p", dst, src, bufbuf);
-
- roar_buffer_foreach(bufbuf) {
-  ROAR_DBG("stream_prethru_send(dst=%i, src=%i): looping with buffer at %p", dst, src, bufbuf);
-
-  if ( roar_buffer_get_data(bufbuf, &bufdata) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_len(bufbuf, &buflen) == -1 )
-   return -1;
-
-  if ( stream_vio_s_write(dst_ss, bufdata, buflen) != buflen )
-   return -1;
- }
-
- ROAR_DBG("stream_prethru_send(dst=%i, src=%i) = 0", dst, src);
+  return 0;
+ }
+
+ roar_buffer_get_next(g_streams[id]->buffer, &next);
+
+ *buf                  = g_streams[id]->buffer;
+ g_streams[id]->buffer = next;
+
+ return 0;
+}
+int stream_unshift_buffer (int id, struct roar_buffer *  buf) {
+ if ( g_streams[id] == NULL )
+  return -1;
+
+ if ( g_streams[id]->buffer == NULL ) {
+  g_streams[id]->buffer = buf;
+  return 0;
+ }
+
+ roar_buffer_add(buf, g_streams[id]->buffer);
+
+ g_streams[id]->buffer = buf;
+
  return 0;
 }
@@ -2216,93 +427,29 @@
 int streams_check  (int id) {
  int fh;
- ssize_t req, realreq, done;
+ size_t req;
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
  struct roar_buffer        *   b;
- void                      * buf;
-// char                        tmp;
-
- _CHECK_SID(id);
+ char                      * buf;
+
+ if ( g_streams[id] == NULL )
+  return -1;
 
  ROAR_DBG("streams_check(id=%i) = ?", id);
 
- s = ROAR_STREAM(ss = g_streams[id]);
+ s = (struct roar_stream *) (ss = g_streams[id]);
 
  if ( (fh = s->fh) == -1 )
   return 0;
 
- if ( streams_get_flag(id, ROAR_FLAG_PAUSE) )
-  return 0;
-
- switch (s->dir) {
-  case ROAR_DIR_LIGHT_IN:
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-    return light_check_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_MIDI_IN:
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-    return midi_check_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_RAW_IN:
-#ifndef ROAR_WITHOUT_DCOMP_RAW
-    return raw_check_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_RDTCS_IN:
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-    return rdtcs_check_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_PLAY:
-  case ROAR_DIR_BIDIR:
-  case ROAR_DIR_RECPLAY:
-   break;
-  case ROAR_DIR_OUTPUT:
-    if ( !streams_get_flag(id, ROAR_FLAG_RECSOURCE) )
-     return 0;
-   break;
-  default:
-/*
-    ROAR_WARN("streams_check(id=%i): Read event on non input stream of type/dir %s", id, roar_dir2str(s->dir));
-    errno = 0;
-    req = stream_vio_s_read(ss, &tmp, 1);
-    ROAR_DBG("streams_check(id=%i): stream_vio_s_read(ss, &tmp, 1) = %li // errno=%s(%i)", id, req, strerror(errno), errno);
-    if ( req == 1 ) {
-     ROAR_ERR("streams_check(id=%i): Client violates protocol, got one byte of data on output stream, kicking stream");
-     streams_delete(id);
-     return -1;
-    }
-*/
-    return 0;
-   break;
- }
+ if ( s->dir != ROAR_DIR_PLAY )
+  return 0;
 
  ROAR_DBG("streams_check(id=%i): fh = %i", id, fh);
 
-/*
- ROAR_DBG("streams_check(id=%i): ROAR_OUTPUT_BUFFER_SAMPLES=%i, s->info.channels=%i, s->info.bits=%i, s->info.rat=%i, g_sa->rate=%i", id, ROAR_OUTPUT_BUFFER_SAMPLES, s->info.channels, s->info.bits, s->info.rate, g_sa->rate);
-*/
-
- req  = ROAR_OUTPUT_CALC_OUTBUFSIZE(&(s->info)); // optimal size
-// req  = ROAR_OUTPUT_BUFFER_SAMPLES * s->info.channels * (s->info.bits / 8) * ((float)s->info.rate/g_sa->rate);
+ req  = ROAR_OUTPUT_BUFFER_SAMPLES * s->info.channels * s->info.bits / 8; // optimal size
  req += ss->need_extra; // bytes left we sould get....
 
- ROAR_DBG("streams_check(id=%i): asking for %i bytes", id, req);
-
- if ( roar_buffer_new_data(&b, req, &buf) == -1 ) {
+ if ( roar_buffer_new(&b, req) == -1 ) {
   ROAR_ERR("streams_check(*): Can not alloc buffer space!");
   ROAR_DBG("streams_check(*) = -1");
@@ -2310,52 +457,23 @@
  }
 
+ roar_buffer_get_data(b, (void **)&buf);
+
  ROAR_DBG("streams_check(id=%i): buffer is up and ready ;)", id);
- ROAR_DBG("streams_check(id=%i): asking for %i bytes", id, req);
-
- if ( ss->codecfilter == -1 ) {
-  realreq = req;
-/*
-  req = read(fh, buf, req);
-  if ( req < realreq ) { // we can do this as the stream is in nonblocking mode!
-   if ( (realreq = read(fh, buf+req, realreq-req)) > 0 )
-    req += realreq;
-  }
-*/
-  done = 0;
-  while (req > 0 && done != realreq) {
-   if ( (req = stream_vio_s_read(ss, buf+done, realreq-done)) > 0 )
-    done += req;
-  }
-  req = done;
-
- } else {
-  req = codecfilter_read(ss->codecfilter_inst, ss->codecfilter, buf, req);
- }
-
- if ( req > 0 ) {
+
+ if ( (req = read(fh, buf, req)) > 0 ) {
   ROAR_DBG("streams_check(id=%i): got %i bytes", id, req);
 
-  if ( roar_buffer_set_len(b, req) != -1 ) {
-   if ( stream_add_buffer(id, &b) != -1 )
-    return 0;
-
-   ROAR_ERR("streams_check(id=%i): something is wrong, could not add buffer to stream!", id);
-  } else {
-   ROAR_ERR("streams_check(id=%i): something is wrong, could not set size of buffer!", id);
-  }
-
+  roar_buffer_set_len(b, req);
+
+  if ( stream_add_buffer(id, b) != -1 )
+   return 0;
+
+  ROAR_ERR("streams_check(id=%i): something is wrong, could not add buffer to stream!", id);
   roar_buffer_free(b);
  } else {
-  ROAR_DBG("streams_check(id=%i): read() = %i // errno: %s", id, req, strerror(errno));
-#ifdef ROAR_HAVE_LIBVORBISFILE
-  if ( errno != EAGAIN && errno != ESPIPE ) { // libvorbis file trys to seek a bit ofen :)
-#else
-  if ( errno != EAGAIN ) {
-#endif
-   ROAR_DBG("streams_check(id=%i): EOF!", id);
-   streams_delete(id);
-   ROAR_DBG("streams_check(id=%i) = 0", id);
-  }
+  ROAR_DBG("streams_check(id=%i): EOF!", id);
   roar_buffer_free(b);
+  streams_delete(id);
+  ROAR_DBG("streams_check(id=%i) = 0", id);
   return 0;
  }
@@ -2367,231 +485,26 @@
 
 
-#define _return(x) return (x)
 int streams_send_mon   (int id) {
-// int fh;
+ int fh;
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
- struct roar_buffer        *  bufbuf = NULL;
- struct roar_remove_state     removalstate;
- void  * ip              = g_output_buffer;
- void  * obuf;
- int     olen;
- int     is_the_same     = 1;
- int     is_vol_eq       = 1;
- int     is_muted;
- int     antiecho        = 0;
- ssize_t ret;
-
- _CHECK_SID(id);
+
+ if ( g_streams[id] == NULL )
+  return -1;
 
  ROAR_DBG("streams_send_mon(id=%i) = ?", id);
 
- s = ROAR_STREAM((ss = g_streams[id]));
-
-/*
+ s = (struct roar_stream *) (ss = g_streams[id]);
+
  if ( (fh = s->fh) == -1 )
   return 0;
-*/
-
- if ( !ss->ready )
-  return 0;
-
- if ( g_config->jumbo_mtu )
-  roar_vio_sync(ss->viop);
-
- if ( streams_get_flag(id, ROAR_FLAG_PAUSE) )
-  return 0;
-
- switch (s->dir) {
-  case ROAR_DIR_LIGHT_OUT:
-#ifndef ROAR_WITHOUT_DCOMP_LIGHT
-    return light_send_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_MIDI_OUT:
-#ifndef ROAR_WITHOUT_DCOMP_MIDI
-    return midi_send_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-  case ROAR_DIR_RDTCS_OUT:
-#ifndef ROAR_WITHOUT_DCOMP_RDTCS
-    return rdtcs_send_stream(id);
-#else
-    streams_delete(id);
-    return -1;
-#endif
-   break;
-
-  case ROAR_DIR_COMPLEX_OUT:
-    // send a tick:
-    if ( ss->codecfilter != -1 ) {
-     if ( codecfilter_write(ss->codecfilter_inst, ss->codecfilter, NULL, 0) == 0 )
-      if ( ss->state != ROAR_STREAMSTATE_OLD ) {
-       //ROAR_INFO("streams_send_mon(id=%i): stream state: %s->old", ROAR_DBG_INFO_VERBOSE, id, roar_streamstate2str(ss->state));
-       _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_send_mon");
-      }
-    }
-    return 0;
-   break;
-
-  case ROAR_DIR_OUTPUT:
-    if ( g_standby )
-     return 0;
-  case ROAR_DIR_MONITOR:
-  case ROAR_DIR_BIDIR:
-   break;
-
-  case ROAR_DIR_RECORD:
-  case ROAR_DIR_RECPLAY:
-    ip = g_input_buffer;
-   break;
-  default:
-    return 0;
-   break;
- }
-
-
- ROAR_DBG("streams_send_mon(id=%i): fh = %i", id, s->fh);
-
- if ( s->info.channels != g_sa->channels || s->info.bits  != g_sa->bits ||
-      s->info.rate     != g_sa->rate     || s->info.codec != g_sa->codec  )
-  is_the_same = 0;
-
- is_muted = streams_get_flag(id, ROAR_FLAG_MUTE);
-
- if ( !is_muted && !streams_get_flag(id, ROAR_FLAG_HWMIXER) ) {
-  is_vol_eq = need_vol_change(g_sa->channels, &(ss->mixer)) ? 0 : 1;
- }
-
- if ( streams_get_flag(id, ROAR_FLAG_ANTIECHO) )
-  antiecho = 1;
-
- if ( !is_the_same || !is_vol_eq || antiecho || is_muted ) {
-  olen = ROAR_OUTPUT_CALC_OUTBUFSIZE(&(s->info)); // we hope g_output_buffer_len
-                                                  // is ROAR_OUTPUT_CALC_OUTBUFSIZE(g_sa) here
-  if ( stream_outputbuffer_request(id, &bufbuf, ROAR_OUTPUT_CALC_OUTBUFSIZE_MAX(&(s->info), g_sa)) == -1 )
-   return -1;
-
-  if ( roar_buffer_get_data(bufbuf, &obuf) == -1 ) {
-   _return(-1);
-  }
-
-  ROAR_DBG("streams_send_mon(id=%i): obuf=%p, olen=%i", id, obuf, olen);
- } else {
-  obuf = ip;
-  olen = g_output_buffer_len;
- }
-
- if ( antiecho ) {
-  ROAR_DBG("streams_send_mon(id=%i): antiecho=%i", id, antiecho);
-  if ( roar_remove_init(&removalstate) == -1 ) {
-   _return(-1);
-  }
-
-  ROAR_DBG("streams_send_mon(id=%i): antiecho=%i", id, antiecho);
-  if ( roar_remove_so(obuf, ip, ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels, g_sa->bits, &removalstate) == -1 ) {
-   ROAR_DBG("streams_send_mon(id=%i): anti echo failed", id);
-   _return(-1);
-  }
-  ROAR_DBG("streams_send_mon(id=%i): antiecho=%i", id, antiecho);
- }
-
- if ( !is_vol_eq ) {
-  if ( roar_amp_pcm(obuf, g_sa->bits, ip, ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels, g_sa->channels, &(ss->mixer)) == -1 ) {
-   _return(-1);
-  }
-
-  ip = obuf;
- }
-
- if ( is_muted ) {
-  memset(obuf, 0, (g_sa->bits*ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels)/8);
-  ip = obuf;
- }
-
- streams_ltm_calc(id, &(s->info), ip, (ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels*g_sa->bits)/8);
-
- if ( !is_the_same ) {
-  if ( roar_conv(obuf, ip, ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels, g_sa, &(s->info)) == -1 ) {
-   _return(-1);
-  }
- }
-
- roar_err_clear_errno();
-
- if ( ss->codecfilter == -1 ) {
-  ROAR_DBG("streams_send_mon(id=%i): not a CF stream", id);
-  if ( s->fh == -1 && ss->vio.inst == NULL ) {
-   ROAR_DBG("streams_send_mon(id=%i) = 0", id);
-   _return(0);
-  }
-
-  ROAR_DBG("streams_send_mon(id=%i) = ?", id);
-
-  if ( (ret = stream_vio_s_write(ss, obuf, olen)) == olen ) {
-   s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, ROAR_OUTPUT_CALC_OUTBUFSAMP(&(s->info), olen)*s->info.channels);
-   if ( ss->state != ROAR_STREAMSTATE_OLD ) {
-    //ROAR_INFO("streams_send_mon(id=%i): stream state: %s->old", ROAR_DBG_INFO_VERBOSE, id, roar_streamstate2str(ss->state));
-    _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_send_mon");
-   }
-   ROAR_DBG("streams_send_mon(id=%i) = 0", id);
-   _return(0);
-  }
-
-  ROAR_DBG("streams_send_mon(id=%i) = ?", id);
-
-  if ( ret > 0 && roar_err_is_errno_clear() ) {
-   ROAR_WARN("streams_send_mon(id=%i): Overrun in stream: wrote %i of %i bytes, %i bytes missing", id, (int)ret, olen, olen-(int)ret);
-   roar_notify_core_emit_simple(ROAR_OE_STREAM_XRUN, -1, id, ROAR_OT_STREAM, ROAR_XRUN_OVER_POST, -1, NULL, 0);
-   s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, ROAR_OUTPUT_CALC_OUTBUFSAMP(&(s->info), ret)*s->info.channels);
-   if ( ss->state != ROAR_STREAMSTATE_OLD ) {
-    //ROAR_INFO("streams_send_mon(id=%i): stream state: %s->old", ROAR_DBG_INFO_VERBOSE, id, roar_streamstate2str(ss->state));
-    _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_send_mon");
-   }
-   _return(0);
-  }
- } else {
-  if ( codecfilter_write(ss->codecfilter_inst, ss->codecfilter, obuf, olen)
-            == olen ) {
-   s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, ROAR_OUTPUT_CALC_OUTBUFSAMP(&(s->info), olen)*s->info.channels);
-   if ( ss->state != ROAR_STREAMSTATE_OLD ) {
-    //ROAR_INFO("streams_send_mon(id=%i): stream state: %s->old", ROAR_DBG_INFO_VERBOSE, id, roar_streamstate2str(ss->state));
-    _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_send_mon");
-   }
-   _return(0);
-  } else { // we cann't retry on codec filetered streams
-   if ( errno != EAGAIN ) {
-    streams_delete(id);
-    _return(-1);
-   }
-  }
- }
-
- if ( errno == EAGAIN ) {
-  // ok, the client blocks for a moment, we try to sleep a bit an retry in the hope not to
-  // make any gapes in any output because of this
-
-#ifdef ROAR_HAVE_USLEEP
-  roar_usleep(100); // 0.1ms
-#endif
-
-  if ( stream_vio_s_write(ss, obuf, olen) == olen ) {
-   s->pos = ROAR_MATH_OVERFLOW_ADD(s->pos, ROAR_OUTPUT_CALC_OUTBUFSAMP(&(s->info), olen)*s->info.channels);
-   if ( ss->state != ROAR_STREAMSTATE_OLD ) {
-    //ROAR_INFO("streams_send_mon(id=%i): stream state: %s->old", ROAR_DBG_INFO_VERBOSE, id, roar_streamstate2str(ss->state));
-    _streams_change_state(ss, ROAR_STREAMSTATE_OLD, "streams_send_mon");
-   }
-   _return(0);
-  } else if ( errno == EAGAIN ) {
-   ROAR_WARN("streams_send_mon(id=%i): Can not send data to client: %s", id, strerror(errno));
-   _return(0);
-  }
- }
+
+ if ( s->dir != ROAR_DIR_MONITOR )
+  return 0;
+
+ ROAR_DBG("streams_send_mon(id=%i): fh = %i", id, fh);
+
+ if ( write(fh, g_output_buffer, g_output_buffer_len) == g_output_buffer_len )
+  return 0;
 
  // ug... error... delete stream!
@@ -2599,43 +512,18 @@
  streams_delete(id);
 
- _return(-1);
-}
-#undef _return
-
-int streams_send_filter_all(void) {
- struct roar_stream_server *  ss;
- int i;
-
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( (ss = g_streams[i]) == NULL )
-   continue;
-
-  if ( ROAR_STREAM(ss)->dir != ROAR_DIR_FILTER )
-   continue;
-
-  if ( !ss->ready )
-   continue;
-
-  if ( ss->state == ROAR_STREAMSTATE_CLOSING )
-   continue;
-
-  streams_send_filter(i);
- }
-
- return 0;
+ return -1;
 }
 
 int streams_send_filter(int id) {
  int fh;
- int have = 0;
- int len;
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
 
- _CHECK_SID(id);
+ if ( g_streams[id] == NULL )
+  return -1;
 
  ROAR_DBG("streams_send_filter(id=%i) = ?", id);
 
- s = ROAR_STREAM(ss = g_streams[id]);
+ s = (struct roar_stream *) (ss = g_streams[id]);
 
  if ( (fh = s->fh) == -1 )
@@ -2645,19 +533,13 @@
   return 0;
 
- if ( streams_get_flag(id, ROAR_FLAG_PAUSE) )
-  return 0;
-
-
  ROAR_DBG("streams_send_filter(id=%i): fh = %i", id, fh);
 
- if ( stream_vio_s_write(ss, g_output_buffer, g_output_buffer_len) == g_output_buffer_len ) {
-  while ( have < g_output_buffer_len ) {
-   if ( (len = stream_vio_s_read(ss, g_output_buffer+have, g_output_buffer_len-have)) < 1 ) {
-    streams_delete(id);
-    return -1;
-   }
-   have += len;
+ if ( write(fh, g_output_buffer, g_output_buffer_len) == g_output_buffer_len ) {
+  if ( read(fh, g_output_buffer, g_output_buffer_len) == g_output_buffer_len ) {
+   return 0;
+  } else {
+   streams_delete(id);
+   return -1;
   }
-  return 0;
  }
 
@@ -2669,139 +551,3 @@
 }
 
-
-// VIO:
-
-ssize_t stream_vio_read (int stream, void *buf, size_t count) {
- _CHECK_SID(stream);
-
- return stream_vio_s_read(g_streams[stream], buf, count);
-}
-
-ssize_t stream_vio_write(int stream, void *buf, size_t count) {
- _CHECK_SID(stream);
-
- return stream_vio_s_write(g_streams[stream], buf, count);
-}
-
-int     stream_vio_ctl  (int stream, roar_vio_ctl_t cmd,   void * data) {
- _CHECK_SID(stream);
-
- return stream_vio_s_ctl(g_streams[stream], cmd, data);
-}
-
-ssize_t stream_vio_s_read (struct roar_stream_server * stream, void *buf, size_t count) {
- void    * orig_buf = buf;
-  size_t   len      =  0;
- ssize_t   r        = -1;
- int       i;
-
- errno = 0;
-
- if ( stream == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- if ( stream->vio.read == NULL ) {
-  roar_err_set(ROAR_ERROR_NOTSUP);
-  return -1;
- }
-
- while ( (r = roar_vio_read(&(stream->vio), buf, count)) > 0 ) {
-  len   += r;
-  buf   += r;
-  count -= r;
-  if ( count == 0 )
-   break;
- }
-
- if ( len == 0 && r == -1 )
-  return -1;
-
- if ( streams_thru_num ) {
-  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-   if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) {
-    if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) {
-     if ( g_streams[i]->ready ) {
-      if ( stream_vio_write(i, orig_buf, len) != len )
-       streams_delete(i);
-
-      if ( g_streams[i] != NULL ) {
-       if ( g_streams[i]->state != ROAR_STREAMSTATE_OLD ) {
-        //ROAR_INFO("stream_vio_s_read(*): (stream: %i) stream state: %s->old", ROAR_DBG_INFO_VERBOSE, i, roar_streamstate2str(g_streams[i]->state));
-        _streams_change_state(g_streams[i], ROAR_STREAMSTATE_OLD, "stream_vio_s_read");
-       }
-      }
-     }
-    }
-   }
-  }
- }
-
- return len;
-}
-
-ssize_t stream_vio_s_write(struct roar_stream_server * stream, void *buf, size_t count) {
- int i;
-
- errno = 0;
-
- if ( stream == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
-// ROAR_WARN("stream_vio_s_write(*): writing...");
-
- if ( streams_thru_num ) {
-  for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-   if ( g_streams[i] != NULL && ROAR_STREAM(g_streams[i])->pos_rel_id == ROAR_STREAM(stream)->id ) {
-    if ( ROAR_STREAM(g_streams[i])->dir == ROAR_DIR_THRU ) {
-     if ( g_streams[i]->ready ) {
-      if ( g_streams[i]->state == ROAR_STREAMSTATE_NEW ) {
-       if ( streams_get_flag(i, ROAR_FLAG_PRETHRU) == 1 ) {
-        if ( stream_prethru_send(i, ROAR_STREAM(stream)->id) == -1 ) {
-         streams_delete(i);
-        }
-       }
-      }
-
-      if ( stream_vio_write(i, buf, count) != count ) {
-       streams_delete(i);
-      }
-
-      if ( g_streams[i] != NULL ) {
-       if ( g_streams[i]->state != ROAR_STREAMSTATE_OLD ) {
-        //ROAR_INFO("stream_vio_s_write(*): (stream: %i) stream state: %s->old", ROAR_DBG_INFO_VERBOSE, i, roar_streamstate2str(g_streams[i]->state));
-        _streams_change_state(g_streams[i], ROAR_STREAMSTATE_OLD, "stream_vio_s_write");
-       }
-      }
-     }
-    }
-   }
-  }
- }
-
- if ( g_config->jumbo_mtu ) {
-  if ( stream->viop != &(stream->jumbo) ) {
-   if ( roar_vio_open_jumbo(&(stream->jumbo), &(stream->vio), g_config->jumbo_mtu) != -1 ) {
-    // if that works we continue using the jumbo vio,
-    // in case it didn't we dont, just use normal VIO.
-    stream->viop = &(stream->jumbo);
-   }
-  }
- }
-
- return roar_vio_write(stream->viop, buf, count);
-}
-
-int     stream_vio_s_ctl  (struct roar_stream_server * stream, roar_vio_ctl_t cmd,   void * data) {
- if ( stream == NULL ) {
-  roar_err_set(ROAR_ERROR_FAULT);
-  return -1;
- }
-
- return roar_vio_ctl(stream->viop, cmd, data);
-}
-
 //ll
Index: roard/waveform.c
===================================================================
--- roard/waveform.c	(revision 6052)
+++ 	(revision )
@@ -1,162 +1,0 @@
-//waveform.c:
-
-/*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
- *
- *  This file is part of roard a part of RoarAudio,
- *  a cross-platform sound system for both, home and professional use.
- *  See README for details.
- *
- *  This file is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3
- *  as published by the Free Software Foundation.
- *
- *  RoarAudio is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this software; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "roard.h"
-
-// declared 'extern'.
-struct waveform_stream g_waveform_mixer, g_waveform_recbridge;
-
-static int waveform_init_recbridge (void) {
- struct roar_stream        *  s;
-
- if ( (g_waveform_recbridge.stream = streams_new()) == -1 )
-  return -1;
-
- client_stream_add(g_self_client, g_waveform_recbridge.stream);
-
- streams_get(g_waveform_recbridge.stream, &(g_waveform_recbridge.ss));
-
- s = ROAR_STREAM(g_waveform_recbridge.ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- s->pos_rel_id    =  g_waveform_mixer.stream;
-
- if ( streams_set_dir(g_waveform_recbridge.stream, ROAR_DIR_BRIDGE, 1) == -1 ) {
-  streams_delete(g_waveform_recbridge.stream);
-  g_waveform_recbridge.stream = -1;
-  g_waveform_recbridge.ss     = NULL;
-  return -1;
- }
-
- streams_set_name(g_waveform_recbridge.stream, "Record Bridge");
-
- streams_set_flag(g_waveform_recbridge.stream, ROAR_FLAG_PRIMARY);
- streams_set_flag(g_waveform_recbridge.stream, ROAR_FLAG_SYNC);
- streams_set_flag(g_waveform_recbridge.stream, ROAR_FLAG_MUTE);
-
- return 0;
-}
-
-int waveform_init  (void) {
- struct roar_stream_server * ss;
- struct roar_stream        *  s;
- int                          i;
- char                      cmap[ROAR_MAX_CHANNELS];
-
- // setup mixer:
- if ( (g_waveform_mixer.stream = add_mixer(ROAR_SUBSYS_WAVEFORM, _MIXER_NAME("Waveform"), &ss)) == -1 )
-  return -1;
-
- g_waveform_mixer.ss = ss;
-
- s = ROAR_STREAM(ss);
-
- memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
-
- roardsp_chanlist_init(cmap,   s->info.channels, ROARDSP_CHANLIST_MAP_ROARAUDIO);
- streams_set_map(g_waveform_mixer.stream, cmap, s->info.channels);
-
- ss->state = ROAR_STREAMSTATE_OLD;
-
-
- // setup Record Bridge:
- if ( waveform_init_recbridge() == -1 ) {
-  ROAR_WARN("waveform_init(void): Can not setup Record Bridge.");
-  streams_delete(g_waveform_mixer.stream);
-  g_waveform_mixer.stream = -1;
-  g_waveform_mixer.ss     = NULL;
-  return -1;
- }
-
- streams_set_mixer_stream(g_waveform_recbridge.stream, g_waveform_mixer.stream);
-
- // attach all waveform streams to the mixer.
- for (i = 0; i < ROAR_STREAMS_MAX; i++) {
-  if ( g_streams[i] != NULL ) {
-   if ( streams_get_subsys(i) == ROAR_SUBSYS_WAVEFORM ) {
-    streams_set_mixer_stream(i, g_waveform_mixer.stream);
-   }
-  }
- }
-
- return 0;
-}
-
-int waveform_free  (void) {
- return 0;
-}
-
-int waveform_update_inputs (void) {
- struct roar_buffer * buf;
- void * bufdata;
-
- // read recorded data...:
- if ( streams_recsource_id != -1 ) {
-  if ( streams_get_outputbuffer(streams_recsource_id, &bufdata, g_input_buffer_len) == -1 ) {
-   ROAR_WARN("waveform_update_mixer(void): can not request output buffer for record stream %i.", streams_recsource_id);
-  } else {
-   if ( streams_fill_mixbuffer2(streams_recsource_id, g_sa) == -1 ) {
-    ROAR_WARN("waveform_update_mixer(void): can not fill output buffer for record stream %i.", streams_recsource_id);
-   } else {
-    memcpy(g_input_buffer, bufdata, g_input_buffer_len);
-   }
-  }
- }
-
- if ( !(g_waveform_recbridge.ss->flags & (ROAR_FLAG_PAUSE|ROAR_FLAG_MUTE)) ) {
-  if ( roar_buffer_new_no_ma(&buf, g_input_buffer_len, g_input_buffer) == -1 ) {
-   ROAR_ERR("waveform_update_inputs(void): Can not create a new buffer object for Record Bridge. Bad.");
-   return -1;
-  }
-
-  if ( stream_add_buffer(g_waveform_recbridge.stream, &buf) == -1 ) {
-   ROAR_ERR("waveform_update_inputs(void): Can not attach a new buffer object to the Record Bridge. Bad.");
-   roar_buffer_free(buf);
-   return -1;
-  }
- }
-
- return 0;
-}
-
-int waveform_update_mixer (void) {
- if ( streams_get_flag(g_waveform_mixer.stream, ROAR_FLAG_MUTE) == 1 ) {
-  memset(g_output_buffer, 0, (g_sa->bits*ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels)/8);
-  return 0;
- }
-
- if ( need_vol_change(ROAR_STREAM(g_waveform_mixer.ss)->info.channels, &(g_waveform_mixer.ss->mixer)) ) {
-  roar_amp_pcm(g_output_buffer, g_sa->bits, g_output_buffer,
-               ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels, g_sa->channels,
-               &(g_waveform_mixer.ss->mixer));
- }
-
- streams_ltm_calc(g_waveform_mixer.stream, &(ROAR_STREAM(g_waveform_mixer.ss)->info), g_output_buffer, (g_sa->bits*ROAR_OUTPUT_BUFFER_SAMPLES*g_sa->channels)/8);
-
- return 0;
-}
-
-//ll
