mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 01:39:16 -04:00
- Add Sndio backend from [1] and fix it
- Remove dead code - Fix format selection and playback with raw devices - Fix OSS backend - Remove dead code - Don't open the device in non-blocking mode. There is no error handling for short writes and looking at how audio_play() is used in say.c it is expected to block. - Fix format selection - Let the kernel handle sample conversion instead of doing it in the backend - Make NAS support optional - Make installing dictionary database tools optional - Add LICENSE Obtained from: OpenBSD [1] (based on) Approved by: lme (mentor) Differential Revision: https://reviews.freebsd.org/D10828
This commit is contained in:
parent
98885b3265
commit
b910ce6bef
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=442097
6 changed files with 163 additions and 75 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
PORTNAME= rsynth
|
PORTNAME= rsynth
|
||||||
PORTVERSION= 2.0
|
PORTVERSION= 2.0
|
||||||
PORTREVISION= 4
|
PORTREVISION= 5
|
||||||
CATEGORIES= audio accessibility
|
CATEGORIES= audio accessibility
|
||||||
MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
|
MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
|
||||||
ftp://ftp.enst.fr/pub/unix/multimedia/
|
ftp://ftp.enst.fr/pub/unix/multimedia/
|
||||||
|
@ -11,14 +11,27 @@ MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
|
||||||
MAINTAINER= ports@FreeBSD.org
|
MAINTAINER= ports@FreeBSD.org
|
||||||
COMMENT= Speech synthesizer
|
COMMENT= Speech synthesizer
|
||||||
|
|
||||||
LIB_DEPENDS= libgdbm.so:databases/gdbm \
|
LICENSE= PD
|
||||||
libaudio.so:audio/nas
|
|
||||||
|
OPTIONS_DEFINE= DB NAS SNDIO
|
||||||
|
OPTIONS_SUB= yes
|
||||||
|
|
||||||
|
DB_DESC= Build dictionary database tools
|
||||||
|
DB_LIB_DEPENDS= libgdbm.so:databases/gdbm
|
||||||
|
DB_CONFIGURE_ENV_OFF= ac_cv_lib_gdbm_gdbm_open=no
|
||||||
|
NAS_LIB_DEPENDS= libaudio.so:audio/nas
|
||||||
|
NAS_CONFIGURE_ENV_OFF= ac_cv_header_audio_audiolib_h=no
|
||||||
|
SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio
|
||||||
|
SNDIO_MAKE_ENV= SAY_LIBS=-lsndio
|
||||||
|
|
||||||
USES= autoreconf
|
USES= autoreconf
|
||||||
GNU_CONFIGURE= yes
|
GNU_CONFIGURE= yes
|
||||||
|
|
||||||
pre-configure:
|
pre-configure-SNDIO-on:
|
||||||
@${CP} ${FILESDIR}/freebsdplay.c ${WRKSRC}/config/freebsdplay.c
|
@${CP} ${FILESDIR}/sndioplay.c ${WRKSRC}/config/freebsdplay.c
|
||||||
|
|
||||||
|
pre-configure-SNDIO-off:
|
||||||
|
@${CP} ${FILESDIR}/ossplay.c ${WRKSRC}/config/freebsdplay.c
|
||||||
|
|
||||||
post-configure:
|
post-configure:
|
||||||
@${REINPLACE_CMD} -E 's,(BIN|LIB)_DIR\),DESTDIR\)$$\(&,g' \
|
@${REINPLACE_CMD} -E 's,(BIN|LIB)_DIR\),DESTDIR\)$$\(&,g' \
|
||||||
|
|
|
@ -29,57 +29,43 @@
|
||||||
#define SAMP_RATE 8000
|
#define SAMP_RATE 8000
|
||||||
long samp_rate = SAMP_RATE;
|
long samp_rate = SAMP_RATE;
|
||||||
|
|
||||||
/* Audio Parameters */
|
|
||||||
|
|
||||||
static int dev_fd = -1;
|
static int dev_fd = -1;
|
||||||
/* file descriptor for audio device */
|
|
||||||
char *dev_file = "/dev/dsp";
|
char *dev_file = "/dev/dsp";
|
||||||
|
|
||||||
static int linear_fd = -1;
|
|
||||||
|
|
||||||
static char *linear_file = NULL;
|
|
||||||
|
|
||||||
char *prog = "hplay";
|
char *prog = "hplay";
|
||||||
|
|
||||||
static int
|
|
||||||
audio_open(void)
|
|
||||||
{
|
|
||||||
dev_fd = open(dev_file, O_WRONLY | O_NDELAY);
|
|
||||||
if (dev_fd < 0)
|
|
||||||
{
|
|
||||||
perror(dev_file);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
audio_init(int argc, char *argv[])
|
audio_init(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int rate_set = 0;
|
int rate_set = 0;
|
||||||
int use_audio = 1;
|
int use_audio = 1;
|
||||||
|
int fmt;
|
||||||
|
|
||||||
prog = argv[0];
|
prog = argv[0];
|
||||||
|
|
||||||
argc = getargs("freebsd Audio",argc, argv,
|
argc = getargs("Audio output",argc, argv,
|
||||||
"r", "%d", &rate_set, "Sample rate",
|
"r", "%d", &rate_set, "Sample rate",
|
||||||
"a", NULL, &use_audio, "Audio enable",
|
"a", NULL, &use_audio, "Audio enable",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (help_only)
|
if (help_only || !use_audio)
|
||||||
return argc;
|
return argc;
|
||||||
|
|
||||||
if (use_audio)
|
dev_fd = open(dev_file, O_WRONLY);
|
||||||
audio_open();
|
if (dev_fd < 0) {
|
||||||
|
perror(dev_file);
|
||||||
|
return argc;
|
||||||
|
}
|
||||||
|
|
||||||
if (rate_set)
|
if (rate_set)
|
||||||
samp_rate = rate_set;
|
samp_rate = rate_set;
|
||||||
|
|
||||||
if (dev_fd > 0)
|
fmt = AFMT_S16_NE;
|
||||||
{
|
if (ioctl(dev_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
||||||
ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate);
|
perror("SNDCTL_DSP_SETFMT");
|
||||||
printf("Actual sound rate: %ld\n", samp_rate);
|
|
||||||
}
|
if (ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate) < 0)
|
||||||
|
perror("SNDCTL_DSP_SPEED");
|
||||||
|
|
||||||
return argc;
|
return argc;
|
||||||
}
|
}
|
||||||
|
@ -87,54 +73,20 @@ audio_init(int argc, char *argv[])
|
||||||
void
|
void
|
||||||
audio_term()
|
audio_term()
|
||||||
{
|
{
|
||||||
int dummy;
|
|
||||||
|
|
||||||
/* Close audio system */
|
|
||||||
if (dev_fd >= 0)
|
if (dev_fd >= 0)
|
||||||
{
|
{
|
||||||
ioctl(dev_fd, SNDCTL_DSP_SYNC, &dummy);
|
|
||||||
close(dev_fd);
|
close(dev_fd);
|
||||||
dev_fd = -1;
|
dev_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish linear file */
|
|
||||||
if (linear_fd >= 0)
|
|
||||||
{
|
|
||||||
ftruncate(linear_fd, lseek(linear_fd, 0L, SEEK_CUR));
|
|
||||||
close(linear_fd);
|
|
||||||
linear_fd = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
audio_play(int n, short *data)
|
audio_play(int n, short *data)
|
||||||
{
|
{
|
||||||
if (n > 0)
|
if (n > 0 && dev_fd >= 0)
|
||||||
{
|
{
|
||||||
unsigned char *converted = (unsigned char *) malloc(n);
|
size_t size = n * sizeof(short);
|
||||||
int i;
|
if (write(dev_fd, data, size) != size)
|
||||||
|
perror("write");
|
||||||
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)
|
|
||||||
perror("write");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev_fd >= 0)
|
|
||||||
{
|
|
||||||
if (write(dev_fd, converted, n) != n)
|
|
||||||
perror("write");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(converted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
11
audio/rsynth/files/patch-Makefile.in
Normal file
11
audio/rsynth/files/patch-Makefile.in
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
--- Makefile.in.orig 2017-05-20 02:25:06 UTC
|
||||||
|
+++ Makefile.in
|
||||||
|
@@ -34,7 +34,7 @@ SAY_OBJS = say.o saynum.o darray.o ASCII.o phones.o te
|
||||||
|
getarg.o Revision.o
|
||||||
|
|
||||||
|
say : $(SAY_OBJS) hplay.o
|
||||||
|
- $(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) hplay.o $(LDLIBS)
|
||||||
|
+ $(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) hplay.o $(SAY_LIBS) $(LDLIBS)
|
||||||
|
|
||||||
|
nasay : $(SAY_OBJS) naplay.o
|
||||||
|
$(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) naplay.o $(XLIBS) $(LDLIBS)
|
|
@ -27,7 +27,7 @@
|
||||||
PROGS="$PROGS mkdictdb dlookup"
|
PROGS="$PROGS mkdictdb dlookup"
|
||||||
else
|
else
|
||||||
DICTS=""
|
DICTS=""
|
||||||
@@ -126,7 +128,7 @@ if test "$ac_cv_header_audio_audiolib_h"
|
@@ -126,7 +128,7 @@ if test "$ac_cv_header_audio_audiolib_h" = yes ; then
|
||||||
XLIBS="-laudio $XLIBS"
|
XLIBS="-laudio $XLIBS"
|
||||||
AC_DEFINE(HAVE_NAS)
|
AC_DEFINE(HAVE_NAS)
|
||||||
],,$XLIBS $LIBS)
|
],,$XLIBS $LIBS)
|
||||||
|
|
112
audio/rsynth/files/sndioplay.c
Normal file
112
audio/rsynth/files/sndioplay.c
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/*****************************************************************/
|
||||||
|
/*** ***/
|
||||||
|
/*** Play out a file on OpenBSD ***/
|
||||||
|
/*** (conf/linuxplay.c with changes) ***/
|
||||||
|
/*** ***/
|
||||||
|
/*****************************************************************/
|
||||||
|
|
||||||
|
#include <useconfig.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
|
||||||
|
#include <sndio.h>
|
||||||
|
|
||||||
|
#include "proto.h"
|
||||||
|
#include "getargs.h"
|
||||||
|
#include "hplay.h"
|
||||||
|
|
||||||
|
#define SAMP_RATE 8000
|
||||||
|
long samp_rate = SAMP_RATE;
|
||||||
|
|
||||||
|
static struct sio_hdl *hdl;
|
||||||
|
static struct sio_par par;
|
||||||
|
|
||||||
|
char *prog = "hplay";
|
||||||
|
|
||||||
|
int
|
||||||
|
audio_init(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int rate_set = 0;
|
||||||
|
int use_audio = 1;
|
||||||
|
|
||||||
|
prog = argv[0];
|
||||||
|
|
||||||
|
argc = getargs("Audio output",argc, argv,
|
||||||
|
"r", "%d", &rate_set, "Sample rate",
|
||||||
|
"a", NULL, &use_audio, "Audio enable",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (help_only)
|
||||||
|
return argc;
|
||||||
|
|
||||||
|
if (rate_set)
|
||||||
|
samp_rate = rate_set;
|
||||||
|
|
||||||
|
if (!use_audio)
|
||||||
|
return argc;
|
||||||
|
|
||||||
|
hdl = sio_open(NULL, SIO_PLAY, 0);
|
||||||
|
if (hdl == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "sio_open failed\n");
|
||||||
|
return argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
sio_initpar(&par);
|
||||||
|
par.bits = 16;
|
||||||
|
par.sig = 1;
|
||||||
|
par.le = SIO_LE_NATIVE;
|
||||||
|
par.rate = samp_rate;
|
||||||
|
par.pchan = 1;
|
||||||
|
|
||||||
|
if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error setting sndio parameters\n");
|
||||||
|
hdl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (par.bits != 16 || par.le != SIO_LE_NATIVE || par.sig != 1 || par.pchan != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "returned incorrect sndio parameters\n");
|
||||||
|
hdl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
samp_rate = par.rate;
|
||||||
|
|
||||||
|
if (hdl && !sio_start(hdl))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error starting sndio\n");
|
||||||
|
hdl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
audio_term()
|
||||||
|
{
|
||||||
|
if (hdl)
|
||||||
|
{
|
||||||
|
sio_close(hdl);
|
||||||
|
hdl = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
audio_play(int n, short *data)
|
||||||
|
{
|
||||||
|
if (n > 0 && hdl)
|
||||||
|
{
|
||||||
|
size_t size = n * sizeof(short);
|
||||||
|
if (sio_write(hdl, data, size) != size)
|
||||||
|
fprintf(stderr, "sio_write: short write");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
bin/dlookup
|
%%DB%%bin/dlookup
|
||||||
bin/mkdictdb
|
%%DB%%bin/mkdictdb
|
||||||
bin/say
|
bin/say
|
||||||
bin/nasay
|
%%NAS%%bin/nasay
|
||||||
|
|
Loading…
Add table
Reference in a new issue