On 2009/11/02 13:44, Jan Stary wrote: > After reinstalling with 4.6, which comes with sox-14.2.0p2, > I can no longer play mp3 files. On a previous install (4.5 > which comes with sox-14.2.0p1) I could.
please test this diff, it cleans up and updates the port, and makes "play foo.mp3" work for me. 14.3.0 adds format detection over pipes, but it's disabled here as it needs a non-portable hack to rewind the pipe. (if anyone's interested in seeing if it can be added, see patch-src_formats_c, but let's do that later). Index: Makefile =================================================================== RCS file: /cvs/ports/audio/sox/Makefile,v retrieving revision 1.41 diff -u -p -r1.41 Makefile --- Makefile 6 Apr 2009 18:56:55 -0000 1.41 +++ Makefile 2 Nov 2009 19:01:19 -0000 @@ -2,10 +2,8 @@ COMMENT= Sound eXchange, the Swiss Army knife of audio manipulation -DISTNAME= sox-14.2.0 -PKGNAME= ${DISTNAME}p2 -SHARED_LIBS += sox 0.0 # .0.0 -SHARED_LIBS += sfx 0.0 # .0.0 +DISTNAME= sox-14.3.0 +SHARED_LIBS += sox 1.0 # .1.0 CATEGORIES= audio HOMEPAGE= http://sox.sourceforge.net/ @@ -27,7 +25,6 @@ LIB_DEPENDS= vorbis.>=6,vorbisenc.>=2,vo mp3lame.>=2::audio/lame \ wavpack.>=0::audio/wavpack \ png.>=8::graphics/png \ - samplerate.>=2::audio/libsamplerate \ gsm.>=1::audio/gsm WANTLIB= c iconv m ogg sndio z @@ -42,33 +39,29 @@ CONFIGURE_ARGS= ${CONFIGURE_SHARED} \ CONFIGURE_ARGS+=--without-libltdl # Sound drivers -CONFIGURE_ARGS+=--disable-libao \ - --disable-oss \ - --enable-sndio \ - --disable-sun-audio +CONFIGURE_ARGS+=--without-ao \ + --without-oss \ + --with-sndio \ + --without-sunaudio # Additional file formats CONFIGURE_ARGS+=--without-sndfile \ - --with-ogg \ + --with-oggvorbis \ --with-flac \ --without-ffmpeg \ --with-magic \ --with-mad \ --with-id3tag \ --with-lame \ - --without-amr-wb \ - --without-amr-nb \ + --without-amrwb \ + --without-amrnb \ --with-wavpack \ --with-png \ - --with-samplerate \ --without-ladspa CONFIGURE_ENV= \ CPPFLAGS="-I${LOCALBASE}/include -I${LOCALBASE}/include/libpng" \ LDFLAGS="-L${WRKBUILD}/src/.libs -L${LOCALBASE}/lib" - -post-extract: - @cp ${FILESDIR}/sndio.c ${WRKSRC}/src AUTO_ENV= AUTOCONF_VERSION=${AUTOCONF_VERSION} \ AUTOMAKE_VERSION=${AUTOMAKE_VERSION} Index: distinfo =================================================================== RCS file: /cvs/ports/audio/sox/distinfo,v retrieving revision 1.9 diff -u -p -r1.9 distinfo --- distinfo 8 Jan 2009 19:48:21 -0000 1.9 +++ distinfo 2 Nov 2009 19:01:19 -0000 @@ -1,5 +1,5 @@ -MD5 (sox-14.2.0.tar.gz) = evwOhdFL4BTwjn07fujCTg== -RMD160 (sox-14.2.0.tar.gz) = fHai21xYOPw9n4tUAuR9VI/QlNU= -SHA1 (sox-14.2.0.tar.gz) = G2Dlr0P0SlEkf7l48kI/Defic2M= -SHA256 (sox-14.2.0.tar.gz) = jRuOszpyoYE2lHXJ2l/cvl9oIOavPYag6E9pOeYancE= -SIZE (sox-14.2.0.tar.gz) = 964800 +MD5 (sox-14.3.0.tar.gz) = jjUJgE5iJyc++ECS4aL+pw== +RMD160 (sox-14.3.0.tar.gz) = kwLgDXbJcsSRaXnRR0aPZA4ErKo= +SHA1 (sox-14.3.0.tar.gz) = NLjpkbqFEfqWg+np01b7f0F50Dw= +SHA256 (sox-14.3.0.tar.gz) = mr9BHJSTZtdciEs2goRpC2yMfV+13w3q9ZlTm3BLI5c= +SIZE (sox-14.3.0.tar.gz) = 1007679 Index: files/sndio.c =================================================================== RCS file: files/sndio.c diff -N files/sndio.c --- files/sndio.c 16 Jan 2009 16:42:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,242 +0,0 @@ -/* - * libsndio sound handler - * - * Copyright (c) 2009 Alexandre Ratchov <a...@caoua.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include <string.h> -#include <sndio.h> -#include "sox_i.h" - -struct sndio_priv { - struct sio_hdl *hdl; /* handle to speak to libsndio */ - struct sio_par par; /* current device parameters */ -#define SNDIO_BUFSZ 0x1000 - unsigned char buf[SNDIO_BUFSZ]; /* temp buffer for converions */ -}; - -/* - * convert ``count'' samples from sox encoding to sndio encoding - */ -static void encode(struct sio_par *par, - sox_sample_t *idata, unsigned char *odata, unsigned count) -{ - int obnext, osnext, s, osigbit; - unsigned oshift, obps, i; - - obps = par->bps; - osigbit = par->sig ? 0 : 1 << (par->bits - 1); - oshift = 32 - (par->msb ? par->bps * 8 : par->bits); - if (par->le) { - obnext = 1; - osnext = 0; - } else { - odata += par->bps - 1; - obnext = -1; - osnext = 2 * par->bps; - } - for (; count > 0; count--) { - s = (*idata++ >> oshift) ^ osigbit; - for (i = obps; i > 0; i--) { - *odata = (unsigned char)s; - s >>= 8; - odata += obnext; - } - odata += osnext; - } -} - -/* - * convert ``count'' samples from sndio encoding to sox encoding - */ -static void decode(struct sio_par *par, - unsigned char *idata, sox_sample_t *odata, unsigned count) -{ - unsigned ishift, ibps, i; - int s = 0xdeadbeef, ibnext, isnext, isigbit; - - ibps = par->bps; - isigbit = par->sig ? 0 : 1 << (par->bits - 1); - ishift = 32 - (par->msb ? par->bps * 8 : par->bits); - if (par->le) { - idata += par->bps - 1; - ibnext = -1; - isnext = 2 * par->bps; - } else { - ibnext = 1; - isnext = 0; - } - for (; count > 0; count--) { - for (i = ibps; i > 0; i--) { - s <<= 8; - s |= *idata; - idata += ibnext; - } - idata += isnext; - *odata++ = (s ^ isigbit) << ishift; - } -} - -static int startany(struct sox_format *ft, unsigned mode) -{ - struct sndio_priv *p = (struct sndio_priv *)ft->priv; - struct sio_par reqpar; - char *device; - - device = ft->filename; - if (strcmp("default", device) == 0) - device = NULL; - - p->hdl = sio_open(device, mode, 0); - if (p->hdl == NULL) - return SOX_EOF; - /* - * set specified parameters, leaving others to the defaults - */ - sio_initpar(&reqpar); - if (ft->signal.rate > 0) - reqpar.rate = ft->signal.rate; - if (ft->signal.channels > 0) { - if (mode == SIO_PLAY) - reqpar.pchan = ft->signal.channels; - else - reqpar.rchan = ft->signal.channels; - } - if (ft->signal.precision > 0) - reqpar.bits = ft->signal.precision; - switch (ft->encoding.encoding) { - case SOX_ENCODING_SIGN2: - reqpar.sig = 1; - break; - case SOX_ENCODING_UNSIGNED: - reqpar.sig = 0; - break; - default: - break; /* use device default */ - } - if (ft->encoding.bits_per_sample > 0) - reqpar.bits = ft->encoding.bits_per_sample; - if (ft->encoding.reverse_bytes != SOX_OPTION_DEFAULT) { - reqpar.le = SIO_LE_NATIVE; - if (ft->encoding.reverse_bytes) - reqpar.le = !reqpar.le; - } - if (!sio_setpar(p->hdl, &reqpar) || - !sio_getpar(p->hdl, &p->par)) - goto failed; - ft->signal.channels = (mode == SIO_PLAY) ? p->par.pchan : p->par.rchan; - ft->signal.precision = p->par.bits; - ft->signal.rate = p->par.rate; - ft->encoding.encoding = p->par.sig ? SOX_ENCODING_SIGN2 : SOX_ENCODING_UNSIGNED; - ft->encoding.bits_per_sample = p->par.bps * 8; - ft->encoding.reverse_bytes = SIO_LE_NATIVE ? !p->par.le : p->par.le; - ft->encoding.reverse_nibbles = SOX_OPTION_NO; - ft->encoding.reverse_bits = SOX_OPTION_NO; - - if (!sio_start(p->hdl)) - goto failed; - return SOX_SUCCESS; - failed: - sio_close(p->hdl); - return SOX_EOF; -} - -static int stopany(struct sox_format *ft) -{ - sio_close(((struct sndio_priv *)ft->priv)->hdl); - return SOX_SUCCESS; -} - -static int startread(struct sox_format *ft) -{ - return startany(ft, SIO_REC); -} - -static int startwrite(struct sox_format *ft) -{ - return startany(ft, SIO_PLAY); -} - -static size_t readsamples(sox_format_t *ft, sox_sample_t *buf, size_t len) -{ - struct sndio_priv *p = (struct sndio_priv *)ft->priv; - unsigned char partial[4]; - unsigned cpb, cc, pc; - size_t todo, n; - - pc = 0; - todo = len * p->par.bps; - cpb = SNDIO_BUFSZ - (SNDIO_BUFSZ % p->par.bps); - while (todo > 0) { - memcpy(p->buf, partial, pc); - cc = cpb - pc; - if (cc > todo) - cc = todo; - n = sio_read(p->hdl, p->buf + pc, cc); - if (n == 0 && sio_eof(p->hdl)) - break; - n += pc; - pc = n % p->par.bps; - n -= pc; - memcpy(partial, p->buf + n, pc); - decode(&p->par, p->buf, buf, n / p->par.bps); - buf += n / p->par.bps; - todo -= n; - } - return len - todo / p->par.bps; -} - -static size_t writesamples(sox_format_t *ft, const sox_sample_t *buf, size_t len) -{ - struct sndio_priv *p = (struct sndio_priv *)ft->priv; - unsigned sc, spb; - size_t n, todo; - - todo = len; - spb = SNDIO_BUFSZ / p->par.bps; - while (todo > 0) { - sc = spb; - if (sc > todo) - sc = todo; - encode(&p->par, buf, p->buf, sc); - n = sio_write(p->hdl, p->buf, sc * p->par.bps); - if (n == 0 && sio_eof(p->hdl)) - break; - n /= p->par.bps; - todo -= n; - buf += n; - } - return len - todo; -} - -SOX_FORMAT_HANDLER(sndio) -{ - static char const * const names[] = {"sndio", NULL}; - static unsigned const write_encodings[] = { - SOX_ENCODING_SIGN2, 32, 24, 16, 8, 0, - SOX_ENCODING_UNSIGNED, 32, 24, 16, 8, 0, - 0 - }; - static sox_format_handler_t const handler = { - SOX_LIB_VERSION_CODE, - "libsndio device driver", - names, - SOX_FILE_DEVICE | SOX_FILE_NOSTDIO, - startread, readsamples, stopany, - startwrite, writesamples, stopany, - NULL, write_encodings, NULL, - sizeof(struct sndio_priv) - }; - return &handler; -} Index: patches/patch-configure_ac =================================================================== RCS file: patches/patch-configure_ac diff -N patches/patch-configure_ac --- patches/patch-configure_ac 16 Jan 2009 16:42:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,35 +0,0 @@ -$OpenBSD: patch-configure_ac,v 1.1 2009/01/16 16:42:56 ratchov Exp $ ---- configure.ac.orig Fri Nov 7 18:54:28 2008 -+++ configure.ac Thu Jan 8 22:08:14 2009 -@@ -225,6 +225,23 @@ fi - AM_CONDITIONAL(HAVE_OSS, test x$enable_oss = xyes) - AC_SUBST(OSS_LIBS) - -+dnl Check for sndio -+AC_MSG_CHECKING([whether to try building sndio sound driver]) -+AC_ARG_ENABLE(sndio, -+ AC_HELP_STRING([--disable-sndio], [Don't build sndio sound driver.]),,enable_sndio=yes) -+AC_MSG_RESULT($enable_sndio) -+if test "$enable_sndio" = "yes"; then -+ AC_CHECK_HEADERS(sndio.h, -+ [AC_CHECK_LIB(sndio, sio_open, SNDIO_LIBS="$SNDIO_LIBS -lsndio")], -+ enable_sndio=no) -+fi -+if test "$enable_sndio" = yes; then -+ AC_DEFINE(HAVE_SNDIO, 1, [Define to 1 if you have sndio.]) -+ audio_driver_found=yes -+fi -+AM_CONDITIONAL(HAVE_SNDIO, test x$enable_sndio = xyes) -+AC_SUBST(SNDIO_LIBS) -+ - dnl Check for Sun audio - AC_MSG_CHECKING([whether to try building Sun audio driver]) - AC_ARG_ENABLE(sun-audio, -@@ -607,6 +624,7 @@ echo "External module support........... $using_libltd - echo "ALSA driver....................... $enable_alsa" - echo "libao driver...................... $enable_libao" - echo "OSS driver........................ $enable_oss" -+echo "sndio driver...................... $enable_sndio" - echo "SUN audio driver.................. $enable_sun_audio" - echo "CoreAudio driver.................. $enable_coreaudio" - echo "symlinks enabled.................. $enable_symlinks" Index: patches/patch-src_Makefile_am =================================================================== RCS file: patches/patch-src_Makefile_am diff -N patches/patch-src_Makefile_am --- patches/patch-src_Makefile_am 16 Jan 2009 16:42:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +0,0 @@ -$OpenBSD: patch-src_Makefile_am,v 1.1 2009/01/16 16:42:56 ratchov Exp $ ---- src/Makefile.am.orig Thu Jan 8 21:57:05 2009 -+++ src/Makefile.am Thu Jan 8 21:59:19 2009 -@@ -239,6 +239,11 @@ libsox_fmt_oss_la_SOURCES = oss.c - libsox_fmt_oss_la_LIBADD = libsox.la @OSS_LIBS@ - pkglib_LTLIBRARIES += libsox_fmt_oss.la - endif -+if HAVE_SNDIO -+libsox_fmt_sndio_la_SOURCES = sndio.c -+libsox_fmt_sndio_la_LIBADD = libsox.la @SNDIO_LIBS@ -+pkglib_LTLIBRARIES += libsox_fmt_sndio.la -+endif - if HAVE_SUN_AUDIO - libsox_fmt_sunau_la_SOURCES = sunaudio.c - libsox_fmt_sunau_la_LIBADD = libsox.la -@@ -360,6 +365,11 @@ if HAVE_OSS - libsox_la_SOURCES += oss.c - libsox_la_LIBADD += @OSS_LIBS@ - sox_LDADD += @OSS_LIBS@ -+endif -+if HAVE_SNDIO -+ libsox_la_SOURCES += sndio.c -+ libsox_la_LIBADD += @SNDIO_LIBS@ -+ sox_LDADD += @SNDIO_LIBS@ - endif - if HAVE_SUN_AUDIO - libsox_la_SOURCES += sunaudio.c Index: patches/patch-src_formats_c =================================================================== RCS file: patches/patch-src_formats_c diff -N patches/patch-src_formats_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_formats_c 2 Nov 2009 19:01:19 -0000 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- src/formats.c.orig Mon Nov 2 17:11:55 2009 ++++ src/formats.c Mon Nov 2 17:11:34 2009 +@@ -403,7 +403,7 @@ static void UNUSED rewind_pipe(FILE * fp) + /* To fix this #error, either simply remove the #error line and live without + * file-type detection with pipes, or add support for your compiler in the + * lines above. Test with cat monkey.au | ./sox --info - */ +- #error FIX NEEDED HERE ++ /* #error FIX NEEDED HERE */ + #define NO_REWIND_PIPE + (void)fp; + #endif Index: patches/patch-src_formats_h =================================================================== RCS file: patches/patch-src_formats_h diff -N patches/patch-src_formats_h --- patches/patch-src_formats_h 16 Jan 2009 16:42:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,12 +0,0 @@ ---- src/formats.h.old Sun Jan 11 19:41:19 2009 -+++ src/formats.h Sun Jan 11 19:41:56 2009 -@@ -87,6 +87,9 @@ - #if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H) - FORMAT(oss) - #endif -+#if defined HAVE_SNDIO -+ FORMAT(sndio) -+#endif - #if defined HAVE_SNDFILE - FORMAT(sndfile) - #if defined HAVE_SNDFILE_1_0_12 Index: patches/patch-src_sox_c =================================================================== RCS file: patches/patch-src_sox_c diff -N patches/patch-src_sox_c --- patches/patch-src_sox_c 16 Jan 2009 16:42:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ ---- src/sox.c.orig Mon Jan 12 11:36:30 2009 -+++ src/sox.c Mon Jan 12 11:37:54 2009 -@@ -2142,7 +2142,7 @@ static char const * device_name(char const * const typ - return NULL; - if (!strcmp(type, "sunau")) name = "/dev/audio"; - else if (!strcmp(type, "oss" ) || !strcmp(type, "ossdsp")) name = "/dev/dsp"; -- else if (!strcmp(type, "alsa") || !strcmp(type, "ao") || !strcmp(type, "coreaudio")) name = "default"; -+ else if (!strcmp(type, "alsa") || !strcmp(type, "ao") || !strcmp(type, "coreaudio") || !strcmp(type, "sndio")) name = "default"; - return name? from_env? from_env : name : NULL; - } - -@@ -2154,6 +2154,7 @@ static char const * set_default_device(file_t * f) - if (!f->filetype && sox_find_format("alsa", sox_false)) f->filetype = "alsa"; - if (!f->filetype && sox_find_format("oss" , sox_false)) f->filetype = "oss"; - if (!f->filetype && sox_find_format("sunau",sox_false)) f->filetype = "sunau"; -+ if (!f->filetype && sox_find_format("sndio", sox_false)) f->filetype = "sndio"; - if (!f->filetype && sox_find_format("ao" , sox_false) && file_count) /*!rec*/ - f->filetype = "ao"; -