diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-05-23 19:25:12 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-05-23 19:25:12 +0000 |
commit | 298f5ad9040c0b93ccd39f1e110caab2684070a4 (patch) | |
tree | d25cfab90de9052fd97269b828e99beabbe85cbc /lib/libsndio/sio.c | |
parent | 6512e92d37b1b4f867171e80f8d8574b6f22912a (diff) |
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/sio.c')
-rw-r--r-- | lib/libsndio/sio.c | 12 |
1 files changed, 9 insertions, 3 deletions
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; |