- use sndio instead of ossaudio

- more precise license comment
- @bin markers in PLIST

ok ratchov
This commit is contained in:
jakemsr 2009-12-20 00:14:40 +00:00
parent 69e9f98047
commit 024531ef8d
3 changed files with 108 additions and 16 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.23 2009/08/10 06:31:43 kili Exp $
# $OpenBSD: Makefile,v 1.24 2009/12/20 00:14:40 jakemsr Exp $
COMMENT= graphical multi-player real-time strategy game for X11
DISTNAME= xblast-2.10.4
PKGNAME= ${DISTNAME}p0
PKGNAME= ${DISTNAME}p1
DIST_SUBDIR= xblast
DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \
images-2005-01-06${EXTRACT_SUFX} \
@ -15,13 +15,13 @@ CATEGORIES= games
HOMEPAGE= http://xblast.sourceforge.net/
# GPL
# GPLv2
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
WANTLIB= ICE X11 c m ossaudio pthread-stubs xcb
WANTLIB= ICE X11 c m pthread-stubs sndio xcb
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=xblast/}
@ -31,7 +31,7 @@ MODULES= devel/gettext
CONFIGURE_STYLE=autoconf
AUTOCONF_VERSION=2.59
CONFIGURE_ENV= LDFLAGS="-lossaudio \
CONFIGURE_ENV= LDFLAGS="-lsndio \
-L${LOCALBASE}/lib -liconv -lintl"
CONFIGURE_ARGS= --enable-sound \
--with-otherdatadir=${PREFIX}/share/xblast \

View File

@ -1,24 +1,116 @@
$OpenBSD: patch-xbsndsrv_c,v 1.3 2007/12/20 22:03:05 ajacoutot Exp $
--- xbsndsrv.c.orig Mon Jun 12 13:06:36 2006
+++ xbsndsrv.c Sun Dec 16 15:37:02 2007
@@ -75,6 +75,9 @@
$OpenBSD: patch-xbsndsrv_c,v 1.4 2009/12/20 00:14:40 jakemsr Exp $
--- xbsndsrv.c.orig Mon Jun 12 04:06:36 2006
+++ xbsndsrv.c Wed Dec 16 19:48:41 2009
@@ -75,6 +75,10 @@
#ifdef HAVE_LINUX_SOUNDCARD_H
#include <linux/soundcard.h>
#endif
+#ifdef __OpenBSD__
+#include <soundcard.h>
+#define USE_SNDIO
+#include <sndio.h>
+#endif
#endif
@@ -263,6 +266,10 @@ static struct _sound_name
@@ -263,6 +267,10 @@ static struct _sound_name
#define SAMPLE_CHANNELS 2
#define SAMPLE_SIZE 16
#define SUN_AUDIO_REF 0
+#elif __OpenBSD__
+#define SOUND_DEVICE "/dev/sound"
+#elif defined(USE_SNDIO)
+#define SOUND_DEVICE "default"
+#define SAMPLE_CHANNELS 1
+#define SAMPLE_SIZE 8
#else
#define SOUND_DEVICE "/dev/dsp"
#define SAMPLE_CHANNELS 1
@@ -283,6 +291,10 @@ static int sample_rate = SAMPLE_RATE;
static int sample_channels = SAMPLE_CHANNELS;
static int sample_size = SAMPLE_SIZE;
+#ifdef USE_SNDIO
+struct sio_hdl *hdl;
+#endif
+
/*
* outcomment the following line to suppress server statistics
*/
@@ -371,8 +383,20 @@ init_dsp (dsp)
fprintf (stderr, " (wanted %d channels, %d bits, %dHz)\n",
sample_channels, sample_size, sample_rate);
-#else
+#elif defined(USE_SNDIO)
+ struct sio_par par;
+ sio_initpar(&par);
+ par.rate = sample_rate;
+ par.bits = sample_size;
+ par.sig = par.bits == 8 ? 0 : 1;
+ par.pchan = sample_channels ? 2 : 1;
+ par.appbufsz = 1024;
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) || !sio_start(hdl))
+ fprintf (stderr, "XBlast sound server: could not configure sndio\n");
+
+#else
if (ioctl (dsp, SNDCTL_DSP_SETFRAGMENT, &fragsize) < 0) {
fprintf (stderr, "XBlast sound server: could not set fragment size %8x on sound device\n",
fragsize);
@@ -418,7 +442,7 @@ resync (dsp)
#ifdef __sun__
ioctl (dsp, I_FLUSH, NULL);
fprintf (stderr, "\nsync\n");
-#else
+#elif !defined(USE_SNDIO)
/* resync sound device to correct any channel flipping */
write (dsp, playbuff, SUBSIZE);
write (dsp, playbuff, SUBSIZE);
@@ -601,7 +625,11 @@ main (argc, argv)
/*
* open and prepare sound device
*/
+#ifdef USE_SNDIO
+ if ((hdl = sio_open (NULL, SIO_PLAY, 0)) == NULL) {
+#else
if ((dsp = open (SOUND_DEVICE, O_WRONLY)) < 0) {
+#endif
fprintf (stderr, "XBlast sound server: could not open sound device %s\n", SOUND_DEVICE);
ack_val = SND_ACK_ERROR;
write (1, &ack_val, sizeof (ack_val));
@@ -780,7 +808,11 @@ main (argc, argv)
}
/* play buffer */
+#ifdef USE_SNDIO
+ sio_write (hdl, playbuff, SUBSIZE);
+#else
write (dsp, playbuff, SUBSIZE);
+#endif
}
}
else {
@@ -928,6 +960,15 @@ main (argc, argv)
}
}
+#elif defined(USE_SNDIO)
+ switch (sample_size) {
+ case 8:
+ sio_write (hdl, playbuff, SUBSIZE);
+ break;
+ case 16:
+ sio_write (hdl, sumbuff, SUBSIZE * 2);
+ break;
+ }
#else
switch (sample_size) {
case 8:
@@ -950,7 +991,7 @@ main (argc, argv)
/* ioctl(dsp,AUDIO_DRAIN,NULL); */
ioctl (dsp, I_FLUSH, NULL);
fprintf (stderr, "\nsync\n");
-#else
+#elif !defined(USE_SNDIO)
(void)ioctl (dsp, SNDCTL_DSP_SYNC, NULL);
#endif
did_sync = TRUE;

View File

@ -1,6 +1,6 @@
@comment $OpenBSD: PLIST,v 1.7 2007/12/20 22:03:05 ajacoutot Exp $
bin/xblast
bin/xbsndsrv
@comment $OpenBSD: PLIST,v 1.8 2009/12/20 00:14:40 jakemsr Exp $
@bin bin/xblast
@bin bin/xbsndsrv
share/locale/de/LC_MESSAGES/xblast.mo
share/locale/fr/LC_MESSAGES/xblast.mo
share/xblast/