On Wed, Jul 15, 2009 at 01:13:11AM +0300, 4625 wrote:
> On OpenBSD timidity reproduce garbled sound, like when CPU overloaded. 
> However, the same version of timidity on FreeBSD-4.11 play files very 
> well.
> 
> OpenBSD localhost 4.5 200907101811#0 i386
> timidity-2.13.2p1

can you try this please?  this adds sndio support.  iirc, it was sent
to ports@ some onths ago by ray iwata.  I don't recall why it wasn't
committed though.  I personally don't use timidity, but really basic
usage works for me.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/timidity/Makefile,v
retrieving revision 1.32
diff -N -u -p Makefile
--- Makefile    22 Nov 2007 12:52:34 -0000      1.32
+++ Makefile    15 Jul 2009 05:22:18 -0000
@@ -20,12 +20,13 @@ PERMIT_PACKAGE_FTP=     copyrighted patches
 PERMIT_DISTFILES_CDROM= copyrighted patches
 PERMIT_DISTFILES_FTP=   copyrighted patches
 
-WANTLIB=               c m ncurses 
+WANTLIB=               c m ncurses sndio
 
-CONFIGURE_STYLE=gnu
-CONFIGURE_ENV+=        CFLAGS="-I${LOCALBASE}/include" \
-               LDFLAGS="-L${LOCALBASE}/lib"
-CONFIGURE_ARGS= --enable-audio=sun \
+CONFIGURE_STYLE=autoconf gnu
+AUTOCONF_VERSION = 2.59
+AUTOMAKE_VERSION = 1.9
+CONFIGURE_ARGS= --enable-audio=sndio,sun \
+               --with-default-output=sndio \
                --enable-vt100 \
                --enable-ncurses \
                --enable-server \
@@ -41,8 +42,9 @@ USE_X11=      Yes
 LIB_DEPENDS+=  gdk-x11-2.0,gdk_pixbuf-2.0,gtk-x11-2.0::x11/gtk+2
 WANTLIB+=      X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes \
                Xi Xinerama Xrandr Xrender atk-1.0 cairo expat \
-               fontconfig freetype glib-2.0 glitz gmodule-2.0 \
-               gobject-2.0 pango-1.0 pangocairo-1.0 pangoft2-1.0 png z
+               fontconfig freetype glib-2.0 glitz gio-2.0 gmodule-2.0 \
+               gobject-2.0 pango-1.0 pangocairo-1.0 pangoft2-1.0 \
+               pixman-1 png z
 .endif
 
 .if ${FLAVOR:L:Mxaw}
@@ -61,6 +63,17 @@ NO_REGRESS=  Yes
 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
