aboutsummaryrefslogtreecommitdiff
path: root/audio/madplay
diff options
context:
space:
mode:
authorTobias Kortkamp <tobik@FreeBSD.org>2018-09-18 10:10:54 +0000
committerTobias Kortkamp <tobik@FreeBSD.org>2018-09-18 10:10:54 +0000
commit89f9209f99c91fcbf23fdf58bfebf7c10954c8ed (patch)
tree5e7aa2dc5ef1a3bb05e34fe4ebce13ae6940d92f /audio/madplay
parent08cabccbc8ec64c7da2761177ff9c1a380ebc854 (diff)
downloadports-89f9209f99c91fcbf23fdf58bfebf7c10954c8ed.tar.gz
ports-89f9209f99c91fcbf23fdf58bfebf7c10954c8ed.zip
audio/madplay: Add sndio backend and option [1]
While here - Follow WWW redirect - Fix license Obtained from: OpenBSD Ports [1]
Notes
Notes: svn path=/head/; revision=480006
Diffstat (limited to 'audio/madplay')
-rw-r--r--audio/madplay/Makefile11
-rw-r--r--audio/madplay/files/audio_sndio.c160
-rw-r--r--audio/madplay/files/patch-audio.h11
-rw-r--r--audio/madplay/files/patch-configure46
-rw-r--r--audio/madplay/pkg-descr4
5 files changed, 227 insertions, 5 deletions
diff --git a/audio/madplay/Makefile b/audio/madplay/Makefile
index 7408c79e9363..1b90a0a7f5b8 100644
--- a/audio/madplay/Makefile
+++ b/audio/madplay/Makefile
@@ -11,7 +11,8 @@ MASTER_SITES= SF/mad/${PORTNAME}/${PORTVERSION} \
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
@@ -23,12 +24,18 @@ 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
diff --git a/audio/madplay/files/audio_sndio.c b/audio/madplay/files/audio_sndio.c
new file mode 100644
index 000000000000..353720ad8f6d
--- /dev/null
+++ b/audio/madplay/files/audio_sndio.c
@@ -0,0 +1,160 @@
+/* $OpenBSD: audio_sndio.c,v 1.2 2009/06/20 14:56:18 martynas Exp $ */
+
+/*
+ * Copyright (c) 2009 Martynas Venckus <martynas@openbsd.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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "global.h"
+#include "gettext.h"
+#include "audio.h"
+
+#include <sndio.h>
+
+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);
+}
+
diff --git a/audio/madplay/files/patch-audio.h b/audio/madplay/files/patch-audio.h
new file mode 100644
index 000000000000..abad1aa16a10
--- /dev/null
+++ b/audio/madplay/files/patch-audio.h
@@ -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;
+
diff --git a/audio/madplay/files/patch-configure b/audio/madplay/files/patch-configure
new file mode 100644
index 000000000000..a9ba72b63710
--- /dev/null
+++ b/audio/madplay/files/patch-configure
@@ -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
diff --git a/audio/madplay/pkg-descr b/audio/madplay/pkg-descr
index 1bb7261da549..7a6cf7fddc7e 100644
--- a/audio/madplay/pkg-descr
+++ b/audio/madplay/pkg-descr
@@ -5,6 +5,4 @@ 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/