Index: head/audio/madplay/Makefile =================================================================== --- head/audio/madplay/Makefile (revision 480005) +++ head/audio/madplay/Makefile (revision 480006) @@ -1,35 +1,42 @@ # Created by: Sergey Akifyev # $FreeBSD$ PORTNAME= madplay PORTVERSION= 0.15.2b PORTREVISION= 7 CATEGORIES= audio MASTER_SITES= SF/mad/${PORTNAME}/${PORTVERSION} \ ftp://ftp.mars.org/pub/mpeg/ MAINTAINER= ports@FreeBSD.org COMMENT= Madplay MP3 player (part of MAD project) -LICENSE= GPLv2 +LICENSE= GPLv2+ +LICENSE_FILE= ${WRKSRC}/COPYRIGHT LIB_DEPENDS= libmad.so:audio/libmad \ libid3tag.so:audio/libid3tag USES= localbase GNU_CONFIGURE= yes CONFIGURE_ARGS= --without-esd LDFLAGS+= -lz ALL_TARGET= all madtime -OPTIONS_DEFINE= NLS +OPTIONS_DEFINE= NLS SNDIO OPTIONS_SUB= yes NLS_USES= gettext NLS_CONFIGURE_ENABLE= nls + +SNDIO_CONFIGURE_WITH= sndio +SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio + +post-extract-SNDIO-on: + @${CP} ${FILESDIR}/audio_sndio.c ${WRKSRC} post-install: ${INSTALL_PROGRAM} ${WRKSRC}/madtime ${STAGEDIR}${PREFIX}/bin .include Index: head/audio/madplay/files/audio_sndio.c =================================================================== --- head/audio/madplay/files/audio_sndio.c (nonexistent) +++ head/audio/madplay/files/audio_sndio.c (revision 480006) @@ -0,0 +1,160 @@ +/* $OpenBSD: audio_sndio.c,v 1.2 2009/06/20 14:56:18 martynas Exp $ */ + +/* + * Copyright (c) 2009 Martynas Venckus + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "global.h" +#include "gettext.h" +#include "audio.h" + +#include + +static audio_pcmfunc_t *audio_pcm; +static struct sio_hdl *hdl; +static int sio_started; + +static int +init(struct audio_init *init) +{ + hdl = sio_open((char *)init->path, SIO_PLAY, 0); + if (hdl == NULL) { + audio_error = ":"; + return (-1); + } + + return (0); +} + +static int +config(struct audio_config *config) +{ + struct sio_par par; + unsigned int bitdepth; + + bitdepth = config->precision & ~7; + if (bitdepth == 0) { + bitdepth = 16; + } else if (bitdepth > 32) { + bitdepth = 32; + } + + sio_initpar(&par); + par.bits = bitdepth; + par.le = SIO_LE_NATIVE; + par.pchan = config->channels; + par.rate = config->speed; + par.sig = (par.bits == 8) ? 0 : 1; + + if (sio_started) { + sio_stop(hdl); + sio_started = 0; + } + + if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) || + !sio_start(hdl)) { + audio_error = ":sio_setpar"; + sio_close(hdl); + return (-1); + } + + sio_started = 1; + + switch(par.bits) { + case 8: + audio_pcm = audio_pcm_u8; + break; + case 16: + audio_pcm = par.le ? audio_pcm_s16le : audio_pcm_s16be; + break; + case 24: + audio_pcm = par.le ? audio_pcm_s32le : audio_pcm_s32be; + break; + case 32: + audio_pcm = par.le ? audio_pcm_s32le : audio_pcm_s32be; + break; + default: + audio_error = _("no supported audio format available"); + sio_close(hdl); + return (-1); + } + + config->channels = par.pchan; + config->precision = par.bits; + config->speed = par.rate; + + return (0); +} + +static int +play(struct audio_play *play) +{ + unsigned char data[MAX_NSAMPLES * 4 * 2]; + unsigned int len; + int count; + + len = audio_pcm(data, play->nsamples, play->samples[0], + play->samples[1], play->mode, play->stats); + + count = (int)sio_write(hdl, data, len); + if (count == 0 && sio_eof(hdl)) + return (-1); + + return (count); +} + +static int +stop(struct audio_stop *stop) +{ + return (0); +} + +static int +finish(struct audio_finish *finish) +{ + sio_close(hdl); + + return (0); +} + +int +audio_sndio(union audio_control *control) +{ + audio_error = 0; + + switch (control->command) { + case AUDIO_COMMAND_INIT: + return (init(&control->init)); + + case AUDIO_COMMAND_CONFIG: + return (config(&control->config)); + + case AUDIO_COMMAND_PLAY: + return (play(&control->play)); + + case AUDIO_COMMAND_STOP: + return (stop(&control->stop)); + + case AUDIO_COMMAND_FINISH: + return (finish(&control->finish)); + } + + return (0); +} + Property changes on: head/audio/madplay/files/audio_sndio.c ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/audio/madplay/files/patch-audio.h =================================================================== --- head/audio/madplay/files/patch-audio.h (nonexistent) +++ head/audio/madplay/files/patch-audio.h (revision 480006) @@ -0,0 +1,11 @@ +$OpenBSD: patch-audio_h,v 1.1 2009/03/28 16:26:46 martynas Exp $ +--- audio.h.orig 2004-01-23 09:41:31 UTC ++++ audio.h +@@ -98,6 +98,7 @@ audio_ctlfunc_t audio_jaguar; + audio_ctlfunc_t audio_nas; + audio_ctlfunc_t audio_oss; + audio_ctlfunc_t audio_qnx; ++audio_ctlfunc_t audio_sndio; + audio_ctlfunc_t audio_sun; + audio_ctlfunc_t audio_win32; + Property changes on: head/audio/madplay/files/patch-audio.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/audio/madplay/files/patch-configure =================================================================== --- head/audio/madplay/files/patch-configure (nonexistent) +++ head/audio/madplay/files/patch-configure (revision 480006) @@ -0,0 +1,46 @@ +Do the bare minimum to provide a toggle for sndio support + +--- configure.orig 2004-02-23 21:36:21 UTC ++++ configure +@@ -27912,7 +27912,30 @@ echo "$as_me: error: cannot use both --with-$audio and + + fi; + ++want_sndio=yes + ++# Check whether --with-esd or --without-esd was given. ++if test "${with_sndio+set}" = set; then ++ withval="$with_sndio" ++ ++ case "$withval" in ++ yes) ++ if test "$audio" = unknown ++ then ++ audio="sndio" ++ else ++ { { echo "$as_me:$LINENO: error: cannot use both --with-$audio and --with-esd" >&5 ++echo "$as_me: error: cannot use both --with-$audio and --with-esd" >&2;} ++ { (exit 1); exit 1; }; } ++ fi ++ ;; ++ no) ++ want_sndio=no ++ ;; ++ esac ++ ++fi; ++ + if test "$audio" = unknown + then + case "$host" in +@@ -28252,6 +28275,10 @@ else + fi + fi + ++if test "$audio" = sndio && test "$want_sndio" = yes ++then ++ ldadd_audio="$ldadd_audio -lsndio" ++fi + + if test "$audio" = unknown + then Property changes on: head/audio/madplay/files/patch-configure ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/audio/madplay/pkg-descr =================================================================== --- head/audio/madplay/pkg-descr (revision 480005) +++ head/audio/madplay/pkg-descr (revision 480006) @@ -1,10 +1,8 @@ MAD is a high-quality MPEG audio decoder. It currently supports MPEG-1 as well as the MPEG-2 extension to Lower Sampling Frequencies. All three audio layers (Layer I, Layer II, and Layer III a.k.a. MP3) are fully implemented. This is madplay (MP3-player) which is part of the project -LICENSE: GPL2 or later - -WWW: http://mad.sourceforge.net/ +WWW: https://www.underbit.com/products/mad/