use sndio instead of audio(4) for audio, although it seems nothing in

the ports tree actually uses libmikmod's audio output API.  kill
esd FLAVOR too.
ok pvalchev@ (MAINTAINER)
This commit is contained in:
jakemsr 2010-01-11 04:25:26 +00:00
parent 1c9d24fcc9
commit 1d3505c9eb
6 changed files with 261 additions and 16 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.16 2009/03/06 21:24:52 jasper Exp $
# $OpenBSD: Makefile,v 1.17 2010/01/11 04:25:26 jakemsr Exp $
COMMENT= mikmod sound library
VERSION= 3.1.10
DISTNAME= libmikmod-${VERSION}
PKGNAME= ${DISTNAME}p7
PKGNAME= ${DISTNAME}p8
SHARED_LIBS += mikmod 2.4 # .2.4
CATEGORIES= audio devel
@ -20,22 +20,18 @@ PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ${HOMEPAGE}/files/libmikmod/ \
${MASTER_SITE_SUNSITE:=apps/sound/libs/}
WANTLIB= sndio
SEPARATE_BUILD= concurrent
CONFIGURE_STYLE= gnu
USE_LIBTOOL= Yes
CONFIGURE_ENV= CFLAGS="-DDRV_SNDIO" LIBRARY_LIB="-lsndio"
CONFIGURE_ARGS+= ${CONFIGURE_SHARED}
CONFIGURE_ARGS+= --disable-dl \
--enable-oss
--disable-oss \
--disable-esd
FLAVORS= esd
FLAVOR?=
.if ${FLAVOR:L:Mesd}
CONFIGURE_ARGS+= --enable-esd
LIB_DEPENDS+= esd.>=2::audio/esound
WANTLIB+= audiofile m sndio
.else
CONFIGURE_ARGS+= --disable-esd
.endif
post-extract:
cp ${FILESDIR}/drv_sndio.c ${WRKSRC}/drivers
.include <bsd.port.mk>

View File

