Index: ChangeLog
===================================================================
--- ChangeLog	(revision 3725)
+++ ChangeLog	(revision 3751)
@@ -22,4 +22,5 @@
 	* Added ALSA driver
 	* Added RSound driver
+	* Added PortAudio driver
 
 v. 0.3beta4 - Sat Feb 06 2010 26:02 CET
Index: roard/Makefile
===================================================================
--- roard/Makefile	(revision 3725)
+++ roard/Makefile	(revision 3751)
@@ -3,5 +3,5 @@
 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
 SUBSYS=midi.o light.o raw.o rdtcs.o waveform.o beep.o
-DRV=driver_esd.o driver_ao.o driver_roar.o driver_raw.o driver_oss.o driver_shout.o driver_sndio.o driver_dmx.o driver_pwmled.o driver_sysclock.o driver_wmm.o driver_dstr.o driver_alsa.o driver_rsound.o
+DRV=driver_esd.o driver_ao.o driver_roar.o driver_raw.o driver_oss.o driver_shout.o driver_sndio.o driver_dmx.o driver_pwmled.o driver_sysclock.o driver_wmm.o driver_dstr.o driver_alsa.o driver_rsound.o driver_portaudio.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
 CF_CONTAINER=codecfilter_wave.o codecfilter_raum.o
@@ -18,5 +18,5 @@
 CFLAGS   += -g -Wall -O2 $(DEFINES) $(INCLUDE) $(INCPATH)
 LDFLAGS   = -g -rdynamic -L../lib/ $(LDPATH)
-DRVLIBS   = $(lib_esd) $(lib_ossaudio) $(lib_ao) $(lib_shout) $(lib_sndio) $(lib_rsound) $(lib_asound) $(lib_winmm)
+DRVLIBS   = $(lib_esd) $(lib_ossaudio) $(lib_ao) $(lib_shout) $(lib_sndio) $(lib_rsound) $(lib_portaudio) $(lib_pablio) $(lib_asound) $(lib_winmm)
 CODECLIBS = $(lib_vorbisfile) $(lib_vorbisenc) $(lib_vorbis) $(lib_celt) $(lib_fishsound) $(lib_speex) $(lib_speexdsp)
 CONTLIBS  = $(lib_oggz) $(lib_sndfile) $(lib_ogg) $(lib_raum)
Index: roard/driver.c
===================================================================
--- roard/driver.c	(revision 3725)
+++ roard/driver.c	(revision 3751)
@@ -68,4 +68,8 @@
  {"rsound", "RSound", "servername", DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
   NULL, NULL, driver_rsound_open},
+#endif
+#ifdef _DRIVER_PORTAUDIO_CAN_OPERATE
+ {"portaudio", "PortAudio", "(none)", DRV_FLAG_NONE, ROAR_SUBSYS_WAVEFORM,
+  NULL, NULL, driver_portaudio_open},
 #endif
 #ifdef ROAR_HAVE_LIBASOUND
Index: roard/driver_portaudio.c
===================================================================
--- roard/driver_portaudio.c	(revision 3751)
+++ roard/driver_portaudio.c	(revision 3751)
@@ -0,0 +1,141 @@
+//driver_portaudio.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-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 _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;
+#endif
+
+ 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:
+       return -1;
+      break;
+    }
+   break;
+  case 16:
+    if ( info->codec != ROAR_CODEC_DEFAULT )
+     return -1;
+    fmt = paInt16;
+   break;
+  case 24:
+    if ( info->codec != ROAR_CODEC_DEFAULT )
+     return -1;
+    fmt = paPackedInt24;
+   break;
+  case 32:
+    if ( info->codec != ROAR_CODEC_DEFAULT )
+     return -1;
+    fmt = paInt32;
+   break;
+  default:
+    return -1;
+ }
+
+ 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->inst  = self;
+ inst->close = driver_portaudio_close;
+ inst->write = driver_portaudio_write;
+
+ Pa_Initialize();
+
+#ifdef ROAR_HAVE_LIBPABLIO
+ switch (info->channels) {
+  case 1: flags |= PABLIO_MONO;   break;
+  case 2: flags |= PABLIO_STEREO; break;
+  default:
+    roar_mm_free(self);
+    Pa_Terminate();
+    return -1;
+ }
+
+ if ( OpenAudioStream(&(self->ostream), info->rate, fmt, flags) != paNoError ) {
+  roar_mm_free(self);
+  Pa_Terminate();
+  return -1;
+ }
+
+ return 0;
+#else
+ return -1;
+#endif
+}
+
+int     driver_portaudio_close        (struct roar_vio_calls * vio) {
+ struct driver_portaudio * self = vio->inst;
+
+#ifdef ROAR_HAVE_LIBPABLIO
+ CloseAudioStream(self->ostream);
+
+ Pa_Terminate();
+
+ roar_mm_free(self);
+
+ 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;
+
+ 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;
+#else
+ return -1;
+#endif
+}
+
+#endif
+
+//ll
Index: roard/include/driver.h
===================================================================
--- roard/include/driver.h	(revision 3725)
+++ roard/include/driver.h	(revision 3751)
@@ -106,4 +106,12 @@
 #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>
Index: roard/include/driver_portaudio.h
===================================================================
--- roard/include/driver_portaudio.h	(revision 3751)
+++ roard/include/driver_portaudio.h	(revision 3751)
@@ -0,0 +1,54 @@
+//driver_portaudio.h:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 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_PORTAUDIO_H_
+#define _DRIVER_PORTAUDIO_H_
+
+#ifdef ROAR_HAVE_LIBPORTAUDIO
+#if defined(ROAR_HAVE_LIBPABLIO)
+#define _DRIVER_PORTAUDIO_CAN_OPERATE
+#endif
+#endif
+
+#ifdef _DRIVER_PORTAUDIO_CAN_OPERATE
+
+struct driver_portaudio {
+#ifdef ROAR_HAVE_LIBPABLIO
+ PABLIO_Stream * ostream;
+#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);
+int     driver_portaudio_ctl          (struct roar_vio_calls * vio, int cmd, void * data);
+
+#endif
+
+#endif
+
+//ll
