This is to make ac3dec use sndio for output, and have one less port using -lossaudio. I tested the output_sndio.c file separately as I couldn't find a ac3 test file that doesn't crash ac3dec.
OK? Index: Makefile =================================================================== RCS file: /cvs/ports/audio/ac3dec/Makefile,v retrieving revision 1.18 diff -u -p -u -p -r1.18 Makefile --- Makefile 10 Mar 2013 22:55:01 -0000 1.18 +++ Makefile 24 Oct 2014 08:54:25 -0000 @@ -3,7 +3,7 @@ COMMENT= ac3 audio (as used on DVDs) decoding tools DISTNAME= ac3dec-0.6.1 -REVISION= 1 +REVISION= 2 CATEGORIES= audio HOMEPAGE= http://liba52.sourceforge.net/ @@ -11,11 +11,14 @@ HOMEPAGE= http://liba52.sourceforge.net/ # GPL PERMIT_PACKAGE_CDROM= Yes -WANTLIB= c m ossaudio +WANTLIB= c m sndio MASTER_SITES= http://liba52.sourceforge.net/files/ CONFIGURE_STYLE= gnu + +post-extract: + @cp ${FILESDIR}/output_sndio.c ${WRKSRC} post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ac3dec Index: files/output_sndio.c =================================================================== RCS file: files/output_sndio.c diff -N files/output_sndio.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/output_sndio.c 24 Oct 2014 08:54:25 -0000 @@ -0,0 +1,103 @@ +/* + * + * output_sndio.c + * + * Copyright (C) Aaron Holtzman - May 1999 + * + * This file is part of ac3dec, a free Dolby AC-3 stream decoder. + * + * ac3dec 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, or (at your option) + * any later version. + * + * ac3dec 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 GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdint.h> +#include <stdio.h> +#include <sndio.h> + +typedef short sint_16; +typedef unsigned int uint_32; + +#include "output.h" + + +static char dev[] = SIO_DEVANY; +static struct sio_hdl *hdl = NULL; + +/* + * open the audio device for writing to + */ +int output_open(int bits, int rate, int channels) +{ + struct sio_par par; + + /* + * Open the device driver + */ + + hdl = sio_open(dev, SIO_PLAY, 0); + if(hdl == NULL) + { + fprintf(stderr,"Error opening audio device %s\n", dev); + goto ERR; + } + + sio_initpar(&par); + par.bits = bits; + par.rate = rate; + par.pchan = channels; + par.sig = 1; + par.le = SIO_LE_NATIVE; + if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) { + fprintf(stderr, "Couldn't set audio parameters\n"); + goto ERR; + } + if (par.rate != rate || par.bits != bits || par.pchan != channels || + par.le != SIO_LE_NATIVE || par.sig != 1) { + fprintf(stderr, "Unsupported audio parameters\n"); + goto ERR; + } + if (!sio_start(hdl)) { + fprintf(stderr, "Couldn't start audio playback\n"); + goto ERR; + } + return 1; + +ERR: + if (hdl != NULL) + sio_close(hdl); + hdl = NULL; + return 0; +} + +/* + * play the sample to the already opened file descriptor + */ +void output_play(sint_16* output_samples, uint_32 num_bytes) +{ + sio_write(hdl, output_samples, num_bytes); +} + + +void +output_close(void) +{ + sio_close(hdl); + hdl = NULL; +} Index: patches/patch-Makefile_in =================================================================== RCS file: /cvs/ports/audio/ac3dec/patches/patch-Makefile_in,v retrieving revision 1.1 diff -u -p -u -p -r1.1 patch-Makefile_in --- patches/patch-Makefile_in 27 Feb 2001 12:12:45 -0000 1.1 +++ patches/patch-Makefile_in 24 Oct 2014 08:54:25 -0000 @@ -1,7 +1,7 @@ $OpenBSD: patch-Makefile_in,v 1.1 2001/02/27 12:12:45 naddy Exp $ ---- Makefile.in.orig Mon Feb 26 01:58:36 2001 -+++ Makefile.in Mon Feb 26 01:59:55 2001 -@@ -70,8 +70,6 @@ VERSION = @VERSION@ +--- Makefile.in.orig Thu Mar 30 02:55:23 2000 ++++ Makefile.in Wed Oct 22 14:31:45 2014 +@@ -70,11 +70,9 @@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = 1.3 foreign @@ -9,7 +9,11 @@ $OpenBSD: patch-Makefile_in,v 1.1 2001/0 - bin_PROGRAMS = ac3dec - ac3dec_LDADD = -L./libac3 -lac3 -lm +-ac3dec_LDADD = -L./libac3 -lac3 -lm ++ac3dec_LDADD = -L./libac3 -lac3 -lm -lsndio + + noinst_HEADERS = output.h + ac3dec_SOURCES = ac3dec.c output.c @@ -97,6 +95,7 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ ac3dec_OBJECTS = ac3dec.o output.o Index: patches/patch-configure =================================================================== RCS file: /cvs/ports/audio/ac3dec/patches/patch-configure,v retrieving revision 1.10 diff -u -p -u -p -r1.10 patch-configure --- patches/patch-configure 19 Mar 2014 13:37:41 -0000 1.10 +++ patches/patch-configure 24 Oct 2014 08:54:25 -0000 @@ -1,6 +1,6 @@ $OpenBSD: patch-configure,v 1.10 2014/03/19 13:37:41 jasper Exp $ --- configure.orig Thu Mar 30 02:51:49 2000 -+++ configure Wed Mar 19 14:35:33 2014 ++++ configure Fri Oct 24 10:39:39 2014 @@ -528,7 +528,7 @@ fi @@ -10,7 +10,60 @@ $OpenBSD: patch-configure,v 1.10 2014/03 if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" -@@ -1273,8 +1273,32 @@ sparc-*) cat >> confdefs.h <<\EOF +@@ -1211,50 +1211,10 @@ else + fi + + +-echo $ac_n "checking for _oss_ioctl in -lossaudio""... $ac_c" 1>&6 +-echo "configure:1216: checking for _oss_ioctl in -lossaudio" >&5 +-ac_lib_var=`echo ossaudio'_'_oss_ioctl | sed 'y%./+-%__p_%'` +-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then +- echo $ac_n "(cached) $ac_c" 1>&6 +-else +- ac_save_LIBS="$LIBS" +-LIBS="-lossaudio $LIBS" +-cat > conftest.$ac_ext <<EOF +-#line 1224 "configure" +-#include "confdefs.h" +-/* Override any gcc2 internal prototype to avoid an error. */ +-/* We use char because int might match the return type of a gcc2 +- builtin and then its argument prototype would still apply. */ +-char _oss_ioctl(); +- +-int main() { +-_oss_ioctl() +-; return 0; } +-EOF +-if { (eval echo configure:1235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +- rm -rf conftest* +- eval "ac_cv_lib_$ac_lib_var=yes" +-else +- echo "configure: failed program was:" >&5 +- cat conftest.$ac_ext >&5 +- rm -rf conftest* +- eval "ac_cv_lib_$ac_lib_var=no" +-fi +-rm -f conftest* +-LIBS="$ac_save_LIBS" +- +-fi +-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then +- echo "$ac_t""yes" 1>&6 +- LIBS="$LIBS -lossaudio" +-else +- echo "$ac_t""no" 1>&6 +-fi +- +- + case "$host" in + *-linux*) rm -f output.c; ln -s output_linux.c output.c;; +-*-openbsd*|*-freebsd*) rm -f output.c; ln -s output_linux.c output.c;; ++*-openbsd*) rm -f output.c; ln -s output_sndio.c output.c;; ++*-freebsd*) rm -f output.c; ln -s output_linux.c output.c;; + *-irix*) rm -f output.c; ln -s output_irix.c output.c;; + *-solaris*) rm -f output.c; ln -s output_solaris.c output.c;; + *) echo "$host is not currently supported by ac3dec"; exit 1;; +@@ -1273,8 +1233,32 @@ sparc-*) cat >> confdefs.h <<\EOF #define __sparc__ 1 EOF ;;