diff options
author | 2012-05-23 19:25:11 +0000 | |
---|---|---|
committer | 2012-05-23 19:25:11 +0000 | |
commit | 9f9aa69f52b872d054b1e1c7120415fd7db7a61f (patch) | |
tree | 3d58baf5d7af15a74d59bb886f7003fb3730f90f | |
parent | Use a predefined structure for not-space cells used to set attributes. (diff) | |
download | wireguard-openbsd-9f9aa69f52b872d054b1e1c7120415fd7db7a61f.tar.xz wireguard-openbsd-9f9aa69f52b872d054b1e1c7120415fd7db7a61f.zip |
Make the "default" string a valid device name that has the same effect
as NULL has. This will (hopefully) simplify ports where the user
passes the device string.
-rw-r--r-- | include/sndio.h | 8 | ||||
-rw-r--r-- | lib/libsndio/mio.c | 12 | ||||
-rw-r--r-- | lib/libsndio/mio_open.3 | 6 | ||||
-rw-r--r-- | lib/libsndio/sio.c | 12 | ||||
-rw-r--r-- | lib/libsndio/sio_open.3 | 8 | ||||
-rw-r--r-- | lib/libsndio/sndio.7 | 6 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.c | 5 | ||||
-rw-r--r-- | usr.bin/aucat/miofile.c | 6 | ||||
-rw-r--r-- | usr.bin/aucat/siofile.c | 10 |
9 files changed, 45 insertions, 28 deletions
diff --git a/include/sndio.h b/include/sndio.h index 15cf8febd7b..4e0ce6bc53d 100644 --- a/include/sndio.h +++ b/include/sndio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sndio.h,v 1.5 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: sndio.h,v 1.6 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -20,6 +20,12 @@ #include <sys/param.h> /* + * default audio device and MIDI port + */ +#define SIO_DEVANY "default" +#define MIO_PORTANY "default" + +/* * private ``handle'' structure */ struct sio_hdl; diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c index e359adcb615..8dc0823a930 100644 --- a/lib/libsndio/mio.c +++ b/lib/libsndio/mio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio.c,v 1.14 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: mio.c,v 1.15 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -34,6 +34,7 @@ struct mio_hdl * mio_open(const char *str, unsigned int mode, int nbio) { + static char portany[] = MIO_PORTANY; struct mio_hdl *hdl; const char *p; @@ -42,9 +43,14 @@ mio_open(const char *str, unsigned int mode, int nbio) #endif if ((mode & (MIO_OUT | MIO_IN)) == 0) return NULL; - if (str == NULL && !issetugid()) + if (str == NULL) /* backward compat */ + str = portany; + if (strcmp(str, portany) == 0 && !issetugid()) { str = getenv("MIDIDEVICE"); - if (str == NULL) { + if (str == NULL) + str = portany; + } + if (strcmp(str, portany) == 0) { hdl = mio_aucat_open("/0", mode, nbio, 1); if (hdl != NULL) return hdl; diff --git a/lib/libsndio/mio_open.3 b/lib/libsndio/mio_open.3 index afe3dea153d..b82916fdac1 100644 --- a/lib/libsndio/mio_open.3 +++ b/lib/libsndio/mio_open.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mio_open.3,v 1.7 2012/04/11 06:05:43 ratchov Exp $ +.\" $OpenBSD: mio_open.3,v 1.8 2012/05/23 19:25:11 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 11 2012 $ +.Dd $Mdocdate: May 23 2012 $ .Dt MIO_OPEN 3 .Os .Sh NAME @@ -72,7 +72,7 @@ The parameter gives the device string discussed in .Xr sndio 7 . If the program is using a single device and is providing no device chooser, -it should be set to NULL to allow the user to select it using the +it should be set to MIO_PORTANY to allow the user to select it using the .Ev MIDIDEVICE environment variable. .Pp diff --git a/lib/libsndio/sio.c b/lib/libsndio/sio.c index 3013f6f92e4..cf7166d774c 100644 --- a/lib/libsndio/sio.c +++ b/lib/libsndio/sio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio.c,v 1.9 2012/05/11 07:50:27 ratchov Exp $ */ +/* $OpenBSD: sio.c,v 1.10 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -43,6 +43,7 @@ sio_initpar(struct sio_par *par) struct sio_hdl * sio_open(const char *str, unsigned int mode, int nbio) { + static char devany[] = SIO_DEVANY; struct sio_hdl *hdl; const char *p; @@ -51,9 +52,14 @@ sio_open(const char *str, unsigned int mode, int nbio) #endif if ((mode & (SIO_PLAY | SIO_REC)) == 0) return NULL; - if (str == NULL && !issetugid()) + if (str == NULL) /* backward compat */ + str = devany; + if (strcmp(str, devany) == 0 && !issetugid()) { str = getenv("AUDIODEVICE"); - if (str == NULL) { + if (str == NULL) + str = devany; + } + if (strcmp(str, devany) == 0) { hdl = sio_aucat_open("/0", mode, nbio); if (hdl != NULL) return hdl; diff --git a/lib/libsndio/sio_open.3 b/lib/libsndio/sio_open.3 index 110af9a8427..712a92d8dae 100644 --- a/lib/libsndio/sio_open.3 +++ b/lib/libsndio/sio_open.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sio_open.3,v 1.32 2012/04/11 06:05:43 ratchov Exp $ +.\" $OpenBSD: sio_open.3,v 1.33 2012/05/23 19:25:11 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 11 2012 $ +.Dd $Mdocdate: May 23 2012 $ .Dt SIO_OPEN 3 .Os .Sh NAME @@ -106,7 +106,7 @@ The .Ar name parameter gives the device string discussed in .Xr sndio 7 . -In most cases it should be set to NULL to allow +In most cases it should be set to SIO_DEVANY to allow the user to select it using the .Ev AUDIODEVICE environment variable. @@ -726,7 +726,7 @@ functions return the number of bytes transferred. .It Ev AUDIODEVICE Device to use if .Fn sio_open -is called with a NULL +is called with SIO_DEVANY .Va name argument. .It Ev SNDIO_DEBUG diff --git a/lib/libsndio/sndio.7 b/lib/libsndio/sndio.7 index 143117430f0..78461bc75ef 100644 --- a/lib/libsndio/sndio.7 +++ b/lib/libsndio/sndio.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sndio.7,v 1.9 2011/12/09 14:38:09 ratchov Exp $ +.\" $OpenBSD: sndio.7,v 1.10 2012/05/23 19:25:11 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 9 2011 $ +.Dd $Mdocdate: May 23 2012 $ .Dt SNDIO 7 .Os .Sh NAME @@ -93,6 +93,8 @@ Audio device exposed by .It Pa midithru MIDI thru box created with .Xr sndiod 1 . +.It Pa default +Any audio device or MIDI port. .El .It Pa hostname The hostname or address where the remote diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 1412980c4a1..82fff7b408b 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.134 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.135 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -26,6 +26,7 @@ #include <limits.h> #include <pwd.h> #include <signal.h> +#include <sndio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -349,7 +350,7 @@ mkdev(char *path, int mode, int bufsz, int round, int hold, int autovol) } else { if (dev_list) return dev_list; - path = "default"; + path = SIO_DEVANY; } if (!bufsz && !round) { round = DEFAULT_ROUND; diff --git a/usr.bin/aucat/miofile.c b/usr.bin/aucat/miofile.c index 6238bbb5065..3acdc2eb2b7 100644 --- a/usr.bin/aucat/miofile.c +++ b/usr.bin/aucat/miofile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: miofile.c,v 1.7 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: miofile.c,v 1.8 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -64,12 +64,10 @@ struct fileops miofile_ops = { struct miofile * miofile_new(struct fileops *ops, char *path, unsigned int mode) { - char *siopath; struct mio_hdl *hdl; struct miofile *f; - siopath = (strcmp(path, "default") == 0) ? NULL : path; - hdl = mio_open(siopath, mode, 1); + hdl = mio_open(path, mode, 1); if (hdl == NULL) return NULL; f = (struct miofile *)file_new(ops, path, mio_nfds(hdl)); diff --git a/usr.bin/aucat/siofile.c b/usr.bin/aucat/siofile.c index 2517f0f9734..426c9e34281 100644 --- a/usr.bin/aucat/siofile.c +++ b/usr.bin/aucat/siofile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: siofile.c,v 1.10 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: siofile.c,v 1.11 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -209,22 +209,20 @@ siofile_new(struct fileops *ops, char *path, unsigned int *rmode, struct aparams *ipar, struct aparams *opar, unsigned int *bufsz, unsigned int *round) { - char *siopath; struct sio_par par; struct sio_hdl *hdl; struct siofile *f; unsigned int mode = *rmode; - siopath = (strcmp(path, "default") == 0) ? NULL : path; - hdl = sio_open(siopath, mode, 1); + hdl = sio_open(path, mode, 1); if (hdl == NULL) { if (mode != (SIO_PLAY | SIO_REC)) return NULL; - hdl = sio_open(siopath, SIO_PLAY, 1); + hdl = sio_open(path, SIO_PLAY, 1); if (hdl != NULL) mode = SIO_PLAY; else { - hdl = sio_open(siopath, SIO_REC, 1); + hdl = sio_open(path, SIO_REC, 1); if (hdl != NULL) mode = SIO_REC; else |