@ -0,0 +1,187 @@
/*
* Copyright (c) 2009 Jacob Meuser <jakemsr@sdf.lonestar.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 "mikmod_internals.h"
#ifdef DRV_SNDIO
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sndio.h>
#define DEFAULT_FRAGSIZE 12
static struct sio_hdl *hdl;
static struct sio_par par;
static int fragsize = 1 << DEFAULT_FRAGSIZE;
static SBYTE *audiobuffer = NULL;
static void Sndio_CommandLine(CHAR *cmdline)
{
CHAR *ptr;
if ((ptr = MD_GetAtom("buffer", cmdline, 0))) {
int buf = atoi(ptr);
if (buf >= 7 && buf <= 17)
fragsize = 1 << buf;
free(ptr);
}
}
static BOOL Sndio_IsThere(void)
{
/* could try sio_open() ? */
return 1;
}
static BOOL Sndio_Init(void)
{
hdl = sio_open(NULL, SIO_PLAY, 0);
if (hdl == NULL) {
_mm_errno = MMERR_OPENING_AUDIO;
return 1;
}
if (!(audiobuffer = (SBYTE *)_mm_malloc(fragsize)))
return 1;
sio_initpar(&par);
par.bits = (md_mode & DMODE_16BITS) ? 16 : 8;
par.pchan = (md_mode & DMODE_STEREO) ? 2 : 1;
par.rate = md_mixfreq;
par.le = SIO_LE_NATIVE;
par.sig = par.bits == 8 ? 0 : 1;
par.appbufsz = 4 * fragsize / SIO_BPS(par.bits) / par.pchan;
if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
_mm_errno = MMERR_SUN_INIT;
return 1;
}
/* Align to what the card gave us */
md_mixfreq = par.rate;
if (par.bits == 8)
md_mode &= ~(DMODE_16BITS);
else if (par.bits == 16)
md_mode |= DMODE_16BITS;
else {
_mm_errno = MMERR_SUN_INIT;
return 1;
}
if (par.pchan == 1)
md_mode &= ~(DMODE_STEREO);
else if (par.pchan == 2)
md_mode |= DMODE_STEREO;
else {
_mm_errno = MMERR_SUN_INIT;
return 1;
}
return VC_Init();
}
static void Sndio_Exit(void)
{
VC_Exit();
_mm_free(audiobuffer);
if (hdl) {
sio_close(hdl);
hdl = NULL;
}
}
static void Sndio_Update(void)
{
int done;
done = VC_WriteBytes((char *)audiobuffer, fragsize);
sio_write(hdl, audiobuffer, done);
}
static void Sndio_Pause(void)
{
int done;
done = VC_SilenceBytes((char *)audiobuffer, fragsize);
sio_write(hdl, audiobuffer, done);
}
static BOOL Sndio_PlayStart(void)
{
if (!sio_start(hdl))
return 1;
return VC_PlayStart();
}
static void Sndio_PlayStop(void)
{
//sio_stop(hdl);
VC_PlayStop();
}
MIKMODAPI MDRIVER drv_sndio = {
NULL,
"Sndio Audio",
"sndio audio driver v1.0",
0, 255,
"audio",
Sndio_CommandLine,
Sndio_IsThere,
VC_SampleLoad,
VC_SampleUnload,
VC_SampleSpace,
VC_SampleLength,
Sndio_Init,
Sndio_Exit,
NULL,
VC_SetNumVoices,
Sndio_PlayStart,
Sndio_PlayStop,
Sndio_Update,
Sndio_Pause,
VC_VoiceSetVolume,
VC_VoiceGetVolume,
VC_VoiceSetFrequency,
VC_VoiceGetFrequency,
VC_VoiceSetPanning,
VC_VoiceGetPanning,
VC_VoicePlay,
VC_VoiceStop,
VC_VoiceStopped,
VC_VoiceGetPosition,
VC_VoiceRealVolume
};
#else
MISSING(drv_sndio);
#endif
/* ex:set ts=4: */

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-configure,v 1.1 2010/01/11 04:25:26 jakemsr Exp $
--- configure.orig Sat Dec 19 01:48:17 2009
+++ configure Sat Dec 19 01:48:17 2009
@@ -3682,7 +3682,7 @@ done
libmikmod_driver_hp=yes
fi
;;
- NetBSD|OpenBSD)
+ NetBSD)
for ac_hdr in sys/audioio.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-include_mikmod_h_in,v 1.1 2004/09/14 22:42:30 brad Exp $
--- include/mikmod.h.in.orig Wed Sep 1 15:31:40 2004
+++ include/mikmod.h.in Wed Sep 1 15:32:10 2004
$OpenBSD: patch-include_mikmod_h_in,v 1.2 2010/01/11 04:25:26 jakemsr Exp $
--- include/mikmod.h.in.orig Thu Jan 17 14:39:38 2002
+++ include/mikmod.h.in Fri Dec 18 23:53:46 2009
@@ -85,7 +85,7 @@ typedef char CHAR;
@DOES_NOT_HAVE_SIGNED@
@ -10,3 +10,11 @@ $OpenBSD: patch-include_mikmod_h_in,v 1.1 2004/09/14 22:42:30 brad Exp $
/* 64 bit architectures */
typedef signed char SBYTE; /* 1 byte, signed */
@@ -669,6 +669,7 @@ MIKMODAPI extern struct MDRIVER drv_hp; /* HP-UX a
MIKMODAPI extern struct MDRIVER drv_oss; /* OpenSound System (Linux,FreeBSD...) */
MIKMODAPI extern struct MDRIVER drv_sgi; /* SGI audio library */
MIKMODAPI extern struct MDRIVER drv_sun; /* Sun/NetBSD/OpenBSD audio device */
+MIKMODAPI extern struct MDRIVER drv_sndio; /* sndio, baby! */
MIKMODAPI extern struct MDRIVER drv_dart; /* OS/2 Direct Audio RealTime */
MIKMODAPI extern struct MDRIVER drv_os2; /* OS/2 MMPM/2 */

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-libmikmod_Makefile_in,v 1.3 2010/01/11 04:25:26 jakemsr Exp $
--- libmikmod/Makefile.in.orig Wed Jan 23 14:15:14 2002
+++ libmikmod/Makefile.in Sat Dec 19 00:06:55 2009
@@ -30,13 +30,13 @@ MKINSTALLDIRS=${top_srcdir}/mkinstalldirs
DEFS=@DEFS@
CFLAGS=@CFLAGS@ -Dunix
-COMPILE=$(LIBTOOL) --silent --mode=compile $(CC) $(DEFS) $(CFLAGS) -I$(top_srcdir)/include -I$(top_builddir) -I$(top_builddir)/include -DMIKMOD_H=$(top_srcdir)/include/mikmod.h
+COMPILE=$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(CFLAGS) -I$(top_srcdir)/include -I$(top_builddir) -I$(top_builddir)/include -DMIKMOD_H=$(top_srcdir)/include/mikmod.h
LIB = libmikmod.la
OBJ = $(LIBOBJS) $(DLOBJS) \
drv_AF.lo drv_aix.lo drv_alsa.lo drv_esd.lo drv_hp.lo drv_nos.lo \
drv_oss.lo drv_pipe.lo drv_raw.lo drv_sam9407.lo drv_sgi.lo \
- drv_stdout.lo drv_sun.lo drv_ultra.lo drv_wav.lo \
+ drv_stdout.lo drv_sun.lo drv_sndio.lo drv_ultra.lo drv_wav.lo \
load_669.lo load_amf.lo load_dsm.lo load_far.lo load_gdm.lo load_it.lo \
load_imf.lo load_m15.lo load_med.lo load_mod.lo load_mtm.lo load_okt.lo \
load_s3m.lo load_stm.lo load_stx.lo load_ult.lo load_uni.lo load_xm.lo \
@@ -117,6 +117,9 @@ drv_stdout.lo: $(top_srcdir)/drivers/drv_stdout.c \
drv_sun.lo: $(top_srcdir)/drivers/drv_sun.c \
$(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
$(COMPILE) -c $(top_srcdir)/drivers/drv_sun.c
+drv_sndio.lo: $(top_srcdir)/drivers/drv_sndio.c \
+ $(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
+ $(COMPILE) -c $(top_srcdir)/drivers/drv_sndio.c
drv_ultra.lo: $(top_srcdir)/drivers/drv_ultra.c \
$(top_builddir)/include/mikmod.h $(top_srcdir)/include/mikmod_internals.h
$(COMPILE) -c $(top_srcdir)/drivers/drv_ultra.c

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-playercode_mdreg_c,v 1.1 2010/01/11 04:25:26 jakemsr Exp $
--- playercode/mdreg.c.orig Fri Dec 18 23:51:15 2009
+++ playercode/mdreg.c Fri Dec 18 23:51:44 2009
@@ -66,6 +66,9 @@ void _mm_registeralldrivers(void)
#ifdef DRV_SUN
_mm_registerdriver(&drv_sun);
#endif
+#ifdef DRV_SNDIO
+ _mm_registerdriver(&drv_sndio);
+#endif
#ifdef DRV_DART
_mm_registerdriver(&drv_dart);
#endif