[xiph-commits] r17004 - in trunk/ao: . src/plugins src/plugins/roar

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Mar 23 00:56:37 PDT 2010


Author: xiphmont
Date: 2010-03-23 00:56:36 -0700 (Tue, 23 Mar 2010)
New Revision: 17004

Added:
   trunk/ao/src/plugins/roar/
   trunk/ao/src/plugins/roar/Makefile.am
   trunk/ao/src/plugins/roar/README
   trunk/ao/src/plugins/roar/ao_roar.c
Modified:
   trunk/ao/configure.ac
   trunk/ao/src/plugins/Makefile.am
Log:
Add RoarAudio driver.  This is modified slightly from the version 
distributed in the Roar package.  It fixes one segfault bug, one mapping 
bug, and updates the mapping convention to the one that will actually be 
released in 1.0; the Roar folks added mappings suppor to the ao driver a 
bit too soon.



Modified: trunk/ao/configure.ac
===================================================================
--- trunk/ao/configure.ac	2010-03-23 06:56:07 UTC (rev 17003)
+++ trunk/ao/configure.ac	2010-03-23 07:56:36 UTC (rev 17004)
@@ -285,6 +285,11 @@
 AC_CHECK_HEADERS(sndio.h)
 AM_CONDITIONAL(HAVE_SNDIO_AUDIO,test "${ac_cv_header_sndio_h}" = yes)
 
+dnl Check for roaraudio
+
+AC_CHECK_HEADERS(roaraudio.h)
+AM_CONDITIONAL(HAVE_ROAR_AUDIO,test "${ac_cv_header_roaraudio_h}" = yes)
+
 dnl Check for AIX audio
 
 case $host in
@@ -401,4 +406,4 @@
 AC_SUBST(PLUGIN_LDFLAGS)
 
 
-AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h src/plugins/Makefile src/plugins/esd/Makefile src/plugins/oss/Makefile src/plugins/alsa/Makefile src/plugins/sun/Makefile src/plugins/irix/Makefile src/plugins/arts/Makefile src/plugins/macosx/Makefile src/plugins/nas/Makefile src/plugins/pulse/Makefile src/plugins/sndio/Makefile ao.pc)
+AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h src/plugins/Makefile src/plugins/esd/Makefile src/plugins/oss/Makefile src/plugins/alsa/Makefile src/plugins/sun/Makefile src/plugins/irix/Makefile src/plugins/arts/Makefile src/plugins/macosx/Makefile src/plugins/nas/Makefile src/plugins/pulse/Makefile src/plugins/sndio/Makefile src/plugins/roar/Makefile ao.pc)

Modified: trunk/ao/src/plugins/Makefile.am
===================================================================
--- trunk/ao/src/plugins/Makefile.am	2010-03-23 06:56:07 UTC (rev 17003)
+++ trunk/ao/src/plugins/Makefile.am	2010-03-23 07:56:36 UTC (rev 17004)
@@ -1,4 +1,4 @@
 ## Process this file with automake to produce Makefile.in
 
 AUTOMAKE_OPTIONS = foreign
-SUBDIRS = oss esd arts alsa sun irix macosx nas pulse sndio
+SUBDIRS = oss esd arts alsa sun irix macosx nas pulse sndio roar

Added: trunk/ao/src/plugins/roar/Makefile.am
===================================================================
--- trunk/ao/src/plugins/roar/Makefile.am	                        (rev 0)
+++ trunk/ao/src/plugins/roar/Makefile.am	2010-03-23 07:56:36 UTC (rev 17004)
@@ -0,0 +1,26 @@
+## Process this file with automake to produce Makefile.in
+
+AUTOMAKE_OPTIONS = foreign
+
+if HAVE_ROAR_AUDIO
+
+roarltlibs = libroar.la
+roarsources = ao_roar.c
+
+else
+
+roarltlibs =
+roarsources =
+
+endif
+
+INCLUDES = -I$(top_builddir)/include/ao -I$(top_srcdir)/include
+
+libdir = $(plugindir)
+lib_LTLIBRARIES = $(roarltlibs)
+
+libroar_la_LDFLAGS = @PLUGIN_LDFLAGS@
+libroar_la_LIBADD = -lroar
+libroar_la_SOURCES = $(roarsources)
+
+EXTRA_DIST = ao_roar.c

Added: trunk/ao/src/plugins/roar/README
===================================================================
--- trunk/ao/src/plugins/roar/README	                        (rev 0)
+++ trunk/ao/src/plugins/roar/README	2010-03-23 07:56:36 UTC (rev 17004)
@@ -0,0 +1,33 @@
+               RoarAudio output plugin for libao
+         -------------------------------------------
+
+Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
+based on ao_esd.c of libao by Stan Seibert - July 2000, July 2001
+
+This is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This (as all of the RoarAudio package) 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 program.  If not, see <http://www.gnu.org/licenses/>.
+
+---------------------------------------------------------------------
+
+OVERVIEW
+
+This plugin adds support for RoarAudio to libao. It is part of
+the RoarAudio distribution but may be distributed separately.
+For a documentation of RoarAudio see the full package.
+
+OPTIONS
+
+ host           - The roard to connect to (ip/hostname[:port] or /.../sock)
+
+

