sound support; diffs sent to eboard for inclusion.

This commit is contained in:
fgsch 2002-05-02 07:46:24 +00:00
parent 2f650ca838
commit a3efef3037
4 changed files with 97 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.11 2002/05/02 07:43:09 fgsch Exp $
# $OpenBSD: Makefile,v 1.12 2002/05/02 07:46:24 fgsch Exp $
COMMENT= "gtk+ chess board interface"
@ -21,7 +21,7 @@ MASTER_SITE_SUBDIR= eboard
LIB_DEPENDS= Imlib.19,gdk_imlib::graphics/imlib
USE_X11= Yes
CONFIGURE_STYLE= gnu
CONFIGURE_STYLE= autoconf
DOCS= Crafty.txt FICS-Timeseal.txt GNUChess4.txt GNUChess5.txt \
Scripts.txt Sjeng.txt Themes.txt

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-config_h_in,v 1.1 2002/05/02 07:46:24 fgsch Exp $
--- config.h.in.orig Wed May 1 21:57:53 2002
+++ config.h.in Wed May 1 21:58:20 2002
@@ -17,6 +17,9 @@
/* Define if you have the <sys/soundcard.h> header file. */
#undef HAVE_SYS_SOUNDCARD_H
+/* Define if you have the <sys/audioio.h> header file. */
+#undef HAVE_SYS_AUDIOIO_H
+
/* Define if you have the <vector> header file. */
#undef HAVE_VECTOR

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-configure_in,v 1.1 2002/05/02 07:46:24 fgsch Exp $
--- configure.in.orig Wed May 1 21:57:45 2002
+++ configure.in Wed May 1 21:58:31 2002
@@ -37,6 +37,7 @@ AC_CHECK_HEADERS(vector)
AC_CHECK_HEADERS(string)
AC_CHECK_HEADERS(sys/soundcard.h)
+AC_CHECK_HEADERS(sys/audioio.h)
AC_PATH_PROGS(GTKCONFIG,gtk-config gtk12-config gtk13-config,no)

View File

@ -0,0 +1,71 @@
$OpenBSD: patch-sound_cc,v 1.1 2002/05/02 07:46:24 fgsch Exp $
--- sound.cc.orig Wed May 1 21:56:47 2002
+++ sound.cc Wed May 1 22:05:06 2002
@@ -45,6 +45,8 @@
#ifdef HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
+#elif defined HAVE_SYS_AUDIOIO_H
+#include <sys/audioio.h>
#endif
SoundEvent::SoundEvent() {
@@ -219,6 +221,58 @@ void SoundEvent::sine_beep(char *device,
i+=::write(fd,&wave[i],ts-i);
ioctl(fd,SNDCTL_DSP_POST,0);
+
+ leave1:
+ close(fd);
+ leave2:
+ free(wave);
+#elif defined HAVE_SYS_AUDIOIO_H
+ audio_info_t ai;
+ int rate=11025; // Hz
+ int interval;
+
+ unsigned char *wave;
+ int bl,fd,i,ts;
+ double r,s;
+
+ interval=120*rate/1000; // 120 msec
+
+ wave=(unsigned char *)malloc(ts = (Count*(bl=(rate*duration)/1000) + (Count-1)*interval) );
+
+ if (!wave)
+ /* return; */
+ memset(wave,127,ts);
+
+ for(i=0;i<bl;i++) {
+ r=(double)pitch;
+ r/=(double)rate;
+ r*=(double)i;
+ s=(double)i;
+ s/=(double)bl;
+ s=0.30+sin(M_PI*s)*0.70;
+ wave[i]=(unsigned char)(128.0+127.0*s*sin(M_PI*2.0*r));
+ }
+
+ for(i=1;i<Count;i++)
+ memcpy(wave+i*(bl+interval),wave,bl);
+
+ fd=open(device,O_WRONLY);
+ if (fd<0)
+ goto leave2;
+
+ AUDIO_INITINFO(&ai);
+ ai.mode = AUMODE_PLAY;
+ ai.play.sample_rate = rate;
+ ai.play.channels = 1;
+ ai.play.encoding = AUDIO_ENCODING_ULINEAR;
+
+ if (ioctl(fd,AUDIO_SETINFO,&ai)==-1)
+ goto leave1;
+
+ for(i=0;i<ts;)
+ i+=::write(fd,&wave[i],ts-i);
+
+ ioctl(fd,AUDIO_DRAIN,0);
leave1:
close(fd);