[Vorbis-dev] sndio support for libao

Christian Weisgerber naddy at mips.inka.de
Mon Dec 8 08:08:43 PST 2008


(Is this the right list for libao patches?)

The following adds support for a sndio plugin to libao.  sndio is
OpenBSD's new audio API.


diff -uNrp libao-0.8.8.orig/configure.ac libao-0.8.8/configure.ac
--- libao-0.8.8.orig/configure.ac	Thu May 24 12:51:05 2007
+++ libao-0.8.8/configure.ac	Mon Dec  8 16:34:44 2008
@@ -300,6 +300,11 @@ dnl Check for Sun audio
 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
@@ -415,4 +420,4 @@ dnl Plugins get special LDFLAGS
 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/alsa09/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/alsa09/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)
diff -uNrp libao-0.8.8.orig/src/plugins/Makefile.am libao-0.8.8/src/plugins/Makefile.am
--- libao-0.8.8.orig/src/plugins/Makefile.am	Thu May 24 11:19:07 2007
+++ libao-0.8.8/src/plugins/Makefile.am	Mon Dec  8 16:34:44 2008
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
 AUTOMAKE_OPTIONS = foreign
-SUBDIRS = oss esd arts alsa alsa09 sun irix macosx nas pulse
+SUBDIRS = oss esd arts alsa alsa09 sun irix macosx nas pulse sndio
+AM_MAKEFLAGS = LIBTOOL="$(LIBTOOL) --tag=disable-static"
diff -uNrp libao-0.8.8.orig/src/plugins/sndio/Makefile.am libao-0.8.8/src/plugins/sndio/Makefile.am
--- libao-0.8.8.orig/src/plugins/sndio/Makefile.am	Thu Jan  1 01:00:00 1970
+++ libao-0.8.8/src/plugins/sndio/Makefile.am	Mon Dec  8 16:35:29 2008
@@ -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
diff -uNrp libao-0.8.8.orig/src/plugins/sndio/ao_sndio.c libao-0.8.8/src/plugins/sndio/ao_sndio.c
--- libao-0.8.8.orig/src/plugins/sndio/ao_sndio.c	Thu Jan  1 01:00:00 1970
+++ libao-0.8.8/src/plugins/sndio/ao_sndio.c	Mon Dec  8 16:35:29 2008
@@ -0,0 +1,106 @@
+/*
+ * 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>
+
+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,
+	NULL,	/* no options */
+	0	/* zero options */
+};
+
+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)
+{
+	struct sio_hdl *hdl;
+
+	hdl = sio_open(NULL, SIO_PLAY, 0);
+	if (hdl == NULL)
+		return 0;
+	device->internal = hdl;
+	return 1;
+}
+
+int ao_plugin_set_option(ao_device *device, const char *key, const char *value)
+{
+	return 1;
+}
+
+int ao_plugin_open(ao_device *device, ao_sample_format *format)
+{
+	struct sio_hdl *hdl = (struct sio_hdl *)device->internal;
+	struct sio_par par;
+
+	sio_initpar(&par);
+	par.sig = 1;
+	par.le = SIO_LE_NATIVE;
+	par.bits = format->bits;
+	par.rate = format->rate;
+	par.pchan = format->channels;
+	if (!sio_setpar(hdl, &par))
+		return 0;
+	device->driver_byte_format = AO_FMT_NATIVE;
+	if (!sio_start(hdl))
+		return 0;
+	return 1;
+}
+
+int ao_plugin_play(ao_device *device, const char *output_samples, uint_32 num_bytes)
+{
+	struct sio_hdl *hdl = (struct sio_hdl *)device->internal;
+
+	if (!sio_write(hdl, output_samples, num_bytes))
+		return 0;
+	return 1;
+}
+
+int ao_plugin_close(ao_device *device)
+{
+	struct sio_hdl *hdl = (struct sio_hdl *)device->internal;
+
+	if (!sio_stop(hdl))
+		return 0;
+	return 1;
+}
+
+void ao_plugin_device_clear(ao_device *device)
+{
+	struct sio_hdl *hdl = (struct sio_hdl *)device->internal;
+
+	sio_close(hdl);	
+}
-- 
Christian "naddy" Weisgerber                          naddy at mips.inka.de


More information about the Vorbis-dev mailing list