summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2020-11-19 08:14:19 +0000
committerratchov <ratchov@openbsd.org>2020-11-19 08:14:19 +0000
commit3801dd1157ff17d1cd363b40fadb58caf722e0cb (patch)
tree9562c015dbc0d7433e04a29c09862864dd6a937f
parentConvert sysctl_sysvsem to sysctl_int_bounded (diff)
downloadwireguard-openbsd-3801dd1157ff17d1cd363b40fadb58caf722e0cb.tar.xz
wireguard-openbsd-3801dd1157ff17d1cd363b40fadb58caf722e0cb.zip
Allow specific devices to be used for play-only and rec-only modes.
Introduce new AUDIO{PLAY,REC}DEVICE environment variables that override AUDIODEVICE in cases play-only and rec-only mode is requested. This allows using different devices for playback and recording in programs requesting twice the default device (one in play-only mode and one in rec-only mode). Based on diffs from Peter J Philipp, semarie, and solene ok solene, sthen
-rw-r--r--lib/libsndio/sio.c9
-rw-r--r--lib/libsndio/sndio.724
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/libsndio/sio.c b/lib/libsndio/sio.c
index da19c80d506..b649d4ba05f 100644
--- a/lib/libsndio/sio.c
+++ b/lib/libsndio/sio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sio.c,v 1.24 2019/06/29 06:05:26 ratchov Exp $ */
+/* $OpenBSD: sio.c,v 1.25 2020/11/19 08:14:19 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -52,7 +52,12 @@ sio_open(const char *str, unsigned int mode, int nbio)
if (str == NULL) /* backward compat */
str = devany;
if (strcmp(str, devany) == 0 && !issetugid()) {
- str = getenv("AUDIODEVICE");
+ if ((mode & SIO_PLAY) == 0)
+ str = getenv("AUDIORECDEVICE");
+ if ((mode & SIO_REC) == 0)
+ str = getenv("AUDIOPLAYDEVICE");
+ if (mode == (SIO_PLAY | SIO_REC) || str == NULL)
+ str = getenv("AUDIODEVICE");
if (str == NULL)
str = devany;
}
diff --git a/lib/libsndio/sndio.7 b/lib/libsndio/sndio.7
index 2bd298b8592..4b9ec4ba12e 100644
--- a/lib/libsndio/sndio.7
+++ b/lib/libsndio/sndio.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sndio.7,v 1.24 2020/07/18 05:01:14 ratchov Exp $
+.\" $OpenBSD: sndio.7,v 1.25 2020/11/19 08:14:19 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: July 18 2020 $
+.Dd $Mdocdate: November 19 2020 $
.Dt SNDIO 7
.Os
.Sh NAME
@@ -151,9 +151,11 @@ If
.Cm default
is used as the audio device, the program will use the
one specified in the
-.Ev AUDIODEVICE
-environment variable.
-If it is not set, the program first tries to connect to
+.Ev AUDIODEVICE , AUDIOPLAYDEVICE
+and/or
+.Ev AUDIORECDEVICE
+environment variables.
+If they are not set, the program first tries to connect to
.Li snd/0 .
If that fails, it then tries to use
.Li rsnd/0 .
@@ -190,10 +192,20 @@ and contains 128 bits of raw random data.
If a session needs to be shared between multiple users, they
can connect to the server using the same cookie.
.Sh ENVIRONMENT
-.Bl -tag -width "AUDIODEVICEXXX" -compact
+.Bl -tag -width "AUDIOPLAYDEVICE" -compact
.It Ev AUDIODEVICE
Audio device descriptor to use
when no descriptor is explicitly specified to a program.
+.It Ev AUDIOPLAYDEVICE
+Audio device descriptor to use for play-only mode
+when no descriptor is explicitly specified to a program.
+Overrides
+.Ev AUDIODEVICE .
+.It Ev AUDIORECDEVICE
+Audio device descriptor to use for record-only mode
+when no descriptor is explicitly specified to a program.
+Overrides
+.Ev AUDIODEVICE .
.It Ev MIDIDEVICE
MIDI port descriptor to use
when no descriptor is explicitly specified to a program.