Index: include/roaraudio/stream.h
===================================================================
--- include/roaraudio/stream.h	(revision 978)
+++ include/roaraudio/stream.h	(revision 1609)
@@ -43,4 +43,5 @@
 #define ROAR_DIR_META     8
 #define ROAR_DIR_BIDIR    9
+#define ROAR_DIR_DIRIDS  10
 
 
Index: roarclients/roartypes.c
===================================================================
--- roarclients/roartypes.c	(revision 1324)
+++ roarclients/roartypes.c	(revision 1609)
@@ -33,4 +33,5 @@
   { "roar_sample",         sizeof(struct roar_sample)         },
   { "roar_client",         sizeof(struct roar_client)         },
+  { "roard_config",        sizeof(struct roard_config)        },
   { "roar_connection",     sizeof(struct roar_connection)     },
   { "roar_audio_info",     sizeof(struct roar_audio_info)     },
@@ -44,5 +45,5 @@
 
  while ((++c)->name != NULL)
-  printf("%-20s = %4i Bytes = %4i Bits\n", c->name, c->len, c->len * 8);
+  printf("%-20s = %5i Bytes = %6i Bits\n", c->name, c->len, c->len * 8);
 
  return 0;
Index: roard/include/roard.h
===================================================================
--- roard/include/roard.h	(revision 1537)
+++ roard/include/roard.h	(revision 1609)
@@ -103,5 +103,14 @@
 int g_terminate;
 
-struct roar_audio_info * g_sa;
+struct roar_audio_info * g_sa, * g_max_sa;
+
+struct roard_config {
+ uint32_t flags;
+ struct {
+  uint32_t flags;
+  struct roar_mixer_settings mixer;
+  int                        mixer_channels;
+ } streams[ROAR_DIR_DIRIDS];
+} * g_config;
 
 #endif
Index: roard/include/streams.h
===================================================================
--- roard/include/streams.h	(revision 1590)
+++ roard/include/streams.h	(revision 1609)
@@ -83,4 +83,6 @@
 int streams_get_client (int id);
 
+int streams_set_dir    (int id, int dir, int defaults);
+
 int streams_set_fh     (int id, int fh);
 int streams_get_fh     (int id);
Index: roard/roard.c
===================================================================
--- roard/roard.c	(revision 1581)
+++ roard/roard.c	(revision 1609)
@@ -129,4 +129,20 @@
 #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;
+ }
+
+ return 0;
+}
+
 int add_output (char * drv, char * dev, char * opts, int prim, int count) {
  int stream;
@@ -171,5 +187,8 @@
  memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
 
- s->dir        = ROAR_DIR_OUTPUT;
+ if ( streams_set_dir(stream, ROAR_DIR_OUTPUT, 1) == -1 ) {
+  streams_delete(stream);
+  return -1;
+ }
  s->pos_rel_id = -1;
 // s->info.codec = codec;
@@ -293,5 +312,6 @@
  char user_sock[80]  = {0};
 #endif
- struct roar_audio_info sa;
+ struct roar_audio_info sa, max_sa;
+ struct roard_config config;
 #ifdef ROAR_HAVE_FORK
  int    daemon       = 0;
@@ -363,5 +383,15 @@
  sa.codec    = ROAR_CODEC_DEFAULT;
 
- g_sa = &sa;
+ g_sa        = &sa;
+ g_max_sa    = &max_sa;
+
+ memcpy(g_max_sa, g_sa, sizeof(max_sa));
+
+ g_config = &config;
+
+ if ( init_config() == -1 ) {
+  ROAR_ERR("Can not init default config!");
+  return 1;
+ }
 
 
Index: roard/sources.c
===================================================================
--- roard/sources.c	(revision 1504)
+++ roard/sources.c	(revision 1609)
@@ -81,5 +81,10 @@
  memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
 
- s->dir        = ROAR_DIR_PLAY;
+ if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
+  streams_delete(stream);
+  close(fh);
+  return -1;
+ }
+
  s->pos_rel_id = -1;
 
@@ -124,5 +129,9 @@
  memcpy(&(s->info.bits    ), buf+34, 2);
 
- s->dir        = ROAR_DIR_PLAY;
+ if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
+  streams_delete(stream);
+  close(fh);
+  return -1;
+ }
  s->pos_rel_id = -1;
 
@@ -154,5 +163,9 @@
  memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
 
- s->dir        = ROAR_DIR_PLAY;
+ if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
+  streams_delete(stream);
+  return -1;
+ }
+
  s->pos_rel_id = -1;
 
@@ -238,5 +251,10 @@
  memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
 
- s->dir        = ROAR_DIR_PLAY;
+ if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
+  streams_delete(stream);
+  close(fh);
+  return -1;
+ }
+
  s->pos_rel_id = -1;
  s->info.codec = codec;
Index: roard/streams.c
===================================================================
--- roard/streams.c	(revision 1590)
+++ roard/streams.c	(revision 1609)
@@ -207,4 +207,26 @@
 }
 
+int streams_set_dir    (int id, int dir, int defaults) {
+ struct roar_stream_server * ss;
+
+ if ( (ss = g_streams[id]) == NULL )
+  return -1;
+
+ ROAR_STREAM(ss)->dir = dir;
+
+ if ( defaults ) {
+  if ( dir <= 0 || dir >= ROAR_DIR_DIRIDS )
+   return -1;
+
+  if ( streams_set_flag(id, g_config->streams[dir].flags) == -1 )
+   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;
+ }
+
+ return 0;
+}
 
 int streams_set_fh     (int id, int fh) {
