Index: TODO
===================================================================
--- TODO	(revision 3589)
+++ TODO	(revision 3591)
@@ -16,5 +16,5 @@
  * (0.3 W/H/-) Get into Debian
  * (0.3 W/N/-) Clean and update libroarpulse
- * (0.3 W/h/-) Cleanup driver: DMX, ESD, Roar
+ * (0.3 W/h/-) Cleanup driver: DMX, Roar
  * (0.3 W/N/-) Implement ALSA support
  * (0.3 W/L/-) Implement support for ICY Meta Data
Index: roard/driver.c
===================================================================
--- roard/driver.c	(revision 3589)
+++ roard/driver.c	(revision 3591)
@@ -31,5 +31,5 @@
 #ifdef ROAR_HAVE_ESD
  { "esd", "EsounD audio driver", "localhost, remote.host.dom", DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
-   NULL, driver_esd_close, driver_esd_open_vio},
+   NULL, NULL, driver_esd_open_vio},
 #endif
  { "roar", "RoarAudio driver", "localhost, remote.host.dom", DRV_FLAG_NONE,
Index: roard/driver_esd.c
===================================================================
--- roard/driver_esd.c	(revision 3517)
+++ roard/driver_esd.c	(revision 3591)
@@ -2,5 +2,5 @@
 
 /*
- *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
  *
  *  This file is part of roard a part of RoarAudio,
@@ -33,77 +33,38 @@
 */
 
-int driver_esd_open_sysio(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) {
+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;
  char name[80] = "roard";
- int * di = malloc(sizeof(int)*2);
 
- if ( di == NULL )
+ if ( fh != -1 )
   return -1;
 
- *inst = (DRIVER_USERDATA_T)di;
+ 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;
+ }
 
- format |= info->bits     == 16 ? ESD_BITS16 : ESD_BITS8;
- format |= info->channels ==  2 ? ESD_STEREO : ESD_MONO;
+ if ( info->channels >= 2 ) {
+  info->channels  = 2;
+  format         |= ESD_STEREO;
+ } else {
+  info->channels  = 1;
+  format         |= ESD_MONO;
+ }
 
- di[1] = info->bits == 8;
+ fh = esd_play_stream_fallback(format, info->rate, device, name);
 
- di[0] = esd_play_stream_fallback(format, info->rate, device, name);
+ shutdown(fh, SHUT_RD);
 
- shutdown(di[0], SHUT_RD);
-
- if ( di[0] == -1 ) {
-  free(di);
-  *inst = NULL;
-  return -1;
- }
+ roar_vio_set_fh(inst, fh);
 
  return 0;
 }
 
-int driver_esd_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
-
- if ( fh != -1 )
-  return -1;
-
- inst->read     = driver_esd_read;
- inst->write    = driver_esd_write;
- inst->nonblock = driver_esd_nonblock;
- inst->sync     = driver_esd_sync;
-
- return driver_esd_open_sysio(&(inst->inst), device, info);
-}
-
-int driver_esd_close(DRIVER_USERDATA_T   inst) {
- int fh;
-
- inst = ((struct roar_vio_calls *)inst)->inst;
-
- fh = *(int*)inst;
-
- free((void*)inst);
-
- return esd_close(fh);
-}
-
-ssize_t driver_esd_write(struct roar_vio_calls * inst, void * buf, size_t len) {
- int * di = (int*)((struct roar_vio_calls *)inst)->inst;
-
- if ( di[1] )
-  roar_conv_codec_s2u8(buf, buf, len);
-
- return write(di[0], buf, len);
-}
-
-ssize_t driver_esd_read(struct roar_vio_calls * inst, void * buf, size_t len) {
- return read(*(int*)((struct roar_vio_calls *)inst)->inst, buf, len);
-}
-
-int driver_esd_nonblock(struct roar_vio_calls * vio, int state) {
- return roar_socket_nonblock(*(int*)vio->inst, state);
-}
-
-int driver_esd_sync    (struct roar_vio_calls * vio) {
- return ROAR_FDATASYNC(*(int*)vio->inst);
-}
 
 #endif
Index: roard/include/driver_esd.h
===================================================================
--- roard/include/driver_esd.h	(revision 3517)
+++ roard/include/driver_esd.h	(revision 3591)
@@ -27,13 +27,5 @@
 #define _DRIVER_ESD_H_
 
-int driver_esd_open_sysio(DRIVER_USERDATA_T * inst,   char * device, struct roar_audio_info * info);
 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_close(DRIVER_USERDATA_T   inst);
-int driver_esd_pause(DRIVER_USERDATA_T   inst, int newstate);
-ssize_t driver_esd_write(struct roar_vio_calls * inst, void * buf, size_t len);
-ssize_t driver_esd_read(struct roar_vio_calls  * inst, void * buf, size_t len);
-int driver_esd_nonblock(struct roar_vio_calls * vio, int state);
-int driver_esd_sync    (struct roar_vio_calls * vio);
-int driver_esd_flush(DRIVER_USERDATA_T   inst);
 
 #endif
