This diff adds an sndio backend to audio/flite. After patching, remove the now empty patches/patch-configure and patches/patch-src_audio_au_sun.c. Tested OK on amd64.
I'll ask upstream for inclusion unless anyone experience problems or have any comments. Oh, and you might need to increase your ulimit -d for this to compile ... Comments, OK? Index: ports/flite/Makefile diff -u ports/flite/Makefile:1.1.1.1 ports/flite/Makefile:1.11 --- ports/flite/Makefile:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/Makefile Sat Apr 25 12:20:14 2009 @@ -1,47 +1,57 @@ # $OpenBSD: Makefile,v 1.10 2008/01/04 17:48:33 espie Exp $ -COMMENT= text to speech utility +COMMENT = text to speech utility .if ${MACHINE_ARCH} == "hppa" || ${MACHINE_ARCH} == "mips64" -BROKEN= gcc hang compiling cmu_us_kal_diphone.c +BROKEN = gcc hang compiling cmu_us_kal_diphone.c .endif -VERSION= 1.2 -DISTNAME= flite-${VERSION}-release -PKGNAME= flite-${VERSION}p1 -SHARED_LIBS= flite 1.2 \ +VERSION = 1.2 +DISTNAME = flite-${VERSION}-release +PKGNAME = flite-${VERSION}p2 +SHARED_LIBS = flite 1.2 \ flite_cmu_time_awb 1.2 \ flite_cmu_us_kal 1.2 \ flite_cmu_us_kal16 1.2 \ flite_cmulex 1.2 \ flite_usenglish 1.2 -MAKE_FLAGS= LIBlibflite.so_VERSION=${LIBflite_VERSION} \ +MAKE_FLAGS = LIBlibflite.so_VERSION=${LIBflite_VERSION} \ LIBlibflite_cmu_time_awb.so_VERSION=${LIBflite_cmu_time_awb_VERSION} \ LIBlibflite_cmu_us_kal.so_VERSION=${LIBflite_cmu_us_kal_VERSION} \ LIBlibflite_cmu_us_kal16.so_VERSION=${LIBflite_cmu_us_kal16_VERSION} \ LIBlibflite_cmulex.so_VERSION=${LIBflite_cmulex_VERSION} \ LIBlibflite_usenglish.so_VERSION=${LIBflite_usenglish_VERSION} -CATEGORIES= audio +CATEGORIES = audio -HOMEPAGE= http://www.cmuflite.org/ +HOMEPAGE = http://www.cmuflite.org/ -MAINTAINER= Jason L. Wright <ja...@openbsd.org> +MAINTAINER = Jason L. Wright <ja...@openbsd.org> -PERMIT_PACKAGE_CDROM= Yes -PERMIT_PACKAGE_FTP= Yes -PERMIT_DISTFILES_CDROM= Yes -PERMIT_DISTFILES_FTP= Yes -WANTLIB= c m +PERMIT_PACKAGE_CDROM = Yes +PERMIT_PACKAGE_FTP = Yes +PERMIT_DISTFILES_CDROM = Yes +PERMIT_DISTFILES_FTP = Yes -MASTER_SITES= http://www.speech.cs.cmu.edu/flite/packed/flite-${VERSION}/ +WANTLIB = c m sndio -CONFIGURE_STYLE= gnu dest -CONFIGURE_ARGS= ${CONFIGURE_SHARED} +AUTOCONF_VERSION = 2.59 +BUILD_DEPENDS = ${MODGNU_AUTOCONF_DEPENDS} -USE_GMAKE= Yes -NO_REGRESS= Yes -VMEM_WARNING= Yes +MASTER_SITES = http://www.speech.cs.cmu.edu/flite/packed/flite-${VERSION}/ + +CONFIGURE_STYLE = gnu dest +CONFIGURE_ARGS = ${CONFIGURE_SHARED} + +USE_GMAKE = Yes +NO_REGRESS = Yes +VMEM_WARNING = Yes + +post-extract: + @cp ${FILESDIR}/au_sndio.c ${WRKSRC}/src/audio/ + +pre-configure: + @cd ${WRKSRC} && env AUTOCONF_VERSION=${AUTOCONF_VERSION} autoconf .include <bsd.port.mk> Index: ports/flite/files/au_sndio.c diff -u /dev/null ports/flite/files/au_sndio.c:1.16 --- /dev/null Sat Apr 25 12:30:34 2009 +++ ports/flite/files/au_sndio.c Sat Apr 25 12:30:01 2009 @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2009 Thomas Pfaff <tpf...@tp76.info> + * + * 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 <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <sndio.h> + +#include "cst_string.h" +#include "cst_wave.h" +#include "cst_audio.h" + +static const char *sndio_audio_device = NULL; + +cst_audiodev *audio_open_sndio (int, int, cst_audiofmt); +int audio_close_sndio (cst_audiodev *); +int audio_write_sndio (cst_audiodev *, void *, int); +int audio_flush_sndio (cst_audiodev *); +int audio_drain_sndio (cst_audiodev *); + +static int par_ok (const struct sio_par *, const struct sio_par *); + +static struct sio_hdl *hdl; + +cst_audiodev * +audio_open_sndio (int sps, int channels, cst_audiofmt fmt) +{ + struct sio_par par; + struct sio_par askpar; + cst_audiodev *ad; + + hdl = sio_open (sndio_audio_device, SIO_PLAY, 0); + if (hdl == NULL) { + cst_errmsg ("sndio_audio: failed to open audio device\n"); + cst_error (); + } + + ad = cst_alloc (cst_audiodev, 1); + ad->sps = sps; + ad->channels = channels; + ad->fmt = fmt; + ad->platform_data = NULL; + + if (ad->channels == 0) + ad->channels = 1; + + sio_initpar (&par); switch (fmt) { + case CST_AUDIO_LINEAR16: + par.bits = 16; + par.sig = 1; + par.le = SIO_LE_NATIVE; + break; + case CST_AUDIO_LINEAR8: + par.bits = 8; + par.sig = 0; + par.le = 0; + break; + case CST_AUDIO_MULAW: + cst_errmsg ("sndio_audio: audio format not supported\n"); + goto error; + default: + cst_errmsg ("sndio_audio: unknown format requested\n"); + goto error; + } + par.pchan = channels; + par.rate = sps; + + /* 250 ms buffer */ + par.appbufsz = par.rate / 4; + + askpar = par; + if (!sio_setpar (hdl, &par) || !sio_getpar (hdl, &par)) { + cst_errmsg ("sndio_audio: failed to set parameters\n"); + goto error; + } + + if (!par_ok (&par, &askpar)) { + cst_errmsg ("sndio_audio: parameters not supported\n"); + goto error; + } + + ad->real_sps = par.rate; + ad->real_channels = par.pchan; + + if (!sio_start (hdl)) { + cst_errmsg ("sndio_audio: failed to start audio device\n"); + goto error; + } + return ad; + +error: + audio_close_sndio (ad); + cst_error (); + return NULL; +} + +int +audio_close_sndio (cst_audiodev *ad) +{ + if (ad == NULL) + return 0; + + sio_close (hdl); + cst_free (ad); + return 0; +} + +int +audio_write_sndio (cst_audiodev *ad, void *samples, int num_bytes) +{ + return sio_write (hdl, samples, num_bytes); +} + +int +audio_flush_sndio (cst_audiodev *ad) +{ + return 1; +} + +int +audio_drain_sndio (cst_audiodev *ad) +{ + return 1; +} + +static int +par_ok (const struct sio_par *got, const struct sio_par *ask) +{ + if ((got->bits != ask->bits) || + (got->bits == 16 && got->le != ask->le) || + (got->sig != ask->sig) || + (got->pchan != ask->pchan) || + ((got->rate * 1000 < ask->rate * 995) || + (got->rate * 1000 > ask->rate * 1005))) + return 0; + return 1; +} Index: ports/flite/patches/patch-configure diff -u ports/flite/patches/patch-configure:1.1.1.1 ports/flite/patches/patch-configure:removed --- ports/flite/patches/patch-configure:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/patches/patch-configure Sat Apr 25 12:30:34 2009 @@ -1,13 +0,0 @@ -$OpenBSD: patch-configure,v 1.1.1.1 2003/04/23 05:33:19 jason Exp $ ---- configure.orig Sun Apr 20 23:05:35 2003 -+++ configure Sun Apr 20 23:04:27 2003 -@@ -1120,6 +1120,9 @@ if test "$shared" = true; then - SHFLAGS="-fPIC" - OTHERLIBS="-lsocket -ldl" - ;; -+ openbsd*) -+ SHFLAGS="-shared -fPIC" -+ ;; - *) - ;; - esac Index: ports/flite/patches/patch-configure_in diff -u ports/flite/patches/patch-configure_in:1.1.1.1 ports/flite/patches/patch-configure_in:1.4 --- ports/flite/patches/patch-configure_in:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/patches/patch-configure_in Fri Apr 24 19:43:15 2009 @@ -1,6 +1,6 @@ $OpenBSD: patch-configure_in,v 1.1.1.1 2003/04/23 05:33:19 jason Exp $ ---- configure.in.orig Sun Apr 20 23:05:32 2003 -+++ configure.in Sun Apr 20 23:04:58 2003 +--- configure.in.orig Tue Feb 18 01:45:45 2003 ++++ configure.in Fri Apr 24 21:28:37 2009 @@ -68,6 +68,9 @@ if test "$shared" = true; then SHFLAGS="-fPIC" OTHERLIBS="-lsocket -ldl" @@ -11,3 +11,25 @@ *) ;; esac +@@ -138,6 +141,10 @@ AC_CHECK_HEADER(mmsystem.h, + [AUDIODRIVER="wince" + AUDIODEFS=-DCST_AUDIO_WINCE + AUDIOLIBS=-lwinmm]) ++AC_CHECK_HEADER(sndio.h, ++ [AUDIODRIVER="sndio" ++ AUDIODEFS=-DCST_AUDIO_SNDIO ++ AUDIOLIBS=-lsndio]) + + dnl + dnl allow the user to override the one detected above +@@ -152,6 +159,10 @@ if test "x$AUDIODEFS" = x; then + AUDIODRIVER=oss + AUDIODEFS=-DCST_AUDIO_LINUX + ;; ++ sndio) ++ AUDIODRIVER=sndio ++ AUDIODEFS=-DCST_AUDIO_SNDIO ++ ;; + *bsd) + AUDIODRIVER=oss + AUDIODEFS=-DCST_AUDIO_FREEBSD Index: ports/flite/patches/patch-main_flite_main_c diff -u ports/flite/patches/patch-main_flite_main_c:1.1.1.1 ports/flite/patches/patch-main_flite_main_c:1.2 --- ports/flite/patches/patch-main_flite_main_c:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/patches/patch-main_flite_main_c Sat Apr 25 12:22:01 2009 @@ -1,6 +1,6 @@ $OpenBSD: patch-main_flite_main_c,v 1.1 2006/12/28 11:47:23 espie Exp $ ---- main/flite_main.c.orig Thu Dec 28 12:45:59 2006 -+++ main/flite_main.c Thu Dec 28 12:46:57 2006 +--- main/flite_main.c.orig Sun Dec 29 23:48:34 2002 ++++ main/flite_main.c Sat Apr 25 01:27:43 2009 @@ -58,6 +58,8 @@ static void flite_version() FLITE_PROJECT_STATE, FLITE_PROJECT_DATE); Index: ports/flite/patches/patch-src_audio_Makefile diff -u /dev/null ports/flite/patches/patch-src_audio_Makefile:1.2 --- /dev/null Sat Apr 25 12:30:34 2009 +++ ports/flite/patches/patch-src_audio_Makefile Fri Apr 24 21:40:49 2009 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- src/audio/Makefile.orig Sun Feb 16 19:49:27 2003 ++++ src/audio/Makefile Fri Apr 24 23:36:56 2009 +@@ -45,7 +45,7 @@ BASESRCS = auclient.c auserver.c audio.c + SRCS = $(BASESRCS) $(AUDIODRIVER:%=au_%.c) + OBJS = $(SRCS:.c=.o) + FILES = Makefile $(H) $(BASESRCS) au_alsa.c au_command.c au_none.c \ +- au_oss.c au_sun.c au_wince.c ++ au_oss.c au_sndio.c au_wince.c + LIBNAME = flite + + LOCAL_INCLUDES = -I. $(AUDIODEFS) Index: ports/flite/patches/patch-src_audio_au_sun_c diff -u ports/flite/patches/patch-src_audio_au_sun_c:1.1.1.1 ports/flite/patches/patch-src_audio_au_sun_c:removed --- ports/flite/patches/patch-src_audio_au_sun_c:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/patches/patch-src_audio_au_sun_c Sat Apr 25 12:30:34 2009 @@ -1,23 +0,0 @@ -$OpenBSD: patch-src_audio_au_sun_c,v 1.1.1.1 2003/04/23 05:33:19 jason Exp $ ---- src/audio/au_sun.c.orig Mon Jan 7 18:25:52 2002 -+++ src/audio/au_sun.c Sun Apr 20 18:12:34 2003 -@@ -45,6 +45,7 @@ - #include <sys/stat.h> - #include <fcntl.h> - #include <errno.h> -+#include <sys/ioctl.h> - #include <sys/filio.h> - #include <sys/audioio.h> - #include "cst_string.h" -@@ -76,7 +77,11 @@ cst_audiodev *audio_open_sun(int sps, in - cst_error(); - } - } -+#ifdef __OpenBSD__ -+ AUDIO_INITINFO(&ainfo); -+#else - ioctl(fd,AUDIO_GETINFO,&ainfo); -+#endif - - switch (fmt) - { Index: ports/flite/patches/patch-src_audio_native_audio_h diff -u /dev/null ports/flite/patches/patch-src_audio_native_audio_h:1.2 --- /dev/null Sat Apr 25 12:30:34 2009 +++ ports/flite/patches/patch-src_audio_native_audio_h Fri Apr 24 20:28:00 2009 @@ -0,0 +1,21 @@ +$OpenBSD$ +--- src/audio/native_audio.h.orig Thu Sep 26 21:46:03 2002 ++++ src/audio/native_audio.h Fri Apr 24 22:24:07 2009 +@@ -107,6 +107,17 @@ + + #endif + ++#ifdef CST_AUDIO_SNDIO ++ ++#define AUDIO_OPEN_NATIVE audio_open_sndio ++#define AUDIO_CLOSE_NATIVE audio_close_sndio ++#define AUDIO_SET_SAMPLE_RATE_NATIVE audio_set_sample_rate_sndio ++#define AUDIO_WRITE_NATIVE audio_write_sndio ++#define AUDIO_DRAIN_NATIVE audio_drain_sndio ++#define AUDIO_FLUSH_NATIVE audio_flush_sndio ++ ++#endif ++ + #ifdef CST_AUDIO_NONE + + #define AUDIO_OPEN_NATIVE audio_open_none Index: ports/flite/patches/patch-tools_find_sts_main_c diff -u ports/flite/patches/patch-tools_find_sts_main_c:1.1.1.1 ports/flite/patches/patch-tools_find_sts_main_c:1.2 --- ports/flite/patches/patch-tools_find_sts_main_c:1.1.1.1 Fri Apr 24 14:48:50 2009 +++ ports/flite/patches/patch-tools_find_sts_main_c Fri Apr 24 16:33:45 2009 @@ -1,7 +1,7 @@ $OpenBSD: patch-tools_find_sts_main_c,v 1.1 2004/12/13 11:59:48 espie Exp $ ---- tools/find_sts_main.c.orig Mon Dec 13 12:55:55 2004 -+++ tools/find_sts_main.c Mon Dec 13 12:58:01 2004 -@@ -75,6 +75,11 @@ cst_sts *find_sts(cst_wave *sig, cst_tra +--- tools/find_sts_main.c.orig Thu Dec 26 18:18:30 2002 ++++ tools/find_sts_main.c Fri Apr 24 18:29:03 2009 +@@ -75,6 +75,11 @@ cst_sts *find_sts(cst_wave *sig, cst_track *lpc) double *resd; int size,start,end; short *sigplus; @@ -13,7 +13,7 @@ sts = cst_alloc(cst_sts,lpc->num_frames); start = 0; -@@ -93,14 +98,16 @@ cst_sts *find_sts(cst_wave *sig, cst_tra +@@ -93,14 +98,16 @@ cst_sts *find_sts(cst_wave *sig, cst_track *lpc) lpc->frames[i],lpc->num_channels, resd, size);