say sndio
--
[email protected]
SDF Public Access UNIX System - http://sdf.lonestar.org
Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/rsynth/Makefile,v
retrieving revision 1.24
diff -N -u -p Makefile
--- Makefile 15 Sep 2007 21:26:03 -0000 1.24
+++ Makefile 20 Dec 2009 07:18:12 -0000
@@ -2,6 +2,7 @@
COMMENT= speech synthesizer
DISTNAME= rsynth-2.0
+PKGNAME= ${DISTNAME}p0
CATEGORIES= audio
MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/
@@ -9,7 +10,7 @@ PERMIT_PACKAGE_CDROM= no license
PERMIT_PACKAGE_FTP= no license
PERMIT_DISTFILES_CDROM= no license
PERMIT_DISTFILES_FTP= no license
-WANTLIB= c m ossaudio
+WANTLIB= c m sndio
FAKE_FLAGS= PREFIX=${WRKINST}${PREFIX}
Index: files/openbsdplay.c
===================================================================
RCS file: /cvs/ports/audio/rsynth/files/openbsdplay.c,v
retrieving revision 1.1.1.1
diff -N -u -p files/openbsdplay.c
--- files/openbsdplay.c 8 Jun 1998 02:00:53 -0000 1.1.1.1
+++ files/openbsdplay.c 20 Dec 2009 07:18:12 -0000
@@ -10,18 +10,15 @@
#include <useconfig.h>
#include <stdio.h>
#include <math.h>
-#include <errno.h>
#include <ctype.h>
-#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/signal.h>
-#include <sys/ioctl.h>
+#include <sndio.h>
-#include <soundcard.h>
#include "proto.h"
#include "getargs.h"
#include "hplay.h"
@@ -31,9 +28,8 @@ long samp_rate = SAMP_RATE;
/* Audio Parameters */
-static int dev_fd = -1;
- /* file descriptor for audio device */
-char *dev_file = "/dev/audio";
+static struct sio_hdl *hdl;
+static struct sio_par par;
static int linear_fd = -1;
@@ -44,10 +40,10 @@ char *prog = "hplay";
static int
audio_open(void)
{
- dev_fd = open(dev_file, O_WRONLY | O_NDELAY);
- if (dev_fd < 0)
+ hdl = sio_open(NULL, SIO_PLAY, 0);
+ if (hdl == NULL)
{
- perror(dev_file);
+ fprintf(stderr, "sio_open failed\n");
return 0;
}
return 1;
@@ -69,32 +65,52 @@ audio_init(int argc, char *argv[])
if (help_only)
return argc;
- if (use_audio)
- audio_open();
-
if (rate_set)
samp_rate = rate_set;
- if (dev_fd > 0)
+ if (!use_audio)
+ return argc;
+
+ audio_open();
+
+ sio_initpar(&par);
+ par.bits = 16;
+ par.sig = 1;
+ par.rate = samp_rate;
+ par.pchan = 1;
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
{
- ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate);
- printf("Actual sound rate: %ld\n", samp_rate);
+ fprintf(stderr, "error setting sndio parameters\n");
+ hdl = NULL;
}
+ else
+ {
+ if (par.bits != 16 || par.sig != 1 || par.pchan != 1 || par.rate !=
samp_rate)
+ {
+ fprintf(stderr, "returned incorrect sndio parameters\n");
+ hdl = NULL;
+ }
+ }
+ if (hdl && !sio_start(hdl))
+ {
+ fprintf(stderr, "error starting sndio\n");
+ hdl = NULL;
+ }
+
return argc;
}
void
audio_term()
{
- int dummy;
/* Close audio system */
- if (dev_fd >= 0)
+ if (hdl)
{
- ioctl(dev_fd, SNDCTL_DSP_SYNC, &dummy);
- close(dev_fd);
- dev_fd = -1;
+ sio_close(hdl);
+ hdl = NULL;
}
/* Finish linear file */
@@ -111,30 +127,19 @@ audio_play(int n, short *data)
{
if (n > 0)
{
- unsigned char *converted = (unsigned char *) malloc(n);
- int i;
+ unsigned size = n * sizeof(short);
- if (converted == NULL)
- {
- fprintf(stderr, "Could not allocate memory for conversion\n");
- exit(3);
- }
-
- for (i = 0; i < n; i++)
- converted[i] = (data[i] - 32768) / 256;
-
if (linear_fd >= 0)
{
- if (write(linear_fd, converted, n) != n)
+ if (write(linear_fd, data, size) != size)
perror("write");
}
- if (dev_fd >= 0)
+ if (hdl)
{
- if (write(dev_fd, converted, n) != n)
- perror("write");
+ if (sio_write(hdl, data, size) != size)
+ fprintf(stderr, "sio_write: short write");
}
- free(converted);
}
}
Index: patches/patch-Makefile_in
===================================================================
RCS file: /cvs/ports/audio/rsynth/patches/patch-Makefile_in,v
retrieving revision 1.1
diff -N -u -p patches/patch-Makefile_in
--- patches/patch-Makefile_in 31 Dec 2002 09:44:45 -0000 1.1
+++ patches/patch-Makefile_in 20 Dec 2009 07:18:12 -0000
@@ -8,7 +8,7 @@ $OpenBSD: patch-Makefile_in,v 1.1 2001/12/31 09:44:45
-LIB_DIR = $(PREFIX)/lib/dict
-LDLIBS = @LIBS@
+LIB_DIR = $(PREFIX)/share/dict
-+LDLIBS = @LIBS@ -lossaudio
++LDLIBS = @LIBS@ -lsndio
+LDFLAGS = @LDFLAGS@
XLIBS = @XLIBS@
CFLAGS = @CFLAGS@
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/audio/rsynth/pkg/PLIST,v
retrieving revision 1.3
diff -N -u -p pkg/PLIST
--- pkg/PLIST 10 Jun 2000 17:39:22 -0000 1.3
+++ pkg/PLIST 20 Dec 2009 07:18:12 -0000
@@ -1,2 +1,2 @@
@comment $OpenBSD: PLIST,v 1.3 2000/06/10 17:39:22 espie Exp $
-bin/say
+...@bin bin/say