diff options
author | 2012-05-23 19:25:11 +0000 | |
---|---|---|
committer | 2012-05-23 19:25:11 +0000 | |
commit | 9f9aa69f52b872d054b1e1c7120415fd7db7a61f (patch) | |
tree | 3d58baf5d7af15a74d59bb886f7003fb3730f90f /lib/libsndio | |
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.
Diffstat (limited to 'lib/libsndio')
-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 |
5 files changed, 29 insertions, 15 deletions
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 |