Hi, This patch adds libsndio to audio/timidity. libsndio is assigned sound output option to '-Os' and set default output.
Thanks. diff -aruN timidity/Makefile timidity-libsndio/Makefile --- timidity/Makefile Thu Nov 22 21:52:34 2007 +++ timidity-libsndio/Makefile Sat Dec 27 11:51:59 2008 @@ -20,12 +20,15 @@ PERMIT_DISTFILES_CDROM= copyrighted patches PERMIT_DISTFILES_FTP= copyrighted patches -WANTLIB= c m ncurses +WANTLIB= c m ncurses sndio -CONFIGURE_STYLE=gnu +CONFIGURE_STYLE=autoconf gnu +AUTOCONF_VERSION = 2.59 +AUTOMAKE_VERSION = 1.9 CONFIGURE_ENV+= CFLAGS="-I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" -CONFIGURE_ARGS= --enable-audio=sun \ +CONFIGURE_ARGS= --enable-audio=libsndio,sun \ + --with-default-output=libsndio \ --enable-vt100 \ --enable-ncurses \ --enable-server \ @@ -61,6 +64,17 @@ WRKDIST= ${WRKDIR} WRKSRC= ${WRKDIR}/${DISTNAME} DATA_DIRS= gsdrum00 gsdrum08 gsdrum40 + +post-patch: + cp ${FILESDIR}/sndio_a.c \ + ${WRKSRC}/timidity/sndio_a.c + cd ${WRKSRC}; AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} aclocal -I autoconf + +pre-configure: + cd ${WRKSRC}; AUTOCONF_VERSION=${AUTOCONF_VERSION} \ + AUTOMAKE_VERSION=${AUTOMAKE_VERSION} automake \ + --foreign --add-missing --copy post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/timidity/goemon diff -aruN timidity/files/sndio_a.c timidity-libsndio/files/sndio_a.c --- timidity/files/sndio_a.c Thu Jan 1 09:00:00 1970 +++ timidity-libsndio/files/sndio_a.c Sat Dec 27 11:20:40 2008 @@ -0,0 +1,124 @@ +/* + TiMidity++ -- MIDI to WAVE converter and player + Copyright (C) 1999-2002 Masanao Izumo <m...@goice.co.jp> + Copyright (C) 1995 Tuukka Toivonen <t...@cgs.fi> + + This program 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 of the License, or + (at your option) any later version. + + This program 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + sndio_a.c + Written by Iwata <ira...@gmail.com> +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ +#include <sndio.h> + +#include "timidity.h" +#include "output.h" +#include "controls.h" +#include "timer.h" +#include "instrum.h" +#include "playmidi.h" +#include "miditrace.h" + +static int open_output(void); /* 0=success, 1=warning, -1=fatal error */ +static void close_output(void); +static int output_data(char *buf, int32 nbytes); +static int acntl(int request, void *arg); + +/* export the playback mode */ + +#define dpm sndio_play_mode + +PlayMode dpm = { + DEFAULT_RATE, PE_SIGNED|PE_16BIT, PF_PCM_STREAM, + -1, + {0}, /* default: get all the buffer fragments you can */ + "Libsndio mode", 's', + NULL, + open_output, + close_output, + output_data, + acntl +}; + +static struct sio_hdl *sndio_ctx; + +static int open_output(void) +{ + static struct sio_par par; + + sndio_ctx = sio_open(NULL, SIO_PLAY, 0); + if (sndio_ctx == NULL) { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", + dpm.name, strerror(errno)); + return -1; + } + + sio_initpar(&par); + + par.sig = 1; + par.pchan = (dpm.encoding & PE_MONO) ? 1 : 2; + par.le = SIO_LE_NATIVE; + par.rate = dpm.rate; + par.bits = (dpm.encoding & PE_24BIT) ? 24 : 0; + par.bits = (dpm.encoding & PE_16BIT) ? 16 : 0; + + if (par.bits == 0) + par.bits = 8; + + if (!sio_setpar(sndio_ctx, &par)) { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", + dpm.name, strerror(errno)); + return -1; + } + + if (!sio_start(sndio_ctx)) { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", + dpm.name, strerror(errno)); + return -1; + } + return 0; +} + +static int output_data(char *buf, int32 nbytes) +{ + if (!sio_write(sndio_ctx, buf, nbytes)) { + ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, "%s: %s", + dpm.name, strerror(errno)); + return -1; + } + return 0; +} + +static void close_output(void) +{ + if (sndio_ctx != NULL) { + sio_close(sndio_ctx); + sndio_ctx = NULL; + } +} + +static int acntl(int request, void *arg) +{ + switch(request) { + case PM_REQ_DISCARD: + case PM_REQ_PLAY_START: /* Called just before playing */ + case PM_REQ_PLAY_END: /* Called just after playing */ + return 0; + } + return -1; +} diff -aruN timidity/patches/patch-TiMidity++-2_13_2_configure timidity-libsndio/patches/patch-TiMidity++-2_13_2_configure --- timidity/patches/patch-TiMidity++-2_13_2_configure Thu Nov 22 21:52:34 2007 +++ timidity-libsndio/patches/patch-TiMidity++-2_13_2_configure Thu Jan 1 09:00:00 1970 @@ -1,28 +0,0 @@ -$OpenBSD: patch-TiMidity++-2_13_2_configure,v 1.2 2007/11/22 12:52:34 ajacoutot Exp $ ---- TiMidity++-2.13.2/configure.orig Sun Oct 3 14:39:51 2004 -+++ TiMidity++-2.13.2/configure Thu Nov 22 09:30:30 2007 -@@ -16190,7 +16190,7 @@ if test "${ac_cv_lib_slang_SLang_init_tty+set}" = set; - echo $ECHO_N "(cached) $ECHO_C" >&6 - else - ac_check_lib_save_LIBS=$LIBS --LIBS="-lslang $LIBS" -+LIBS="-lslang -ltermcap $LIBS" - cat >conftest.$ac_ext <<_ACEOF - /* confdefs.h. */ - _ACEOF -@@ -16426,13 +16426,13 @@ else - ENABLE_SLANG_FALSE= - fi - -- LIBS="$LIBS -lslang" -+ LIBS="$LIBS -lslang -ltermcap" - INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c" - - ;; - xdynamic) - dynamic_targets="$dynamic_targets interface_s.\$(so)" -- s_so_libs="-lslang" -+ s_so_libs="-lslang -ltermcap" - echo "$as_me:$LINENO: checking for initscr in -ltermcap" >&5 - echo $ECHO_N "checking for initscr in -ltermcap... $ECHO_C" >&6 - if test "${ac_cv_lib_termcap_initscr+set}" = set; then diff -aruN timidity/patches/patch-TiMidity++-2_13_2_configure_in timidity-libsndio/patches/patch-TiMidity++-2_13_2_configure_in --- timidity/patches/patch-TiMidity++-2_13_2_configure_in Thu Jan 1 09:00:00 1970 +++ timidity-libsndio/patches/patch-TiMidity++-2_13_2_configure_in Sat Dec 27 11:39:01 2008 @@ -0,0 +1,72 @@ +--- TiMidity++-2.13.2/configure.in.orig Sat Dec 27 11:22:53 2008 ++++ TiMidity++-2.13.2/configure.in Sat Dec 27 11:27:27 2008 +@@ -694,6 +694,7 @@ + dnl gogo(g): MP3 GOGO + dnl jack(j): JACK + dnl ao(O): Libao ++dnl sndio(s): libsndio + + audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 alib nas arts esd vorbis flac gogo portaudio jack ao' + +@@ -722,6 +723,7 @@ + portaudio: PortAudio + jack: JACK + ao: Libao ++ libsndio: Libsndio + vorbis: Ogg Vorbis + flac: FLAC / OggFLAC + speex: Ogg Speex +@@ -746,7 +748,7 @@ + [ --with-default-output=<mode> Specify default output mode (optional): + (default|alsa|alib|arts|nas| + esd|wav|au|aiff|list|vorbis|flac|speex| +- gogo|portaudio|jack|ao)], ++ gogo|portaudio|jack|ao|libsndio)], + [ if test "$enable_audio" != no; then + DEFAULT_PLAYMODE=$withval + eval "au_enable_$DEFAULT_PLAYMODE=yes" +@@ -1158,6 +1160,22 @@ + AC_MSG_RESULT(no) + fi + ++dnl sndio ++AC_MSG_CHECKING(enable_audio=libsndio) ++if test "x$au_enable_libsndio" = xyes; then ++ AC_MSG_RESULT([yes, configuring libsndio]) ++ AC_CHECK_HEADERS(sndio.h) ++ if test "x${ac_cv_header_sndio_h}" = xyes ; then ++ EXTRADEFS="$EXTRADEFS -DAU_LIBSNDIO" ++ SYSEXTRAS="$SYSEXTRAS sndio_a.c" ++ EXTRALIBS="$EXTRALIBS -lsndio" ++ else ++ AC_MSG_WARN(Couldn't configure libsndio.) ++ fi ++else ++ AC_MSG_RESULT(no) ++fi ++ + dnl ogg's vorbis + AC_MSG_CHECKING(enable_audio=vorbis) + if test "x$au_enable_vorbis" = xyes; then +@@ -1304,6 +1322,8 @@ + .speex) TIMIDITY_OUTPUT_ID=S ;; + .gogo) TIMIDITY_OUTPUT_ID=g ;; + .jack) TIMIDITY_OUTPUT_ID=j ;; ++ .ao) TIMIDITY_OUTPUT_ID=O ;; ++ .libsndio) TIMIDITY_OUTPUT_ID=s ;; + *) TIMIDITY_OUTPUT_ID= ;; + esac + AC_MSG_RESULT($DEFAULT_PLAYMODE/$TIMIDITY_OUTPUT_ID) +@@ -1506,10 +1526,10 @@ + ]) + AC_CHECK_HEADERS(slang/slang.h slang.h) + ], +- [ LIBS="$LIBS -lslang" ++ [ LIBS="$LIBS -lslang -ltermcap" + INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c" + ], +- [ s_so_libs="-lslang" ++ [ s_so_libs="-lslang -ltermcap" + AC_CHECK_LIB(termcap,initscr,s_so_libs="$s_so_libs -ltermcap") + ]) + diff -aruN timidity/patches/patch-TiMidity++-2_13_2_timidity_Makefile_am timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_Makefile_am --- timidity/patches/patch-TiMidity++-2_13_2_timidity_Makefile_am Thu Jan 1 09:00:00 1970 +++ timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_Makefile_am Sat Dec 27 11:39:23 2008 @@ -0,0 +1,10 @@ +--- TiMidity++-2.13.2/timidity/Makefile.am.orig Sat Dec 27 11:29:49 2008 ++++ TiMidity++-2.13.2/timidity/Makefile.am Sat Dec 27 11:29:28 2008 +@@ -138,6 +138,7 @@ + mfnode.h \ + nas_a.c \ + portaudio_a.c \ ++ sndio_a.c \ + sun_a.c \ + vorbis_a.c \ + flac_a.c \ diff -aruN timidity/patches/patch-TiMidity++-2_13_2_timidity_freq_c timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_freq_c --- timidity/patches/patch-TiMidity++-2_13_2_timidity_freq_c Thu Jan 1 09:00:00 1970 +++ timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_freq_c Sat Dec 27 12:00:29 2008 @@ -0,0 +1,11 @@ +--- TiMidity++-2.13.2/timidity/freq.c.orig Sat Dec 27 11:59:06 2008 ++++ TiMidity++-2.13.2/timidity/freq.c Sat Dec 27 11:59:19 2008 +@@ -371,7 +371,7 @@ + /* go out 2 zero crossings in both directions, starting at maxpos */ + /* find the peaks after the 2nd crossing */ + minoffset1 = 0; +- for (n = 0, oldamp = origdata[maxpos], i = maxpos - 1; i >= 0 && n < 2; i--) ++ for (n = 0, oldamp = origdata[maxpos], i = maxpos - 1; i > 0 && n < 2; i--) + { + amp = origdata[i]; + if ((oldamp && amp == 0) || (oldamp > 0 && amp < 0) || diff -aruN timidity/patches/patch-TiMidity++-2_13_2_timidity_output_c timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_output_c --- timidity/patches/patch-TiMidity++-2_13_2_timidity_output_c Thu Jan 1 09:00:00 1970 +++ timidity-libsndio/patches/patch-TiMidity++-2_13_2_timidity_output_c Sat Dec 27 11:40:12 2008 @@ -0,0 +1,35 @@ +--- TiMidity++-2.13.2/timidity/output.c.orig Sat Dec 27 11:31:23 2008 ++++ TiMidity++-2.13.2/timidity/output.c Sat Dec 27 11:32:11 2008 +@@ -112,6 +112,10 @@ + extern PlayMode ao_play_mode; + #endif /* AU_AO */ + ++#ifdef AU_LIBSNDIO ++extern PlayMode sndio_play_mode; ++#endif /* AU_LIBSNDIO */ ++ + #ifndef __MACOS__ + /* These are always compiled in. */ + extern PlayMode raw_play_mode, wave_play_mode, au_play_mode, aiff_play_mode; +@@ -165,7 +169,7 @@ + + #if defined(AU_JACK) + &jack_play_mode, +-#endif /* AU_PORTAUDIO */ ++#endif /* AU_JACK */ + + #if defined(AU_NAS) + &nas_play_mode, +@@ -173,7 +177,11 @@ + + #if defined(AU_AO) + &ao_play_mode, +-#endif /* AU_PORTAUDIO */ ++#endif /* AU_AO */ ++ ++#if defined(AU_LIBSNDIO) ++ &sndio_play_mode, ++#endif /* AU_LIBSNDIO */ + + #ifndef __MACOS__ + &wave_play_mode,