Hi!
Add sndio for audio/bonk
Tested on i386.
Comments ? OK ?
--
Alexandr Shadchin
Index: bonk/Makefile
===================================================================
RCS file: /cvs/ports/audio/bonk/Makefile,v
retrieving revision 1.12
diff -N -u -p bonk/Makefile
--- bonk/Makefile 15 Sep 2007 21:26:00 -0000 1.12
+++ bonk/Makefile 18 Dec 2009 22:45:37 -0000
@@ -3,6 +3,7 @@
COMMENT= lossy/lossless audio coder
DISTNAME= bonk-0.6
+PKGNAME= ${DISTNAME}p0
CATEGORIES= audio
HOMEPAGE= http://www.logarithmic.net/pfh/bonk
@@ -13,11 +14,11 @@ PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
-WANTLIB= c m ossaudio stdc++
+WANTLIB= c m sndio stdc++
MASTER_SITES= http://www.logarithmic.net/pfh-files/bonk/
-MAKE_FLAGS= CXX='${CXX}' CXXFLAGS='${CXXFLAGS}' LIBS=-lossaudio
+MAKE_FLAGS= CXX='${CXX}' CXXFLAGS='${CXXFLAGS}' LIBS=-lsndio
FAKE_FLAGS= PREFIX='${WRKINST}${PREFIX}' INSTALL='${INSTALL_PROGRAM}'
NO_REGRESS= Yes
Index: bonk/patches/patch-bonk_cc
===================================================================
RCS file: /cvs/ports/audio/bonk/patches/Attic/patch-bonk_cc,v
diff -N -u -p bonk/patches/patch-bonk_cc
--- /dev/null 18 Dec 2009 22:45:37 -0000
+++ bonk/patches/patch-bonk_cc 18 Dec 2009 22:45:37 -0000
@@ -0,0 +1,115 @@
+$OpenBSD$
+--- bonk.cc.orig Sun Jun 23 09:58:57 2002
++++ bonk.cc Sat Dec 19 03:40:21 2009
+@@ -56,14 +56,21 @@ using namespace std;
+ # define AFMT_S16_NE AFMT_S16_BE
+ # endif
+ # endif
+-#elif defined(__NetBSD__) || defined(__OpenBSD__)
++#elif defined(__NetBSD__)
+ # define dsp_device "/dev/sound"
+ # include <soundcard.h>
++#elif defined(__OpenBSD__)
++# define USE_SNDIO
++# include <sndio.h>
+ #endif
+
+ #include "utility.h"
+ #include "wav.h"
+
++#ifdef USE_SNDIO
++static struct sio_hdl *hdl;
++#endif
++
+ //Accuracy of fixed point calculations
+ const int lattice_shift = 10,
+ sample_shift = 4,
+@@ -540,6 +547,7 @@ struct decoder {
+ }
+ };
+
++#ifndef USE_SNDIO
+ FILE *open_dsp(int rate,bool stereo) {
+ int device = open(dsp_device,O_WRONLY);
+ if (device < 0)
+@@ -558,6 +566,7 @@ FILE *open_dsp(int rate,bool stereo) {
+
+ return fdopen(device,"wb");
+ }
++#endif
+
+ bool has_parameter(int &argc,char **&argv,char *name,char *&value) {
+ for(int i=1;i<argc-1;i++) {
+@@ -597,10 +606,41 @@ void play_file(char *name) {
+
+ deco.begin(f_in);
+
++#ifdef USE_SNDIO
++ struct sio_par par, askpar;
++
++ hdl = sio_open(NULL, SIO_PLAY, 0);
++ if (hdl == NULL)
++ throw error("Failed to open audio device");
++
++ sio_initpar (&par);
++ par.pchan = deco.channels;
++ par.rate = deco.rate;
++ par.bits = 16;
++ par.sig = 1;
++ par.le = SIO_LE_NATIVE;
++ par.appbufsz = par.rate / 4;
++
++ askpar = par;
++ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
++ throw error("Failed to set parameters");
++
++ if ((par.bits == 16 && par.le != askpar.le) ||
++ par.bits != askpar.bits ||
++ par.sig != askpar.sig ||
++ par.pchan != askpar.pchan ||
++ ((par.rate * 1000 < askpar.rate * 995) ||
++ (par.rate * 1000 > askpar.rate * 1005)))
++ throw error("Parameters not supported");
++
++ if (!sio_start(hdl))
++ throw error("Failed to start audio device");
++#else
+ if (deco.channels > 2)
+ throw error("Don't know how to play more than 2 channels");
+
+ FILE *f_out = open_dsp(deco.rate,deco.channels>1);
++#endif
+
+ while(deco.length_remaining) {
+ vector<int> samples;
+@@ -615,12 +655,20 @@ void play_file(char *name) {
+ else
+ little_samples[i] = samples[i];
+ }
++#ifdef USE_SNDIO
++ sio_write(hdl, &(little_samples[0]), 2 * little_samples.size());
++#else
+ fwrite(&(little_samples[0]),2,little_samples.size(),f_out);
+ fflush(f_out);
++#endif
+ }
+
+ fclose(f_in);
++#ifdef USE_SNDIO
++ sio_close(hdl);
++#else
+ fclose(f_out);
++#endif
+ }
+
+ void do_play(int argc,char **argv) {
+@@ -929,6 +977,9 @@ int main(int argc,char **argv) {
+ }
+
+ } catch(error e) {
++#ifdef USE_SNDIO
++ sio_close(hdl);
++#endif
+ fprintf(stderr,"\nError: %s\n",e.message);
+ return 1;
+ }