On Tue, 28 Oct 2008, Alexandre Ratchov wrote: > below is the mplayer backend.
Don't forget to bump the PKGNAME ;-) > > -- Alexandre > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/x11/mplayer/Makefile,v > retrieving revision 1.137 > diff -u -p -r1.137 Makefile > --- Makefile 11 Oct 2008 11:07:32 -0000 1.137 > +++ Makefile 27 Oct 2008 16:19:01 -0000 > @@ -20,7 +20,7 @@ PERMIT_PACKAGE_CDROM= patents > PERMIT_PACKAGE_FTP= Yes > PERMIT_DISTFILES_CDROM= Yes > PERMIT_DISTFILES_FTP= Yes > -WANTLIB= c m ncurses pthread stdc++ util z > +WANTLIB= c m ncurses pthread stdc++ util sndio z > > MASTER_SITES= http://www1.mplayerhq.hu/MPlayer/releases/ \ > http://www2.mplayerhq.hu/MPlayer/releases/ \ > @@ -211,7 +211,7 @@ CONFIGURE_ARGS+=--disable-jack > NO_REGRESS= Yes > > post-patch: > - @cp ${FILESDIR}/ao_rtunes.c ${WRKSRC}/libao2 > + @cp ${FILESDIR}/ao_rtunes.c ${FILESDIR}/ao_libsndio.c ${WRKSRC}/libao2 > > post-install: > ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/mplayer > Index: files/ao_libsndio.c > =================================================================== > RCS file: files/ao_libsndio.c > diff -N files/ao_libsndio.c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ files/ao_libsndio.c 27 Oct 2008 16:19:01 -0000 > @@ -0,0 +1,226 @@ > +#include <sys/types.h> > +#include <poll.h> > +#include <errno.h> > +#include <sndio.h> > + > +#include "config.h" > +#include "mp_msg.h" > +#include "mixer.h" > +#include "help_mp.h" > + > +#include "libaf/af_format.h" > + > +#include "audio_out.h" > +#include "audio_out_internal.h" > + > +static ao_info_t info = { > + "libsndio audio output", > + "libsndio", > + "Alexandre Ratchov <[EMAIL PROTECTED]>", > + "" > +}; > + > +LIBAO_EXTERN(libsndio) > + > +static struct sio_hdl *hdl = NULL; > +static struct sio_par par; > +static long long realpos = 0, playpos = 0; > +#define SILENCE_NMAX 0x1000 > +static char silence[SILENCE_NMAX]; > + > +/* > + * misc parameters (volume, etc...) > + */ > +static int control(int cmd, void *arg) > +{ > + return CONTROL_FALSE; > +} > + > +/* > + * call-back invoked to notify of the hardware position > + */ > +static void movecb(void *addr, int delta) > +{ > + realpos += delta * (int)(par.bps * par.pchan); > +} > + > +/* > + * open device and setup parameters > + * return: 1 = success, 0 = failure > + */ > +static int init(int rate, int channels, int format, int flags) > +{ > + hdl = sio_open(NULL, SIO_PLAY, 0); > + if (hdl == NULL) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: can't open libsndio\n"); > + return 0; > + } > + > + sio_initpar(&par); > + switch (format) { > + case AF_FORMAT_U8: > + par.bits = 8; > + par.sig = 0; > + break; > + case AF_FORMAT_S8: > + par.bits = 8; > + par.sig = 1; > + break; > + case AF_FORMAT_U16_LE: > + par.bits = 16; > + par.sig = 0; > + par.le = 1; > + break; > + case AF_FORMAT_S16_LE: > + par.bits = 16; > + par.sig = 1; > + par.le = 1; > + break; > + case AF_FORMAT_U16_BE: > + par.bits = 16; > + par.sig = 0; > + par.le = 0; > + break; > + case AF_FORMAT_S16_BE: > + par.bits = 16; > + par.sig = 1; > + par.le = 0; > + break; > + default: > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: unsupported format\n"); > + return 0; > + } > + par.rate = rate; > + par.pchan = channels; > + par.bufsz = par.rate * 250 / 1000; /* 250ms buffer */ > + if (!sio_setpar(hdl, &par)) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't set params\n"); > + return 0; > + } > + if (!sio_getpar(hdl, &par)) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't get params\n"); > + return 0; > + } > + if (par.bits == 8 && par.bps == 1) { > + format = par.sig ? AF_FORMAT_S8 : AF_FORMAT_U8; > + } else if (par.bits == 16 && par.bps == 2) { > + format = par.sig ? > + (par.le ? AF_FORMAT_S16_LE : AF_FORMAT_S16_BE) : > + (par.le ? AF_FORMAT_U16_LE : AF_FORMAT_U16_BE); > + } else { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't set format\n"); > + return 0; > + } > + ao_data.samplerate = par.rate; > + ao_data.channels = par.pchan; > + ao_data.format = format; > + ao_data.bps = par.bps * par.pchan * par.rate; > + ao_data.buffersize = par.bufsz * par.bps * par.pchan; > + ao_data.outburst = par.round * par.bps * par.pchan; > + sio_onmove(hdl, movecb, NULL); > + realpos = playpos = 0; > + if (!sio_start(hdl)) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: init: couldn't start\n"); > + } > + return 1; > +} > + > +/* > + * close device > + */ > +static void uninit(int immed) > +{ > + if (hdl) > + sio_close(hdl); > +} > + > +/* > + * stop playing and empty buffers (for seeking/pause) > + */ > +static void reset(void) { > + if (!sio_stop(hdl)) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: reset: couldn't stop\n"); > + } > + realpos = playpos = 0; > + if (!sio_start(hdl)) { > + mp_msg(MSGT_AO, MSGL_ERR, "ao2: reset: couldn't start\n"); > + } > +} > + > +/* > + * how many bytes can be played without blocking > + */ > +static int get_space(void) > +{ > + struct pollfd pfd; > + int bufused, space, revents, n; > + > + /* > + * call poll() and sio_revents(), so the > + * playpos and realpos counters are updated > + */ > + n = sio_pollfd(hdl, &pfd, POLLOUT); > + while (poll(&pfd, n, 0) < 0 && errno == EINTR) > + ; /* nothing */ > + revents = sio_revents(hdl, &pfd); > + bufused = (realpos < 0) ? playpos : playpos - realpos; > + space = par.bufsz * par.pchan * par.bps - bufused; > + return space; > +} > + > +/* > + * play given number of bytes until sio_write() blocks > + */ > +static int play(void *data, int len, int flags) > +{ > + int n; > + > + n = sio_write(hdl, data, len); > + playpos += n; > + return n; > +} > + > +/* > + * return: delay in seconds between first and last sample in buffer > + */ > +static float get_delay(void) > +{ > + int bufused; > + bufused = (realpos < 0) ? playpos : playpos - realpos; > + return (float)bufused / (par.bps * par.pchan * par.rate); > +} > + > +/* > + * stop playing, keep buffers (for pause) > + */ > +static void audio_pause(void) > +{ > + /* libsndio stops automatically if no data is available */ > +} > + > +/* > + * resume playing, after audio_pause() > + */ > +static void audio_resume(void) > +{ > + struct pollfd pfd; > + int n, count, todo, revents; > + > + todo = par.bufsz * par.pchan * par.bps; > + > + /* > + * libsndio starts automatically if enough data is available; > + * however we want to start with buffers full, because video > + * would accelerate during buffers are filled > + */ > + while (todo > 0) { > + count = todo; > + if (count > SILENCE_NMAX) > + count = SILENCE_NMAX; > + n = sio_write(hdl, silence, count); > + if (n == 0) > + break; > + todo -= n; > + realpos -= n; > + } > +} > Index: patches/patch-configure > =================================================================== > RCS file: /cvs/ports/x11/mplayer/patches/patch-configure,v > retrieving revision 1.46 > diff -u -p -r1.46 patch-configure > --- patches/patch-configure 1 May 2008 13:52:19 -0000 1.46 > +++ patches/patch-configure 27 Oct 2008 16:19:01 -0000 > @@ -1,6 +1,5 @@ > -$OpenBSD: patch-configure,v 1.46 2008/05/01 13:52:19 sthen Exp $ > ---- configure.orig Sun Oct 7 20:49:33 2007 > -+++ configure Thu May 1 00:29:07 2008 > +--- configure.old Mon Sep 29 17:11:48 2008 > ++++ configure Mon Sep 29 17:13:03 2008 > @@ -76,7 +76,7 @@ cc_check() { > } > > @@ -10,7 +9,15 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > } > > tmp_run() { > -@@ -501,7 +501,7 @@ _libavcodec_a=auto > +@@ -397,6 +397,7 @@ Audio output: > + --disable-nas disable NAS audio output [autodetect] > + --disable-sgiaudio disable SGI audio output [autodetect] > + --disable-sunaudio disable Sun audio output [autodetect] > ++ --disable-libsndio disable libsndio audio output [autodetect] > + --disable-win32waveout disable Windows waveout audio output [autodetect] > + --disable-select disable using select() on the audio device [enable] > + > +@@ -501,7 +502,7 @@ _libavcodec_a=auto > _libamr_nb=auto > _libamr_wb=auto > _libavdecoders_all=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' > libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` > @@ -19,7 +26,24 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _libavencoders_all=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' > libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` > _libavencoders=` echo $_libavencoders_all | sed -e s/LIBGSM_ENCODER// -e > s/LIBGSM_MS_ENCODER// -e s/LIBTHEORA_ENCODER// ` > _libavparsers_all=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' > libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` > -@@ -1557,6 +1557,8 @@ if x86 ; then > +@@ -598,6 +599,7 @@ _xf86keysym=auto > + _mlib=no #broken, thus disabled > + _sgiaudio=auto > + _sunaudio=auto > ++_libsndio=auto > + _alsa=auto > + _fastmemcpy=yes > + _unrarlib=yes > +@@ -963,6 +965,8 @@ for ac_option do > + --disable-mlib) _mlib=no ;; > + --enable-sunaudio) _sunaudio=yes ;; > + --disable-sunaudio) _sunaudio=no ;; > ++ --enable-libsndio) _libsndio=yes ;; > ++ --disable-libsndio) _libsndio=no ;; > + --enable-sgiaudio) _sgiaudio=yes ;; > + --disable-sgiaudio) _sgiaudio=no ;; > + --enable-alsa) _alsa=yes ;; > +@@ -1557,6 +1561,8 @@ if x86 ; then > pparam=`echo $exts | sed -e s/k6_mtrr/mtrr/ -e s/cyrix_arr/mtrr/ -e > s/centaur_mcr/mtrr/ \ > -e s/xmm/sse/ -e s/kni/sse/` > > @@ -28,7 +52,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > for ext in $pparam ; do > eval test \"\$_$ext\" = auto 2>/dev/null && eval _$ext=kernel_check > done > -@@ -3065,7 +3067,7 @@ int main(void) { pthread_t tid; return pthread_create > +@@ -3065,7 +3071,7 @@ int main(void) { pthread_t tid; return pthread_create > EOF > _pthreads=no > if not hpux ; then > @@ -37,7 +61,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > # for crosscompilation, we cannot execute the program, be happy if we > can link statically > cc_check $_ld_tmp && (tmp_run || test "$_ld_static") && > _ld_pthread="$_ld_tmp" && _pthreads=yes && break > done > -@@ -3108,7 +3110,7 @@ fi > +@@ -3108,7 +3114,7 @@ fi > echores "$_rpath" > > echocheck "iconv" > @@ -46,7 +70,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > cat > $TMPC << EOF > #include <stdio.h> > #include <unistd.h> > -@@ -4369,6 +4371,8 @@ if test "$_aa" = yes ; then > +@@ -4369,6 +4375,8 @@ if test "$_aa" = yes ; then > _def_aa='#define HAVE_AA 1' > if cygwin ; then > _libs_mplayer="$_libs_mplayer `aalib-config --libs | cut -d " " -f > 2,5,6`" > @@ -55,7 +79,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > fi > _vosrc="$_vosrc vo_aa.c" > _vomodules="aa $_vomodules" > -@@ -4576,7 +4580,7 @@ fi > +@@ -4576,7 +4584,7 @@ fi > echores "$_png" > if test "$_png" = yes ; then > _def_png='#define HAVE_PNG 1' > @@ -64,7 +88,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _vosrc="$_vosrc vo_png.c" > _vomodules="png $_vomodules" > else > -@@ -5054,7 +5058,7 @@ if test "$_arts" = yes ; then > +@@ -5054,7 +5062,7 @@ if test "$_arts" = yes ; then > _def_arts='#define USE_ARTS 1' > _aosrc="$_aosrc ao_arts.c" > _aomodules="arts $_aomodules" > @@ -73,7 +97,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _inc_extra="$_inc_extra `artsc-config --cflags`" > else > _noaomodules="arts $_noaomodules" > -@@ -5129,7 +5133,8 @@ fi > +@@ -5129,7 +5137,8 @@ fi > echocheck "JACK" > if test "$_jack" = auto ; then > _jack=yes > @@ -83,7 +107,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > cat > $TMPC << EOF > #include <jack/jack.h> > int main(void) { jack_client_new("test"); return 0; } > -@@ -5144,6 +5149,7 @@ EOF > +@@ -5144,6 +5153,7 @@ EOF > fi > fi > > @@ -91,7 +115,35 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > if test "$_jack" = yes ; then > _def_jack='#define USE_JACK 1' > _aosrc="$_aosrc ao_jack.c" > -@@ -5343,7 +5349,7 @@ fi #if irix > +@@ -5303,6 +5313,27 @@ fi > + echores "$_sunaudio" > + > + > ++echocheck "libsndio audio" > ++if test "$_libsndio" = auto ; then > ++ cat > $TMPC << EOF > ++#include <sndio.h> > ++int main(void) { struct sio_par par; sio_initpar(&par); return 0; } > ++EOF > ++ _libsndio=no > ++ cc_check -lsndio && _libsndio=yes > ++fi > ++if test "$_libsndio" = yes ; then > ++ _def_libsndio='#define USE_LIBSNDIO_AUDIO 1' > ++ _aosrc="$_aosrc ao_libsndio.c" > ++ _aomodules="libsndio $_aomodules" > ++ _libs_mplayer="$_libs_mplayer -lsndio" > ++else > ++ _def_libsndio='#undef USE_LIBSNDIO_AUDIO' > ++ _noaomodules="libsndio $_noaomodules" > ++fi > ++echores "$_libsndio" > ++ > ++ > + if sunos; then > + echocheck "Sun mediaLib" > + if test "$_mlib" = auto ; then > +@@ -5343,7 +5374,7 @@ fi #if irix > > > echocheck "VCD support" > @@ -100,7 +152,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _inputmodules="vcd $_inputmodules" > _def_vcd='#define HAVE_VCD 1' > _vcd="yes" > -@@ -5592,7 +5598,7 @@ int main() > +@@ -5592,7 +5623,7 @@ int main() > } > EOF > _fontconfig=no > @@ -109,7 +161,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _ld_tmp="-lfontconfig $_ld_tmp" > cc_check $_ld_tmp && _fontconfig=yes && _ld_extra="$_ld_extra $_ld_tmp" > && break > done > -@@ -5704,10 +5710,10 @@ cat > $TMPC << EOF > +@@ -5704,10 +5735,10 @@ cat > $TMPC << EOF > int main(void) { (void) inflate(0, Z_NO_FLUSH); return 0; } > EOF > _zlib=no > @@ -122,7 +174,7 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > else > _def_zlib='#undef HAVE_ZLIB' > _libavdecoders=`echo $_libavdecoders | sed -e s/FLASHSV_DECODER// -e > s/PNG_DECODER// -e s/ZMBV_DECODER// -e s/DXA_DECODER// ` > -@@ -6207,7 +6213,7 @@ if test "$_real" = auto ; then > +@@ -6207,7 +6238,7 @@ if test "$_real" = auto ; then > _real=no > _res_comment="dynamic loader support needed" > if test "$_dl" = yes || test "$_win32dll" = yes && > @@ -131,3 +183,11 @@ $OpenBSD: patch-configure,v 1.46 2008/05 > _real=yes > fi > fi > +@@ -8151,6 +8182,7 @@ $_def_openal_h > + $_def_sys_asoundlib_h > + $_def_alsa_asoundlib_h > + $_def_sunaudio > ++$_def_libsndio > + $_def_sgiaudio > + $_def_win32waveout > + $_def_nas > Index: patches/patch-libao2_audio_out_c > =================================================================== > RCS file: /cvs/ports/x11/mplayer/patches/patch-libao2_audio_out_c,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-libao2_audio_out_c > --- patches/patch-libao2_audio_out_c 12 Feb 2008 11:33:16 -0000 1.1 > +++ patches/patch-libao2_audio_out_c 27 Oct 2008 16:19:01 -0000 > @@ -1,7 +1,16 @@ > -$OpenBSD: patch-libao2_audio_out_c,v 1.1 2008/02/12 11:33:16 jakemsr Exp $ > ---- libao2/audio_out.c.orig Sun Oct 7 12:49:27 2007 > -+++ libao2/audio_out.c Sun Feb 10 17:00:56 2008 > -@@ -74,6 +74,7 @@ extern ao_functions_t audio_out_v4l2; > +--- libao2/audio_out.c.orig Sun Oct 7 21:49:27 2007 > ++++ libao2/audio_out.c Tue Oct 14 11:48:58 2008 > +@@ -53,6 +53,9 @@ extern ao_functions_t audio_out_sdl; > + #ifdef USE_SUN_AUDIO > + extern ao_functions_t audio_out_sun; > + #endif > ++#ifdef USE_LIBSNDIO_AUDIO > ++extern ao_functions_t audio_out_libsndio; > ++#endif > + #ifdef USE_SGI_AUDIO > + extern ao_functions_t audio_out_sgi; > + #endif > +@@ -74,6 +77,7 @@ extern ao_functions_t audio_out_v4l2; > extern ao_functions_t audio_out_mpegpes; > extern ao_functions_t audio_out_pcm; > extern ao_functions_t audio_out_pss; > @@ -9,7 +18,17 @@ $OpenBSD: patch-libao2_audio_out_c,v 1.1 > > ao_functions_t* audio_out_drivers[] = > { > -@@ -140,6 +141,7 @@ ao_functions_t* audio_out_drivers[] = > +@@ -102,6 +106,9 @@ ao_functions_t* audio_out_drivers[] = > + #ifdef USE_SGI_AUDIO > + &audio_out_sgi, > + #endif > ++#ifdef USE_LIBSNDIO_AUDIO > ++ &audio_out_libsndio, > ++#endif > + #ifdef USE_SUN_AUDIO > + &audio_out_sun, > + #endif > +@@ -140,6 +147,7 @@ ao_functions_t* audio_out_drivers[] = > &audio_out_null, > // should not be auto-selected: > &audio_out_pcm, > > -- Antoine