[xiph-commits] r17003 - in trunk/ao: . src/plugins src/plugins/sndio
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Mar 22 23:56:07 PDT 2010
Author: xiphmont
Date: 2010-03-22 23:56:07 -0700 (Mon, 22 Mar 2010)
New Revision: 17003
Added:
trunk/ao/src/plugins/sndio/
trunk/ao/src/plugins/sndio/Makefile.am
trunk/ao/src/plugins/sndio/ao_sndio.c
Modified:
trunk/ao/configure.ac
trunk/ao/src/plugins/Makefile.am
Log:
Add OpenBSD sndio driver (patch from #1631). This required some updates to fit with current ao. COMPLETELY UNTESTED, I don't even
know that it builds.... OpenBSD testers, please contact me! :-)
Modified: trunk/ao/configure.ac
===================================================================
--- trunk/ao/configure.ac 2010-03-23 06:23:31 UTC (rev 17002)
+++ trunk/ao/configure.ac 2010-03-23 06:56:07 UTC (rev 17003)
@@ -280,6 +280,11 @@
AC_CHECK_HEADERS(sys/audioio.h)
AM_CONDITIONAL(HAVE_SUN_AUDIO,test "${ac_cv_header_sys_audioio_h}" = yes)
+dnl Check for libsndio audio
+
+AC_CHECK_HEADERS(sndio.h)
+AM_CONDITIONAL(HAVE_SNDIO_AUDIO,test "${ac_cv_header_sndio_h}" = yes)
+
dnl Check for AIX audio
case $host in
@@ -396,4 +401,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 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 ao.pc)
Modified: trunk/ao/src/plugins/Makefile.am
===================================================================
--- trunk/ao/src/plugins/Makefile.am 2010-03-23 06:23:31 UTC (rev 17002)
+++ trunk/ao/src/plugins/Makefile.am 2010-03-23 06:56:07 UTC (rev 17003)
@@ -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
+SUBDIRS = oss esd arts alsa sun irix macosx nas pulse sndio
Added: trunk/ao/src/plugins/sndio/Makefile.am
===================================================================
--- trunk/ao/src/plugins/sndio/Makefile.am (rev 0)
+++ trunk/ao/src/plugins/sndio/Makefile.am 2010-03-23 06:56:07 UTC (rev 17003)
@@ -0,0 +1,26 @@
+## Process this file with automake to produce Makefile.in
+
+AUTOMAKE_OPTIONS = foreign
+
+if HAVE_SNDIO_AUDIO
+
+sndioltlibs = libsndio.la
+sndiosources = ao_sndio.c
+
+else
+
+sndioltlibs =
+sndiosources =
+
+endif
+
+INCLUDES = -I$(top_builddir)/include/ao -I$(top_srcdir)/include
+
+libdir = $(plugindir)
+lib_LTLIBRARIES = $(sndioltlibs)
+
+libsndio_la_LDFLAGS = @PLUGIN_LDFLAGS@
+libsndio_la_LIBADD = -lsndio
+libsndio_la_SOURCES = $(sndiosources)
+
+EXTRA_DIST = ao_sndio.c
Added: trunk/ao/src/plugins/sndio/ao_sndio.c
===================================================================
--- trunk/ao/src/plugins/sndio/ao_sndio.c (rev 0)
+++ trunk/ao/src/plugins/sndio/ao_sndio.c 2010-03-23 06:56:07 UTC (rev 17003)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2008 Alexandre Ratchov <alex at caoua.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <sndio.h>
+#include <ao/ao.h>
+#include <ao/plugin.h>
+
+static char * ao_sndio_options[] = {
+ "verbose",
+ "quiet",
+ "matrix",
+ "debug",
+ "dev"
+};
+
+ao_info ao_sndio_info = {
+ AO_TYPE_LIVE,
+ "sndio audio output",
+ "sndio",
+ "Alexandre Ratchov <alex at caoua.org>",
+ "Outputs to the sndio library",
+ AO_FMT_NATIVE,
+ 30,
+ ao_sndio_options,
+ 4
+};
+
+typedef struct ao_alsa_internal
+{
+ struct sio_hdl *hdl;
+ char *dev;
+} ao_sndio_internal;
+
+int ao_plugin_test()
+{
+ struct sio_hdl *hdl;
+
+ hdl = sio_open(NULL, SIO_PLAY, 0);
+ if (hdl == NULL)
+ return 0;
+ sio_close(hdl);
+ return 1;
+}
+
+ao_info *ao_plugin_driver_info(void)
+{
+ return &ao_sndio_info;
+}
+
+int ao_plugin_device_init(ao_device *device)
+{
+ ao_sndio_internal *internal;
+ internal = (ao_sndio_internal *) calloc(1,sizeof(*internal));
+ 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_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+
+ if (!strcmp(key, "dev")) {
+ if (internal->dev)
+ free (internal->dev);
+ if(!value){
+ internal->dev=NULL;
+ }else{
+ if (!(internal->dev = strdup(value)))
+ return 0;
+ }
+ }
+ return 1;
+}
+
+int ao_plugin_open(ao_device *device, ao_sample_format *format)
+{
+ ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+ struct sio_par par;
+
+ internal->hdl = sio_open(internal->dev, SIO_PLAY, 0);
+ if (internal->hdl == NULL)
+ return 0;
+
+ sio_initpar(&par);
+ par.sig = 1;
+ par.le = SIO_LE_NATIVE;
+ par.bits = format->bits;
+ par.rate = format->rate;
+ par.pchan = device->output_channels;
+ if (!sio_setpar(hdl, &par))
+ return 0;
+ device->driver_byte_format = AO_FMT_NATIVE;
+ if (!sio_start(hdl))
+ return 0;
+
+ if(!device->inter_matrix){
+ /* set up matrix such that users are warned about > stereo playback */
+ if(device->output_channels<=2)
+ device->inter_matrix=strdup("L,R");
+ //else no matrix, which results in a warning
+ }
+
+ return 1;
+}
+
+int ao_plugin_play(ao_device *device, const char *output_samples, uint_32 num_bytes)
+{
+ ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+ struct sio_hdl *hdl = internal->hdl;
+
+ if (!sio_write(hdl, output_samples, num_bytes))
+ return 0;
+ return 1;
+}
+
+int ao_plugin_close(ao_device *device)
+{
+ ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+ struct sio_hdl *hdl = internal->hdl;
+
+ if (!sio_stop(hdl))
+ return 0;
+ return 1;
+}
+
+void ao_plugin_device_clear(ao_device *device)
+{
+ ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+ struct sio_hdl *hdl = internal->hdl;
+
+ sio_close(hdl);
+ if(internal->dev)
+ free(internal->dev);
+ internal->dev=NULL;
+}
More information about the commits
mailing list