Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154299176
D10828.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D10828.id.diff
View Options
Index: head/audio/rsynth/Makefile
===================================================================
--- head/audio/rsynth/Makefile
+++ head/audio/rsynth/Makefile
@@ -3,7 +3,7 @@
PORTNAME= rsynth
PORTVERSION= 2.0
-PORTREVISION= 4
+PORTREVISION= 5
CATEGORIES= audio accessibility
MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
ftp://ftp.enst.fr/pub/unix/multimedia/
@@ -11,14 +11,27 @@
MAINTAINER= ports@FreeBSD.org
COMMENT= Speech synthesizer
-LIB_DEPENDS= libgdbm.so:databases/gdbm \
- libaudio.so:audio/nas
+LICENSE= PD
+
+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
GNU_CONFIGURE= yes
-pre-configure:
- @${CP} ${FILESDIR}/freebsdplay.c ${WRKSRC}/config/freebsdplay.c
+pre-configure-SNDIO-on:
+ @${CP} ${FILESDIR}/sndioplay.c ${WRKSRC}/config/freebsdplay.c
+
+pre-configure-SNDIO-off:
+ @${CP} ${FILESDIR}/ossplay.c ${WRKSRC}/config/freebsdplay.c
post-configure:
@${REINPLACE_CMD} -E 's,(BIN|LIB)_DIR\),DESTDIR\)$$\(&,g' \
Index: head/audio/rsynth/files/freebsdplay.c
===================================================================
--- head/audio/rsynth/files/freebsdplay.c
+++ head/audio/rsynth/files/freebsdplay.c
@@ -1,140 +0,0 @@
-#include <config.h>
-
-/*****************************************************************/
-/*** ***/
-/*** Play out a file on FreeBSD ***/
-/*** (conf/linuxplay.c with changes) ***/
-/*** ***/
-/*****************************************************************/
-
-#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 <sys/soundcard.h>
-#include "proto.h"
-#include "getargs.h"
-#include "hplay.h"
-
-#define SAMP_RATE 8000
-long samp_rate = SAMP_RATE;
-
-/* Audio Parameters */
-
-static int dev_fd = -1;
- /* file descriptor for audio device */
-char *dev_file = "/dev/dsp";
-
-static int linear_fd = -1;
-
-static char *linear_file = NULL;
-
-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
-audio_init(int argc, char *argv[])
-{
- int rate_set = 0;
- int use_audio = 1;
-
- prog = argv[0];
-
- argc = getargs("freebsd Audio",argc, argv,
- "r", "%d", &rate_set, "Sample rate",
- "a", NULL, &use_audio, "Audio enable",
- NULL);
-
- if (help_only)
- return argc;
-
- if (use_audio)
- audio_open();
-
- if (rate_set)
- samp_rate = rate_set;
-
- if (dev_fd > 0)
- {
- ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate);
- printf("Actual sound rate: %ld\n", samp_rate);
- }
-
- return argc;
-}
-
-void
-audio_term()
-{
- int dummy;
-
- /* Close audio system */
- if (dev_fd >= 0)
- {
- ioctl(dev_fd, SNDCTL_DSP_SYNC, &dummy);
- close(dev_fd);
- 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
-audio_play(int n, short *data)
-{
- if (n > 0)
- {
- unsigned char *converted = (unsigned char *) malloc(n);
- int i;
-
- 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);
- }
-}
Index: head/audio/rsynth/files/ossplay.c
===================================================================
--- head/audio/rsynth/files/ossplay.c
+++ head/audio/rsynth/files/ossplay.c
@@ -0,0 +1,92 @@
+#include <config.h>
+
+/*****************************************************************/
+/*** ***/
+/*** Play out a file on FreeBSD ***/
+/*** (conf/linuxplay.c with changes) ***/
+/*** ***/
+/*****************************************************************/
+
+#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 <sys/soundcard.h>
+#include "proto.h"
+#include "getargs.h"
+#include "hplay.h"
+
+#define SAMP_RATE 8000
+long samp_rate = SAMP_RATE;
+
+static int dev_fd = -1;
+char *dev_file = "/dev/dsp";
+
+char *prog = "hplay";
+
+int
+audio_init(int argc, char *argv[])
+{
+ int rate_set = 0;
+ int use_audio = 1;
+ int fmt;
+
+ 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 || !use_audio)
+ return argc;
+
+ dev_fd = open(dev_file, O_WRONLY);
+ if (dev_fd < 0) {
+ perror(dev_file);
+ return argc;
+ }
+
+ if (rate_set)
+ samp_rate = rate_set;
+
+ fmt = AFMT_S16_NE;
+ if (ioctl(dev_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
+ perror("SNDCTL_DSP_SETFMT");
+
+ if (ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate) < 0)
+ perror("SNDCTL_DSP_SPEED");
+
+ return argc;
+}
+
+void
+audio_term()
+{
+ if (dev_fd >= 0)
+ {
+ close(dev_fd);
+ dev_fd = -1;
+ }
+}
+
+void
+audio_play(int n, short *data)
+{
+ if (n > 0 && dev_fd >= 0)
+ {
+ size_t size = n * sizeof(short);
+ if (write(dev_fd, data, size) != size)
+ perror("write");
+ }
+}
Index: head/audio/rsynth/files/patch-Makefile.in
===================================================================
--- head/audio/rsynth/files/patch-Makefile.in
+++ head/audio/rsynth/files/patch-Makefile.in
@@ -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)
Index: head/audio/rsynth/files/patch-configure.in
===================================================================
--- head/audio/rsynth/files/patch-configure.in
+++ head/audio/rsynth/files/patch-configure.in
@@ -27,7 +27,7 @@
PROGS="$PROGS mkdictdb dlookup"
else
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"
AC_DEFINE(HAVE_NAS)
],,$XLIBS $LIBS)
Index: head/audio/rsynth/files/sndioplay.c
===================================================================
--- head/audio/rsynth/files/sndioplay.c
+++ head/audio/rsynth/files/sndioplay.c
@@ -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");
+ }
+}
Index: head/audio/rsynth/pkg-plist
===================================================================
--- head/audio/rsynth/pkg-plist
+++ head/audio/rsynth/pkg-plist
@@ -1,4 +1,4 @@
-bin/dlookup
-bin/mkdictdb
+%%DB%%bin/dlookup
+%%DB%%bin/mkdictdb
bin/say
-bin/nasay
+%%NAS%%bin/nasay
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 28, 4:50 PM (14 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32292906
Default Alt Text
D10828.id.diff (9 KB)
Attached To
Mode
D10828: audio/rsynth: Fix audio output
Attached
Detach File
Event Timeline
Log In to Comment