Index: roard/Makefile
===================================================================
--- roard/Makefile	(revision 5908)
+++ roard/Makefile	(revision 5917)
@@ -4,5 +4,5 @@
 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
+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_raum.o codecfilter_au.o
 EMUL=emul_simple.o emul_rsound.o
Index: roard/codecfilter_roardmx.c
===================================================================
--- roard/codecfilter_roardmx.c	(revision 5917)
+++ roard/codecfilter_roardmx.c	(revision 5917)
@@ -0,0 +1,94 @@
+//codecfilter_roardmx.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2013
+ *
+ *  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
+
+int cf_light_roardmx_read(int id, struct roar_stream_server * ss) {
+ struct roar_roardmx_message  mes;
+ int i, c;
+ uint16_t channel;
+ uint8_t value;
+
+ if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) {
+  return -1;
+ }
+
+ // 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;
+}
+
+int cf_light_roardmx_write(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.changes[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.state[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;
+}
+
+#endif
+
+//ll
Index: roard/include/light.h
===================================================================
--- roard/include/light.h	(revision 5916)
+++ roard/include/light.h	(revision 5917)
@@ -57,4 +57,8 @@
 int light_dmxchannel_set(size_t index, uint8_t val);
 
+// 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
 
Index: roard/light.c
===================================================================
--- roard/light.c	(revision 5916)
+++ roard/light.c	(revision 5917)
@@ -124,9 +124,6 @@
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
- struct roar_roardmx_message  mes;
  char buf[512];
- int i, c;
- uint16_t      channel;
- uint8_t value;
+ int i;
 
  if ( g_streams[id] == NULL )
@@ -155,24 +152,7 @@
   case ROAR_CODEC_ROARDMX:
     ROAR_DBG("light_check_stream(id=%i): Codec: RoarDMX", id);
-    if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) {
-     streams_delete(id); // because we don't know at the moment...
+    if ( cf_light_roardmx_read(id, ss) == -1 ) {
+     streams_delete(id); // simply drop the client on error.
      return -1;
-    }
-
-    // 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
-     }
     }
    break;
@@ -185,13 +165,33 @@
 }
 
+static inline int light_send_stream_dmx512  (int id, struct roar_stream * s, struct roar_stream_server * ss) {
+ int 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.state;
+ } else {
+  memset(buf, 0, 512);
+  memcpy(buf, g_light_state.state, 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) {
- int chans;
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
- uint8_t buf[512];
- register uint8_t * bufptr;
- struct roar_roardmx_message  mes;
- int i;
- int have_message = 0;
 
  if ( g_streams[id] == NULL )
@@ -204,52 +204,8 @@
  switch (s->info.codec) {
   case ROAR_CODEC_DMX512:
-    chans = g_light_state.channels;
-
-    if ( chans > 512 )
-     chans = 512;
-
-    if ( chans == 512 ) {
-     bufptr = g_light_state.state;
-    } else {
-     memset(buf, 0, 512);
-     memcpy(buf, g_light_state.state, 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;
+    return light_send_stream_dmx512(id, s, ss);
    break;
   case ROAR_CODEC_ROARDMX:
-    for (i = 0; i < g_light_state.channels; i++) {
-     if ( g_light_state.changes[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.state[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;
+    return cf_light_roardmx_write(id, ss);
    break;
   default:
