From 243bd58e143ed40a5d8691573171baa7ff223d25 Mon Sep 17 00:00:00 2001 From: jakemsr Date: Mon, 14 Dec 2009 00:47:07 +0000 Subject: [PATCH] - sndio instead of audio(4), with help from ratchov@ - update MAITAINER and MASTER_SITES --- audio/morseplayer/Makefile | 13 +- audio/morseplayer/patches/patch-morseplayer_1 | 13 ++ audio/morseplayer/patches/patch-morseplayer_c | 202 ++++++++++++++++++ audio/morseplayer/pkg/PLIST | 4 +- 4 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 audio/morseplayer/patches/patch-morseplayer_1 create mode 100644 audio/morseplayer/patches/patch-morseplayer_c diff --git a/audio/morseplayer/Makefile b/audio/morseplayer/Makefile index dd2a23af630..582ba16221b 100644 --- a/audio/morseplayer/Makefile +++ b/audio/morseplayer/Makefile @@ -1,20 +1,23 @@ -# $OpenBSD: Makefile,v 1.8 2008/01/04 17:48:33 espie Exp $ +# $OpenBSD: Makefile,v 1.9 2009/12/14 00:47:07 jakemsr Exp $ COMMENT= morse player DISTNAME= morseplayer-1.4 +PKGNAME= ${DISTNAME}p0 CATEGORIES= audio -HOMEPAGE= http://www.thought.net/jason/radio/morseplayer.html -MAINTAINER= Jason Wright # BSD PERMIT_PACKAGE_CDROM= Yes PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes -WANTLIB= c m +WANTLIB= c m sndio -MASTER_SITES= http://www.thought.net/jason/radio/ +# no longer exists +#MASTER_SITES= http://www.thought.net/jason/radio/ +MASTER_SITES= ${MASTER_SITE_OPENBSD} + +MAKE_FLAGS+= LDADD="-lsndio -lm" FAKE_FLAGS= BINDIR="${PREFIX}/bin" MANDIR="${PREFIX}/man/cat" diff --git a/audio/morseplayer/patches/patch-morseplayer_1 b/audio/morseplayer/patches/patch-morseplayer_1 new file mode 100644 index 00000000000..a0c7a69eea0 --- /dev/null +++ b/audio/morseplayer/patches/patch-morseplayer_1 @@ -0,0 +1,13 @@ +$OpenBSD: patch-morseplayer_1,v 1.1 2009/12/14 00:47:07 jakemsr Exp $ +--- morseplayer.1.orig Thu Dec 10 12:07:44 2009 ++++ morseplayer.1 Thu Dec 10 12:08:15 2009 +@@ -94,8 +94,7 @@ as the character rate; default is 18. + .It Fl d Ar device + use + .Ar device +-for audio output instead of the default: +-.Pa /dev/audio ++for audio output instead of the default + .It Fl f Ar freq + use + .Ar freq diff --git a/audio/morseplayer/patches/patch-morseplayer_c b/audio/morseplayer/patches/patch-morseplayer_c new file mode 100644 index 00000000000..a9ab1f2fcf5 --- /dev/null +++ b/audio/morseplayer/patches/patch-morseplayer_c @@ -0,0 +1,202 @@ +--- morseplayer.c.old Fri Dec 11 00:18:56 2009 ++++ morseplayer.c Fri Dec 11 00:26:36 2009 +@@ -32,9 +32,6 @@ + * April 1990 (http://www.arrl.org/files/infoserv/tech/code-std.txt) + */ + +-#include +-#include +-#include + #include + #include + #include +@@ -42,6 +39,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -72,6 +70,7 @@ struct play_head { + }; + + struct s_params { ++ struct sio_hdl *hdl; /* sndio handle */ + u_int sp_rate; /* sample rate */ + double sp_hz; /* audio frequency */ + u_int sp_ditlen; /* dit length */ +@@ -81,7 +80,6 @@ struct s_params { + u_int sp_blocksize; /* audio block size */ + u_int sp_channels; /* number of channels */ + u_int sp_precision; /* sample precision (bits) */ +- int sp_fd; /* audio file descriptor */ + int sp_seenspace; /* seen a space character? */ + }; + +@@ -353,16 +351,16 @@ feed_audio(struct s_params *pars) + struct play_list *e; + + if (SIMPLEQ_EMPTY(&playhead.l)) { +- r = write(pars->sp_fd, quietBlock.buf, res); +- if (r == -1) ++ r = sio_write(pars->hdl, quietBlock.buf, res); ++ if (r == 0) + err(1, "write"); + break; + } + + e = SIMPLEQ_FIRST(&playhead.l); + if (e->pl_res > res) { +- r = write(pars->sp_fd, e->pl_ptr, res); +- if (r == -1) ++ r = sio_write(pars->hdl, e->pl_ptr, res); ++ if (r == 0) + err(1, "write"); + e->pl_ptr += res; + e->pl_res -= res; +@@ -370,8 +368,8 @@ feed_audio(struct s_params *pars) + break; + } + +- r = write(pars->sp_fd, e->pl_ptr, e->pl_res); +- if (r == -1) ++ r = sio_write(pars->hdl, e->pl_ptr, e->pl_res); ++ if (r == 0) + err(1, "write"); + playhead.nsamps -= e->pl_res; + res -= e->pl_res; +@@ -386,22 +384,18 @@ int + main_loop(struct s_params *pars) + { + struct pollfd fds[2]; +- ssize_t r; ++ nfds_t nfds; + int iseof = 0; + +- /* +- * first, play one block of silence... /dev/audio +- * isn't poll-able until it's been kicked. +- */ +- r = write(pars->sp_fd, quietBlock.buf, quietBlock.len); +- if (r == -1) +- err(1, "write"); +- +- fds[0].fd = pars->sp_fd; +- fds[0].events = POLLOUT; ++ nfds = sio_nfds(pars->hdl); ++ if (nfds != 1) ++ errx(1, "too many sndio file handles"); + fds[1].events = POLLIN; + + for (;;) { ++ nfds = sio_pollfd(pars->hdl, &fds[0], POLLOUT); ++ if (nfds == 0) ++ fds[0].fd = -1; + if (playhead.nsamps < pars->sp_sampthresh && !iseof) + fds[1].fd = fileno(stdin); + else +@@ -416,12 +410,10 @@ main_loop(struct s_params *pars) + iseof = 1; + } + +- if (fds[0].revents & POLLOUT) { ++ if (sio_revents(pars->hdl, &fds[0]) & POLLOUT) { + /* feed the audio device */ + feed_audio(pars); + if (iseof && SIMPLEQ_EMPTY(&playhead.l)) { +- if (ioctl(fds[0].fd, AUDIO_DRAIN, NULL) == -1) +- err(1, "audio_drain"); + break; + } + } +@@ -726,8 +718,8 @@ int + main(int argc, char *argv[]) + { + struct s_params pars; +- int f, c; +- audio_info_t ai; ++ int c; ++ struct sio_par par; + float cwpm = -1.0, owpm = -1.0, pitch = -1.0; + char *afname = NULL; + +@@ -765,7 +757,7 @@ main(int argc, char *argv[]) + break; + case '?': + default: +- fprintf(stderr, "%s [-d /dev/audio] [-c cwpm] " ++ fprintf(stderr, "%s [-d ] [-c cwpm] " + "[-w owpm] [-f freq] [-D]\n", argv[0]); + return (1); + } +@@ -798,49 +790,36 @@ main(int argc, char *argv[]) + overallwpm = owpm; + charwpm = cwpm; + +- if (afname == NULL) +- afname = "/dev/audio"; ++ pars.hdl = sio_open(afname, SIO_PLAY, 0); ++ if (pars.hdl == NULL) ++ errx(1, "Could not open sndio device"); + +- f = open(afname, O_WRONLY, 0); +- if (f == -1) +- err(1, "open %s", afname); ++ sio_initpar(&par); ++ par.rate = 22050; ++ par.sig = 0; ++ par.bits = 8; ++ par.pchan = 1; ++ if (!sio_setpar(pars.hdl, &par)) ++ errx(1, "sio_setpar failed"); ++ if (!sio_getpar(pars.hdl, &par)) ++ errx(1, "sio_getpar failed"); + +- AUDIO_INITINFO(&ai); +- /* ai.play.sample_rate = 22050; */ +- ai.play.encoding = AUDIO_ENCODING_SLINEAR; +- ai.play.precision = 8; +- ai.play.channels = 1; +- if (ioctl(f, AUDIO_SETINFO, &ai) == -1) { +-#if BYTE_ORDER == LITTLE_ENDIAN +- ai.play.encoding = AUDIO_ENCODING_SLINEAR_LE; +-#elif BYTE_ORDER == BIG_ENDIAN +- ai.play.encoding = AUDIO_ENCODING_SLINEAR_BE; +-#else +-# error "oh please, get the pdp outta here." +-#endif +- ai.play.precision = 16; +- ai.play.channels = 2; +- if (ioctl(f, AUDIO_SETINFO, &ai) == -1) { +- err(1, "setinfo"); +- } +- } +- +- if (ioctl(f, AUDIO_GETINFO, &ai) == -1) +- err(1, "getinfo"); +- pars.sp_rate = ai.play.sample_rate; ++ pars.sp_rate = par.rate; + pars.sp_hz = pitch; +- pars.sp_sampthresh = ai.blocksize * ai.hiwat; +- pars.sp_blocksize = ai.blocksize; ++ pars.sp_sampthresh = par.appbufsz * par.bps; ++ pars.sp_blocksize = par.round * par.bps; + pars.sp_seenspace = 0; +- pars.sp_fd = f; +- pars.sp_channels = ai.play.channels; +- pars.sp_precision = ai.play.precision; ++ pars.sp_channels = par.pchan; ++ pars.sp_precision = par.bits; + + if (diagmode > 0) { + check_chars(); + test_times(&pars); + return (0); + } ++ ++ if (!sio_start(pars.hdl)) ++ errx(1, "could not start sndio"); + + playlist_init(); + init_sounds(); diff --git a/audio/morseplayer/pkg/PLIST b/audio/morseplayer/pkg/PLIST index 5809105fd52..cccc3342665 100644 --- a/audio/morseplayer/pkg/PLIST +++ b/audio/morseplayer/pkg/PLIST @@ -1,3 +1,3 @@ -@comment $OpenBSD: PLIST,v 1.2 2005/09/05 12:46:15 espie Exp $ -bin/morseplayer +@comment $OpenBSD: PLIST,v 1.3 2009/12/14 00:47:07 jakemsr Exp $ +@bin bin/morseplayer @man man/cat1/morseplayer.0