use sndio for audio

ok ratchov@
This commit is contained in:
jakemsr 2010-01-07 09:49:21 +00:00
parent a8100f792c
commit d7d1f081c0
4 changed files with 128 additions and 18 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.36 2009/08/10 06:31:42 kili Exp $
# $OpenBSD: Makefile,v 1.37 2010/01/07 09:49:21 jakemsr Exp $
COMMENT= gtk+2 chess board interface
DISTNAME= eboard-1.0.4
PKGNAME= ${DISTNAME}p4
PKGNAME= ${DISTNAME}p5
CATEGORIES= games x11
HOMEPAGE= http://www.bergo.eng.br/eboard/
@ -18,7 +18,7 @@ WANTLIB= X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes \
Xi Xinerama Xrandr Xrender atk-1.0 c cairo expat fontconfig \
freetype gio-2.0 glib-2.0 glitz gmodule-2.0 gobject-2.0 \
m pango-1.0 pangocairo-1.0 pangoft2-1.0 pixman-1 \
png pthread pthread-stubs stdc++ xcb z
png pthread pthread-stubs sndio stdc++ xcb z
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=eboard/}

View File

@ -1,15 +1,17 @@
$OpenBSD: patch-configure,v 1.3 2007/12/19 09:01:25 fgsch Exp $
--- configure.orig Wed May 23 20:57:45 2007
+++ configure Sun Dec 16 02:26:41 2007
@@ -6,7 +6,7 @@ my $prefix = "/usr/local";
$OpenBSD: patch-configure,v 1.4 2010/01/07 09:49:21 jakemsr Exp $
--- configure.orig Wed May 23 11:57:45 2007
+++ configure Sat Dec 26 03:23:34 2009
@@ -6,8 +6,8 @@ my $prefix = "/usr/local";
my $package = "eboard";
my $version = "1.0.4";
my $cxx = "g++";
-my @cxxflags = ("-O6");
-my @ldflags = ("-lpthread");
+my @cxxflags = ();
my @ldflags = ("-lpthread");
+my @ldflags = ("-pthread");
my @libs = ();
my $configh = "config.h";
my $configmake = "config.make";
@@ -236,7 +236,7 @@ sub append_flags {
my $x = shift @_;
my @y;
@ -37,7 +39,18 @@ $OpenBSD: patch-configure,v 1.3 2007/12/19 09:01:25 fgsch Exp $
} else {
$program = "#include <$z>\nint main() { return 0; }\n";
}
@@ -536,7 +538,7 @@ if ($t2 != 0) {
@@ -512,6 +514,10 @@ if (!header_check("stdio.h","stdlib.h","string.h","uni
#optional headers
header_check("strings.h","sys/soundcard.h","sys/audioio.h","linux/joystick.h");
+if (header_check("sndio.h")) {
+ append_libs("sndio");
+}
+
$t1=macro_check("netinet/in.h","IPPROTO_TCP","HAVE_IPPROTO_TCP_ON_IN_H");
$t2=macro_check("netinet/in.h","TCP_NODELAY","HAVE_TCP_NODELAY_ON_IN_H");
$t3=macro_check("netinet/in.h","SOL_TCP","HAVE_SOL_TCP_ON_IN_H");
@@ -536,7 +542,7 @@ if ($t2 != 0) {
print "netinet/tcp.h not required, SOL_TCP present.\n";
}
} else {

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-sound_cc,v 1.6 2007/12/03 18:54:58 fgsch Exp $
--- sound.cc.orig Wed May 23 19:57:45 2007
+++ sound.cc Mon Dec 3 11:58:00 2007
@@ -46,6 +46,7 @@
$OpenBSD: patch-sound_cc,v 1.7 2010/01/07 09:49:21 jakemsr Exp $
--- sound.cc.orig Wed May 23 11:57:45 2007
+++ sound.cc Sat Dec 26 04:11:49 2009
@@ -46,14 +46,25 @@
#include "eboard.h"
#define SOME_DRIVER 1
@ -9,8 +9,16 @@ $OpenBSD: patch-sound_cc,v 1.6 2007/12/03 18:54:58 fgsch Exp $
#ifdef HAVE_SYS_SOUNDCARD_H
@@ -54,6 +55,9 @@
#define OSS_DRIVER 1
#include <sys/soundcard.h>
+#elif defined HAVE_SNDIO_H
+
+#define SNDIO_DRIVER 1
+#include <sndio.h>
+#undef SOUND_DEV
+#define SOUND_DEV "default"
+
#elif defined HAVE_SYS_AUDIOIO_H
+#undef SOUND_DEV
@ -19,7 +27,7 @@ $OpenBSD: patch-sound_cc,v 1.6 2007/12/03 18:54:58 fgsch Exp $
#define OPENBSD_DRIVER 1
#include <sys/audioio.h>
@@ -74,7 +78,7 @@ SoundEvent::SoundEvent() {
@@ -74,7 +85,7 @@ SoundEvent::SoundEvent() {
Pitch=800;
Duration=250;
Count=1;
@ -28,7 +36,7 @@ $OpenBSD: patch-sound_cc,v 1.6 2007/12/03 18:54:58 fgsch Exp $
ExtraData[0]=0;
enabled = true;
}
@@ -157,7 +161,7 @@ ostream & operator<<(ostream &s, SoundEvent e) {
@@ -157,7 +168,7 @@ ostream & operator<<(ostream &s, SoundEvent e) {
s << e.Device << ',' << e.Count << ',' << (e.enabled?1:0);
break;
case EXT_WAVE:
@ -37,3 +45,92 @@ $OpenBSD: patch-sound_cc,v 1.6 2007/12/03 18:54:58 fgsch Exp $
s << "1," << e.Device << ',' << e.ExtraData;
s << ',' << (e.enabled?1:0);
break;
@@ -200,8 +211,12 @@ void SoundEvent::play() {
switch(type) {
case EXT_WAVE:
+#ifdef SNDIO_DRIVER
+ execlp("aucat","aucat","-i",ExtraData,(char *)NULL);
+#else
execlp("play","play","-d",Device,ExtraData,0);
execlp("sox",ExtraData,"-t","ossdsp",Device,0);
+#endif
break;
case EXT_PROGRAM:
execlp("/bin/sh","/bin/sh","-c",ExtraData,0);
@@ -231,6 +246,11 @@ void SoundEvent::sine_beep(char *device,int pitch,int
int channels=1;
#endif
+#ifdef SNDIO_DRIVER
+ struct sio_hdl *hdl;
+ struct sio_par par;
+#endif
+
#ifdef OPENBSD_DRIVER
audio_info_t ai;
#endif // OPENBSD
@@ -257,9 +277,15 @@ void SoundEvent::sine_beep(char *device,int pitch,int
for(i=1;i<Count;i++)
memcpy(wave+i*(bl+interval),wave,bl);
+#ifdef SNDIO_DRIVER
+ hdl=sio_open(NULL,SIO_PLAY,0);
+ if (hdl==NULL)
+#else
fd=open(device,O_WRONLY);
if (fd<0)
+#endif
goto leave2;
+
#endif // SOME
#ifdef OSS_DRIVER
@@ -273,6 +299,20 @@ void SoundEvent::sine_beep(char *device,int pitch,int
goto leave1;
#endif // OSS
+#ifdef SNDIO_DRIVER
+ sio_initpar(&par);
+ par.bits=8;
+ par.sig=0;
+ par.pchan=1;
+ par.rate=rate;
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
+ goto leave1;
+ if (par.bits != 8 || par.sig != 0 || par.pchan != 1 || par.rate != rate)
+ goto leave1;
+ if (!sio_start(hdl))
+ goto leave1;
+#endif
+
#ifdef OPENBSD_DRIVER
AUDIO_INITINFO(&ai);
ai.mode = AUMODE_PLAY;
@@ -285,8 +325,13 @@ void SoundEvent::sine_beep(char *device,int pitch,int
#endif // OPENBSD
#ifdef SOME_DRIVER
- for(i=0;i<ts;)
+ for(i=0;i<ts;) {
+#ifdef SNDIO_DRIVER
+ i+=sio_write(hdl,&wave[i],ts-i);
+#else
i+=::write(fd,&wave[i],ts-i);
+#endif
+ }
#endif // SOME
#ifdef OSS_DRIVER
@@ -299,7 +344,11 @@ void SoundEvent::sine_beep(char *device,int pitch,int
#ifdef SOME_DRIVER
leave1:
+#ifdef SNDIO_DRIVER
+ sio_close(hdl);
+#else
close(fd);
+#endif // SNDIO
leave2:
free(wave);
#endif // SOME

View File

@ -1,5 +1,5 @@
@comment $OpenBSD: PLIST,v 1.8 2007/12/03 18:54:58 fgsch Exp $
bin/eboard
@comment $OpenBSD: PLIST,v 1.9 2010/01/07 09:49:21 jakemsr Exp $
@bin bin/eboard
bin/eboard-addtheme
bin/eboard-config
@man man/man1/eboard-addtheme.1