Yet another sndio backend and one less -lossaudio user. Tested on
amd64.
OK?
Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/libdca/Makefile,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 Makefile
--- Makefile 21 Mar 2013 08:45:12 -0000 1.8
+++ Makefile 24 Oct 2014 11:28:32 -0000
@@ -4,7 +4,7 @@ COMMENT= free DTS Coherent Acoustics dec
V= 0.0.5
DISTNAME= libdca-${V}
-REVISION= 2
+REVISION= 3
EXTRACT_SUFX= .tar.bz2
CATEGORIES= audio
MASTER_SITES= http://download.videolan.org/pub/videolan/libdca/${V}/
@@ -16,8 +16,15 @@ HOMEPAGE= http://www.videolan.org/develo
# GPLv2
PERMIT_PACKAGE_CDROM= Yes
-WANTLIB= c m ossaudio
+WANTLIB= c m sndio
-CONFIGURE_STYLE= gnu
+CONFIGURE_STYLE = autoconf
+AUTOCONF_VERSION = 2.61
+CONFIGURE_ARGS += ${CONFIGURE_SHARED}
+CONFIGURE_ARGS += --disable-oss
+MODGNU_CONFIG_GUESS_DIRS = ${WRKSRC}/autotools
+
+post-extract:
+ @cp ${FILESDIR}/audio_out_sndio.c ${WRKSRC}/libao
.include <bsd.port.mk>
Index: files/audio_out_sndio.c
===================================================================
RCS file: files/audio_out_sndio.c
diff -N files/audio_out_sndio.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/audio_out_sndio.c 24 Oct 2014 11:28:32 -0000
@@ -0,0 +1,170 @@
+/*
+ * audio_out_sndio.c
+ * Copyright (C) 2000-2003 Michel Lespinasse <[email protected]>
+ * Copyright (C) 1999-2000 Aaron Holtzman <[email protected]>
+ *
+ * This file is part of a52dec, a free ATSC A-52 stream decoder.
+ * See http://liba52.sourceforge.net/ for updates.
+ *
+ * a52dec 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.
+ *
+ * a52dec 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#ifdef LIBAO_SNDIO
+
+#include <sndio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "dca.h"
+#include "audio_out.h"
+#include "audio_out_internal.h"
+
+typedef struct sndio_instance_s {
+ ao_instance_t ao;
+ struct sio_hdl *hdl;
+ int sample_rate;
+ int set_params;
+ int flags;
+} sndio_instance_t;
+
+static int sndio_setup (ao_instance_t * _instance, int sample_rate, int *
flags,
+ level_t * level, sample_t * bias)
+{
+ sndio_instance_t * instance = (sndio_instance_t *) _instance;
+
+ if ((instance->set_params == 0) && (instance->sample_rate != sample_rate))
+ return 1;
+ instance->sample_rate = sample_rate;
+
+ *flags = instance->flags;
+ *level = CONVERT_LEVEL;
+ *bias = CONVERT_BIAS;
+
+ return 0;
+}
+
+static int sndio_play (ao_instance_t * _instance, int flags, sample_t *
_samples)
+{
+ sndio_instance_t * instance = (sndio_instance_t *) _instance;
+ int16_t int16_samples[256*6];
+ int chans = -1;
+
+#ifdef LIBDCA_DOUBLE
+ convert_t samples[256 * 6];
+ int i;
+
+ for (i = 0; i < 256 * 6; i++)
+ samples[i] = _samples[i];
+#else
+ convert_t * samples = _samples;
+#endif
+
+ chans = channels_multi (flags);
+ flags &= DCA_CHANNEL_MASK | DCA_LFE;
+
+ if (instance->set_params) {
+ struct sio_par par;
+
+ sio_initpar(&par);
+ par.bits = 16;
+ par.sig = 1;
+ par.le = SIO_LE_NATIVE;
+ par.pchan = chans;
+ par.rate = instance->sample_rate;
+ if (!sio_setpar(instance->hdl, &par) || !sio_setpar(instance->hdl,
&par)) {
+ fprintf (stderr, "Can not set audio parameters\n");
+ return 1;
+ }
+ if (par.bits != 16 || par.sig != 1 || par.le != SIO_LE_NATIVE ||
+ par.pchan != chans || par.rate != instance->sample_rate) {
+ fprintf (stderr, "Unsupported audio parameters\n");
+ return 1;
+ }
+ instance->flags = flags;
+ instance->set_params = 0;
+ sio_start(instance->hdl);
+ } else if ((flags == DCA_DOLBY) && (instance->flags == DCA_STEREO)) {
+ fprintf (stderr, "Switching from stereo to dolby surround\n");
+ instance->flags = DCA_DOLBY;
+ } else if ((flags == DCA_STEREO) && (instance->flags == DCA_DOLBY)) {
+ fprintf (stderr, "Switching from dolby surround to stereo\n");
+ instance->flags = DCA_STEREO;
+ } else if (flags != instance->flags)
+ return 1;
+
+ convert2s16_multi (samples, int16_samples, flags);
+ sio_write (instance->hdl, int16_samples, 256 * sizeof (int16_t) * chans);
+
+ return 0;
+}
+
+static void sndio_close (ao_instance_t * _instance)
+{
+ sndio_instance_t * instance = (sndio_instance_t *) _instance;
+
+ sio_close (instance->hdl);
+}
+
+static ao_instance_t * sndio_open (int flags)
+{
+ sndio_instance_t * instance;
+
+ instance = (sndio_instance_t *) malloc (sizeof (sndio_instance_t));
+ if (instance == NULL)
+ return NULL;
+
+ instance->ao.setup = sndio_setup;
+ instance->ao.play = sndio_play;
+ instance->ao.close = sndio_close;
+
+ instance->sample_rate = 0;
+ instance->set_params = 1;
+ instance->flags = flags;
+
+ instance->hdl = sio_open (SIO_DEVANY, SIO_PLAY, 0);
+ if (instance->hdl == NULL) {
+ fprintf (stderr, "Can not open " SIO_DEVANY " device\n");
+ free (instance);
+ return NULL;
+ }
+
+ return (ao_instance_t *) instance;
+}
+
+ao_instance_t * ao_sndio_open (void)
+{
+ return sndio_open (DCA_STEREO);
+}
+
+ao_instance_t * ao_sndiodolby_open (void)
+{
+ return sndio_open (DCA_DOLBY);
+}
+
+ao_instance_t * ao_sndio4_open (void)
+{
+ return sndio_open (DCA_2F2R);
+}
+
+ao_instance_t * ao_sndio6_open (void)
+{
+ return sndio_open (DCA_3F2R | DCA_LFE);
+}
+
+#endif
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- patches/patch-configure 12 Jul 2009 23:26:08 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-$OpenBSD: patch-configure,v 1.1.1.1 2009/07/12 23:26:08 jolan Exp $
---- configure.orig Tue Apr 10 07:31:19 2007
-+++ configure Sun Jul 12 18:21:25 2009
-@@ -4242,9 +4242,9 @@ echo "${ECHO_T}$ac_cv_try_cflags_ok" >&6; }
- fi
-
-
-- TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"|sed "s/-O[0-9]*//g"`
-+ TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"`
-
-- TRY_CFLAGS="$TRY_CFLAGS -O3"
-+ #TRY_CFLAGS="$TRY_CFLAGS -O3"
- { echo "$as_me:$LINENO: checking if $CC supports $TRY_CFLAGS flags" >&5
- echo $ECHO_N "checking if $CC supports $TRY_CFLAGS flags... $ECHO_C" >&6; }
- SAVE_CFLAGS="$CFLAGS"
Index: patches/patch-libao_Makefile_am
===================================================================
RCS file: patches/patch-libao_Makefile_am
diff -N patches/patch-libao_Makefile_am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-libao_Makefile_am 24 Oct 2014 11:28:32 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- libao/Makefile.am.orig Fri Oct 24 12:06:39 2014
++++ libao/Makefile.am Fri Oct 24 12:06:56 2014
+@@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
+
+ noinst_LTLIBRARIES = libao.la
+ libao_la_SOURCES = audio_out.c audio_out_null.c audio_out_float.c \
+- audio_out_oss.c audio_out_solaris.c audio_out_al.c \
++ audio_out_oss.c audio_out_sndio.c audio_out_solaris.c
audio_out_al.c \
+ audio_out_win.c audio_out_wav.c audio_out_aif.c \
+ audio_out_peak.c convert2s16.c \
+ audio_out_internal.h
Index: patches/patch-libao_Makefile_in
===================================================================
RCS file: patches/patch-libao_Makefile_in
diff -N patches/patch-libao_Makefile_in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-libao_Makefile_in 24 Oct 2014 11:28:32 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+--- libao/Makefile.in.orig Fri Oct 24 12:07:06 2014
++++ libao/Makefile.in Fri Oct 24 12:08:02 2014
+@@ -46,7 +46,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
+ am__DEPENDENCIES_1 =
+ libao_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ am_libao_la_OBJECTS = audio_out.lo audio_out_null.lo \
+- audio_out_float.lo audio_out_oss.lo audio_out_solaris.lo \
++ audio_out_float.lo audio_out_oss.lo audio_out_sndio.lo
audio_out_solaris.lo \
+ audio_out_al.lo audio_out_win.lo audio_out_wav.lo \
+ audio_out_aif.lo audio_out_peak.lo convert2s16.lo
+ libao_la_OBJECTS = $(am_libao_la_OBJECTS)
+@@ -176,7 +176,7 @@ AM_CFLAGS = $(OPT_CFLAGS)
+ AM_CPPFLAGS = -I$(top_srcdir)/include
+ noinst_LTLIBRARIES = libao.la
+ libao_la_SOURCES = audio_out.c audio_out_null.c audio_out_float.c \
+- audio_out_oss.c audio_out_solaris.c audio_out_al.c \
++ audio_out_oss.c audio_out_sndio.c audio_out_solaris.c
audio_out_al.c \
+ audio_out_win.c audio_out_wav.c audio_out_aif.c \
+ audio_out_peak.c convert2s16.c \
+ audio_out_internal.h
+@@ -240,6 +240,7 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/audio_out_float.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_out_null.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_out_oss.Plo@am__quote@
++@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/audio_out_sndio.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_out_peak.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/audio_out_solaris.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_out_wav.Plo@am__quote@
Index: patches/patch-libao_audio_out_c
===================================================================
RCS file: patches/patch-libao_audio_out_c
diff -N patches/patch-libao_audio_out_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-libao_audio_out_c 24 Oct 2014 11:28:32 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+--- libao/audio_out.c.orig Fri Oct 24 12:21:31 2014
++++ libao/audio_out.c Fri Oct 24 12:22:02 2014
+@@ -34,6 +34,10 @@ extern ao_open_t ao_oss_open;
+ extern ao_open_t ao_ossdolby_open;
+ extern ao_open_t ao_oss4_open;
+ extern ao_open_t ao_oss6_open;
++extern ao_open_t ao_sndio_open;
++extern ao_open_t ao_sndiodolby_open;
++extern ao_open_t ao_sndio4_open;
++extern ao_open_t ao_sndio6_open;
+ extern ao_open_t ao_solaris_open;
+ extern ao_open_t ao_solarisdolby_open;
+ extern ao_open_t ao_al_open;
+@@ -61,6 +65,12 @@ static ao_driver_t audio_out_drivers[] = {
+ {"ossdolby", ao_ossdolby_open},
+ {"oss4", ao_oss4_open},
+ {"oss6", ao_oss6_open},
++#endif
++#ifdef LIBAO_SNDIO
++ {"sndio", ao_sndio_open},
++ {"sndiodolby", ao_sndiodolby_open},
++ {"sndio4", ao_sndio4_open},
++ {"sndio6", ao_sndio6_open},
+ #endif
+ #ifdef LIBAO_SOLARIS
+ {"solaris", ao_solaris_open},
Index: patches/patch-libao_configure_incl
===================================================================
RCS file: patches/patch-libao_configure_incl
diff -N patches/patch-libao_configure_incl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-libao_configure_incl 24 Oct 2014 11:28:32 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+--- libao/configure.incl.orig Fri Oct 24 12:09:22 2014
++++ libao/configure.incl Fri Oct 24 12:10:49 2014
+@@ -12,6 +12,15 @@ if test x"$enable_oss" != x"no"; then
+ esac
+ fi
+
++dnl check for sndio
++AC_ARG_ENABLE([sndio],
++ [ --disable-sndio make a version not using sndio])
++if test x"$enable_sndio" != x"no"; then
++ AC_DEFINE([LIBAO_SNDIO],,[libao sndio support])
++ AC_CHECK_LIB([sndio],[sio_initpar],
++ [LIBAO_LIBS="$LIBAO_LIBS -lsndio"])
++fi
++
+ dnl check for solaris
+ AC_ARG_ENABLE([solaris-audio],
+ [ --disable-solaris-audio make a version not using solaris audio])