please test ... and notice how much simpler this is than what it replaces, even though esound prefers to use a fd for audio access.
-- jake...@sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org Index: Makefile =================================================================== RCS file: /cvs/ports/audio/esound/Makefile,v retrieving revision 1.44 diff -u -r1.44 Makefile --- Makefile 31 Mar 2008 01:05:54 -0000 1.44 +++ Makefile 11 Dec 2008 20:36:52 -0000 @@ -4,7 +4,7 @@ COMMENT= sound library for Enlightenment DISTNAME= esound-0.2.38 -PKGNAME= ${DISTNAME}v0 +PKGNAME= ${DISTNAME}p0v0 SHARED_LIBS += esd 2.40 # .2.38 CATEGORIES= audio MASTER_SITES= ${MASTER_SITE_GNOME:=sources/esound/0.2/} @@ -18,7 +18,7 @@ PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes -WANTLIB= c m wrap +WANTLIB= c m sndio wrap FLAVORS= arts FLAVOR?= @@ -47,7 +47,7 @@ esdconfdir=${PREFIX}/share/examples/esound post-extract: - @cp -f ${FILESDIR}/audio_sun.c ${WRKSRC} + @cp -f ${FILESDIR}/audio_sndio.c ${WRKSRC} pre-configure: @perl -pi -e 's|_LOCALBASE_|${LOCALBASE}|' \ Index: files/audio_sndio.c =================================================================== RCS file: files/audio_sndio.c diff -N files/audio_sndio.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/audio_sndio.c 11 Dec 2008 20:36:52 -0000 @@ -0,0 +1,112 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2008 Jacob Meuser <jake...@sdf.lonestar.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Neither the name of CubeSoft Communications, nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include <sndio.h> + +struct sio_hdl *hdl = NULL; + +#define ARCH_esd_audio_open +int esd_audio_open() +{ + char *device; + struct sio_par par; + int mode = SIO_PLAY; + + sio_initpar(&par); + + if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) + mode |= SIO_REC; + + device = esd_audio_device ? esd_audio_device : getenv("AUDIODEVICE"); + if ((hdl = sio_open(device, mode, 0)) == NULL) { + fprintf(stderr, "sio_open failed\n"); + return( -2 ); + } + + if ((esd_audio_format & ESD_MASK_BITS) == ESD_BITS16) { + par.bits = 16; + par.sig = 1; + par.le = (BYTE_ORDER == 4321) ? 0 : 1; + } else { + par.bits = 8; + par.sig = 0; + par.le = (BYTE_ORDER == 4321) ? 0: 1; + } + + par.pchan = (((esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1); + if (mode & SIO_REC) + par.rchan = par.pchan; + + par.bufsz = ESD_BUF_SIZE; + + par.rate = esd_audio_rate; + + if (!sio_setpar(hdl, &par)) { + fprintf(stderr, "sio_setpar failed\n"); + return(-1); + } + + if (!sio_getpar(hdl, &par)) { + fprintf(stderr, "sio_getpar failed\n"); + return(-1); + } + + if (fabs(par.rate - esd_audio_rate) > esd_audio_rate * 0.05) { + fprintf(stderr, "Unsupported rate: %i Hz\n", esd_audio_rate); + return(-1); + } + + if (!sio_start(hdl)) { + fprintf(stderr, "sio_start failed\n"); + return(-1); + } + + return(1); +} + +#define ARCH_esd_audio_close +void esd_audio_close() +{ + if (hdl != NULL) { + sio_close(hdl); + hdl = NULL; + } +} + +#define ARCH_esd_audio_write +int esd_audio_write(void *buffer, int buf_size) +{ + return sio_write(hdl, buffer, buf_size); +} + +#define ARCH_esd_audio_read +int esd_audio_read(void *buffer, int buf_size) +{ + return sio_read(hdl, buffer, buf_size); +} Index: files/audio_sun.c =================================================================== RCS file: files/audio_sun.c diff -N files/audio_sun.c --- files/audio_sun.c 31 Mar 2008 01:05:54 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,165 +0,0 @@ -/* $OpenBSD: audio_sun.c,v 1.4 2008/03/31 01:05:54 jakemsr Exp $ */ - -/* - * Copyright (c) 2002 CubeSoft Communications, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Neither the name of CubeSoft Communications, nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/audioio.h> -#include <string.h> - -static void sun_panic(int fd, char *s) -{ - perror(s); - close(fd); - esd_audio_fd = -1; -} - -#define ARCH_esd_audio_devices -const char *esd_audio_devices() -{ - return "/dev/audio"; -} - - -#define ARCH_esd_audio_open -int esd_audio_open() -{ - const char *device; - int afd = -1; - int fmt = 0, channels = 0, bits = 0; - int mode = O_WRONLY; - audio_info_t info; - - AUDIO_INITINFO(&info); - - /* set the appropriate mode */ - if((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) { - mode = O_RDWR; - info.mode = AUMODE_PLAY | AUMODE_PLAY_ALL | AUMODE_RECORD; - } else { - info.mode = AUMODE_PLAY | AUMODE_PLAY_ALL; - } - - /* open the sound device */ - device = esd_audio_device ? esd_audio_device : "/dev/audio"; - if ((afd = open(device, mode, 0)) == -1) { - perror(device); - return( -2 ); - } - - /* set the requested mode */ - if(ioctl(afd, AUDIO_SETINFO, &info) < 0) { - sun_panic(afd, "AUDIO_SETINFO"); - return(-1); - } - - /* set full-duplex mode if we are recording */ - if ( (esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD ) { - if (ioctl(afd, AUDIO_SETFD, 1) == -1) { - sun_panic(afd, "AUDIO_SETFD"); - return(-1); - } - } - - /* pick a supported encoding */ - if ((esd_audio_format & ESD_MASK_BITS) == ESD_BITS16) { - bits = 16; - fmt = (BYTE_ORDER == 4321) ? - AUDIO_ENCODING_SLINEAR_BE : AUDIO_ENCODING_SLINEAR_LE; - } else { - bits = 8; - fmt = (BYTE_ORDER == 4321) ? - AUDIO_ENCODING_ULINEAR_BE : AUDIO_ENCODING_ULINEAR_LE; - } - info.play.encoding = fmt; - info.play.precision = bits; - if(ioctl(afd, AUDIO_SETINFO, &info) == -1) { - fprintf(stderr, "Unsupported encoding: %i-bit (0x%x)\n", - bits, fmt); - sun_panic(afd, "SETINFO"); - return(-1); - } - - /* number of channels */ - channels = (((esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO) - ? /* stereo */ 2 - : /* mono */ 1); - - info.play.channels = channels; - if((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) { - info.record.channels = channels; - } - if(ioctl(afd, AUDIO_SETINFO, &info) == -1) { - fprintf(stderr, "Unsupported channel count: %d\n", - channels); - sun_panic(afd, "SETINFO"); - return(-1); - } - - /* blocksize, sync to internal esd buffer size */ - info.blocksize = ESD_BUF_SIZE; - info.hiwat = 4; - if(ioctl(afd, AUDIO_SETINFO, &info) < 0) { - fprintf(stderr, "Unsupported blocksize: %d\n", - info.blocksize); - sun_panic(afd, "SETINFO"); - return(-1); - } - - /* finally, set the sample rate */ - info.play.sample_rate = esd_audio_rate; - if(ioctl(afd, AUDIO_SETINFO, &info) < 0 || - fabs(info.play.sample_rate - esd_audio_rate) > esd_audio_rate * 0.05) { - fprintf(stderr, "Unsupported rate: %i Hz\n", esd_audio_rate); - sun_panic(afd, "SETINFO"); - return(-1); - } - - return(esd_audio_fd = afd); -} - -#define ARCH_esd_audio_pause -void esd_audio_pause() -{ - audio_info_t info; - int afd = esd_audio_fd; - - AUDIO_INITINFO(&info); - - if(ioctl(afd, AUDIO_GETINFO, &info) < 0) { - sun_panic(afd, "AUDIO_GETINFO"); - return; - } - - if((info.mode & AUMODE_PLAY) == AUMODE_PLAY) - info.play.pause = !info.play.pause; - if((info.mode & AUMODE_RECORD) == AUMODE_RECORD) - info.record.pause = !info.record.pause; - - return; -} Index: patches/patch-audio_c =================================================================== RCS file: /cvs/ports/audio/esound/patches/patch-audio_c,v retrieving revision 1.5 diff -u -r1.5 patch-audio_c --- patches/patch-audio_c 31 Mar 2008 01:05:54 -0000 1.5 +++ patches/patch-audio_c 11 Dec 2008 20:36:52 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-audio_c,v 1.5 2008/03/31 01:05:54 jakemsr Exp $ ---- audio.c.orig Thu Apr 19 17:43:59 2007 -+++ audio.c Sat Jun 2 23:15:49 2007 +--- audio.c.orig Thu Apr 19 07:43:59 2007 ++++ audio.c Thu Dec 11 04:01:24 2008 @@ -20,34 +20,7 @@ static int esd_audio_fd = -1; /*******************************************************************/ /* returns audio_fd for use by main prog - platform dependent */ @@ -33,7 +33,7 @@ -#else -# include "audio_none.c" -#endif -+#include "audio_sun.c" ++#include "audio_sndio.c" /*******************************************************************/ /* display available devices */ Index: patches/patch-configure_ac =================================================================== RCS file: /cvs/ports/audio/esound/patches/patch-configure_ac,v retrieving revision 1.3 diff -u -r1.3 patch-configure_ac --- patches/patch-configure_ac 31 Mar 2008 01:05:54 -0000 1.3 +++ patches/patch-configure_ac 11 Dec 2008 20:36:52 -0000 @@ -1,7 +1,15 @@ $OpenBSD: patch-configure_ac,v 1.3 2008/03/31 01:05:54 jakemsr Exp $ --- configure.ac.orig Thu May 3 13:47:30 2007 -+++ configure.ac Sun Mar 9 20:03:26 2008 -@@ -301,21 +301,16 @@ if test "x$enable_local_sound" = "xyes"; then ++++ configure.ac Thu Dec 11 04:16:03 2008 +@@ -48,6 +48,7 @@ AC_C_INLINE + + dnl Check for system libs needed + ++LIBS="$LIBS -lsndio" + AC_FUNC_ALLOCA + AC_CHECK_FUNCS(setenv putenv fchown fchmod gethostbyname2) + AC_CHECK_FUNC(connect,,[AC_CHECK_LIB(socket,connect)]) +@@ -301,21 +302,16 @@ if test "x$enable_local_sound" = "xyes"; then if test "x$HAVE_ARTS" = "xyes"; then found_sound=yes CFLAGS="$CFLAGS $ARTSC_CFLAGS" @@ -24,7 +32,7 @@ AC_CHECK_FUNC(ALnewconfig,,[AC_CHECK_LIB(audio,ALnewconfig)]) if test "x$enable_alsa" = "xyes"; then AC_CHECK_FUNC(snd_cards,,[AC_CHECK_LIB(sound,snd_cards)]) -@@ -393,7 +388,8 @@ if test "x$with_libwrap" = "xyes"; then +@@ -393,7 +389,8 @@ if test "x$with_libwrap" = "xyes"; then wrap_ok=no AC_TRY_LINK( @@ -34,7 +42,7 @@ #include <syslog.h> int allow_severity = LOG_INFO; int deny_severity = LOG_WARNING;], -@@ -403,7 +399,8 @@ int deny_severity = LOG_WARNING;], +@@ -403,7 +400,8 @@ int deny_severity = LOG_WARNING;], wrap_ok=yes], [LIBS="$LIBS -lnsl" AC_TRY_LINK( Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/audio/esound/pkg/PLIST,v retrieving revision 1.18 diff -u -r1.18 PLIST --- pkg/PLIST 31 Mar 2008 01:05:54 -0000 1.18 +++ pkg/PLIST 11 Dec 2008 20:36:52 -0000 @@ -1,14 +1,14 @@ @comment $OpenBSD: PLIST,v 1.18 2008/03/31 01:05:54 jakemsr Exp $ -bin/esd +...@bin bin/esd bin/esd-config -bin/esdcat -bin/esdctl -bin/esdfilt -bin/esdloop -bin/esdmon -bin/esdplay -bin/esdrec -bin/esdsample +...@bin bin/esdcat +...@bin bin/esdctl +...@bin bin/esdfilt +...@bin bin/esdloop +...@bin bin/esdmon +...@bin bin/esdplay +...@bin bin/esdrec +...@bin bin/esdsample include/esd.h lib/libesd.a lib/libesd.la