Added: trunk/ao/src/plugins/roar/ao_roar.c
===================================================================
--- trunk/ao/src/plugins/roar/ao_roar.c	                        (rev 0)
+++ trunk/ao/src/plugins/roar/ao_roar.c	2010-03-23 07:56:36 UTC (rev 17004)
@@ -0,0 +1,174 @@
+/*
+ *
+ *  ao_roar.c
+ *
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
+ *      based on ao_esd.c of libao by Stan Seibert - July 2000, July 2001
+ *
+ *  This file is part of RoarAudio, a cross-platform sound server. See
+ *  README for a history of this source code.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  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 GNU Make; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <roaraudio.h>
+#include <ao/ao.h>
+#include <ao/plugin.h>
+
+static char *ao_roar_options[] = {"host","verbose","quiet","matrix","debug"};
+
+/*
+typedef struct ao_info {
+        int  type; // live output or file output?
+        char *name; // full name of driver
+        char *short_name; // short name of driver
+        char *author; // driver author
+        char *comment; // driver comment
+        int  preferred_byte_format;
+        int  priority;
+        char **options;
+        int  option_count;
+} ao_info;
+*/
+
+static ao_info ao_roar_info ={
+  AO_TYPE_LIVE,
+  "RoarAudio output",
+  "roar",
+  "Philipp 'ph3-der-loewe' Schafft, Based on code by: Stan Seibert <volsung at asu.edu>",
+  "Outputs to the RoarAudio Sound Daemon.",
+  AO_FMT_NATIVE,
+  50,
+  ao_roar_options,
+  5
+};
+
+
+typedef struct ao_roar_internal {
+  struct roar_vio_calls svio;
+  char * host;
+} ao_roar_internal;
+
+
+int ao_plugin_test(void) {
+  struct roar_connection con;
+
+  if ( roar_simple_connect(&con, NULL, "libao client") == -1 )
+    return 0;
+
+  if (roar_get_standby(&con)) {
+    roar_disconnect(&con);
+    return 0;
+  }
+
+  roar_disconnect(&con);
+  return 1;
+}
+
+
+ao_info * ao_plugin_driver_info(void) {
+  return &ao_roar_info;
+}
+
+
+int ao_plugin_device_init(ao_device * device) {
+  ao_roar_internal * internal;
+
+  internal = (ao_roar_internal *) calloc(1,sizeof(ao_roar_internal));
+
+  if (internal == NULL)
+    return 0;
+
+  internal->host = NULL;
+
+  device->internal = internal;
+  device->output_matrix_order = AO_OUTPUT_MATRIX_FIXED;
+
+  return 1;
+}
+
+int ao_plugin_set_option(ao_device * device, const char * key, const char * value) {
+  ao_roar_internal * internal = (ao_roar_internal *) device->internal;
+
+  if ( strcmp(key, "host") == 0 ) {
+    if(internal->host) free(internal->host);
+    internal->host = strdup(value);
+  }
+
+  return 1;
+}
+
+int ao_plugin_open(ao_device * device, ao_sample_format * format) {
+  ao_roar_internal * internal = (ao_roar_internal *) device->internal;
+  char * map = NULL;
+
+  if ( roar_vio_simple_stream(&(internal->svio), format->rate, format->channels, format->bits,
+                             ROAR_CODEC_DEFAULT, internal->host, ROAR_DIR_PLAY, "libao client") == -1 )
+    return 0;
+
+  device->driver_byte_format = AO_FMT_NATIVE;
+
+  if(!device->inter_matrix){ /* It would be set if an app or user force-sets the mapping; don't overwrite! */
+    switch (format->channels) {
+    case  1: map = "M";               break;
+    case  2: map = "L,R";             break;
+    case  3: map = "L,R,C";           break;
+    case  4: map = "L,R,BL,BR";       break;
+    case  5: map = "L,R,C,BL,BR";     break;
+    case  6: map = "L,R,C,LFE,BL,BR"; break;
+    }
+    /* >6 channels will warn about inability to map */
+
+    if ( map )
+      device->inter_matrix = strdup(map);
+  }
+
+  return 1;
+}
+
+int ao_plugin_play(ao_device * device, const char * output_samples, uint_32 num_bytes) {
+  ao_roar_internal * internal = (ao_roar_internal *) device->internal;
+
+  if (roar_vio_write(&(internal->svio), (char*)output_samples, num_bytes) == -1) {
+    return 0;
+  } else {
+    return 1;
+  }
+}
+
+
+int ao_plugin_close(ao_device * device) {
+  ao_roar_internal * internal = (ao_roar_internal *) device->internal;
+
+  roar_vio_close(&(internal->svio));
+
+  return 1;
+}
+
+
+void ao_plugin_device_clear(ao_device * device) {
+  ao_roar_internal * internal = (ao_roar_internal *) device->internal;
+
+  if( internal->host != NULL )
+    free(internal->host);
+
+  free(internal);
+}



More information about the commits mailing list