Index: files/sndio_a.c
===================================================================
RCS file: files/sndio_a.c
diff -N -u -p files/sndio_a.c
--- /dev/null   14 Jul 2009 23:22:18 -0000
+++ files/sndio_a.c     15 Jul 2009 05:22:18 -0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2008 IWATA Ray <iw...@quasiquote.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.
+ */
+
+#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 */
+  "sndio 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, "sio_open() failed");
+    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, "sio_setpar() failed");
+    return -1;
+  }
+
+  if (sio_getpar(sndio_ctx, &par) == 0) {
+    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_getpar() failed");
+    return -1;
+  }
+
+  if (!sio_start(sndio_ctx)) {
+    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_start() failed");
+    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, "sio_write() failed");
+    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;
+}
+
Index: patches/patch-TiMidity++-2_13_2_configure
===================================================================
RCS file: /cvs/ports/audio/timidity/patches/patch-TiMidity++-2_13_2_configure,v
retrieving revision 1.2
diff -N -u -p patches/patch-TiMidity++-2_13_2_configure
--- patches/patch-TiMidity++-2_13_2_configure   22 Nov 2007 12:52:34 -0000      
1.2
+++ /dev/null   15 Jul 2009 04:31:02 -0000
@@ -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
Index: patches/patch-TiMidity++-2_13_2_configure_in
===================================================================
RCS file: patches/patch-TiMidity++-2_13_2_configure_in
diff -N -u -p patches/patch-TiMidity++-2_13_2_configure_in
--- /dev/null   14 Jul 2009 23:22:18 -0000
+++ patches/patch-TiMidity++-2_13_2_configure_in        15 Jul 2009 05:22:18 
-0000
@@ -0,0 +1,84 @@
+--- TiMidity++-2.13.2/configure.in.orig        Sun Oct  3 05:39:52 2004
++++ TiMidity++-2.13.2/configure.in     Tue Mar 24 01:31:03 2009
+@@ -81,7 +81,7 @@ if test "x$timidity_cv_debug" = "xno"; then
+ fi
+ AC_MSG_RESULT($timidity_cv_debug)
+ 
+-CFLAGS=${CFLAGS-"-O2"}
++dnl CFLAGS=${CFLAGS-"-O2"}
+ 
+ dnl --with-x turns on if `--with-x' is NOT specified.
+ if test "x$with_x" = x; then
+@@ -694,8 +694,9 @@ dnl speex(S):   Ogg Speex
+ dnl gogo(g):    MP3 GOGO
+ dnl jack(j):    JACK
+ dnl ao(O):      Libao
++dnl sndio(s):   sndio
+ 
+-audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 alib nas arts 
esd vorbis flac gogo portaudio jack ao'
++audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 alib nas arts 
esd vorbis flac gogo portaudio jack ao sndio'
+ 
+ AC_ARG_WITH(nas-library,
+   [  --with-nas-library=library NAS absolute library path(Don't use -laudio)])
+@@ -722,6 +723,7 @@ AC_ARG_ENABLE(audio,
+                               portaudio: PortAudio
+                               jack:      JACK
+                               ao:        Libao
++                              sndio:     Sndio
+                               vorbis:    Ogg Vorbis
+                               flac:      FLAC / OggFLAC
+                               speex:     Ogg Speex
+@@ -746,7 +748,7 @@ AC_ARG_WITH(default-output,
+   [  --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|sndio)],
+   [ if test "$enable_audio" != no; then
+     DEFAULT_PLAYMODE=$withval
+     eval "au_enable_$DEFAULT_PLAYMODE=yes"
+@@ -1158,6 +1160,22 @@ else
+   AC_MSG_RESULT(no)
+ fi
+ 
++dnl sndio
++AC_MSG_CHECKING(enable_audio=sndio)
++if test "x$au_enable_sndio" = xyes; then
++  AC_MSG_RESULT([yes, configuring sndio])
++  AC_CHECK_HEADERS(sndio.h)
++  if test "x${ac_cv_header_sndio_h}" = xyes ; then
++    EXTRADEFS="$EXTRADEFS -DAU_SNDIO"
++    SYSEXTRAS="$SYSEXTRAS sndio_a.c"
++    EXTRALIBS="$EXTRALIBS -lsndio"
++  else
++    AC_MSG_WARN(Couldn't configure sndio.)
++  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 @@ case ".$DEFAULT_PLAYMODE" in
+   .speex)    TIMIDITY_OUTPUT_ID=S ;;
+   .gogo)     TIMIDITY_OUTPUT_ID=g ;;
+   .jack)     TIMIDITY_OUTPUT_ID=j ;;
++  .ao)       TIMIDITY_OUTPUT_ID=O ;;
++  .sndio)    TIMIDITY_OUTPUT_ID=s ;;
+   *)         TIMIDITY_OUTPUT_ID= ;;
+ esac
+ AC_MSG_RESULT($DEFAULT_PLAYMODE/$TIMIDITY_OUTPUT_ID)
+@@ -1506,10 +1526,10 @@ CONFIG_INTERFACE(slang,SLANG,s,
+     ])
+     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")
+   ])
+ 
Index: patches/patch-TiMidity++-2_13_2_timidity_Makefile_am
===================================================================
RCS file: patches/patch-TiMidity++-2_13_2_timidity_Makefile_am
diff -N -u -p patches/patch-TiMidity++-2_13_2_timidity_Makefile_am
--- /dev/null   14 Jul 2009 23:22:18 -0000
+++ patches/patch-TiMidity++-2_13_2_timidity_Makefile_am        15 Jul 2009 
05:22:18 -0000
@@ -0,0 +1,10 @@
+--- TiMidity++-2.13.2/timidity/Makefile.am.orig        Mon May 31 17:05:29 2004
++++ TiMidity++-2.13.2/timidity/Makefile.am     Tue Mar 24 01:00:25 2009
+@@ -138,6 +138,7 @@ EXTRA_timidity_SOURCES = \
+       mfnode.h \
+       nas_a.c \
+       portaudio_a.c \
++      sndio_a.c \
+       sun_a.c \
+       vorbis_a.c \
+       flac_a.c \
Index: patches/patch-TiMidity++-2_13_2_timidity_freq_c
===================================================================
RCS file: patches/patch-TiMidity++-2_13_2_timidity_freq_c
diff -N -u -p patches/patch-TiMidity++-2_13_2_timidity_freq_c
--- /dev/null   14 Jul 2009 23:22:18 -0000
+++ patches/patch-TiMidity++-2_13_2_timidity_freq_c     15 Jul 2009 05:22:18 
-0000
@@ -0,0 +1,11 @@
+--- TiMidity++-2.13.2/timidity/freq.c.orig     Tue Sep  7 07:27:26 2004
++++ TiMidity++-2.13.2/timidity/freq.c  Tue Mar 24 01:00:15 2009
+@@ -371,7 +371,7 @@ float freq_fourier(Sample *sp, int *chord)
+     /* 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) ||
Index: patches/patch-TiMidity++-2_13_2_timidity_output_c
===================================================================
RCS file: patches/patch-TiMidity++-2_13_2_timidity_output_c
diff -N -u -p patches/patch-TiMidity++-2_13_2_timidity_output_c
--- /dev/null   14 Jul 2009 23:22:18 -0000
+++ patches/patch-TiMidity++-2_13_2_timidity_output_c   15 Jul 2009 05:22:18 
-0000
@@ -0,0 +1,35 @@
+--- TiMidity++-2.13.2/timidity/output.c.orig   Thu May 13 18:32:34 2004
++++ TiMidity++-2.13.2/timidity/output.c        Tue Mar 24 01:00:15 2009
+@@ -112,6 +112,10 @@ extern PlayMode nas_play_mode;
+ extern PlayMode ao_play_mode;
+ #endif /* AU_AO */
+ 
++#ifdef AU_SNDIO
++extern PlayMode sndio_play_mode;
++#endif /* AU_SNDIO */
++
+ #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 @@ PlayMode *play_mode_list[] = {
+ 
+ #if defined(AU_JACK)
+   &jack_play_mode,
+-#endif /* AU_PORTAUDIO */
++#endif /* AU_JACK */
+ 
+ #if defined(AU_NAS)
+   &nas_play_mode,
+@@ -173,7 +177,11 @@ PlayMode *play_mode_list[] = {
+ 
+ #if defined(AU_AO)
+   &ao_play_mode,
+-#endif /* AU_PORTAUDIO */
++#endif /* AU_AO */
++
++#if defined(AU_SNDIO)
++  &sndio_play_mode,
++#endif /* AU_SNDIO */
+ 
+ #ifndef __MACOS__
+   &wave_play_mode,
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/audio/timidity/pkg/PLIST,v
retrieving revision 1.6
diff -N -u -p pkg/PLIST
--- pkg/PLIST   22 Nov 2007 12:52:34 -0000      1.6
+++ pkg/PLIST   15 Jul 2009 05:22:18 -0000
@@ -1,5 +1,5 @@
 @comment $OpenBSD: PLIST,v 1.6 2007/11/22 12:52:34 ajacoutot Exp $
-bin/timidity
+...@bin bin/timidity
 @man man/man1/timidity.1
 @man man/man5/timidity.cfg.5
 share/examples/timidity/

Reply via email to